xautolock -exit 2>/dev/null; xautolock -corners "+---" -time 10 -notify 30 -locker "xlock -mode random"
#!/usr/bin/expect
set myserver "10.0.0.1"
set myport "21"
send "Try to connect to server $myserver port $myport\n"
spawn telnet $myserver $myport
expect "220 " { send "USER ftp\n" }
expect "331 " { send "PASS foo\n" }
expect "230 " { send "PASV\n" }
expect "227 " { send "HELP\n" }
expect "214 " { interact }
/usr/bin/rsync --rsync-path=/usr/local/bin/rsync -rlpe ssh QUELLE ZIEL
rsync --compress --progress --no-whole-file -rlpe ssh remote:/path/file file
ls -lS
stat myfile.txt
cat /var/log/syslog | grep ^"`date +%b\ %d`"
# date +'%Y%m%d_%H%M%S'
20081103_1759026
grep -ve ^\ *\#'\|'^$ /etc/*.conf
echo "ABC123DEF456GHI" | grep --color [0-9H]
ABC123DEF456GHI
echo "ABC123DEF456GHI" | grep -E --only-matching [0-9H]+
123
456
H
grep --files-with-match foo *
echo "ABC123DEF456GHI" | sed 's/[0-9H]\+/_&_/g'
ABC_123_DEF_456_G_H_I
echo "ABC223DEF456GHI" | sed s/"\([0-9]\+\)"/"_\1_"/
ABC_223_DEF456GHI
grep error /var/log/syslog | awk '{ print $3 }'
awk '/error/ { print $3 }' /var/log/syslog
EXAMMLEand want to replace the second M with a P.
M(?=L)The difference to this one
MLis that the the L in the first case would not be replaced, but in the second case it would be replaced
M(?!M)Search for a String which does not start with CA
^(?!CA)
awk 'BEGIN {FS=" - "} {print $1 $2 $3}'
awk 'BEGIN {FS="\t"} {print $3}
echo foo,bar,test | awk 'BEGIN {FS=","} {split($0,a,","); for (i=1; i<=NF; i++) print a[i]; }'
echo 42 11 | awk '{print $1*1000, $2}'
cat foo | awk '{mycol2 += $2; mycol3 += $3}; END {print mycol2":"mycol3}'
cat foo | awk '$1>45 {print $0}'
cat foo | awk 'NR>11 { print $0 }'
cat foo | awk '$2~/FooBar/ {print $0}'
echo 1 2 | awk '{ printf("%.3d %s\n", $1, $2) }'
less -S
watch -n3 cat /proc/mdstat
diff -ubB FOO BAR
expr FooBar-5.2 : ".*-5.2"
mount -t smbfs -o username=uname,password=passwd //smbserv/share /destination
mlabel -i /dev/sdc1 ::FOOBAR
nice --5 make dep clean bzImage modules bzlilo modules_install
/usr/src/linux/Documentation/kernel-parameters.txt
48x48 ppm -> pgm -> pbm -> xbm
cat file.xbm | xbm2ikon > file.48
compface file.48 file.face
gs -sPDFPassword=password -sDEVICE=pswrite -dNOPAUSE -sOutputFile=out.ps in.pdf
a2ps --medium A4dj -E -o /tmp/pretty.ps A B C D ...
Unicode / utf-8: u2ps ...(gnome-u2ps)
psbook normal.ps | psnup -2 -m25 > book.ps
transcode -i myVobFolder -o movie.avi -y xvid -x vobScale
-B 4Select a different audio channel, don't select a non existing audio channel or your VOB files will only be read once and no content will be generated
-a1Encoder bitrate
-w 1800Clipping, this cuts the first and last 16 rows of
-j 16,0Linear interpolation for interlaced videos
-I1Cut the results
avisplit -c -i movie.avi -t 00:00:00.00-00:05:10.00,00:11:59.00-00:22:41.00Use tcaud
-y xvid,tcaudCreate DivX files
-y ffmpeg -F mpeg4Use mencoder instead of transcode
cat *.vob | mencoder -oac mp3lame -ovc xvid -xvidencopts pass=1 - -o movie.avi;
cat *.vob | mencoder -oac mp3lame -ovc xvid -xvidencopts pass=2:bitrate=700 - -o movie.avi;
mencoder -oac pcm -ovc copy -ofps 30000/1001 -o Movi.avi Movi.mkv
nice transcode -i vts_01_6.vob -o soundtrack.wav -y null,wav -x vob -e 44000
mplayer -ao pcm:fast:file=audio.wav -vo null -vc null video.avi
mencoder 'mf://*.jpg' -mf type=jpg:fps=10 -xvidencopts bitrate=1600 -ovc xvid -oac copy -o output.avi
animate -delay 10 *.jpg
animate -help
convert -delay 10 *.jpg out.gif
convert large.jpg -resize 120x120 small.jpgGot pictures from different cameras from one event? Use the exif header in the JPEG pictures to extract the date and time and put it into the filename so you can sort the files chronologically.
convert large.jpg -resize 50% small.jpg
for i in *.jpg; do d=`exif -t 0x9003 $i | grep Value | sed s/^" Value: "// | sed s/\ /_/g | sed s/:/-/g`; mv "$i" "$d""_""$i"; doneChange the date from 2005 to 2006
for i in *;
do
n=`exif -t 0x9004 "$i" | grep ^" Value: " | sed s/^" Value: "// | sed s/2005/2006/`;
x="exif --ifd=EXIF -t 0x9004 --set-value=\"$n\" $i";
eval "$x";
done
alias unix2dos='recode lat1..ibmpc'
alias dos2unix='recode ibmpc..lat1'
iconv --from-code=ISO-8859-1 --to-code=UTF-8 ./oldfile.htm > ./newfile.html
setfacl -m u:foo:r-- DEST
setfacl -x u:foo DEST
setfacl -m g:bar:r-- DEST
setfacl -x g:bar DEST
setfacl -m d:u:foo:r-- DIR
setfacl -m d:g:bar:r-- DIR
setfacl -m m:r-- DEST
setfacl -m d:m:r-- DIR
alias my_mozilla='mozilla -remote "ping()" && mozilla -remote "openURL (,new-window)" || mozilla -splash'
sa-learn --dump | grep non-token\ data: | grep nspam$'\|'nham$
sa-learn --dump | grep -v non-token\ data: | sort -n
(echo "Hello world"; uuencode file1.txt ReadThis.txt; uuencode file2.txt AndThis.txt) | mailx -s subject foo@example.com
echo "Hello world" | mutt -a file1.txt foo@example.com
sftp -o "batchmode no" -b meinebefehle.sftp user@computer
lcd /home/foo/4upload/
cd /tmp/uploaded/
put Backup1.img
put Backpu2.img
quit
| Name | (Bytes) |
|---|---|
| DVD | 4590200 |
| CD | FIXME |
ssh root@otherhost -c blowfish 'cd /YOURPATH; tar -f - -p -P -c --exclude=/YOURPATH/tmp --exclude=/YOURPATH/var/cache /' | dd of=/daten/backup.tar
tar --multi-volume --tape-length=1024 -cf archive.tar foo // n archive.001.tar n ...
tar --multi-volume --tape-length=1024 -c -f archive.tar -f archive001.tar -f archive002.tar -f ... foo
tar --multi-volume --tape-length=1024 --new-volume-script=/usr/local/bin/tar_changer.sh -cf archive.tar foo
tar --multi-volume -t -f archive.tar -f archive001.tar -f archive002.tar -f ...
#!/bin/sh
new_vol=`echo $TAR_VOLUME | awk '{printf "%04d\n", $1;}'`
new_name="$TAR_ARCHIVE"
new_name="`echo "$new_name" | sed s/"\."tar$//`"
new_name="`echo "$new_name" | sed s/"\."[0-9][0-9]*$//`"
new_name="$new_name"".""$new_vol"".tar"
echo "For volume $TAR_VOLUME of $TAR_ARCHIVE the next file name will be: $new_name"
if [ -e "$new_name" ]; then
echo "Error: file already exists!"
exit 1
else
echo "$new_name" >&$TAR_FD
fi
par2 create myparfiles foo*
mkisofs -udf -allow-limited-size -o foo.img foo
mount /dev/hda1 / -o remount,rw;
dd if=/dev/zero of=/delme1 bs=4048; rm /delme1;
mount /dev/hda1 / -o remount,ro;
dd if=/dev/hda1 bs=4048 | bzip2 > /mountpoint/image_hda1.bz;
ssh host -c blowfish 'dd if=/dev/hda1 bs=4048 | bzip2' | dd of=/image_hda1.bz
xterm: xset b off
setterm -blength
echo 'set bell-style visible' >> ~/.inputrc
chmod ABCD FILEA:
4=user ID, 2=group ID, 1=stickyB(owner), C(group), D(other):
4=r, 2=w, 1=x
if=/dev/hda of=/tmp/mbrbackupwithouttable.img bs=446 count=1
if=/dev/hda of=/tmp/mbrbackupwithtable.img bs=512 count=1
grub> find /boot/grub/stage1
grub> root (hd0,3)
grub> setup (hd0)
grub> setup (hd0,3)
export LESS="-i"
export LESS="-i"
echo Cool | sed s/c/T/i
echo fOo | tr "[:lower:]" "[:upper:]" # FOO
echo fOo | tr "[:upper:]" "[:lower:]" # foo
sort -k 3,3 -k 2,2 -k 6,6n
# echo "1:1:1
1:1:0" | sort -t : -k 3
1:1:0
1:1:1
# fruits=(apple banana strawberry)
# echo ${fruits}
apple
# echo ${fruits[1]}
banana
# echo ${fruits[*]}
apple banana strawberry
# echo ${#fruits[*]}
3
# echo ${fruits[*]}
apple banana strawberry
# for ((idx=(${#fruits[*]}-1); idx>=0; idx--)); do echo ${fruits[$idx]}; done
strawberry
banana
apple
| !! | Run the last command you entered again |
| !-3 | Run the command you entered three steps before this one |
| !mount | Re-run the last command which started with mount |
| !!:s/mount/umount/ | Re-run the last command and replace the string mount with the string remount |
| ^mount^umount^ | Alternative for the last command |
| export HISTSIZE=1000 | Remember the last 1000 commands |
| export HISTCONTROL=ignoreboth | Don't store commands which start with a space or successive identical entered commands |
| shopt -s histappend | The last Bash session you close won't overwrite the history |
| shopt -s histverify | Commands you repeat with ! are not executed immediately |
| Shortcut | Description |
|---|---|
| Ctrl+A | move to the start of the line |
| Ctrl+E | move to the end of the line |
| Ctrl+U | Cut from the cursor to the beginning of the line into the clipboard |
| Ctrl+K | Cut from the cursor to the end of the line into the clipboard |
| Ctrl+W | Cut from the cursor to the start of the word into the clipboard |
| Ctrl+Y | pastes text from the clipboard |
find / -printf "%CY%Cm%Cd%CI%CM | %d | %i | %s | %h | %f\n"find can spawn a new command for each file or start the command once and give it all found files
find / -exec echo '{}' +
find / -exec echo '{}' ';'
find /foo -type f -ctime +165
find /foo -type f -ctime 165
find /foo -type f -ctime -165
find /foo -size +3000000c
find /foo -size +3M
| Command | Description | Will find | Will not find |
|---|---|---|---|
| # find . -perm 400 # find . -perm u=r |
Finds files with exactly these permissions | -r-------- | -r--r----- |
| # find . ! -perm 400 # find . ! -perm u=r |
Finds files whose permissions are not equal to these permissions | -rwxrwxrwx | -r-------- |
| # find . -perm -440 # find . -perm -u=r,g=r |
At least these permissions have to be there | -rwxrwxrwx -rw-r--r-- lrwxrwxrwx |
-r-------- ----r----- |
| # find . -perm /440 # find . -perm /u=r,g=r |
At least one of these permissions have to be there | -rwxrwxrwx -r-------- ----r----- |
--w------- |
find /tmp/tg1/ -type l | while read link
do
if [ -h "$link" -a ! -e "$link" ];
then echo "$link";
fi;
done
find /tmp/tg1/ -printf '%Y %p \n' | grep ^N\ | sed s/^N\ //
find /mnt/mnt/ -L -samefile /mnt/mnt/bin/foo
netstat -rn
route delete default
route add default 1.2.3.4
ioreg -l | grep IOBa
# pwd
/tmp
# pushd /etc/network/
# pushd /var/log/
/var/log /etc/network /tmp
# pushd /usr/sbin/
/usr/sbin /var/log /etc/network /tmp
# dirs
/usr/sbin /var/log /etc/network /tmp
# pushd
/var/log /usr/sbin /etc/network /tmp
# pwd
/var/log
# pushd
/usr/sbin /var/log /etc/network /tmp
# pwd
/usr/sbin
# pushd +2
/etc/network /tmp /usr/sbin /var/log
/# pwd
/etc/network
# dirs
/etc/network /usr/sbin /var/log
# popd
/usr/sbin /var/log
# pwd
/usr/sbin
# popd
/var/log
# pwd
/var/log
echo "$OLDPWD"
# echo /etc/group /etc/passwd >/dev/nullWith
# echo !$
echo /dev/null
ESC .you get the last token at the current cursor position.
# cp backup2008a.tar /mnt/streamer/backup2008a.tar 2>/dev/null
# echo $_
/mnt/streamer/backup2008a.tar
# cp backup2008.tar /mnt/streamer/However, this substitutes only the first occurrence, which also applies to the long version
# ^2008^2009^
cp backup2009.tar /mnt/streamer/
# cp backup2008a.tar backup2008b.tar /mnt/streamer/
# !!:s/2008/2009/
cp backup2009a.tar backup2008b.tar /mnt/streamer/
# cp -v backup2008a.tar backup2008b.tar /mnt/streamer/
# !!:gs/2008/2009/
exec 3>&1
exec 1>>/var/log/mylogfile.txt
...
exec 1>&3
exec 3>&-
cat foo.txt | sed s/t/T/ | sponge foo.txt
$ ssh foo@bar.example.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/cygdrive/p/.ssh/id_dsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /cygdrive/p/.ssh/id_dsa
Permission denied (publickey).
$ CYGWIN=nontsec ssh foo@bar.example.com
# free -m
# df -ah
# top -n1
htop
# vmstat 5 3
smartctl --all /dev/sda
memstat -w
lsof +D /mnt/foo
fuser /mnt/foo
# nproc
6
# make -j $(nproc)
zcav /dev/sdb > zcav.txtBenchmark a drive with bonnie++
gnuplot
set yrange [0:*]
set format y '%g Blocks/s'
set format x '%g MB'
plot "zcav.txt" using 1:2 title "Foo"
bonnie++ -u root -d /mnt/mnt/
ps -efbut you also have another ps which can be more verbose
prstat -a
truss -f /bin/date
truss -fp PID
/usr/ucb/ps -auxww
digest -v -a md5 foo
# perl -MCPAN -e 'install HTML::CalendarMonthSimple'
# cpan
cpan> install HTML::CalendarMonthSimple
require HTML::CalendarMonthSimple;
perl -d myPerlScript.pl
ls *.txt | xargs gzip
ls *.txt | xargs -n1 gzip
ls *.txt | xargs -n1 gzip &
ls *.txt | xargs -n1 -P5 gzip