mv file_abc.jpg pic.XX.jpg
mv random.jpg pic.XX.jpg
mv other.jpg pic.XX.jpg
mv name.jpg pic.XX.jpg
If you do this:
:%s/XX/\=line(".")/
A place for John to record his techy notes, both to refer back to when needed, and as a help for others...
mv file_abc.jpg pic.XX.jpg
mv random.jpg pic.XX.jpg
mv other.jpg pic.XX.jpg
mv name.jpg pic.XX.jpg
If you do this:
:%s/XX/\=line(".")/
Make SSH ignore your SSH key, not prompt for a passphrase, only use password:
$ ssh -o PreferredAuthentications=keyboard-interactive -o PubkeyAuthentication=no destination.host
Find files that are not world readable and make them readable:
sudo find . -type f \! -perm -4 -exec chmod o+r {} +
Find files that are not group readable
find . -type f \! -perm -40 -ls
Find files that are group writable
find . -type f -perm -20 -ls
Find files that are world writable
find . -type f -perm -2 -ls
If the file /usr/sbin/virtinfo exists, run:
$ /usr/sbin/virtinfo -a
If you run it as root it will also tell you the hostname of the Control domain and the Chassis serial#.
( printf "GET /path/to/file HTTP/1.0\n\n" 1>&0 ; cat ) 0<> /dev/tcp/<HOSTNAME>/80Thanks David!
You can tell it's likely to be a Windows box by what ports it has open...
"The target host OS can often be guessed simply by looking at the ports which are open. Microsoft Windows machines often have TCP ports 135 and 139 open. Windows 2000 and newer also listen on port 445." ( from: http://nmap.org/book/osdetect-other-methods.html )
Once you've identified it's a Windows host, how can you tell which one?
Try this:
$ nmblookup -A 12.34.56.78
Looking up status of 12.34.56.78
HOSTNAME <00> - M <ACTIVE>
DOMAINNAME <00> - <GROUP> M <ACTIVE>
HOSTNAME <1f> - M <ACTIVE>
HOSTNAME <20> - M <ACTIVE>
DOMAINNAME <1e> - <GROUP> M <ACTIVE>
MAC Address = 00-11-22-33-44-55
ps -eo vsz,rss,pid,args | sort -n
top -b -o size
pmap -S $PID | tail -1 | awk '{print $4}'
20236
prstat -s rss
prstat -s size
#!/usr/bin/perl -s
use warnings;
use strict;
if ( $< != 0 ) {
die "ERROR: $0 Needs to be run as root\n";
}
our ($c,$m,$n,$t);
opendir(my $proc,"/proc");
my $pids;
my $total;
for my $pid (grep {/^[0-9]+$/} readdir($proc)) {
#
# If the process has terminated already, skip on to the next one.
#
open(my $smaps, "/proc/$pid/smaps") || next;
while(<$smaps>) { next if !/^Swap:\s+(\d+) kB$/; $pids->{$pid}->{swap} += $1; }
close($smaps);
if ( $pids->{$pid}->{swap} ) {
open(my $cmdline, "/proc/$pid/cmdline");
while(<$cmdline>) { s/\0/ /g; $pids->{$pid}->{cmdline} = $_; }
$total += $pids->{$pid}->{swap};
} else {
delete $pids->{$pid};
}
}
if ( $c && ! $n ) {
print " PID Swap Cmd\n";
}
for my $pid ( sort { $pids->{$b}{swap} <=> $pids->{$a}{swap} } keys %$pids ) {
# Only report procs > 1MB
next if $pids->{$pid}->{swap} < 1024;
# Specify minimum size (MB) to report
# print "m [$m] swap[$pids->{$pid}->{swap}]\n";
next if ( $m && $pids->{$pid}->{swap} < $m * 1024 );
if ( $c ) {
printf "%5d %4dMB %s\n", $pid, $pids->{$pid}->{swap} / 1024, $pids->{$pid}->{cmdline};
} else {
printf "%5d %4dMB\n", $pid, $pids->{$pid}->{swap} / 1024;
}
}
if ( $t ) {
printf "Total: %dMB\n", ${total} / 1024;
}
cd repository
git log --pretty=email --patch-with-stat --reverse -- path/to/file_or_folder > ../patch
cd ../other_repository
git am < ../patch
Ever missed seq on a non-gnu system (like older Solaris)?
Here's an extremely portable alternative which turns out to be much more efficient too!
yes '' | head -100000 | cat -n
Phil explained that the efficiency is to do with the way that cat does its line numbering (by incrementing the ASCII characters rather than counting numbers and converting them to characters) Thanks Phil!