* 32 bits or 64 bits?
>> getconf LONG_BIT
* 32 bits or 64 bits?
>> sudo lshw -C cpu|grep width
* A bash function to show the files most recently modified in the named (or curr
>> ent) directoryfunction t { ls -ltch $* | head -20 ; }
* A bit of privacy in .bash_history
>> export HISTCONTROL=ignoreboth
* A command's package details
>> dpkg -S `which nm` | cut -d':' -f1 | (read PACKAGE; echo "[${PACKAGE}]"; dpkg -s "${PACKAGE}"; dpkg -L "${PACKAGE}") | less
* Activate on-the-fly GTK accels
>> gconftool-2 -t bool -s /desktop/gnome/interface/can_change_accels true
* Add 10 random unrated songs to xmms2 playlist
>> xmms2 mlib search NOT +rating | grep -r '^[0-9]' | sed -r 's/^([0-9]+).*/\1/' |sort -R | head | xargs -L 1 xmms2 addid
* Add a directory with a name to /etc/passwd to get quick access using cd ~name
>> function qcd { useradd -No -s /bin/false -u 999 -g 999 -lf -1 -d $1 $2 ; }
* add a gpg key to aptitute package manager in a ubuntu system
>> wget -q http://xyz.gpg -O- | sudo apt-key add -
* Add a line to a file using sudo
>> echo "foo bar" | sudo tee -a /path/to/some/file
* Add another tty device using mknod command
>> sudo mknod /dev/ttyS4 c 4 68
* Add a shadow to picture
>> convert {$file_in} \( +clone -background black -shadow 60x5+10+10 \) +swap -background none -layers merge +repage {$file_out}
* Add calendar to desktop wallpaper
>> convert -font -misc-fixed-*-*-*-*-*-*-*-*-*-*-*-* -fill black -draw "text 270,260 \" `cal` \"" testpic.jpg newtestpic.jpg
* Add forgotten changes to the last git commit
>> git commit --amend
* Adding Color Escape Codes to global CC array for use by echo -e
>> declare -ax CC; for i in `seq 0 7`;do ii=$(($i+7)); CC[$i]="\033[1;3${i}m"; CC[$ii]="\033[0;3${i}m"; done
* Add Password Protection to a file your editing in vim.
>> vim -x
* Add
>> rename 's/^/prefix/' *
* Add some color to ls
>> eval "`dircolors -b`"
* add static arp entry to default gateway, arp poison protection
>> arp -s $(route -n | awk '/^0.0.0.0/ {print $2}') \ $(arp -n | grep `route -n | awk '/^0.0.0.0/ {print $2}'`| awk '{print $3}')
* Add the sbin directories to your PATH if it doesn't already exist in ZSH.
>> path+=( /sbin /usr/sbin /usr/local/sbin ); path=( ${(u)path} );
* Add user to group on OS X 10.5
>> sudo dscl localhost -append /Local/Default/Groups/admin GroupMembership username
* Adobe Updater Crashes on Mac OS X Fix
>> sudo /Applications/Utilities/Adobe\ Utilities.localized/Adobe\ Updater5/Adobe\ Updater.app/Contents/MacOS/Adobe\ Updater
* A faster ls
>> echo *
* A function to find the newest file of a set.
>> newest () { candidate=''; for i in "$@"; do [[ -f $i ]] || continue; [[ -z $candidate || $i -nt $candidate ]] && candidate="$i"; done; echo "$candidate"; }
* A fun thing to do with ram is actually open it up and take a peek. This comman
>> d will show you all the string (plain text) values in ramstrings /dev/mem|less
* A fun thing to do with ram is actually open it up and take a peek. This comman
>> d will show you all the string (plain text) values in ramsudo strings /dev/mem
* Alert on Mac when server is up
>> ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1'
* Alias for getting OpenPGP keys for Launchpad PPAs on Ubuntu
>> alias launchpadkey="sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys"
* alias to close terminal with :q
>> alias ':q'='exit'
* Alias to edit and source your .bashrc file
>> alias vb='vim ~/.bashrc; source ~/.bashrc'
* alias to list hidden files of a folder
>> alias lh='ls -a | egrep "^\."'
* alias to show my own configured ip
>> alias showip="ifconfig eth0 | grep 'inet addr:' | sed 's/.*addr\:\(.*\) Bcast\:.*/\1/'"
* Allows incoming traffic from specific IP address to port 80
>> sudo ufw allow proto tcp from 1.2.3.4 to any port 80
* Alternative size (human readable) of directories (biggest first)
>> du -h -s -x * | sort -g -b -r | less -F
* Alternative size (human readable) of directories (biggest first)
>> function duf { du -k $@ | sort -rn | perl -ne '($s,$f)=split(/\t/,$_,2);for(qw(K M G T)){if($s<1024){$x=($s<10?"%.1f":"%3d");printf("$x$_\t%s",$s,$f);last};$s/=1024}' }
* Alternative size (human readable) of directories (biggest last)
>> function duf { du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done; }
* Alternative size (human readable) of files and directories (biggest last)
>> du -ms * | sort -nk1
* Alternative size (human readable) of files and directories (biggest last)
>> du -ms * .[^.]*| sort -nk1
* Amazing real time picture of the sun in your wallpaper
>> curl http://sohowww.nascom.nasa.gov/data/realtime/eit_195/512/latest.jpg | xli -onroot -fill stdin
* amixer : raise volume and unmute if necessary
>> amixer -c 0 set Master 1+ unmute
* Analyse compressed Apache access logs for the most commonly requested pages
>> zcat access_log.*.gz | awk '{print $7}' | sort | uniq -c | sort -n | tail -n 20
* analyze traffic remotely over ssh w/ wireshark
>> mkfifo /tmp/fifo; ssh-keygen; ssh-copyid root@remotehostaddress; sudo ssh root@remotehost "tshark -i eth1 -f 'not tcp port 22' -w -" > /tmp/fifo &; sudo wireshark -k -i /tmp/fifo;
* analyze traffic remotely over ssh w/ wireshark
>> ssh root@server.com 'tshark -f "port !22" -w -' | wireshark -k -i -
* analyze traffic remotely over ssh w/ wireshark
>> sudo ssh -Y remoteuser@remotehost sudo wireshark
* Another Matrix Style Implementation
>> COL=$(( $(tput cols) / 2 )); clear; tput setaf 2; while :; do tput cup $((RANDOM%COL)) $((RANDOM%COL)); printf "%$((RANDOM%COL))s" $((RANDOM%2)); done
* Another Matrix Style Implementation
>> echo -ne "\e[32m" ; while true ; do echo -ne "\e[$(($RANDOM % 2 + 1))m" ; tr -c"[:print:]" " " < /dev/urandom | dd count=1 bs=50 2> /dev/null ; done
* Another way to calculate sum size of all files matching a pattern
>> find . -iname '*.jar' | xargs du -ks | cut -f1 | xargs echo | sed "s/ /+/g" | bc
* Another way to see the network interfaces
>> ip addr show
* Append output to the beginning of a file.
>> command > tmp && cat logfile.txt >> tmp && tmp > logfile.txt && rm tmp
* Apply substitution only on the line following a marker
>> sed '/MARKER/{N;s/THIS/THAT/}'
* A quick shell command to weed out the small wallpapers
>> for i in ~/Desktop/Personal/Wallpapers/*.jpg ; { size=$((`identify -format "%wx%h" $i | sed 's/x/*/'`)) ; if [[ $size -lt 800001 ]] then ; rm -f "$i" ; fi; }
* Archive all SVN repositories in platform indepenent form
>> budir=/tmp/bu.$$;for name in repMainPath/*/format;do dir=${name%/format};bufil=dumpPath/${dir##*/};svnadmin hotcopy --clean-logs $dir $budir;svnadmin dump --delta $budir>$bufil;rm -rf $budir;done
* Archive all SVN repositories in platform indepenent form
>> find repMainPath -maxdepth 1 -mindepth 1 -type d | while read dir; do echo processing $dir; sudo svnadmin dump --deltas $dir >dumpPath/`basename $dir`; done
* Archive every file in /var/logs
>> find /var/logs -name * | xargs tar -jcpf logs_`date +%Y-%m-%e`.tar.bz2
* a trash function for bash
>> trash
* Attach all discovered iscsi nodes
>> iscsiadm -m node -l
* Attach screen over ssh
>> ssh -t remote_host screen -r
* automount samba shares as devices in /mnt/
>> sudo vi /etc/fstab; Go//smb-share/gino /mnt/place smbfs defaults,username=gino,password=pass 0 0:wq; mount //smb-share/gino
* autossh + ssh + screen = super rad perma-sessions
>> AUTOSSH_POLL=1 autossh -M 21010 hostname -t 'screen -Dr'
* avi to ogv (Ogg Theora)
>> ffmpeg2theora input.avi
* Awk: Perform a rolling average on a column of data
>> awk 'BEGIN{size=5} {mod=NR%size; if(NR<=size){count++}else{sum-=array[mod]};sum+=$1;array[mod]=$1;print sum/count}' file.dat
* Backup all MySQL Databases to individual files
>> mysql -e 'show databases' | sed -n '2,$p' | xargs -I DB 'mysqldump DB > DB.sql'
* backup all your commandlinefu.com favourites to a plaintext file
>> clfavs(){ URL="http://www.commandlinefu.com";wget -O - --save-cookies c --post-data "username=$1&password=$2&submit=Let+me+in" $URL/users/signin;for i in `seq 0 25 $3`;do wget -O - --load-cookies c $URL/commands/favourites/plaintext/$i >>$4;done;rm -f c;}
* backup and remove files with access time older than 5 days.
>> tar -zcvpf backup_`date +"%Y%m%d_%H%M%S"`.tar.gz `find -atime +5` 2> /dev/null | xargs rm -fr ;
* backup and synchronize entire remote folder locally (curlftpfs and rsync over
>> FTP using FUSE FS)curlftpfs ftp://YourUsername:YourPassword@YourFTPServerURL /tmp/remote-website/&& rsync -av /tmp/remote-website/* /usr/local/data_latest && umount /tmp/remote-website
* Back up a PLESK Installation
>> /opt/psa/bin/pleskbackup server -v --output-file=plesk_server.bak
* Backup a remote database to your local filesystem
>> ssh user@host 'mysqldump dbname | gzip' > /path/to/backups/db-backup-`date +%Y-%m-%d`.sql.gz
* Backup files incremental with rsync to a NTFS-Partition
>> rsync -rtvu --modify-window=1 --progress /media/SOURCE/ /media/TARGET/
* backup local MySQL database into a folder and removes older then 5 days backup
>> smysqldump -uUSERNAME -pPASSWORD database | gzip > /path/to/db/files/db-backup-`date +%Y-%m-%d`.sql.gz ;find /path/to/db/files/* -mtime +5 -exec rm {} \;
* back up your commandlinefu contributed commands
>> curl http://www.commandlinefu.com/commands/by//rss|gzip ->commandlinefu-contribs-backup-$(date +%Y-%m-%d-%H.%M.%S).rss.gz
* backup your entire hosted website using cPanel backup interface and wget
>> wget --http-user=YourUsername --http-password=YourPassword http://YourWebsiteUrl:2082/getbackup/backup-YourWebsiteUrl-`date +"%-m-%d-%Y"`.tar.gz
* Backup your hard drive with dd
>> sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
* badblocks for floppy
>> /sbin/badblocks -v /dev/fd0 1440
* Base conversions with bc
>> echo "obase=2; 27" | bc -l
* Bash Alias That Plays Music from SomaFM
>> alias somafm='read -p "Which station? "; mplayer --reallyquiet -vo none -ao sdlhttp://somafm.com/startstream=${REPLY}.pls'
* bash/ksh function: given a file, cd to the directory it lives
>> function fcd () { [ -f $1 ] && { cd $(dirname $1); } || { cd $1 ; } pwd }
* bash or tcsh redirect both to stdout and to a file
>> echo "Hello World." | tee -a hello.txt
* bash screensaver (scrolling ascii art with customizable message)
>> while [ 1 ]; do banner 'ze missiles, zey are coming! ' | while IFS="\n" read l;do echo "$l"; sleep 0.01; done; done
* Basic Local Port Scan
>> [command too long]
* batch convert Nikon RAW (nef) images to JPG
>> ufraw-batch --out-type=jpeg --out-path=./jpg ./*.NEF
* batch convert OGG to WAV
>> for f in *.ogg ; do mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="$f.wav" "$f" ; done
* Batch file name renaming (copying or moving) w/ glob matching.
>> for x in *.ex1; do mv "${x}" "${x%ex1}ex2"; done
* Batch image resize
>> for a in `ls`; do echo $a && convert $a -resize x $a; done
* beep when a server goes offline
>> while true; do [ "$(ping -c1W1w1 server-or-ip.com | awk '/received/ {print $4}')" != 1 ] && beep; sleep 1; done
* benchmark web server with apache benchmarking tool
>> ab -n 9000 -c 900 localhost:8080/index.php
* Be notified about overheating of your CPU and/or motherboard
>> sensors | grep "Core 1" | [[ `sed -e 's/^.*+\([0-9]\{2,3\}\).*(.*/\1/'` -gt 50 ]] && notify-send "Core 1 temperature exceeds 50 degrees"
* Binary Clock
>> watch -n 1 'echo "obase=2;`date +%s`" | bc'
* Binary editor
>> bvi [binary-file]
* Binary injection
>> echo -n $HEXBYTES | xxd -r -p | dd of=$FILE seek=$((0x$OFFSET)) bs=1 conv=notrunc
* Both view and pipe the file without saving to disk
>> cat /path/to/some/file.txt | tee /dev/pts/0 | wc -l
* Browse system RAM in a human readable form
>> sudo cat /proc/kcore | strings | awk 'length > 20' | less
* Brute force discover
>> sudo zcat /var/log/auth.log.*.gz | awk '/Failed password/&&!/for invalid user/{a[$9]++}/Failed password for invalid user/{a["*" $11]++}END{for (i in a) printf "%6s\t%s\n", a[i], i|"sort -n"}'
* Buffer in order to avoir mistakes with redirections that empty your files
>> buffer () { tty -s && return; tmp=$(mktemp); cat > "${tmp}"; if [ -n "$1" ] && ( ( [ -f "$1" ] && [ -w "$1" ] ) || ( ! [ -a "$1" ] && [ -w "$(dirname "$1")" ] ) ); then mv -f "${tmp}" "$1"; else echo "Can't write in \"$1\""; rm -f "${tmp}"; fi }
* Build an exhaustive list of maildir folders for mutt
>> find ~/Maildir/ -mindepth 1 -type d | egrep -v '/cur$|/tmp$|/new$' | xargs
* Burn a directory of mp3s to an audio cd.
>> alias burnaudiocd='mkdir ./temp && for i in *.[Mm][Pp]3;do mpg123 -w "./temp/${i%%.*}.wav" "$i";done;cdrecord -pad ./temp/* && rm -r ./temp'
* Bypass 1000 Entry limit of Active Directory with ldapsearch
>> ldapsearch -LLL -H ldap://${HOST}:389 -b 'DC=${DOMAIN},DC=${TLD}' -D '${USER}'-w 'password' objectclass=* -E pr=2147483647/noprompt
* Calculating series with awk: add numbers from 1 to 100
>> awk 'BEGIN {for(i=1;i<=100;i++)sum+=i}; END {print sum}' /dev/null
* Calculating series with awk: add numbers from 1 to 100
>> seq 100 | awk '{sum+=$1} END {print sum}'
* Cap apt-get download speed
>> sudo apt-get -o Acquire::http::Dl-Limit=25 install
* Capture data in ASCII. 1500 bytes
>> tcpdump -ieth0 -n tcp port 80 -A -s1500
* Carriage return for reprinting on the same line
>> while true; do echo -ne "$(date)\r"; sleep 1; done
* cat large file to clipboard with speed-o-meter
>> pv large.xml | xclip
* cd up a number of levels
>> function ..(){ for ((j=${1:-1},i=0;i> cd /usr/home && for i in *;do chsh -s bash $i;done
* change exif data in all jpeg's
>> for f in *.jpg; do exif --ifd=0 --tag=0x0110 --set-value="LOMO LC-A" --output=$f $f; exif --ifd=0 --tag=0x010f --set-value="LOMO" --output=$f $f; done }
* Change Gnome wallpaper
>> gconftool-2 -t string -s /desktop/gnome/background/picture_filename
* change newlines to spaces (or commas or whatever). Acts as a filter or can hav
>> e c/l argsalias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) ,qq{\n};}' "
* change ownership en masse of files owned by a specific user, including files a
>> nd directories with spacesfind . -uid 0 -print0 | xargs -0 chown foo:foo
* Change permissions of every directory in current directory
>> find . -type d -exec chmod 755 {} \;
* Change the case of a single word in vim
>> g~w
* Change Title of Terminal Window to Verbose Info useful at Login
>> echo -ne "\033]0;`id -un`:`id -gn`@`hostname||uname -n|sed 1q` `who -m|sed -e "s%^.* \(pts/[0-9]*\).*(\(.*\))%[\1] (\2)%g"` [`uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g"` / `ps aux|wc -l`]\007"
* Change user, assume environment, stay in current dir
>> su -- user
* Change wallpaper for xfce4 >= 4.6.0
>> xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s
* Change Windows Domain password from Linux
>> smbpasswd -r -U
* Changing tha mac adresse
>> sudo ifconfig eth0 hw ether 00:01:02:03:04:05
* Changing the terminal title to the last shell command
>> if [ "$SHELL" = '/bin/zsh' ]; then case $TERM in rxvt|*term|linux) preexec () {print -Pn "\e]0;$1\a" };; esac; fi
* Changing the terminal title to the last shell command
>> trap 'echo -e "\e]0;$BASH_COMMAND\007"' DEBUG
* Changing the terminal title to the last shell command
>> [[ "x$TERM" == "xrxvt" || "x$XTERM_VERSION" == xXTerm* || "x$COLORTERM" == 'gnome-terminal' && "x$SHELL" == */bin/zsh ]] && preexec () { print -Pn "\e]0;$1\a" }
* Check a server is up. If it isn't mail me.
>> curl -fs brandx.jp.sme 2&>1 > /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk
* Check a server is up. If it isn't mail me.
>> ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk
* Check availability of Websites based on HTTP_CODE
>> urls=('www.ubuntu.com' 'google.com'); for i in ${urls[@]}; do http_code=$(curl -I -s $i -w %{http_code}); echo $i status: ${http_code:9:3}; done
* Check cobbler environment
>> cobbler check
* Check for login failures and summarize
>> zgrep "Failed password" /var/log/auth.log* | awk '{print $9}' | sort | uniq -c | sort -nr | less
* Check if a domain is available and get the answer in just one line
>> whois domainnametocheck.com | grep match
* Check if a .no domain is available
>> check_dns_no() { for i in $* ; do if `wget -O - -q http://www.norid.no/domenenavnbaser/whois/?query=$i.no | grep "no match" &>/dev/null` ; then echo $i.no "available" ; fi ; sleep 1 ;done }
* Check if a process is running
>> kill -0 [pid]
* Check if filesystem hangs
>> ls /mnt/badfs &
* Check if variable is a number
>> if [ "$testnum" -eq "$testnum" 2>/dev/null ]; then echo It is numeric; fi
* Check if you need to run LaTeX more times to get the refefences right
>> egrep "(There were undefined references|Rerun to get (cross-references|the bars) right)" texfile.log
* Checking total connections to each Ip inserver
>> netstat -alpn | grep :80 | awk '{print $4}' |awk -F: '{print $(NF-1)}' |sort |uniq -c | sort -n
* Check processes runed not by you
>> ps aux | grep -v `whoami`
* Check reverse DNS
>> dig +short -x {ip}
* Check reverse DNS
>> dig -x {IP}
* Check reverse DNS
>> host {checkIp or hostname} [dns server]
* Check reverse DNS
>> nslookup {ip}
* Checks apache's access_log file, strips the search queries and shoves them up
>> your e-mailawk '/q=/{print $11}' /var/log/httpd/access_log.4 | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1
* Checks apache's access_log file, strips the search queries and shoves them up
>> your e-mailcat /var/log/httpd/access_log | grep q= | awk '{print $11}' | awk -F 'q=' '{print $2}' | sed 's/+/ /g;s/%22/"/g;s/q=//' | cut -d "&" -f 1 | mail youremail@isp.com -s "[your-site] search strings for `date`"
* checks if host /service is up on a host that doesn't respond to ping
>> while true; do clear; nmap ${hostname} -PN -p ${hostport}; sleep 5; done
* Check syntax of all PHP files before an SVN commit
>> for i in `svn status | egrep '^(M|A)' | sed -r 's/\+\s+//' | awk '{ print $2 }'` ; do if [ ! -d $i ] ; then php -l $i ; fi ; done
* Check the apt security keys
>> apt-key list
* Check the backdoors and security.chkrootkit is a tool to locally check for sig
>> ns of a rootkit.chkrootkit -x | less
* Check the last 15 package operations (on yum systems)
>> tail -n 15 /var/log/yum.log | tac
* Check the status of a network interface
>> mii-tool [if]
* Check variable has been set
>> : ${VAR:?unset variable}
* Check version of DNS Server
>> nslookup -q=txt -class=CHAOS version.bind NS.PHX5.NEARLYFREESPEECH.NET
* Check which files are opened by Firefox then sort by largest size.
>> FFPID=$(pidof firefox-bin) && lsof -p $FFPID | awk '{ if($7>0) print ($7/1024/1024)" MB -- "$9; }' | grep ".mozilla" | sort -rn
* Check your unread Gmail from the command line
>> curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
* Check your unread Gmail from the command line
>> curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'
* Cleanly manage tempfiles in scripts
>> TMPROOT=/tmp; TMPDIR=$(mktemp -d $TMPROOT/somedir.XXXXXX); TMPFILE=$(mktemp $TMPROOT/somefile.XXXXXX); trap "rm -rf $TMPDIR $TMPFILE; exit" INT TERM EXIT; sometreatment using $TMPDIR and $TMPFILE; exit 0
* Cleanly quit KDE4 apps
>> kquitapp plasma
* Clean swap area after using a memory hogging application
>> swapoff -a ; swapon -a
* Cleanup firefox's database.
>> find ~/Library/Application\ Support/Firefox/ -type f -name "*.sqlite" -exec sqlite3 {} VACUUM \;
* Cleanup firefox's database.
>> find ~/.mozilla/firefox/ -type f -name "*.sqlite" -exec sqlite3 {} VACUUM \;
* Cleanup firefox's database.
>> pgrep -u `id -u` firefox-bin || find ~/.mozilla/firefox -name '*.sqlite'|(whileread -e f; do echo 'vacuum;'|sqlite3 "$f" ; done)
* Clean up poorly named TV shows.
>> rename -v 's/.*[s,S](\d{2}).*[e,E](\d{2}).*\.avi/SHOWNAME\ S$1E$2.avi/' poorly.named.file.s01e01.avi
* Clean your broken terminal
>> stty sane
* Clear current session history
>> history -r
* Clears Firefox` cache without clicking around
>> rm_cache() { rm -f $HOME/.mozilla/firefox//Cache/* }; alias rmcache='rm_cache'
* Click on a GUI window and show its process ID and command used to run the proc
>> essxprop | awk '/PID/ {print $3}' | xargs ps h -o pid,cmd
* clone a hard drive to a remote directory via ssh tunnel, and compressing the i
>> mage
* Clone current directory into /destination verbosely
>> find . | cpio -pumdv /destination
* Clone /
>> find . -path ./mnt -prune -o -path ./lost+found -prune -o -path ./sys -prune -o-path ./proc -prune -o -print | cpio -pumd /destination && mkdir /destination/mnt/ && mkdir /destination/proc && mkdir /destination/sys
* Clone IDE Hard Disk
>> sudo dd if=/dev/hda1 of=/dev/hdb2
* Collect a lot of icons from /usr/share/icons (may overwrite some, and complain
>> a bit)mkdir myicons; find /usr/share/icons/ -type f -exec cp {} ./myicons/ \;
* Collect a lot of icons from /usr/share/icons (may overwrite some, and complain
>> a bit)mkdir myicons && find /usr/share/icons/ -type f | xargs cp -t myicons
* Colored diff ( via vim ) on 2 remotes files on your local computer.
>> vimdiff scp://root@server-foo.com//etc/snmp/snmpd.conf scp://root@server-bar.com//etc/snmp/snmpd.conf
* colored prompt
>> export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
* Colored SVN diff
>> svn diff | vim -R -
* colored tail
>> tail -f FILE | grep --color=always KEYWORD
* Colorized grep in less
>> ack --pager='less -r'
* Colorized grep in less
>> grep --color=always | less -R
* Combine all .mpeg files in current directory into one big one.
>> cat *.mpg > all.mpg
* Command Line to Get the Stock Quote via Yahoo
>> curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=csco&f=l1'
* command! -nargs=1 Vs vs <args>
>> ;Create aliases for common vim minibuffer/cmd typos
* Command to build one or more network segments - with for
>> seg() { for b in $(echo $1); do for x in $(seq 10); do echo $b.$x; done; done }
* Command to build one or more network segments - with while
>> seg() { echo -e "$1" | while read LINE; do for b in $(seq 10); do echo $LINE.$b; done; done; }
* command to change the exif date time of a image
>> exiftool -DateTimeOriginal='2009:01:01 02:03:04' file.jpg
* Comment out a line in a file
>> sed -i '19375 s/^/#/' file
* Commit only newly added files to subversion repository
>> svn ci `svn stat |awk '/^A/{printf $2" "}'`
* Compare two directory trees.
>> diff <(cd dir1 && find | sort) <(cd dir2 && find | sort)
* complete extraction of a debian-package
>> dpkg-deb -x $debfile $extractdir; dpkg-deb -e $debfile $extractdir/DEBIAN;
* Compress archive(s) or directory(ies) and split the output file
>> rar a -m5 -v5M -R myarchive.rar /home/
* Compression formats Benchmark
>> for a in bzip2 lzma gzip;do echo -n>$a;for b in $(seq 0 256);do dd if=/dev/zeroof=$b.zero bs=$b count=1;c=$(date +%s%N);$a $b.zero;d=$(date +%s%N);total=$(echo $d-$c|bc);echo $total>>$a;rm $b.zero *.bz2 *.lzma *.gz;done;done
* concatenate avi files
>> avimerge -o output.avi -i file1.avi file2.avi file3.avi
* configify the list of gems on ur machine. the quick hack
>> gem list --local | python -c "import sys;import re;l=sys.stdin.readlines();x=['config.gem :'+line[:-1][:line.index(' ')] + ' , ' +line[:-1][line.index(' '):].replace('(',':version => ').replace(')','') for line in l];print '\n'.join(x)"
* configify the list of gems on ur machine. the quick hack
>> gem list --local | python -c "import sys;import re;l=sys.stdin.readlines();x=['config.gem \"'+line[:-1][:line.index(' ')] + '\" , ' +line[:-1][line.index(' '):].replace('(',':version => \"').replace(')','')+'\"' for line in l];print '\n'.join(x)"
* Configure a serial line device so you can evaluate it with a shell script
>> stty -F "/dev/ttyUSB0" 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke time 5 min 1 line 0
* Connect to all running screen instances
>> for i in `screen -ls | perl -ne'if(/^\s+\d+\.([^\s]+)/){print $1, " "}'`; do gnome-terminal -e "screen -x $i"; done
* Connect to google talk through ssh by setting your IM client to use the localh
>> ost 5432 portssh -f -N -L 5432:talk.google.com:5222 user@home.network.com
* Connect to SMTP server using STARTTLS
>> openssl s_client -starttls smtp -crlf -connect 127.0.0.1:25
* Convert a bunch of oggs into mp3s
>> for x in *.ogg; do ffmpeg -i "$x" "`basename "$x" .ogg`.mp3"
* Convert a file from ISO-8859-1 (or whatever) to UTF-8 (or whatever)
>> tcs -f 8859-1 -t utf /some/file
* Convert a flv video file to avi using mencoder
>> mencoder your_video.flv -oac mp3lame -ovc xvid -lameopts preset=standard:fast -xvidencopts pass=1 -o your_video.avi
* convert all files in a dir of a certain type to flv
>> for f in *.m4a; do ffmpeg -i "$f" "${f%.m4a}.flv"; done
* Convert all MySQL tables and fields to UTF8
>> mysql --database=dbname -B -N -e "SHOW TABLES" | awk '{print "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"}' | mysql --database=dbname &
* Convert a MOV captured from a digital camera to a smaller AVI
>> ffmpeg -i input.mov -b 4096k -vcodec msmpeg4v2 -acodec pcm_u8 output.avi
* Convert a mp3 file to m4a
>> mplayer -vo null -vc null -ao pcm:fast:file=file.wav file.mp3; faac -b 128 -c 44100 -w file.wav
* convert a pdf to jpeg
>> sips -s format jpeg Bild.pdf --out Bild.jpg
* Convert a SVG file to grayscale
>> inkscape -f file.svg --verb=org.inkscape.color.grayscale --verb=FileSave --verb=FileClose
* Convert a VMWare screencast into a flv file
>> mencoder -of avi -ovc lavc movie.avi -o movie2.avi; ffmpeg -i movie2.avi -r 12-b 100 movie.flv
* convert a .wmv to a .avi
>> mencoder "/path/to/file.wmv" -ofps 23.976 -ovc lavc -oac copy -o "/path/to/file.avi"
* Convert decimal numbers to binary
>> function decToBin { echo "ibase=10; obase=2; $1" | bc; }
* Convert encoding of given files from one encoding to another
>> iconv -f utf8 -t utf16 /path/to/file
* convert filenames in current directory to lowercase
>> rename 'y/A-Z/a-z/' *
* Convert files with CR-terminated lines (as created by Mac OS X programs) into
>> NL-terminated lines suitable for Unix programsfunction crtonl { perl -i -ape 's/\r/\n/g;' $* ; }
* Convert .flv to .3gp
>> ffmpeg -i file.flv -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y out.3gp
* Convert images to a multi-page pdf
>> convert -adjoin -page A4 *.jpeg multipage.pdf
* Convert man page to PDF
>> man -Tps ls >> ls_manpage.ps && ps2pdf ls_manpage.ps
* Convert "man page" to text file
>> man ls | col -b > ~/Desktop/man_ls.txt
* Convert mp3/wav file to asterisk ulaw for music on hold (moh)
>> sox -v 0.125 -V -t au -r 8000 -U -b -c 1 resample -ql
* Convert ogg to mp3
>> for x in *.ogg; do ffmpeg -i "$x" "`basename "$x" .ogg`.mp3"; done
* Convert seconds to human-readable format
>> date -d@1234567890
* Converts to PDF all the OpenOffice.org files in the directory
>> for i in $(ls *.od{tp]); do unoconv -f pdf $i; done
* convert strings toupper/tolower with tr
>> echo "aBcDeFgH123" | tr a-z A-Z
* convert unixtime to human-readable
>> echo "0t${currentEpoch}=Y" | /usr/bin/adb
* convert unixtime to human-readable
>> perl -e 'print scalar(gmtime(1234567890)), "\n"'
* convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk forma
>> t)VBoxManage internalcommands converttoraw winxp.vdi winxp.raw && qemu-img convert -O vmdk winxp.raw winxp.vmdk && rm winxp.raw
* Convert video files to XviD
>> mencoder "$1" -ofps 23.976 -ovc lavc -oac copy -o "$1".avi
* convert wav files to flac
>> flac --best *.wav
* convert wav files to ogg
>> oggenc *.wav
* Convert Windows/DOS Text Files to Unix
>> Convert Windows/DOS Text Files to Uni
* Convert Windows/DOS Text Files to Unix
>> flip -u
* Convert .wma files to .ogg with ffmpeg
>> find -name '*wma' -exec ffmpeg -i {} -acodec vorbis -ab 128k {}.ogg \;
* Convert your favorite image in xpm for using in grub
>> convert image123.png -colors 14 -resize 640x480 grubimg.xpm
* cooking a list of numbers for calculation
>> echo $( du -sm /var/log/* | cut -f 1 ) | sed 's/ /+/g'
* copy ACL of one file to another using getfacl and setfacl
>> getfacl | setfacl -f -
* Copy a file over SSH without SCP
>> ssh HOST cat < LOCALFILE ">" REMOTEFILE
* Copy a file over SSH without SCP
>> uuencode -m
* Copy a folder tree through ssh using compression (no temporary files)
>> ssh 'tar -cz //' | tar -xvz
* Copy all documents PDF in disk for your home directory
>> find / -name "*.pdf" -exec cp -t ~/Documents/PDF {} +
* Copy all documents PDF in disk for your home directory
>> for i in `find / -name *.pdf`; do cp -v $i $HOME; done
* Copy all files. All normal files, all hidden files and all files starting with
>> - (minus).cp ./* .[!.]* ..?* /path/to/dir
* Copy All mp3 files in iTunes into one folder (Example: Music on Desktop) (Os X
>> )find ~/Music/iTunes/ -name *.mp3 -exec cp {} ~/Desktop/Music/ \;
* Copy data using gtar
>> gtar cpf - . | (cd /dest/directory; gtar xpf -)
* Copy files and directories from a remote machine to the local machine
>> ssh user@host "(cd /path/to/remote/top/dir ; tar cvf - ./*)" | tar xvf -
* Copy files from list with hierarchy
>> cat files.txt | xargs tar -cv | tar -x -c $DIR/
* Copy files over network using compression
>> on the listening side: sudo nc -lp 2022 | sudo tar -xvf - and on the sendingside: tar -cvzf - ./*| nc -w 3 name_of_listening_host 2022
* Copy input sent to a command to stderr
>> rev <<< 'lorem ipsum' | tee /dev/stderr | rev
* copy partition table from /dev/sda to /dev/sdb
>> sfdisk -d /dev/sda | sed 's/sda/sdb/g' | sfdisk /dev/sdb
* copy partition table from /dev/sda to /dev/sdb
>> sfdisk /dev/sdb <(sfdisk -d /dev/sda| perl -pi -e 's/sda/sdb/g')
* Copy recursivelly files of specific filetypes
>> rsync -rvtW --progress --include='*.wmv' --include='*.mpg' --exclude='*.*'
* Copy stdin to your X11 buffer
>> ssh user@host cat /path/to/some/file | xclip
* Copy structure
>> structcp(){ ( mkdir -pv $2;f="$(realpath "$1")";t="$(realpath "$2")";cd "$f";find * -type d -exec mkdir -pv $t/{} \;);}
* Copy the sound content of a video to an mp3 file
>> ffmpeg -i source.flv -vn acodec copy destination.mp3
* Copy with progress
>> copy(){ cp -v "$1" "$2"&watch -n 1 'du -h "$1" "$2";printf "%s%%\n" $(echo `du -h "$2"|cut -dG -f1`/0.`du -h "$1"|cut -dG -f1`|bc)';}
* copy working directory and compress it on-the-fly while showing progress
>> tar -cf - . | pv -s $(du -sb . | awk '{print $1}') | gzip > out.tgz
* Count all conections estabilished on gateway
>> cat /proc/net/ip_conntrack | grep ESTABLISHED | grep -c -v ^#
* count and number lines of output, useful for counting number of matches
>> ps aux | grep [h]ttpd | cat -n
* Count emails in an MBOX file
>> grep -c '^From ' mbox_file
* count how many times a string appears in a (source code) tree
>> $ grep -or string path/ | wc -l
* count how many times a string appears in a (source code) tree
>> grep -rc logged_in app/ | cut -d : -f 2 | awk '{sum+=$1} END {print sum}'
* count occurences of each word in novel David Copperfield
>> wget -q -O- http://www.gutenberg.org/dirs/etext96/cprfd10.txt | sed '1,419d' |tr "\n" " " | tr " " "\n" | perl -lpe 's/\W//g;$_=lc($_)' | grep "^[a-z]" | awk'length > 1' | sort | uniq -c | awk '{print $2"\t"$1}'
* Count the total number of files in each immediate subdirectory
>> find . -type f -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
* Count the total number of files in each immediate subdirectory
>> ps -ef | grep pmon
* Count to 65535 in binary (for no apparent reason)
>> a=`printf "%*s" 16`;b=${a//?/{0..1\}}; echo `eval "echo $b"`
* covert m4a audio files to wav
>> find . -name '*.m4a' | xargs -I audiofile mplayer -ao pcm "audiofile" -ao pcm:file="audiofile.wav"
* CPU model
>> cat /proc/cpuinfo
* Creat a tar file for backup info
>> tar --create --file /path/$HOSTNAME-my_name_file-$(date -I).tar.gz --atime-preserve -p -P --same-owner -z /path/
* Create a directory and change into it at the same time
>> md () { mkdir -p "$@" && cd "$@"; }
* Create a favicon
>> convert -colors 256 -resize 16x16 face.jpg face.ppm && ppmtowinicon -output favicon.ico face.ppm
* Create a file list of all package files installed on your Red-Hat-like system
>> for easy greppingfor i in `rpm -qva | sort ` ; do ; echo "===== $i =====" ; rpm -qvl $i ; done >/tmp/pkgdetails
* Create a list of binary numbers
>> echo {0..1}{0..1}{0..1}{0..1}
* Create an audio test CD of sine waves from 1 to 99 Hz
>> (echo CD_DA; for f in {01..99}; do echo "$f Hz">&2; sox -nt cdda -r44100 -c2 $f.cdda synth 30 sine $f; echo TRACK AUDIO; echo FILE \"$f.cdda\" 0; done) > cdrdao.toc && cdrdao write cdrdao.toc && rm ??.cdda cdrdao.toc
* create an emergency swapfile when the existing swap space is getting tight
>> sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000;sudo mkswap /swapfile; sudo swapon /swapfile
* Create an ISO Image from a folder and burn it to CD
>> hdiutil makehybrid -o CDname.iso /Way/to/folder ; hdiutil burn CDname.iso
* create an mp3 with variable bitrate
>> lame -h -V 6 track9.wav track9.mp3
* Create a P12 file, using OpenSSL
>> openssl pkcs12 -export -in /dir/CERTIFICATE.pem -inkey /dir/KEY.pem -certfile /dir/CA-cert.pem -name "certName" -out /dir/certName.p12
* Create a random file of a specific size
>> dd if=/dev/zero of=testfile.txt bs=1M count=10
* Create a simple backup
>> tar pzcvf /result_path/result.tar.gz /target_path/target_folder
* Create a single-use TCP (or UDP) proxy
>> nc -l -p 2000 -c "nc example.org 3000"
* Create a single-use TCP proxy with copy to stdout
>> gate() { mkfifo /tmp/sock1 /tmp/sock2 &> /dev/null && nc -p $1 -l < /tmp/sock1 | tee /tmp/sock2 & PID=$! && nc $2 $3 < /tmp/sock2 | tee /tmp/sock1; kill -KILL $PID; rm -f /tmp/sock1 /tmp/sock2 ; }
* Create a single-use TCP proxy with debug output to stderr
>> socat -v tcp4-l: tcp4::
* Create a tar archive using 7z compression
>> tar cf - /path/to/data | 7z a -si archivename.tar.7z
* Create a tar.gz in a single command
>> tar cvf - foodir | gzip > foo.tar.gz
* Create AUTH PLAIN string to test SMTP AUTH session
>> printf '\!:1\0\!:1\0\!:2' | mmencode | tr -d '\n' | sed 's/^/AUTH PLAIN /'
* Create a video that is supported by youtube
>> ffmpeg -i mymovie.mpg -ar 22050 -acodec libmp3lame -ab 32K -r 25 -s 320x240 -vcodec flv mytarget.flv
* Create a zip file ignoring .svn files
>> find . -not \( -name .svn -prune \) -type f | xargs zip XXXXX.zip
* Create a zip file ignoring .svn files
>> zip -r foo.zip DIR -x "*/.svn/*"
* Create black and white image
>> convert -colorspace gray face.jpg gray_face.jpg
* Create date based backups
>> backup() { for i in "$@"; do cp -va $i $i.$(date +%Y%m%d-%H%M%S); done }
* Create directory named after current date
>> mkdir $(date +%Y%m%d)
* Create Encrypted WordPress MySQL Backup without any DB details, just the wp-co
>> nfig.phpeval $(sed -e "s/^d[^D]*DB_\([NUPH]\).*',[^']*'\([^']*\)'.*/_\1='\2';/" -e "/^_/!d" wp-config.php) && mysqldump --opt --add-drop-table -u$_U -p$_P -h$_H $_N | gpg -er AskApache >`date +%m%d%y-%H%M.$_N.sqls`
* Create more threads with less stack space
>> ulimit -s 64
* Create new repo in Cobbler for CentOS 5.3 updates
>> cobbler repo add --name=CentOS-5.3-i386-updates --mirror=http://mirror3.mirror.garr.it/mirrors/CentOS/5.3/updates/i386/
* Creates a minimalist xorg.conf
>> dpkg-reconfigure -phigh xserver-xorg
* Creates a proxy based on tsocks.
>> alias tproxy='ssh -ND 8118 user@server&; export LD_PRELOAD="/usr/lib/libtsocks.so"'
* create SQL-statements from textfile with awk
>> for each in `cut -d " " -f 1 inputfile.txt`; do echo "select * from table whereid = \"$each\";"; done
* Creates Solaris alternate boot environment on another zpool.
>> lucreate -n be1 [-c be0] -p zpool1
* Create subdirectory and move files into it
>> (ls; mkdir subdir; echo subdir) | xargs mv
* create tar archive of files in a directory and its sub-directories
>> tar czf /path/archive_of_foo.`date -I`.tgz /path/foo
* create tar.gz archive
>> tar -pczf archive_name.tar.gz /path/to/dir/or/file
* Creating a Maven project
>> mvn archetype:create -DgroupId=my.work -DartifactId=MyProject
* Creating a Mirrored Storage Pool using Zpool
>> zpool create tank mirror c0t0d0 c0t1d0 mirror c0t2d0 c0t3d0
* Creating a ZFS Storage Pool by Using Files
>> zpool create tank /path/to/file/a /path/to/file/b
* Creating sequence of number with text
>> seq 10 |xargs -n1 echo Printing line
* Creating shortened URLs from the command line
>> curl -s http://tinyurl.com/create.php?url=http:/// | sed -n 's/.*\(http:\/\/tinyurl.com\/[a-z0-9][a-z0-9]*\).*/\1/p' | uniq
* c_rehash replacement
>> for file in *.pem; do ln -s $file `openssl x509 -hash -noout -in $file`.0; done
* currently mounted filesystems in nice layout
>> column -t /proc/mounts
* currently mounted filesystems in nice layout
>> mount | column -t
* Current sub-folders sizes
>> du -sh *
* Cut out a piece of film from a file. Choose an arbitrary length and starting t
>> ime.ffmpeg -vcodec copy -acodec copy -i orginalfile -ss 00:01:30 -t 0:0:20 newfile
* Day Date Time> Instead of $ or # at the terminal
>> export PS1='\D{%a %D %T}> '
* dd if=/dev/sda | gzip -c | ssh user@ip 'dd of=/mnt/backups/sda.dd'
* (Debian/Ubuntu) Discover what package a file belongs to
>> dpkg -S /usr/bin/ls
* Decode a MIME message
>> munpack file.txt
* decoding Active Directory date format
>> ldapsearch -v -H ldap:// -x -D cn=,cn=,dc=,dc= -w -b ou=,dc=,dc= -s sub sAMAccountName=* '*' | perl -pne 's/(\d{11})\d{7}/"DATE-AD(".scalar(localtime($1-11644473600)).")"/e'
* Define an alias with a correct completion
>> old='apt-get'; new="su-${old}"; command="sudo ${old}"; alias "${new}=${command}"; $( complete | sed -n "s/${old}$/${new}/p" ); alias ${new}; complete -p ${new}
* Define a quick calculator function
>> ? () { echo "$*" | bc -l; }
* Delete all aliases for a network interface on a (Free)BSD system
>> ifconfig | grep "0xffffffff" | awk '{ print $2 }' | xargs -n 1 ifconfig em0 delete
* Delete all but the latest 5 files, ignoring directories
>> ls -lt|grep ^-|awk 'NR>5 { print $8 }'|xargs -r rm
* Delete all but the latest 5 files
>> ls -t | awk 'NR>5 {system("rm \"" $0 "\"")}'
* Delete all but the latest 5 files
>> ls -t | tail +6 | xargs rm
* delete all DrWeb status, failure and other messages on a postfix server
>> mailq | grep DrWEB | awk {'print $1'} | sed s/*//g | postsuper -d -
* Delete all files found in directory A from directory B
>> for file in /*; do rm /`basename $file`; done
* Delete all files in current directory that have been modified less than 5 days
>> ago.find ./ -mtime -5 | xargs rm -f
* Delete Empty Directories
>> find . -type d -exec rmdir {} \;
* Delete empty directories with zsh
>> rm -d **/*(/^F)
* Delete files older than..
>> find /dir_name -mtime +5 -exec rm {} \
* Delete line number 10 from file
>> sed -i '10d'
* Delete more than one month old thumbnails from home directory
>> find ~/.thumbnails/ -type f -atime +30 -print0 | xargs -0 rm
* detected hardware and boot messages
>> sudo dmesg
* Detect encoding of a text file
>> file -i
* detect the Super I/O chip on your computer, tell you at which configuration po
>> rt it is located and can dump all the register contents.superiotool
* Determine an image's dimensions
>> identify -format "%wx%h" /path/to/image.jpg
* Determine configure options used for MySQL binary builds
>> cat `whereis mysqlbug | awk '{print $2}'` | grep 'CONFIGURE_LINE='
* Determine configure options used for MySQL binary builds
>> grep CONFIG $(which mysqlbug)
* determine if tcp port is open
>> if (nc -zw2 www.example.com 80); then echo open; fi
* determine if tcp port is open
>> nc -zw2 www.example.com 80 && echo open
* determine if tcp port is open
>> nmap -p 80 hostname
* Determine what an process is actually doing
>> sudo strace -pXXXX -e trace=file
* Diff files on two remote hosts.
>> diff <(ssh alice cat /etc/apt/sources.list) <(ssh bob cat /etc/apt/sources.list)
* Diff with colour highlighting
>> svn diff ARGUMENTS_FOR_DIFF | source-highlight --out-format=esc --src-lang=diff
* Disable all iptables rules without disconnecting yourself
>> iptables -F && iptables -X && iptables -P INPUT ACCEPT && iptables -OUTPUT ACCEPT
* Disable annoying sound emanations from the PC speaker
>> sudo rmmod pcspkr
* Disable beep sound from your computer
>> echo "blacklist pcspkr"|sudo tee -a /etc/modprobe.d/blacklist.conf
* disable caps lock
>> xmodmap -e "remove Lock = Caps_Lock"
* Display a block of text with vim with offset, like with AWK
>> vim -e -s -c 'g/start_pattern/+1,/stop_pattern/-1 p' -cq file.txt
* Display a cool clock on your terminal
>> watch -t -n1 "date +%T|figlet"
* Display a File with Line Number
>> nl filename | more
* Display all installed ISO/IEC 8859 manpages
>> for i in $(seq 1 11) 13 14 15 16; do man iso-8859-$i; done
* Display all readline binding that use CTRL
>> bind -p | grep -F "\C"
* Display Dilbert strip of the day
>> display http://dilbert.com$(curl -s dilbert.com|grep -Po '"\K/dyn/str_strip(/0+){4}/.*strip.[^\.]*\.gif')
* Display duplicated lines in a file
>> cat file.txt | sort | uniq -dc
* display embeded comments for every --opt, usefull for auto documenting your sc
>> riptvim -n -es -c 'g/# CommandParse/+2,/^\s\+esac/-1 d p | % d | put p | %<' -c 'g/^\([-+]\+[^)]\+\))/,/^\(\s\+[^- \t#]\|^$\)/-1 p' -c 'q!' $0
* Display information sent by browser
>> nc -l 8000
* Display IP adress of the given interface in a most portable and reliable way.
>> That should works on many platforms.x=IO::Interface::Simple; perl -e 'use '$x';' &>/dev/null || cpan -i "$x"; perl -e 'use '$x'; my $ip='$x'->new($ARGV[0]); print $ip->address,$/;'
* Display kernel profile of currently executing functions in Solaris.
>> lockstat -I -i 977 -s 30 -h sleep 1 > /tmp/profile.out
* Display laptop battery information
>> cat /proc/acpi/battery/BAT1/info
* Display rows and columns of random numbers with awk
>> seq 6 | awk '{for(x=1; x<=5; x++) {printf ("%f ", rand())}; printf ("\n")}'
* Displays a 3-Month Calendar
>> cal -3
* Display screen window number in prompt
>> [[ "$WINDOW" ]] && PS1="\u@\h:\w[$WINDOW]\$ "
* Display _something_ when an X app fails
>> xlaunch(){ T=/tmp/$$;sh -c "$@" >$T.1 2>$T.2;S=$?;[ $S -ne 0 ]&&{ echo -e "'$@'failed with error $S\nSTDERR:\n$(cat $T.2)\nSTDOUT:\n$(cat $T.1)\n"|xmessage -file -;};rm -f $T.1 $T.2;}
* Display summary of git commit ids and messages for a given branch
>> git log master | awk '/commit/ {id=$2} /\s+\w+/ {print id, $0}'
* Display summary of git commit ids and messages for a given branch
>> git log --pretty='format:%Cgreen%H %Cred%ai %Creset- %s'
* Display the history and optionally grep
>> h() { if [ -z "$1" ]; then history; else history | grep "$@"; fi; }
* Display the list of all opened tabs from Firefox via a python one-liner and a
>> shell hack to deal with python indentation.python <<< $'import minjson\nf = open("sessionstore.js", "r")\njdata = minjson.read(f.read())\nf.close()\nfor win in jdata.get("windows"):\n\tfor tab in win.get("tabs"):\n\t\ti = tab.get("index") - 1\n\t\tprint tab.get("entries")[i].get("url")'
* Display the output of a command from the first line until the first instance o
>> f a regular expression.command | sed -n '1,/regex/p'
* Display the output of a command from the first line until the first instance o
>> f a regular expression.command | sed '/regex/q'
* Display the standard deviation of a column of numbers with awk
>> awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END {print sqrt(mean2 / NR); }'
* display typedefs, structs, unions and functions provided by a header file
>> cpp /usr/include/stdio.h | grep -v '^#' | grep -v '^$' | less
* Display which distro is installed
>> test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
* DNS cache snooping
>> for i in `cat names.txt`; do host -r $i [nameserver]; done
* do a directory disk usage summary without giving the details for the subdirect
>> oriesfor dir in $(ls); do du -sk ${dir}; done
* do a release upgrade in ubuntu
>> do-release-upgrade
* Do a search-and-replace in a file after making a backup
>> sed -i.bak 's/old/new/g' file
* dolphins on the desktop (compiz)
>> xwinwrap -ni -argb -fs -s -st -sp -nf -b -- /usr/libexec/xscreensaver/atlantis -count 20 -window-id WID &
* Do quick arithmetic on numbers from STDIN with any formatting using a perl one
>> liner.perl -ne '$sum += $_ for grep { /\d+/ } split /[^\d\-\.]+/; print "$sum\n"'
* dos2unix
>> $ perl -pi -e 's/\r\n/\n/g'
* Download all Delicious bookmarks
>> curl -u username -o bookmarks.xml https://api.del.icio.us/v1/posts/all
* download all the presentations from UTOSC2009
>> b="http://2009.utosc.com"; for p in $( curl -s $b/presentation/schedule/ | grep/presentation/[0-9]*/ | cut -d"\"" -f2 ); do f=$(curl -s $b$p | grep "/static/slides/" | cut -d"\"" -f4); if [ -n "$f" ]; then echo $b$f; curl -O $b$f; fi done
* Download all the Super Mario World Hacks from smwcentral.net
>> smw=http://www.smwcentral.net;for f in $(curl -s "$smw/?p=hacks"|grep -o "download.php?id=[0-9]*&type=hack"); do i=$(echo $f|sed "s/download.php?id=\([0-9]*\)&type=hack/\1/");wget -O $i "$smw/download.php?id=$id&type=hack";unzip -qqo $i;rm $i;done
* Download an entire ftp directory using wget
>> wget -r ftp://user:pass@ftp.example.com
* Download a TiVo Show
>> curl -s -c /tmp/cookie -k -u tivo:$MAK --digest "$(curl -s -c /tmp/cookie -k -utivo:$MAK --digest https://$tivo/nowplaying/index.html | sed 's;.*Download MPEG-PS.*;\1;' | sed 's|\&|\&|')" | tivodecode -m $MAK -- - > tivo.mpg
* Download file with multiple simultaneous connections
>> aria2c -s 4 http://my/url
* Download from Rapidshare Premium using wget - Part 1
>> wget --save-cookies ~/.cookies/rapidshare --post-data "login=USERNAME&password=PASSWORD" -O - https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi > /dev/null
* Download from Rapidshare Premium using wget - Part 2
>> wget -c -t 1 --load-cookies ~/.cookies/rapidshare
* Download Youtube Playlist
>> y=http://www.youtube.com;for i in $(curl -s $f|grep -o "url='$y/watch?v=[^']*'");do d=$(echo $i|sed "s;url\='$y/watch?v=\(.*\)';\1;");wget -O $d.flv "$y/get_video.php?video_id=$d&t=$(curl -s "$y/watch?v=$d"|sed -n 's/.*, "t": "\([^"]*\)", .*/\1/p')";done
* Downsample mp3s to 128K
>> for f in *.mp3 ; do lame --mp3input -b 128 "$f" ./resamp/"$f" ; done
* Draw a Sierpinski triangle
>> perl -e 'print "P1\n256 256\n", map {$_&($_>>8)?1:0} (0..0xffff)' | display
* Drop or block attackers IP with null routes
>> sudo route add xxx.xxx.xxx.xxx gw 127.0.0.1 lo
* dstat - a mix of vmstat, iostat, netstat, ps, sar...
>> dstat -ta
* Dump all of perl's config info
>> perl -le 'use Config; foreach $i (keys %Config) {print "$i : @Config{$i}"}'
* Dump dvd from a different machine onto this one.
>> ssh user@machine_A dd if=/dev/dvd0 > dvddump.iso
* Dump HTTP header using lynx or w3m
>> lynx -dump -head http://www.example.com/
* Dump HTTP header using wget
>> wget --server-response --spider http://www.example.com/
* Dump the root directory to an external hard drive
>> dump -0 -M -B 4000000 -f /media/My\ Passport/Fedora10bckup/root_dump_fedora -z2/
* Duplicate a directory tree using tar and pipes
>> (cd /source/dir ; tar cv .)|(cd /dest/dir ; tar xv)
* Duplicate a directory tree using tar and pipes
>> (cd /source/dir ; tar cvf - .)|(cd /dest/dir ; tar xvpf -)
* Duplicate several drives concurrently
>> dd if=/dev/sda | tee >(dd of=/dev/sdb) | dd of=/dev/sdc
* DVD to YouTube ready watermarked MPEG-4 AVI file using mencoder (step 1)
>> mencoder -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mjpeg -o dvd.avi dvd://0
* DVD to YouTube ready watermarked MPEG-4 AVI file using mencoder (step 2)
>> mencoder -sub heading.ssa -subpos 0 -subfont-text-scale 4 -utf8 -oac copy -ovc lavc -lavcopts vcodec=mpeg4 -vf scale=320:-2,expand=:240:::1 -ffourcc xvid -o output.avi dvd.avi
* Easily create and share X screen shots (local webserver version)
>> scrot -e 'mv $f \$HOME/public_html/shots/; echo "http://\$HOSTNAME/~\$USER/shots/$f" | xsel -i; feh `xsel -o`'
* Easily create and share X screen shots (remote webserver version)
>> scrot -e 'mv $f \$HOME/shots/; sitecopy -u shots; echo "\$BASE/$f" | xsel -i; feh `xsel -o`'
* Easily decode unix-time (funtion)
>> utime(){ perl -e "print localtime($1).\"\n\"";}
* Easily scp a file back to the host you're connecting from
>> mecp () { scp "$@" ${SSH_CLIENT%% *}:Desktop/; }
* Easy and fast access to often executed commands that are very long and complex
>> .some_very_long_and_complex_command # label
* echo something backwards
>> echo linux|rev
* Echo the local IP addresses of the machines on your local network
>> for i in 192.168.1.{61..71};do ping -c 1 $i &> /dev/null && echo $i;fi;done
* Eclipse needs to know the path to the local maven repository. Therefore the cl
>> asspath variable M2_REPO has to be set.mvn -Declipse.workspace= eclipse:add-maven-repo
* eDirectory LDAP Search for Statistics
>> ldapsearch -h ldapserver.willeke.com -p389 -b "" -s base -D cn=admin,ou=administration,dc=willeke,dc=com -w secretpwd "(objectclass=*)" chainings removeEntryOps referralsReturned listOps modifyRDNOps repUpdatesIn repUpdatesOut strongAuthBinds addEntryOps
* Edit all files found having a specific string found by grep
>> find . -exec grep foobar /dev/null {} \; | awk -F: '{print $1}' | xargs vi
* Edit all files found having a specific string found by grep
>> find . -type f -exec grep -qi 'foo' {} \; -print0 | xargs -0 vim
* Edit all files found having a specific string found by grep
>> grep -Hrli 'foo' * | xargs vim
* Edit all files found having a specific string found by grep
>> grep -ir 'foo' * | awk -F '{print $1}' | xargs vim
* Edit all files found having a specific string found by grep
>> grep -ir 'foo' * | awk '{print $1}' | sed -e 's/://' | xargs vim
* Edit a script that's somewhere in your path.
>> vim `which `
* Edit your command in vim ex mode by <ctrl-f>
>> ; in ex mode in vim
* Efficient count files in directory (no recursion)
>> perl -e 'if(opendir D,"."){@a=readdir D;print $#a-1,"\n"}'
* Efficiently print a line deep in a huge log file
>> sed '1000000!d;q' < massive-log-file.log
* Email HTML content
>> mailx bar@foo.com -s "HTML Hello" -a "Content-Type: text/html" < body.htm
* Emptying a text file in one shot
>> :1,$d
* Emptying a text file in one shot
>> ggdG
* Emptying a text file in one shot in VIM
>> :!>test.txt
* Empty Trash in Gnome When the Trash Can Refuses to Clear
>> rm -rf ~/.local/share/Trash/files/*
* Enable cd by variable names
>> shopt -s cdable_vars
* Enable Hibernate in OS X
>> sudo pmset -a hibernatemode 1
* Enable ** to expand files recursively (>=bash-4.0)
>> shopt -s globstar
* Encode a file to MPEG4 format
>> mencoder video.avi lavc -lavcopts vcodec=mpeg4:vbitrate=800 newvideo.avi
* encode image to base64 and copy to clipboard
>> uuencode -m $1 /dev/stdout | sed '1d' | sed '$d' | tr -d '\n' | xclip -selection clipboard
* Encoding with base64
>> echo "Hello world" | base64
* Encrypted archive with openssl and tar
>> openssl des3 -salt -in unencrypted-data.tar -out encrypted-data.tar.des3
* Encrypted archive with openssl and tar
>> tar c folder_to_encrypt | openssl enc -aes-256-cbc -e > secret.tar.enc
* en/decrypts files in a specific directory
>> for a in path/* ; do ccenrypt -K $a; done
* ensure your ssh tunnel will always be up (add in crontab)
>> [[ $(COLUMNS=200 ps faux | awk '/grep/ {next} /ssh -N -R 4444/ {i++} END {printi}') ]] || nohup ssh -N -R 4444:localhost:22 user@relay &
* Equivelant of a Wildcard
>> `ls`
* Erase empty files
>> find . -size 0 -exec rm '{}' \;
* exclude file(s) from rsync
>> rsync -vazuK --exclude "*.mp3" --exclude "*.svn*" * user@host:/path
* Execute AccuRev pop command to retrieve missing files from a workspace.
>> accurev stat -M -fl | awk '{print "\"" $0 "\""}' | xargs accurev pop
* Execute a command before display the bash prompt
>> PROMPT_COMMAND=command
* Execute a command with a timeout
>> timeout 10 sleep 11
* Execute a sudo command remotely, without displaying the password
>> stty -echo; ssh HOSTNAME "sudo some_command"; stty echo
* Execute text from the OS X clipboard.
>> `pbpaste` | pbcopy
* exit without saving history
>> kill -9 $$
* Expand shell variables in sed scripts
>> expanded_script=$(eval "echo \"$(cat ${sed_script_file})\"") && sed -e "${expanded_script}" your_input_file
* Explanation of system and MySQL error codes
>> perror NUMBER
* external projector for presentations
>> xrandr --auto
* Extract a bash function
>> sed -n '/^function h\(\)/,/^}/p' script.sh
* Extract all urls from last firefox sessionstore used in a portable way.
>> perl -lne 'print for /url":"\K[^"]+/g' $(ls -t ~/.mozilla/firefox/*/sessionstore.js | sed q)
* Extract all urls from the last firefox sessionstore.js file used.
>> grep -oP '"url":"\K[^"]+' $(ls -t ~/.mozilla/firefox/*/sessionstore.js | sed q)
* Extract all urls from the last firefox sessionstore.js file used.
>> sed -e 's/{"url":/\n&/g' ~/.mozilla/firefox/*/sessionstore.js | cut -d\" -f4
* Extract an audio track from a multilingual video file, for a specific language
>> .mencoder -aid 2 -oac copy file.avi -o english.mp3
* Extract audio from Mythtv recording to Rockbox iPod using ffmpeg
>> ffmpeg -ss 0:58:15 -i DavidLettermanBlackCrowes.mpg -acodec copy DavidLettermanBlackCrowes.ac3
* Extract audio track from a video file using mencoder
>> mencoder -of rawaudio -ovc copy -oac mp3lame -o output.mp3 input.avi
* Extract icons from windows exe/dll
>> wrestool -x --output . -t14 /path/to/your-file.exe
* extracting audio and video from a movie
>> ffmpeg -i source_movie.flv -vcodec mpeg2video target_video.m2v -acodec copy target_audio.mp3
* Extract multiple file in a directory
>> for i in *.tar.gz; do tar -xzf $i; done
* extract plain text from MS Word docx files
>> unzip -p some.docx word/document.xml | sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g'
* Extract tar.gz in a single command
>> gunzip < foo.tar.gz | tar xvf -
* Extract the daily average number of iops
>> for x in `seq -w 1 30`; do sar -b -f /var/log/sa/sa$x | gawk '/Average/ {print $2}'; done
* Extract track 9 from a CD
>> mplayer -fs cdda://9 -ao pcm:file=track9.wav
* FAST and NICE Search and Replace for Strings in Files
>> nice -n19 sh -c 'S=askapache && R=htaccess; find . -type f|xargs -P5 -iFF grep -l -m1 "$S" FF|xargs -P5 -iFF sed -i -e s%${S}%${R}% FF'
* Fast command-line directory browsing
>> function cdls { cd $1; ls; }
* Fast grepping (avoiding UTF overhead)
>> export LANG=C; grep string longBigFile.log
* fetch all revisions of a specific file in an SVN repository
>> svn log fileName|cut -d" " -f 1|grep -e "^r[0-9]\{1,\}$"|awk {'sub(/^r/,"",$1);print "svn cat fileName@"$1" > /tmp/fileName.r"$1'}|sh
* fetch all revisions of a specific file in an SVN repository
>> svn log fileName | sed -ne "/^r\([0-9][0-9]*\).*/{;s//\1/;s/.*/svn cat fileName@& > fileName.r&/p;}" | sh -s
* Fibonacci numbers with awk
>> awk 'BEGIN {a=1;b=1;for(i=0;i<'${NUM}';i++){print a;c=a+b;a=b;b=c}}'
* Fibonacci numbers with awk
>> seq 50| awk 'BEGIN {a=1; b=1} {print a; c=a+b; a=b; b=c}'
* Fill up disk space (for testing)
>> dd if=/dev/zero of=/fs/to/fill/dummy00 bs=8192 count=$(df --block-size=8192 / |awk 'NR!=1 {print $4-100}')
* Fill up disk space (for testing)
>> tail $0 >> $0
* Filter IPs out of files
>> egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' file.txt
* Find a file's package or list a package's contents.
>> dlocate [ package | string ]
* find all active IP addresses in a network
>> arp-scan -l
* find all active IP addresses in a network
>> nmap -sP 192.168.0.*
* Find all directories on filesystem containing more than 99MB
>> du -hS / | perl -ne '(m/\d{3,}M\s+\S/ || m/G\s+\S/) && print'
* Find all dot files and directories
>> echo .*
* Find all dot files and directories
>> ls -a | egrep "^\.\w"
* Find all dot files and directories
>> ls -d .*
* Find all dot files and directories
>> printf "%s\n" .*
* Find all files <10MB and sum up their size
>> i=0; for f in $(find ./ -size -10M -exec stat -c %s {} \; ); do i=$(($i + $f));done; echo $i
* Find all PowerPC applications on OS X
>> system_profiler SPApplicationsDataType | perl -nl -e '@al=<>; $c=@al; while($j<$c){ $apps[$i].=$al[$j]; $i++ if ($al[$j] ) =~ /^\s\s\s\s\S.*:$/; $j++} while($k<$i){ $_=$apps[$k++]; if (/Kind: PowerPC/s) {print;}}'
* Find all uses of PHP constants in a set of files
>> $class=ExampleClass; $path=src; for constant in `grep ' const ' $class.php | awk '{print $2;}'`; do grep -r "$class::$constant" $path; done
* Find and display most recent files using find and perl
>> find $HOME -type f -print0 | perl -0 -wn -e '@f=<>; foreach $file (@f){ (@el)=(stat($file)); push @el, $file; push @files,[ @el ];} @o=sort{$a->[9]<=>$b->[9]} @files; for $i (0..$#o){print scalar localtime($o[$i][9]), "\t$o[$i][-1]\n";}'|tail
* find and grep Word docs
>> find . -iname '*filename*.doc' | { while read line; do antiword "$line"; done; } | grep -C4 search_term;
* Find chronological errors or bad timestamps in a Subversion repository
>> URL=http://svn.example.org/project; diff -u <(TZ=UTC svn -q log -r1:HEAD $URL |grep \|) <(TZ=UTC svn log -q $URL | grep \| | sort -k3 -t \|)
* Find corrupted jpeg image files
>> find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"
* Find distro name and/or version/release
>> cat /etc/*-release
* find/edit your forgotten buddy pounces for pidgin
>> vim ~/.purple/pounces.xml
* Find files containing string and open in vim
>> vim $(grep test *)
* find files containing text
>> grep -lir "some text" *
* find files containing text
>> grep -lir "sometext" * > sometext_found_in.log
* find files in $PATH that were not installed through dpkg
>> echo -e "${PATH//://\n}" >/tmp/allpath; grep -Fh -f /tmp/allpath /var/lib/dpkg/info/*.list|grep -vxh -f /tmp/allpath >/tmp/installedinpath ; find ${PATH//:/ } |grep -Fxv -f /tmp/installedinpath
* find files larger than 1 GB, everywhere
>> find / -type f -size +1000000000c
* Find files modified in the last 5 days, no more than 2 levels deep in the curr
>> ent directory.find . -type f -depth -3 -mtime -5
* Find files recursively that were updated in the last hour ignoring SVN files a
>> nd folders.find . -mmin -60 -not -path "*svn*" -print|more
* Find 'foo' in located files
>> locate searchstring | xargs grep foo
* find geographical location of an ip address
>> lynx -dump http://www.ip-adress.com/ip_tracer/?QRY=$1|sed -nr s/'^.*My IP address city: (.+)$/\1/p'
* Find if the command has an alias
>> type -all command
* Find in all files in the current directory, just a find shorthand
>> find ./ -name $1 -exec grep -H -n $2 '{}' ';'
* Find in all files in the current directory, just a find shorthand
>> grep -H -n "pattern" *
* Finding files with different extensions
>> find . -regex '.*\(h\|cpp\)'
* Find iPod's fwguid
>> lsusb -v | grep -o "[0-9A-Z]{16}"
* Find jpeg images and copy them to a central location
>> find . -iname "*.jpg" -print0 | tr '[A-Z]' '[a-z]' | xargs -0 cp --backup=numbered -dp -u --target-directory {location} &
* find largest file in /var
>> find /var -mount -ls -xdev | /usr/bin/sort -nr +6 | more
* find listening ports by pid
>> lsof -nP +p 24073 | grep -i listen | awk '{print $1,$2,$7,$8,$9}'
* find . -name
>> find . -name "*.txt" -exec sed -i "s/old/new/" {} \;
* find . -name "*.txt" | xargs sed -i "s/old/new/"
>> find . -name "*.txt" | xargs sed -i "s/old/new/"
* find only current directory (universal)
>> find . \( ! -name . -prune \) \( -type f -o -type l \)
* Find out current working directory of a process
>> echo COMMAND | xargs -ixxx ps -C xxx -o pid= | xargs -ixxx ls -l /proc/xxx/cwd
* find out how much space are occuipied by files smaller than 1024K
>> find dir -size -1024k -type f | xargs -d $'\n' -n1 ls -l | cut -d ' ' -f 5 | sed -e '2,$s/$/+/' -e '$ap' | dc
* find out how much space are occuipied by files smaller than 1024K (sic) - impr
>> ovedfind dir -size -1024k -type f -print0 | du --files0-from - -bc
* Find out what package some command belongs to (on RPM systems)
>> rpm -qif `which more`
* find read write traffic on disk since startup
>> iostat -m -d /dev/sda1
* Find removed files still in use via /proc
>> find -L /proc/*/fd -links 0 2>/dev/null
* Find running binary executables that were not installed using dpkg
>> cat /var/lib/dpkg/info/*.list > /tmp/listin ; ls /proc/*/exe |xargs -l readlink| grep -xvFf /tmp/listin; rm /tmp/listin
* Find status of all symlinks
>> symlinks -r $(pwd)
* find the 10 latest (modified) files
>> ls -1t | head -n10
* find the biggest files recursively, no matter how many
>> find . -type f -printf '%20s %p\n' | sort -n | cut -b22- | tr '\n' '\000' | xargs -0 ls -laSr
* Find the cover image for an album
>> albumart(){ local y="$@";awk '/View larger image/{gsub(/^.*largeImagePopup\(.|., .*$/,"");print;exit}' <(curl -s 'http://www.albumart.org/index.php?srchkey='${y// /+}'&itempage=1&newsearch=1&searchindex=Music');}
* Find the location of the currently loaded php.ini file
>> php -i | grep php.ini
* find the longest command in your history
>> history | perl -lane '$lsize{$_} = scalar(@F); if($longest<$lsize{$_}) { $longest = $lsize{$_}; print "$_"; };' | tail -n1
* Find which jars contain a class
>> find . -name "*.jar" | while read file; do echo "Processing ${file}"; jar -tvf $file | grep "Foo.class"; done
* Find which package a file belongs to on Solaris
>> pkgchk -l -p
* Find which version of Linux You are Running
>> lsb_release -d
* Find writable files
>> find -writable
* Find
>> xwininfo
* Find your graphics chipset
>> lspci |grep VGA
* Fix Ubuntu's Broken Sound Server
>> sudo killall -9 pulseaudio; pulseaudio >/dev/null 2>&1 &
* floating point bash calculator w/o precision
>> b(){ echo "scale=${2:-2}; $1" | bc -l; }
* floating point operations in shell scripts
>> bc -l <<< s(3/5)
* floating point operations in shell scripts
>> echo $((3.0/5.0))
* floating point operations in shell scripts
>> echo "5 k 3 5 / p" | dc
* floating point operations in shell scripts
>> echo "scale=4; 3 / 5" | bc
* floating point shell calculator
>> calc() { awk 'BEGIN { OFMT="%f"; print '"$*"'; exit}'; }
* FLV to AVI with subtitles and forcing audio sync using mencoder
>> mencoder -sub subs.ssa -utf8 -subfont-text-scale 4 -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -o output.avi input.flv
* Follow tail by name (fix for rolling logs with tail -f)
>> tail -F file
* Follow the most recently updated log files
>> ls -drt /var/log/* | tail -n5 | xargs sudo tail -n0 -f
* For a $FILE, extracts the path, filename, filename without extension and exten
>> sion.FILENAME=`echo ${FILE##*/}`;FILEPATH=`echo ${FILE%/*}`;NOEXT=`echo ${FILENAME%\.*}`;EXT=`echo ${FILE##*.}`
* for all flv files in a dir, grab the first frame and make a jpg.
>> for f in *.flv; do ffmpeg -y -i "$f" -f image2 -ss 10 -vframes 1 -an "${f%.flv}.jpg"; done
* Force hard reset on server
>> echo 1 > /proc/sys/kernel/sysrq; echo b > /proc/sysrq-trigger
* Force logout after 24 hours idle
>> fuser -k `who -u | awk '$6 == "old" { print "/dev/"$2'}`
* For Gentoo users : helping with USE / emerge
>> emerge -epv world | grep USE | cut -d '"' -f 2 | sed 's/ /\n/g' | sed '/[(,)]/d' | sed s/'*'//g | sort | uniq > use && grep ^- use | sed s/^-// | sed ':a;N;$!ba;s/\n/ /g' > notuse && sed -i /^-/d use && sed -i ':a;N;$!ba;s/\n/ /g' use
* for i in $(seq 1 25); do dd if=/dev/urandom of= bs=1M ; done
* for loop with leading zero in bash 3
>> for i in {0..1}{0..9}; do echo $i; done
* for loop with leading zero in bash 3
>> printf "%02u " {3..20}; echo
* for loop with leading zero in bash 3
>> seq -s " " -w 3 20
* for loop with leading zeros
>> for s in `seq -f %02.0f 5 15`; do echo $s; done
* Free unused memory currently unavailable
>> dd if=/dev/zero of=junk bs=1M count=1K
* Frequency Sweep
>> l=500; x=500; y=200; d=-15;for i in `seq $x $d $y`; do beep -l $l -f $i;done
* from the console, start a second X server
>> xinit -- :1
* Functions to display, save and restore $IFS
>> ifs () { echo -n "${IFS}"|hexdump -e '"" 10/1 "'\''%_c'\''\t" "\n"' -e '"" 10/1 "0x%02x\t" "\n\n"'|sed "s/''\|\t0x[^0-9]//g; $,/^$/d"
* Function that counts recursively number of lines of all files in specified fol
>> derscount() { find $@ -type f -exec cat {} + | wc -l; }
* Function that outputs dots every second until command completes
>> sleeper(){ while `ps -p $1 &>/dev/null`; do echo -n "${2:-.}"; sleep ${3:-1}; done; }; export -f sleeper
* Function to output an ASCII character given its decimal equivalent
>> chr () { echo -en "\0$(printf %x $1)"}
* Function to output an ASCII character given its decimal equivalent
>> chr () { printf \\$(($1/64*100+$1%64/8*10+$1%8)); }
* Function to output an ASCII character given its decimal equivalent
>> chr() { printf \\$(printf %o $1); }
* Generate a binary file with all ones (0xff) in it
>> tr '\000' '\377' < /dev/zero | dd of=allones bs=1024 count=2k
* Generate a graph of package dependencies
>> apt-cache dotty apache2 | dot -T png | display
* Generate a list of installed packages on Debian-based systems
>> dpkg --get-selections > LIST_FILE
* generate a unique and secure password for every website that you login to
>> sitepass() { echo -n "$@" | md5sum | sha1sum | sha224sum | sha256sum | sha384sum | sha512sum | gzip - | strings -n 1 | tr -d "[:space:]" | tr -s '[:print:]' | tr '!-~' 'P-~!-O' | rev | cut -b 2-11; history -d $(($HISTCMD-1)); }
* Generate Files with Random Content and Size in Bash
>> no_of_files=10; counter=1; while [[ $counter -le $no_of_files ]]; do echo Creating file no $counter; dd bs=1024 count=$RANDOM skip=$RANDOM if=/dev/sda of=random-file.$counter; let "counter += 1"; done
* generate random password
>> openssl rand -base64 1000 | tr "[:upper:]" "[:lower:]" | tr -cd "[:alnum:]" | tr -d "lo" | cut -c 1-8 | pbcopy
* generate random password
>> openssl rand -base64 6
* generate random password
>> pwgen -Bs 10 1
* Generate random password
>> randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}
* Generate Random Passwords
>> dd if=/dev/urandom count=200 bs=1 2>/dev/null | tr "\n" " " | sed 's/[^a-zA-Z0-9]//g' | cut -c-16
* Gentoo: Get the size of all installed packets, sorted
>> equery s | sed 's/(\|)/ /g' | sort -n -k 9 | gawk '{print $1" "$9/1048576"m"}'
* geoip information
>> curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>][^>]*>//g'
* geoip information
>> geo(){ curl -s "http://www.geody.com/geoip.php?ip=$(dig +short $1)"| sed '/^IP:/!d;s/<[^>][^>]*>//g'; }
* geoip information
>> GeoipLookUp(){ curl -A "Mozilla/5.0" -s "http://www.geody.com/geoip.php?ip=$1" | grep "^IP.*$1" | html2text; }
* geoip information
>> geoiplookup www.commandlinefu.com
* Get absolut path to your bash-script
>> script_path=$(cd $(dirname $0);pwd)
* Get a list of all your VirtualBox virtual machines by name and UUID from the s
>> hellVBoxManage list vms
* Get all IPs via ifconfig
>> ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'
* Get all IPs via ifconfig
>> ifconfig | awk '/ddr:[0-9]/ {sub(/addr:/, ""); print $2}'
* Get all IPs via ifconfig
>> ifconfig | awk -F':| +' '/ddr:/{print $4}'
* Get all IPs via ifconfig
>> ifconfig | grep "inet addr" | cut -d: -f2 | cut -d' ' -f1
* Get all IPs via ifconfig
>> ifconfig | grep "inet [[:alpha:]]\+" | cut -d: -f2 | cut -d' ' -f2
* Get all IPs via ifconfig
>> ifconfig | perl -nle'/dr:(\S+)/ && print $1'
* Get all IPs via ifconfig
>> ipconfig getpacket en0 | grep yi| sed s."yiaddr = "."en0: ". ipconfig getpacket en1 | grep yi| sed s."yiaddr = "."en1: ".
* Get all members from one AD group and put them in another AD group
>> for /F "DELIMS=""" %i in ('dsquery group -name SourceGroupName ^| dsget group -members') do dsquery group -name TargetGroupName | dsmod group -addmbr %i
* Get all possible problems from any log files
>> grep -2 -iIr "err\|warn\|fail\|crit" /var/log/*
* get all the data about your IP configuration across all network cards
>> ipconfig /all
* Get all the keyboard shortcuts in screen
>> ^A ?
* Get a MySQL DB dump from a remote machine
>> ssh user@host "mysqldump -h localhost -u mysqluser -pP@$$W3rD databasename | gzip -cf" | gunzip -c > database.sql
* Get an IP address out of fail2ban jail
>> iptables -D fail2ban-SSH -s -j DROP
* Get a regular updated list of zombies
>> watch "ps auxw | grep [d]efunct"
* Get a regular updated list of zombies
>> watch "ps auxw | grep 'defunct' | grep -v 'grep' | grep -v 'watch'"
* Get a text on a position on the file and store in a variable with a specific s
>> eparatorTIMEUNIT=$( cat a | grep -n "timescale" | awk -F ":" '{ print $1 } ' )
* get basic information out of your computer
>> lspci
* get colorful side-by-side diffs of files in svn with vim
>> vimdiff <(svn cat "$1") "$1"
* get cpu info from dmesg
>> dmesg | grep cpu
* get daily wizard of id comic
>> curl -o id.gif `date +http://d.yimg.com/a/p/uc/%Y%m%d/largeimagecrwiz%y%m%d.gif`
* get debian version number
>> lsb_release -a
* Get ethernet card information.
>> ethtool eth0
* Get ethX mac addresses
>> ifconfig | awk '/HW/ {print $5}'
* Get ethX mac addresses
>> ip link | grep 'link/ether' | awk '{print $2}'
* Get ethX mac addresses
>> ip link show eth0 | grep "link/ether" | awk '{print $2}'
* get events from google calendar for a given dates range
>> wget -q -O - 'URL/full?orderby=starttime&singleevents=true&start-min=2009-06-01&start-max=2009-07-31' | perl -lane '@m=$_=~m/(.+?)> URL=[target.URL]; curl -q -d "url=$URL" http://untr.im/api/ajax/api | awk -F 'href="' '{print $3}' | awk -F '" rel="' '{print $1}'
* Get Futurama quotations from slashdot.org servers
>> curl -Is slashdot.org | sed -ne '/^X-[FBL]/s/^X-//p'
* Get Futurama quotations from slashdot.org servers
>> curl -sI http://slashdot.org/ | sed -nr 's/X-(Bender|Fry)(.*)/\1\2/p'
* Get Futurama quotations from slashdot.org servers
>> echo -e "HEAD / HTTP/1.1\nHost: slashdot.org\n\n" | nc slashdot.org 80 | head -n5 | tail -1 | cut -f2 -d-
* Get Futurama quotations from slashdot.org servers
>> lynx -head -dump http://slashdot.org|egrep 'Bender|Fry'|sed 's/X-//'
* Get info about remote host ports and OS detection
>> nmap -sS -P0 -sV -O
* Get internal and external IP addresses
>> ips(){ for if in ${1:-$(ip link list|grep '^.: '|cut -d\ -f2|cut -d: -f1)};do cur=$(ifconfig $if|grep "inet addr"|sed 's/.*inet addr:\([0-9\.]*\).*/\1/g');printf '%-5s%-15s%-15s\n' $if $cur $(nc -s $cur sine.cluenet.org 128 2>/dev/null||echo $cur);done;}
* get kernel version
>> uname -a
* Get last changed revision to all eclipse projects in a SVN working copy
>> find . -iname ".project"| xargs -I {} dirname {} | LC_ALL=C xargs -I {} svn info {} | grep "Last Changed Rev\|Path" | sed "s/Last Changed Rev: /;/" | sed "s/Path: //" | sed '$!N;s/\n//'
* Get lines count of a list of files
>> find . -name "*.sql" -print0 | wc -l --files0-from=-
* get linkspeed, ip-adress, mac-address and processor type from osx
>> echo "-------------" >> nicinfo.txt; echo "computer name x" >> nicinfo.txt; ifconfig | grep status >> nicinfo.txt; ifconfig | grep inet >> nicinfo.txt; ifconfig | grep ether >> nicinfo.txt; hostinfo | grep type >> nicinfo.txt;
* Get names of files in /dev, a USB device is attached to
>> ls -la /dev/disk/by-id/usb-*
* get newest jpg picture in a folder
>> cp `ls -x1tr *.jpg | tail -n 1` newest.jpg
* Get number of diggs for a news URL
>> curl -s "http://services.digg.com/stories?link=$NEWSURL&appkey=http://www.whatever.com&type=json" | python -m simplejson.tool | grep diggs
* Get own public IP address
>> wget -qO- whatismyip.org
* gets all files committed to svn by a particular user since a particular date
>> svn log -v -r{2009-05-21}:HEAD | awk '/^r[0-9]+ / {user=$3} /yms_web/ {if (user=="george") {print $2}}' | sort | uniq
* Gets a random Futurama quote from /.
>> curl -Is slashdot.org | egrep '^X-(F|B|L)' | cut -d \- -f 2
* Get ssh server fingerprints
>> ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub && ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
* Get the absolute path of a file
>> absolute_path () { readlink -f "$1"; };
* Get the current svn branch/tag (Good for PS1/PROMPT_COMMAND cases)
>> svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$'
* Get the information about the Apache loaded modules from command line
>> httpd2 -M
* Get the information about the internet usage from the commandline.
>> vnstat
* Get the IP address of a machine. Just the IP, no junk.
>> /sbin/ifconfig -a | awk '/(cast)/ { print $2 }' | cut -d':' -f2 | head -1
* Get the size of all the directories in current directory
>> du -hd 1
* Get the size of all the directories in current directory
>> du --max-depth=1
* Get the size of all the directories in current directory (Sorted Human Readabl
>> e)sudo du -ks $(ls -d */) | sort -nr | cut -f2 | xargs -d '\n' du -sh 2> /dev/null
* Get the size of all the directories in current directory
>> sudo du -sh $(ls -d */) 2> /dev/null
* Get the time from NIST.GOV
>> cat > m:sfind -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
* get time in other timezones
>> let utime=$offsetutc*3600+$(date --utc +%s)+3600; date --utc --date=@${utime}
* get time in other timezones
>> tzwatch
* get users process list
>> ps -u
* Get video information with ffmpeg
>> ffmpeg -i filename.flv
* get xclip to own the clipboard contents
>> xclip -o -selection clipboard | xclip -selection clipboard
* Get yesterday's date or a previous time
>> date -d '1 day ago'; date -d '11 hour ago'; date -d '2 hour ago - 3 minute'; date -d '16 hour'
* Get your bash scripts to handle options (-h, --help etc) and spit out auto-for
>> matted help or man page when asked!!process-getopt
* Get your external IP address
>> curl ip.appspot.com
* Get your external IP address
>> curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
* Get your external IP address
>> curl whatismyip.org
* Get your external IP address
>> echo -e "GET /automation/n09230945.asp HTTP/1.0\r\nHost: whatismyip.com\r\n" | nc whatismyip.com 80 | tail -n1
* Get your external IP address
>> exec 3<>/dev/tcp/whatismyip.com/80; echo -e "GET /automation/n09230945.asp HTTP/1.0\r\nHost: whatismyip.com\r\n" >&3; a=( $(cat <&3) ); echo ${a[${#a[*]}-1]};
* Get your external IP address
>> fetch -q -o - http://ipchicken.com | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'
* Get your external IP address
>> lynx --dump http://ip.boa.nu|sed -e 's/^[[:space:]]*//' -e 's/*[[:space:]]$//'|grep -v ^$
* Get your external IP address
>> wget -O - -q ip.boa.nu
* Get your external IP address
>> wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
* Get your external IP address
>> wget -qO - http://www.sputnick-area.net/ip;echo
* Get your external IP address with a random commandlinefu.com command
>> IFS=$'\n';cl=($(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p}'));c=${cl[$(( $RANDOM % ${#cl[@]} ))]};eval $c;echo "Command used: $c"
* Get your external IP address with the best commandlinefu.com command
>> eval $(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p;q}')
* Get your internal IP address and nothing but your internal IP address
>> ifconfig $devices | grep "inet addr" | sed 's/.*inet addr:\([0-9\.]*\).*/\1/g'
* Get your public ip
>> python -c "import socket; s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.connect(('google.com', 80)); print s.getsockname()[0]"
* git diff of files that have been staged ie 'git add'ed
>> git diff --cached
* git remove files which have been deleted
>> git add -u
* git remove files which have been deleted
>> git ls-files -z --deleted | xargs -0 git rm
* git remove files which have been deleted
>> git rm $(git ls-files --deleted)
* (Git) Revert files with changed mode, not content
>> git diff --numstat | awk '{if ($1 == "0" && $1 == "0") print $3}' | xargs git checkout HEAD
* Give any files that don't already have it group read permission under the curr
>> ent folder (recursive)find . -type f ! -perm /g=r -exec chmod g+r {} +
* Go (cd) directly into a new temp folder
>> cd $(mktemp -d)
* Go get those photos from a Picasa album
>> echo 'Enter Picasa album RSS URL:"; read -e feedurl; GET "$feedurl" |sed 's/\n wgetlist
* Go get those photos from a Picasa album
>> wget 'link of a Picasa WebAlbum' -O - |perl -e'while(<>){while(s/"media":{"content":\[{"url":"(.+?\.JPG)//){print "$1\n"}}' |wget -w1 -i -
* google search
>> perl -e '$i=0;while($i<10){open(WGET,qq/|xargs lynx -dump/);printf WGET qq{http://www.google.com/search?q=site:g33kinfo.com&hl=en&start=$i&sa=N},$i+=10}'|grep '\/\/g33kinfo.com\/'
* Go to /
>> ...
* go to home directory
>> cd
* Go to parent directory of filename edited in last command
>> cd `dirname $_`
* Go to parent directory of filename edited in last command
>> cd !$:h
* Go up multiple levels of directories quickly and easily.
>> alias ..="cd .."; alias ...="cd ../.."; alias ....="cd ../../.."
* Go up multiple levels of directories quickly and easily.
>> alias ..="cd .." ...="cd ../.." ....="cd ../../.."
* Go up multiple levels of directories quickly and easily.
>> cd() { if [[ "$1" =~ ^\.\.+$ ]];then local a dir;a=${#1};while [ $a -ne 1 ];do dir=${dir}"../";((a--));done;builtin cd $dir;else builtin cd "$@";fi ;}
* Grab all .flv files from a webpage to the current working directory
>> wget `lynx -dump http://www.ebow.com/ebowtube.php | grep .flv$ | sed 's/[[:blank:]]\+[[:digit:]]\+\. //g'`
* Grab an interface's IP from ifconfig without screen clutter
>> ifconfig eth1 | grep inet\ addr | awk '{print $2}' | cut -d: -f2 | sed s/^/eth1:\ /g
* grep certain file types recursively
>> find . -name "*.[ch]" | xargs grep "TODO"
* grep (or anything else) many files with multiprocessor power
>> find . -type f -print0 | xargs -0 -P 4 -n 40 grep -i foobar
* gzip vs bzip2 at compressing random strings?
>> < /dev/urandom tr -dc A-Za-z0-9_ | head -c $((1024 * 1024)) | tee >(gzip -c > out.gz) >(bzip2 -c > out.bz) > /dev/null
* hanukkah colored bash prompt
>> export PS1="\e[0;34m[\u\e[0;34m@\h[\e[0;33m\w\e[0m\e[0m\e[0;34m]#\e[0m "
* Harder, Faster, Stronger SSH clients
>> ssh -4 -C -c blowfish-cbc
* Have subversion ignore a file pattern in a directory
>> svn propset svn:ignore "*txt" log/
* hdparm -mRuUwx --dco-restore --drq-hsm-error --fwdownload --security-unlock PW
>> D --security-set-pass PWD --security-disable PWD --security-erase PWD --security-erase-enhanced PWD --user-master USER --security-mode MODE [device]
* Hexadecimal dump of a file, pipe, or anything
>> cat testfile | hexdump -C
* Hiding and Show files on Mac OS X
>> setfile -a V foo.bar; setfile -a v foo.bar;
* How many files in the current directory ?
>> find . -maxdepth 1 -type f | wc -l
* How to check webserver by Nikto
>> nikto.pl -h yourwebserver
* How to copy CD/DVD into hard disk (.iso)
>> dd if=/dev/cdrom of=whatever.iso
* How to Find the Block Size
>> /sbin/dumpe2fs /dev/hda2 | grep 'Block size'
* How to know the total number of packages available
>> apt-cache stats
* How to run a command on a list of remote servers read from a file
>> dsh -M -c -f servers -- "command HERE"
* How to run a specific command in remote server by ssh
>> ssh user@remotehost [anycommand](i.e uptime,w)
* how to run firefox in safe mode from command line
>> firefox --safe-mode
* How to watch files
>> watch -d 'ls -l'
* Identify differences between directories (possibly on different servers)
>> diff <(ssh server01 'cd config; find . -type f -exec md5sum {} \;| sort -k 2') <(ssh server02 'cd config;find . -type f -exec md5sum {} \;| sort -k 2')
* Identify long lines in a file
>> awk 'length>72' file
* Identify name and resolution of all jpgs in current directory
>> identify -verbose *.jpg|grep "\(Image:\|Resolution\)"
* IFS - use entire lines in your for cycles
>> export IFS=$(echo -e "\n")
* ignore hidden directory in bash completion (e.g. .svn)
>> Add to ~/.inputrc: set match-hidden-files off
* ignore hidden directory in bash completion (e.g. .svn)
>> bind 'set match-hidden-files off'
* Incase you miss the famous 'C:\>' prompt
>> export PS1='C:${PWD//\//\\\}>'
* Increase mplayer maximum volume
>> mplayer dvd:// -softvol -softvol-max 500
* Informations sur les connexions reseau
>> netstat -taupe
* Inserts the results of an autocompletion in the command line
>> ESC *
* Install a Firefox add-on/theme to all users
>> sudo firefox -install-global-extension /path/to/add-on
* Install a LAMP server in a Debian based distribution
>> sudo tasksel install lamp-server
* Install an mpkg from the command line on OSX
>> sudo installer -pkg /Volumes/someapp/someapp.mpkg -target /
* Install the Debian-packaged version of a Perl module
>> function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; }
* Instant mirror from your laptop + webcam (fullscreen+grab)
>> mplayer -fs -vf screenshot,mirror tv://
* Instant mirror from your laptop + webcam
>> mplayer tv:// -vf mirror
* Interactively build regular expressions
>> txt2regex
* IP address of current host
>> hostname -i
* iso-8859-1 to utf-8 safe recursive rename
>> detox -r -s utf_8 /path/to/old/win/files/dir
* Job Control
>> ^Z $bg $disown
* Jump to a song in your XMMS2 playlist, based on song title/artist
>> function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1| sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; }
* kalarm 1 per minute simplest e-mail beacom for Geovision surveillance DVR
>> curl http://www.spam.la/?f=sender | grep secs| awk '{print; exit}' | osd_cat -i40 -d 30 -l 2
* Keep from having to adjust your volume constantly
>> find . -iname \*.mp3 -print0 | xargs -0 mp3gain -krd 6 && vorbisgain -rfs .
* Kill a daemon by name, not by PID
>> kill_daemon() { echo "Daemon?"; read dm; kill -15 $(netstat -atulpe | grep $dm| cut -d '/' -f1 | awk '{print $9}') }; alias kd='kill_daemon
* Kill all processes that don't belong to root/force logoff
>> for i in $(pgrep -v -u root);do kill -9 $i;done
* Kill a process with its name
>> pkill $1
* kills all processes for a certain program e.g. httpd
>> ps aux | grep 'httpd ' | awk {'print $2'} | xargs kill -9
* kill some process (same as others) but parsing to a variable
>> pkill -9 -f program
* Know when you will type :q in your term instead of vi(m), the alias will chewe
>> d you out.alias :q='tput setaf 1; echo >&2 "this is NOT vi(m) :/"; tput sgr0'
* Know which modules are loaded on an Apache server
>> apache2 -t -D DUMP_MODULES
* Know which version dpkg/apt considers more recent
>> dpkg --compare-versions 1.0-2ubuntu5 lt 1.1-1~raphink3 && echo y || echo n
* Launch a command from a manpage
>> !date
* Launch a VirtualBox virtual machine
>> VBoxManage startvm "name"
* Lazy man's vim
>> function v { if [ -z $1 ]; then vim; else vim *$1*; fi }
* LDAP search to query an ActiveDirectory server
>> ldapsearch -LLL -H ldap://activedirectory.example.com:389 -b 'dc=example,dc=com' -D 'DOMAIN\Joe.Bloggs' -w 'p@ssw0rd' '(sAMAccountName=joe.bloggs)'
* Leave a comment when voting down..
>> if [ "${vote}" = "down" ]; then echo leave comment; fi
* Less a grep result, going directly to the first match in the first file
>> argv=("$@"); rest=${argv[@]:1}; less -JMN +"/$1" `grep -l $1 $rest`
* less an message on a postfix mailsystem with a specific message-id
>> id=; find /var/spool/postfix/ -name $id -exec less {} \;
* Lire une video dans une console Linux
>> mplayer -vo caca foo.avi
* List all authors of a particular git project
>> git log --format='%aN' | sort -u
* List all authors of a particular git project
>> git shortlog -s | cut -c8-
* List all available commands (bash, ksh93)
>> printf "%s\n" ${PATH//:/\/* }
* List all available commands
>> in bash hit "tab" twice and answer y
* List all files opened by a particular command
>> lsof -c dhcpd
* List all groups and the user names that were in each group
>> for u in `cut -f1 -d: /etc/passwd`; do echo -n $u:; groups $u; done | sort
* List all rpms on system by name, version and release numbers, and architecture
>> rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'
* List all symbolic links in current directory
>> find /path -type l
* List all symbolic links in current directory
>> \ls -1 | xargs -l readlink
* List all symbolic links in current directory
>> ls -lah | grep ^l
* List all text files (exclude binary files)
>> find . -type f -exec file {} \; | grep ".*: .* text" | cut -f 1 -d :
* List all text files (exclude binary files)
>> find . | xargs file | grep ".*: .* text" | sed "s;\(.*\): .* text.*;\1;"
* list and sort files by size in reverse order (file size in human readable outp
>> ut)ls -S -lhr
* List apache2 virtualhosts
>> /usr/sbin/apache2ctl -S 2>&1 | perl -ne 'm@.*port\s+([0-9]+)\s+\w+\s+(\S+)\s+\((.+):.*@ && do { print "$2:$1\n\t$3\n"; $root = qx{grep DocumentRoot $3}; $root =~ s/^\s+//; print "\t$root\n" };'
* List bash functions defined in .bash_profile or .bashrc
>> declare -F | sed 's/^declare -f //'
* List bash functions defined in .bash_profile or .bashrc
>> set | fgrep " ()"
* List commands with a short summary
>> find `echo "${PATH}" | tr ':' ' '` -type f | while read COMMAND; do man -f "${COMMAND##*/}"; done
* List contents of tar archive within a compressed 7zip archive
>> 7z x -so testfile.tar.7z | tar tvf -
* Listen to BBC Radio from the command line.
>> bbcradio() { local s;echo "Select a station:";select s in 1 1x 2 3 4 5 6 7 "Asian Network an" "Nations & Local lcl";do break;done;s=($s);mplayer -playlist "http://www.bbc.co.uk/radio/listen/live/r"${s[@]: -1}".asx";}
* Listen to the OS X system's voices
>> for person in Alex Bruce Fred Kathy Vicki Victoria ; do say -v $person "Hello, my name is $person"; sleep 1; done
* List files in tarballs
>> find -name "*.tgz" -or -name "*.tar.gz" | while read file; do echo "$file: "; tar -tzf $file; done
* List files in tarballs
>> for F in $(find ./ -name "*.tgz") ; do tar -tvzf $F ; done
* List files opened by a PID
>> lsof -p 15857
* List files recursively sorted by modified time
>> find /home/fizz -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
* List files that DO NOT match a pattern
>> ls | grep -vi pattern
* List files that DO NOT match a pattern
>> ls *[^p][^a][^t]* ; # or shopt -s extglob; ls !(*pattern*)
* List files that DO NOT match a pattern
>> printf "%s\n" !(pattern) ## ksh, or bash with shopt -s extglob
* Listing the Size and usage of the connected Hard Disks
>> df -H
* List Network Tools in Linux
>> apropos network |more
* List of directories sorted by number of files they contain.
>> sort -n <( for i in $(find . -maxdepth 1 -mindepth 1 -type d); do echo $(find $i | wc -l) ": $i"; done;)
* List of reverse DNS records for a subnet
>> nmap -R -sL 209.85.229.99/27 | awk '{if($3=="not")print"("$2") no PTR";else print$3" is "$2}' | grep '('
* List open TCP/UDP ports
>> netstat -ltun
* List out classes in of all htmls in directory
>> find . -name '*.html' -exec 'sed' 's/.*class="\([^"]*\?\)".*/\1/ip;d' '{}' ';'|sort -su
* Lists unambigously names of all xml elements used in files in current director
>> ygrep -Eho '<[a-ZA-Z_][a-zA-Z0-9_-:]*' * | sort -u | cut -c2-
* Lists unambigously names of all xml elements used in files in current director
>> ygrep -h -o '<[^/!?][^ >]*' * | sort -u | cut -c2-
* List symbols from a dynamic library (.so file)
>> nm --dynamic
* List the CPU model name
>> grep "model name" /proc/cpuinfo
* List the CPU model name
>> sed -n 's/^model name[ \t]*: *//p' /proc/cpuinfo
* List the largest directories & subdirectoties in the current directory sorted
>> from largest to smallest.du -k | sort -r -n | more
* list the last week's added files in xmms2's library
>> xmms2 mlib search added \> $(echo $(date +%s) - 604800|bc)
* List your largest installed packages.
>> dpkg --get-selections | cut -f1 | while read pkg; do dpkg -L $pkg | xargs -I'{}' bash -c 'if [ ! -d "{}" ]; then echo "{}"; fi' | tr '\n' '\000' | du -c --files0-from - | tail -1 | sed "s/total/$pkg/"; done
* List your largest installed packages (on Debian/Ubuntu)
>> dpigs
* List your largest installed packages (on Debian/Ubuntu)
>> perl -ne '$pkg=$1 if m/^Package: (.*)/; print "$1\t$pkg\n" if m/^Installed-Size: (.*)/;' < /var/lib/dpkg/status | sort -rn | less
* List your largest installed packages (on Debian/Ubuntu)
>> sed -ne '/^Package: \(.*\)/{s//\1/;h;};/^Installed-Size: \(.*\)/{s//\1/;G;s/\n/ /;p;}' /var/lib/dpkg/status | sort -rn
* List your largest installed packages.
>> wajig large
* live ssh network throughput test
>> pv /dev/zero|ssh $host 'cat > /dev/null'
* live ssh network throughput test
>> yes | pv | ssh $host "cat > /dev/null"
* Load another file in vim
>> :split
* load changes without logging in and out vim
>> :source ~/.vimrc
* Load multiple sql script in mysql
>> cat schema.sql data.sql test_data.sql | mysql -u user --password=pass dbname
* locate a filename, make sure it exists and display it with full details
>> locate -e somefile | xargs ls -l
* Log a command's votes
>> while true; do curl -s http://www.commandlinefu.com/commands/view/3643/log-a-commands-votes | grep 'id="num-votes-' | sed 's;.*id="num-votes-[0-9]*">\([0-9\-]*\);\1;' >> votes; sleep 10; done
* Log your internet download speed
>> echo $(date +%s) > start-time; URL=http://www.google.com; while true; do echo $(curl -L --w %{speed_download} -o/dev/null -s $URL) >> bps; sleep 10; done &
* ls to show hidden file, but not . or ..
>> ls -A
* Mac, ip, and hostname change - sweet!
>> ifconfig eth0 down hw ether (newmacaddresshere) && ifconfig eth0 up && ifconfigeth0 (newipaddresshere) netmask 255.255.255.0 up && /bin/hostname (newhostnamehere)
* Mac OS X: Change Color of the ls Command
>> export LSCOLORS=gxfxcxdxbxegedabagacad
* Mac Sleep Timer
>> sudo pmset schedule sleep "08/31/2009 00:00:00"
* mail with attachment
>> tar cvzf - data1 data2 | uuencode data.tar.gz | mail -s 'data' you@host.fr
* Make a DVD ISO Image from a VIDEO_TS folder on MacOSX
>> hdiutil makehybrid -udf -udf-volume-name DVD_NAME -o MY_DVD.iso /path/
* Make a high definition VNC
>> vncserver -nohttpd -name hidef-server -depth 24 -geometry 1440x900
* Make an iso file out of your entire hard drive
>> cat /dev/hda > ~/hda.iso
* Make an iso file out of your entire hard drive
>> dd if=/dev/hda of=file.img
* Make anything more awesome
>> command | figlet
* Make a statistic about the lines of code
>> find . -name \*.c | xargs wc -l | tail -1 | awk '{print $1}'
* Make a statistic about the lines of code
>> find . -type f -name '*.c' -exec wc -l {} \; | awk '{sum+=$1} END {print sum}'
* make a zip file containing all files with the openmeta tag "data"
>> mdfind "tag:data" > /tmp/data.txt ; zip -r9@ ~/Desktop/data.zip < /tmp/data.txt
* Make directories for and mount all iso files in a folder
>> for file in *.iso; do mkdir `basename $file | awk -F. '{print $1}'`; sudo mount-t iso9660 -o loop $file `basename $file | awk -F. '{print $1}'`; done
* Makefile argument passing
>> make [target] VAR=foobar
* Make ogg file from wav file
>> oggenc --tracknum='track' track.cdda.wav -o 'track.ogg'
* Makes a project directory, unless it exists; changes into the dir, and creates
>> an empty git repository, all in one commandgitstart () { if ! [[ -d "$@" ]]; then mkdir -p "$@" && cd "$@" && git init; else cd "$@" && git init; fi }
* Make sure a script is run in a terminal.
>> [ -t 0 ] || exit 1
* Make sure a script is run in a terminal.
>> tty > /dev/null 2>&1 || { aplay error.wav ; exit 1 ;}
* Make the "tree" command pretty and useful by default
>> alias tree="tree -CAFa -I 'CVS|*.*.package|.svn|.git' --dirsfirst"
* Manage "legacy" service run control links
>> sudo find /etc/rc{1..5}.d -name S99myservice -type l -exec sh -c 'NEWFN=`echo {} | sed 's/S99/K99/'` ; mv -v {} $NEWFN' \;
* Manually Pause/Unpause Firefox Process with POSIX-Signals
>> killall -STOP -m firefox
* Match a URL
>> cho "(Something like http://foo.com/blah_blah)" | awk '{for(i=1;i<=NF;i++){if($i~/^(http|ftp):\/\//)print $i}}'
* Match a URL
>> echo "(Something like http://foo.com/blah_blah)" | grep -oP "\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))"
* Match a URL
>> egrep 'https?://([[:alpha:]]([-[:alnum:]]+[[:alnum:]])*\.)+[[:alpha:]]{2,3}(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?'
* Match non-empty lines
>> grep -v "^\W$"
* Matrix Style
>> check the sample output below, the command was too long :(
* Matrix Style
>> echo -e "\e[31m"; while $t; do for i in `seq 1 30`;do r="$[($RANDOM % 2)]";h="$[($RANDOM % 4)]";if [ $h -eq 1 ]; then v="\e[1m $r";else v="\e[2m $r";fi;v2="$v2$v";done;echo -e $v2;v2="";done;
* Matrix Style
>> echo -e "\e[32m"; while :; do for i in {1..16}; do r="$(($RANDOM % 2))"; if [[ $(($RANDOM % 5)) == 1 ]]; then if [[ $(($RANDOM % 4)) == 1 ]]; then v+="\e[1m $r "; else v+="\e[2m $r "; fi; else v+=" "; fi; done; echo -e "$v"; v=""; done
* Matrix Style
>> LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
* Matrix Style
>> tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
* Matrix Style
>> while $t; do for i in `seq 1 30`;do r="$[($RANDOM % 2)]";h="$[($RANDOM % 4)]";if [ $h -eq 1 ]; then v="\e[1m $r";else v="\e[2m $r";fi;v2="$v2 $v";done;echo -e $v2;v2="";done;
* Matrix Style
>> while true ; do IFS="" read i; echo "$i"; sleep .01; done < <(tr -c "[:digit:]"" " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]")
* Maven Install 3rd party JAR
>> mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging= -DgeneratePom=true
* Measures download speed on eth0
>> while true; do X=$Y; sleep 1; Y=$(ifconfig eth0|grep RX\ bytes|awk '{ print $2 }'|cut -d : -f 2); echo "$(( Y-X )) bps"; done
* Merges given files line by line
>> paste -d ',:' file1 file2 file3
* Migrate existing Ext3 filesystems to Ext4
>> tune2fs -O extents,uninit_bg,dir_index /dev/yourpartition
* modify (mozldap) with proxy authentication and no other controls
>> ldapmodify -Y "dn:uid=rob,dc=example.com" -g -R -J 2.16.840.1.113730.3.4.16 ...
* Monitor logs in Linux using Tail
>> find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f
* monitor network traffic and throughput in real time
>> iptraf
* Monitor server load as well as running MySQL processes
>> watch -n 1 uptime\;myqladmin --user= --password= --verbose processlist
* Monitor the queries being run by MySQL
>> watch -n 1 mysqladmin --user= --password= processlist
* More precise BASH debugging
>> env PS4=' ${BASH_SOURCE}:${LINENO}(${FUNCNAME[0]}) ' sh -x /etc/profile
* most dangerous command ever.
* Most simple way to get a list of open ports
>> netstat -lnp
* Mount a disk image (dmg) file in Mac OSX
>> hdiutil attach somefile.dmg
* Mount a .iso file in UNIX/Linux
>> mount /path/to/file.iso /mnt/cdrom -oloop
* mount an iso
>> mount -o loop -t iso9660 my.iso /mnt/something
* Mount a partition from within a complete disk dump
>> INFILE=/path/to/your/backup.img; MOUNTPT=/mnt/foo; PARTITION=1; mount "$INFILE""$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
* Mount a partition from within a complete disk dump
>> lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo
* Mount a Windows share on the local network (Ubuntu) with user rights and use a
>> specific samba usersudo mount -t cifs -o credentials=/path/to/credenials //hostname/sharename /mount/point
* Mount important virtual system directories under chroot'ed directory
>> for i in sys dev proc; do sudo mount --bind /$i /mnt/xxx/$i; done
* Move a file up a directory.
>> mv file_name.extension ..
* Move all but the newest 100 emails to a gzipped archive
>> find $MAILDIR/ -type f -printf '%T@ %p\n' | sort --reverse | sed -e '{ 1,100d; s/[0-9]*\.[0-9]* \(.*\)/\1/g }' | xargs -i sh -c "cat {}&&rm -f {}" | gzip -c >>ARCHIVE.gz
* Move all files untracked by git into a directory
>> git clean -n | sed 's/Would remove //; /Would not remove/d;' | xargs mv -t stuff/
* Move all images in a directory into a directory hierarchy based on year, month
>> and day based on exif informationexiftool '-Directory> rsync -az /home/user/test user@sshServer:/tmp/
* move a lot of files over ssh
>> tar -cf - /home/user/test | gzip -c | ssh user@sshServer 'cd /tmp; tar xfz -'
* Move files around local filesystem with tar without wasting space using an int
>> ermediate tarball.( cd SOURCEDIR && tar cf - . ) | (cd DESTDIR && tar xvpf - )
* Move files around local filesystem with tar without wasting space using an int
>> ermediate tarball.tar -C
"|grep -oE "
"|sed -e 's/<\/p>/\n/g' -e 's/
//g' -e's/
//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1
* Random number generation within a range N, here N=10
>> echo $(( $RANDOM % 10 + 1 ))
* Random play a mp3 file
>> mpg123 "`locate -r '\.mp3$'|awk '{a[NR]=$0}END{print a['"$RANDOM"' % NR]}'`"
* random xkcd comic as xml
>> curl -sL 'dynamic.xkcd.com/comic/random/' | awk -F\" '/^\n\n\n %s\n %s\n %s\n\n\n", $6, $4, $2)}'
* random xkcd comic
>> display "$(wget -q http://dynamic.xkcd.com/comic/random/ -O - | grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)')"
* raw MySQL output to use in pipes
>> mysql DATABASE -N -s -r -e 'SQL COMMAND'
* Read almost everything (Changelog.gz, .tgz, .deb, .png, .pdf, etc, etc....)
>> less -r
* Read aloud a text file in Ubuntu (and other Unixes with espeak installed
>> espeak -f text.txt
* Read just the IP address of a device
>> ifconfig $DEVICE | perl -lne '/inet addr:([\d.]+)/ and print $1'
* Read just the IP address of a device
>> /sbin/ifconfig eth0 | grep "inet addr" | sed -e 's/.*inet addr:\(.*\) B.*/\1/g'
* read manpage of a unix command as pdf in preview (Os X)
>> man -t UNIX_COMMAND | open -f -a preview
* Real time satellite wheather wallpaper
>> curl http://www.cpa.unicamp.br/imagens/satelite/ult.gif | xli -onroot -fill stdin
* Receive, sign and send GPG key id
>> caff
* Record a screencast and convert it to an mpeg
>> ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
* Record audio and video from webcam using ffmpeg
>> ffmpeg -f alsa -r 16000 -i hw:2,0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -sameq -acodec libmp3lame -ab 96k output.avi
* Record audio and video from webcam using mencoder
>> mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:fps=30:outfmt=yuy2:forceaudio:alsa:adevice=hw.2,0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800 -ffourcc xvid -oac mp3lame -lameopts cbr=128 -o output.avi
* Record a webcam output into a video file.
>> ffmpeg -an -f video4linux -s 320x240 -b 800k -r 15 -i /dev/v4l/video0 -vcodec mpeg4 myvideo.avi
* Record camera's output to a avi file
>> mencoder -tv device=/dev/video1 tv:// -ovc copy -o video.avi
* Record live sound in Vorbis (eg for bootlegs or to take audio notes)
>> rec -c 2 -r 44100 -s -t wav - | oggenc -q 5 --raw --raw-chan=2 --raw-rate=44100--raw-bits=16 - > MyLiveRecording.ogg
* Record microphone input and output to date stamped mp3 file
>> arecord -q -f cd -r 44100 -c2 -t raw | lame -S -x -h -b 128 - `date +%Y%m%d%H%M`.mp3
* Record MP3 audio via ALSA using ffmpeg
>> ffmpeg -f alsa -ac 2 -i hw:1,0 -acodec libmp3lame -ab 96k output.mp3
* Record output of any command using 'tee' at backend; mainly can be used to cap
>> ture the output of ssh from client side while connecting to a server.ssh user@server | tee logfilename
* Record your desktop
>> xvidcap --file filename.mpeg --fps 15 --cap_geometry 1680x1050+0+0 --rescale 25--time 200.0 --start_no 0 --continue yes --gui no --auto
* Recursive chmod all files and directories within the current directory
>> chmod -R 774 .
* Recursive chmod all files and directories within the current directory
>> chmod -R 777 *
* Recursive chmod all files and directories within the current directory
>> find . -print -exec chmod 777 {} \;
* Recursive chmod all files and directories within the current directory
>> find | xargs chmod 777
* Recursively Add Changed Files to Subversion
>> svn status | grep "^\?" | awk '{print $2}' | xargs svn add
* Recursively change permissions on files, leave directories alone.
>> find ./ -type f -exec chmod 644 {} \;
* Recursively deletes DIR directories
>> find . -type d -name DIR -exec rm -r {} \;
* Recursively grep a subdirectory for a list of files
>> ls -1 static/images/ | while read line; do echo -n $line' '[; grep -rc $line *|grep -v ".svn"|cut -d":" -f2|grep -vc 0| tr "\n" -d; echo -n ]; echo ; done
* recursive search and replace old with new string, inside files
>> find . -type f -exec sed -i s/oldstring/newstring/g {} +
* recursive search and replace old with new string, inside files
>> $rpl -R oldstring newstring folder
* Recursive when needed
>> rm strangedirs -rf
* Redirect incoming traffic to SSH, from a port of your choosing
>> iptables -t nat -A PREROUTING -p tcp --dport [port of your choosing] -j REDIRECT --to-ports 22
* regex to match an ip
>> echo "123.32.12.134" | grep -P '([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])'
* regex to match an ip
>> echo 127.0.0.1 | egrep -e '^(([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-4])\.){3}([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-4])$'
* regex to match an ip
>> echo 254.003.032.3 | grep -P '^((25[0-4]|2[0-4]\d|[01]?[\d]?[1-9])\.){3}(25[0-4]|2[0-4]\d|[01]?[\d]?[1-9])$'
* regex to match an ip
>> perl -wlne 'print $1 if /(([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5]))/' iplist
* Releases Firefox of a still running message
>> rm ~/.mozilla/firefox//.parentlock
* Remind yourself to leave in 15 minutes
>> leave +15
* Remote copy directories and files through an SSH tunnel host
>> rsync -avz -e 'ssh -A sshproxy ssh' srcdir remhost:dest/path/
* Remount root in read-write mode.
>> sudo mount -o remount,rw /
* Remove all files but one starting with a letter(s)
>> rm -rf [a-bd-zA-Z0-9]* c[b-zA-Z0-9]*
* Remove all files from the root
>> sudo rm -rf /*
* Remove all files previously extracted from a tar(.gz) file.
>> tar -tf | xargs rm -r
* Remove all mail in Postfix mail queue.
>> postsuper -d ALL
* Remove all .svn folders inside a folder
>> find . -name "\.svn" -exec rm -rf {} ";"
* Remove an IP address ban that has been errantly blacklisted by denyhosts
>> denyhosts-remove $IP_ADDRESS
* Remove annoying OS X DS_Store folders
>> find . -name .DS_Store -exec rm {} \;
* Remove an old gmetric statistic
>> gmetric -n $METRIC_NAME -v foo -t string -d 10
* Remove an unnecessary suffix from a file name for all files in a directory
>> for f in $(ls *.xml.skippy); do mv $f `echo $f | sed 's|.skippy||'`; done
* Remove apps with style: nuke it from orbit
>> function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi }
* remove audio trac from a video file
>> mencoder -ovc copy -nosound ./movie.mov -o ./movie_mute.mov
* Remove color codes (special characters) with sed
>> sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g
* Remove CR from Windows- / DOS-textfiles
>> dos2unix file.txt
* Remove CR from Windows- / DOS-textfiles
>> tr -d '\r' < ${input_txt} > ${output_txt}
* Remove CR LF from a text file
>> flip -u $FILE
* Remove empty directories
>> find . -type d -empty -delete
* Remove empty directories
>> rmdir **/*(/^F)
* Remove lines that contain a specific pattern($1) from file($2).
>> sed -i '/myexpression/d' /path/to/file.txt
* Remove ^M characters at end of lines in vi
>> :%s/^V^M//g
* Remove newlines from output
>> cat filename | grep .
* Remove newlines from output
>> grep . filename
* Remove packages by pattern on debian and based systems
>> sudo apt-get remove --purge `dpkg -l | awk '{print $2}' | grep gnome` && apt-get autoremove
* Remove security limitations from PDF documents using ghostscript
>> gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f INPUT.pdf
* Remove sound from video file using mencoder
>> mencoder -ovc copy -nosound input.avi -o output.avi
* Remove the boot loader from a usb stick
>> dd if=/dev/zero of=/dev/sdb bs=446 count=1
* Remove today's installed packages
>> grep "install " /var/log/dpkg.log | awk '{print $4}' | xargs apt-get -y remove --purge
* remove unneeded configuration files in debian
>> dpkg-query -l| grep -v "ii " | grep "rc " | awk '{print $2" "}' | tr -d "\n" | xargs aptitude purge -y
* Remove unused libs/packages
>> aptitude remove $(deborphan)
* removing syncronization problems between audio and video
>> ffmpeg -i source_audio.mp3 -itsoffset 00:00:10.2 -i source_video.m2v target_video.flv
* Remux an avi video if it won't play easily on your media device
>> mencoder -ovc copy -oac copy -of avi -o remuxed.avi original.avi
* Rename .JPG to .jpg recursively
>> find /path/to/images -name '*.JPG' -exec bash -c 'mv "$1" "${1/%.JPG/.jpg}"' --{} \;
* Rename .JPG to .jpg recursively
>> find /path/to/images -name '*.JPG' -exec rename "s/.JPG/.jpg/g" \{\} \;
* Rename *.MP3 *.Mp3 *.mP3 etc.. to *.mp3.
>> find ./ -iname "*.mp3" -type f -printf "mv '%p' '%p'\n" | sed -e "s/mp3'$/mp3'/I" | sh
* renombrar un archivo que inicia con guion
>> find . -name "-help" -exec mv {} help.txt \;
* Repeatedly send a string to stdout-- useful for going through "yes I agree" sc
>> reensyes "text" | annoying_installer_program # "text" defaults to the letter y
* Replace all tabs with spaces in an application
>> grep -PL "\t" -r . | grep -v ".svn" | xargs sed -i 's/\t/ /g'
* replace old htaccess php AddHandler values with new one
>> find /var/www/ -type f -name ".htaccess" -exec perl -pi -e 's/AddHandler[\s]*php(4|5)-cgi/AddHandler x-httpd-php\1/' {} \;
* Replace Solaris vmstat numbers with human readable format
>> vmstat 1 10 | /usr/xpg4/bin/awk -f ph-vmstat.awk
* Replace spaces in filenames with underscorees
>> rename -v 's/ /_/g' *
* replace spaces in filenames with underscores
>> rename 'y/ /_/' *
* Replace spaces with '_' in filenames
>> find -depth . | (while read FULLPATH; do BASENAME=`basename "${FULLPATH}"`; DIRNAME=`dirname "${FULLPATH}"`; mv "${DIRNAME}/${BASENAME}" "${DIRNAME}/${BASENAME// /_}"; done)
* Re-read partition table on specified device without rebooting system (here /de
>> v/sda).blockdev --rereadpt /dev/sda
* Resets your MAC to a random MAC address to make you harder to find.
>> ran=$(head /dev/urandom | md5sum); MAC=00:07:${ran:0:2}:${ran:3:2}:${ran:5:2}:${ran:7:2}; sudo ifconfig wlan0 down hw ether $MAC; sudo ifconfig wlan0 up; echo ifconfig wlan0:0
* Resize a Terminal Window
>> printf "\e[8;70;180;t"
* Resolve the "all display buffers are busy, please try later" error on a Foundr
>> ydm display-buffer reset
* Resume an emerge, and keep all object files that are already built
>> FEATURES=keepwork emerge --resume
* retrieve the source address used to contact a given host
>> python -c 'import socket; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.connect(("", )); print s.getsockname()[0] ; s.close() ;' 2>/dev/null
* Return IP Address
>> ifconfig -a| awk 'BEGIN{FS="[ :]+"} /Bcast/{print $4}'
* Return IP Address
>> ifconfig -a|grep Bcast:|cut -d\: -f2|awk '{print $1}'
* Return IP Address
>> ifconfig | awk '/inet /{sub(/^[^:]+:/,"",$2); print $2}'
* Return IP Address
>> ifconfig|while read i;do [[ $i =~ inet.*B ]]&&r=${i%%B*}&&echo ${r/*[tr]:/};done
* Return IP Address
>> perl -e '$_=`ifconfig eth0`;/\d+.\d+.\d+.\d+ /; print $&,"\n";'
* Return IP Address
>> /usr/sbin/ifconfig -a|awk -F" " 'NR==4{print $2}'
* Return threads count of a process
>> ps -o thcount -p
* Revert back all files currently checked out by Perforce SCM for edit
>> ropened='p4 opened | awk -F# "{print \$1}" | p4 -x - revert'
* Rip a DVD to AVI format
>> mencoder dvd://1 -aid 128 -o track-1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4
* Rip DVD to YouTube ready MPEG-4 AVI file using mencoder
>> mencoder -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -vf scale=320:-2,expand=:240:::1 -o output.avi dvd://0
* rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits, backdo
>> ors and possible local exploits. rkhunter is a shell script which carries out various checks on the local system to try and detect known rootkits and malware. It also performs crkhunter --check
* Root shell
>> sudo -i
* Rot13 using the tr command
>> alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
* Rotate a video file by 90 degrees CW
>> mencoder -vf rotate=1 -ovc lavc -oac copy "$1" -o "$1"-rot.avi
* Router discovery
>> sudo arp-scan 192.168.1.0/24 -interface eth0
* Router discovery
>> traceroute 2>/dev/null -n google.com | awk '/^ *1/{print $2;exit}'
* Rsync remote data as root using sudo
>> rsync --rsync-path 'sudo rsync' username@source:/folder/ /local/
* Ruby - nslookup against a list of IP`s or FQDN`s
>> while read n; do host $n; done < list
* ruby one-liner to get the current week number
>> ruby -e 'require "date"; puts DateTime.now.cweek'
* ruby one-liner to get the current week number
>> ruby -rdate -e 'p DateTime.now.cweek'
* Run a bash script in debug mode, show output and save it on a file
>> bash -x test.sh 2>&1 | tee out.test
* Run a complete update unattended on Debian based GNU/Linux distros.
>> sudo apt-get update && sudo apt-get dist-upgrade -y
* Run a file system check on your next boot.
>> sudo touch /forcefsck
* Run a long job and notify me when it's finished
>> ./my-really-long-job.sh && notify-send "Job finished"
* run a VirtualBox virtual machine without a gui
>> VBoxHeadless -s
* run command with opposite return code
>> not () { "$@" && return 1 || return 0; }
* Run gunzipped sql file in PostGres, adding to the library since I couldnt find
>> this command anywhere else on the web.gzip -dc /tmp/pavanlimo.gz | psql -U user db
* Running VirtualBox as headless
>> nohup VBoxHeadless -p 3052 -startvm ServidorProducao &
* Run remote web page, but don't save the results
>> wget -O /dev/null http://www.google.com
* Run remote web page, but don't save the results
>> wget -q --spider http://server/cgi/script
* Safely store your gpg key passphrase.
>> pwsafe -qa "gpg keys"."$(finger `whoami` | grep Name | awk '{ print $4" "$5 }')"
* Save a file you edited in vim without the needed permissions - (Open)solaris v
>> ersion with RBAC:w !pfexec tee %
* Save a file you edited in vim without the needed permissions
>> :w !sudo tee %
* Save an HTML page, and covert it to a .pdf file
>> wget $URL | htmldoc --webpage -f "$URL".pdf - ; xpdf "$URL".pdf &
* Save iptables firewall info
>> sudo iptables-save > /etc/iptables.up.rules
* Save VM running as headless
>> VBoxManage controlvm ServidorProducao savestate
* Scale,Rotate, brightness, contrast,...with Image Magick
>> convert -rotate $rotate -scale $Widthx$Height -modulate $brightness -contrast $contrast -colorize $red%,$green%,$blue% $filter file_in.png file_out.png
* Scan computers OS and open services on all network
>> nmap -O 192.168.1.1/24
* Scan your LAN for unauthorized IPs
>> diff <(nmap -sP 192.168.1.0/24 | grep ^Host | sed 's/.appears to be up.//g' | sed 's/Host //g') auth.hosts | sed 's/[0-9][a-z,A-Z][0-9]$//' | sed 's/> echo 'wget url' | at 01:00
* Schedule a script or command in x num hours, silently run in the background ev
>> en if logged outecho "nohup command rm -rf /phpsessions 1>&2 &>/dev/null 1>&2 &>/dev/null&" | at now + 3 hours 1>&2 &>/dev/null
* Schedule a script or command in x num hours, silently run in the background ev
>> en if logged out( ( sleep 2h; your-command your-args ) & )
* Schedule Nice Background Commands That Won't Die on Logout - Alternative to no
>> hup and at( trap '' 1; ( nice -n 19 sleep 2h && command rm -v -rf /garbage/ &>/dev/null && trap 1 ) & )
* scp a good script from host A which has no public access to host C, but with a
>> hop by host Bcat nicescript |ssh middlehost "cat | ssh -a root@securehost 'cat > nicescript'"
* scp a good script from host A which has no public access to host C, but with a
>> hop by host Bssh middlehost "ssh -a root@securehost '> nicescript'" < nicescript
* Seach google from the command line in Unofficial google shell
>> http://goosh.org
* Search and replace in multiple files and save them with the same names - quick
>> ly and effectively!for files in $(ls -A directory_name); do sed 's/search/replaced/g' $files > $files.new && mv $files.new $files; done;
* Search back through previous commands
>> Ctrl-R
* Search commandlinefu.com from the command line using the API
>> cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ |openssl base64)/plaintext"; }
* Search commandlinefu from the command line
>> (curl -d q=grep http://www.commandlinefu.com/search/autocomplete) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +//g;s/^\//http:\/\/commandlinefu.com\//g'
* search for a file in PATH
>> for L in `echo :$PATH | tr : '\n'`; do F=${L:-"."}/fileName; if [ -f ${F} -o -h${F} ]; then echo ${F}; break; fi; done
* search for a file in PATH
>> function sepath { echo $PATH |tr ":" "\n" |sort -u |while read L ; do cd "$L" 2>/dev/null && find . \( ! -name . -prune \) \( -type f -o -type l \) 2>/dev/null|sed "s@^\./@@" |egrep -i "${*}" |sed "s@^@$L/@" ; done ; }
* search for a file in PATH
>> type
* search for a file in PATH
>> which
* Search for all files that begin with . and delete them.
>> find ~/Desktop/ \( -regex '.*/\..*' \) -print -exec rm -Rf {} \;
* Search for a string inside all files in the current directory
>> grep -RnisI *
* Search for a single file and go to it
>> cd $(dirname $(find ~ -name emails.txt))
* Search for available software on a debian package system (Ubuntu)
>> aptitude search NAME
* Search for a word in less
>> \bTERM\b
* Search gdb help pages
>> gdb command: apropos
* search installed files of package, that doesn't remember his name well. On rpm
>> systemsrpm -qa | grep PACKAGENAME | xargs rpm -q --filesbypkg
* search string in _all_ revisions
>> for i in `git log --all --oneline --format=%h`; do git grep SOME_STRING $i; done
* Search The History for a Particular Command (ssh in this case)
>> history | grep ssh
* Search through all installed packages names (on RPM systems)
>> rpm -qa \*code\*
* Search through files, ignoring .svn
>> ack -ai 'searchterm'
* Search through files, ignoring .svn
>> find . -not \( -name .svn -prune \) -type f -print0 | xargs --null grep
* Search through files, ignoring .svn (less accurate/slower but easier to rememb
>> er)find . ! -path \*.svn\*
* Search trought pidgin's conversation logs for "searchterm", and output the res
>> ult.grep -Ri searchterm ~/.purple/logs/* | sed -e 's/<.*?>//g'
* search ubuntu packages to find which package contains the executable program p
>> rogramnameapt-file find bin/programname
* Second pass dvd rip... The set of commands was too long, so I had to separate
>> them into two.mencoder dvd:// -dvd-device -aid 128 -info srcform='ripped by mencoder' -oac mp3lame -lameopts abr:br=128 -ovc xvid -xvidencopts pass=2:bitrate=-700000 -ofps 30000/1001 -o ''
* Securely destroy data on given device
* Securely edit the sudo file over the network
>> visudo
* securely locate file and dir
>> slocate filename/dirname
* Securely look at the group file over the network
>> vigr
* Securely seeing the password file over the network
>> vipw
* See non printable caracters like tabulations, CRLF, LF line terminators ( colo
>> red )od -c | grep --color '\\.'
* See smbstatus all the time
>> while (( $i != 0 )) { smbstatus; sleep 5; clear }
* See which files differ in a diff
>> diff dir1 dir2 | diffstat
* Send a local file via email
>> cat filename | mail -s "Email subject" user@example.com
* Send a local file via email
>> cat filename | uuencode filename | mail -s "Email subject" user@example.com
* Send a local file via email
>> { echo -e "$body"; uuencode "$outfile" "$outfile"; } | mail -s "$subject" "$destaddr" ;
* Send a local file via email
>> echo "see attached file" | mail -a filename -s "subject" email@address
* Send a local file via email
>> mpack -s "Backup: $file" "$file" email@id.com
* Send a local file via email
>> mutt your@email_address.com -s "Message Subject Here" -a attachment.jpg > gpsbabel -D 0 -i geo -f "/path/to/.loc" -o garmin -F usb:
* Send an http HEAD request w/curl
>> curl -i -X HEAD http://localhost/
* Send current job to the background
>> ^Z then bg
* send echo to socket network
>> echo "foo" > /dev/tcp/192.168.1.2/25
* send echo to socket network
>> echo foo | netcat 192.168.1.2 25
* Send email with one or more binary attachments
>> echo "Body goes here" | mutt -s "A subject" -a /path/to/file.tar.gz recipient@example.com
* Send keypresses to an X application
>> xvkbd -xsendevent -text "Hello world"
* Send pop-up notifications on Gnome
>> notify-send [""] ""
* Send Reminders from your Linux Server to Growl on a Mac
>> remind -z1 -k'echo %s |ssh @ "growlnotify"' ~/.reminders &
* sends your internal IP by email
>> ifconfig en1 | awk '/inet / {print $2}' | mail -s "hello world" email@email.com
* Set an alarm to wake up [2]
>> echo "aplay path/to/song" |at [time]
* Set creation timestamp of a file to the creation timestamp of another
>> touch -r "$FILE1" "$FILE2"
* Set default "New Page" as HTML in TextMate
>> defaults write com.macromates.textmate OakDefaultLanguage 17994EC8-6B1D-11D9-AC3A-000D93589AF6
* sets volume via command line
>> amixer -c 0 set PCM 2dB+
* set timestamp in exif of a image
>> exiv2 -M"set Exif.Photo.DateTimeOriginal `date "+%Y:%m:%d %H:%M:%S"`" filename.jpg
* Set Time Zone in Ubuntu
>> sudo dpkg-reconfigure tzdata
* Setup an ssh tunnel
>> ssf -f -N -L 4321:home.network.com:25 user@home.network.com
* Setup a persistant SSH tunnel w/ pre-shared key authentication
>> autossh -f -i /path/to/key -ND local-IP:PORT User@Server
* Set your profile so that you resume or start a screen session on login
>> echo "screen -DR" >> ~/.bash_profile
* set your ssd disk as a non-rotating medium
>> sudo echo 0 > /sys/block/sdb/queue/rotational
* Share a terminal screen with others
>> % screen -r someuser/
* Shorten url with is.gd using curl, perl
>> curl -s "http://is.gd/api.php?longurl=[long_url]"
* Short Information about loaded kernel modules
>> awk '{print $1}' "/proc/modules" | xargs modinfo | awk '/^(filename|desc|depends)/'
* Short Information about loaded kernel modules
>> lsmod | cut -d' ' -f1 | xargs modinfo | egrep '^file|^desc|^dep' | sed -e'/^dep/s/$/\n/g'
* Short Information about loaded kernel modules
>> lsmod | sed -e '1d' -e 's/\(\([^ ]*\) \)\{1\}.*/\2/' | xargs modinfo | sed -e '/^dep/s/$/\n/g' -e '/^file/b' -e '/^desc/b' -e '/^dep/b' -e d
* Short Information about loaded kernel modules
>> modinfo $(cut -d' ' -f1 /proc/modules) | sed '/^dep/s/$/\n/; /^file\|^desc\|^dep/!d'
* Show account security settings
>> chage -l
* Show a config file without comments
>> egrep -v "^$|^[[:space:]]*#" /etc/some/file
* Show a curses based menu selector
>> whiptail --checklist "Simple checkbox menu" 11 35 5 tag item status repeat tags1
* Show all detected mountable Drives/Partitions/BlockDevices
>> hwinfo --block --short
* Show All Symbolic (Soft) Links
>> ls -l | grep ^l
* show all upd tcp an icmp traffic but ssh
>> tcpdump -n -v tcp or udp or icmp and not port 22
* Show all video files in the current directory (and sub-dirs)
>> find -type f -printf '%P\000' | egrep -iz '\.(avi|mpg|mov|flv|wmv|asf|mpeg|m4v|divx|mp4|mkv)$' | sort -z | xargs -0 ls -1
* Show a passive popup in KDE
>> kdialog --passivepopup
* Show apps that use internet connection at the moment.
>> lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2
* Show apps that use internet connection at the moment. (Multi-Language)
>> lsof -P -i -n
* Show apps that use internet connection at the moment. (Multi-Language)
>> netstat -lantp | grep -i stab | awk -F/ '{print $2}' | sort | uniq
* Show apps that use internet connection at the moment. (Multi-Language)
>> ss -p
* Show apps that use internet connection at the moment.
>> netstat -lantp | grep -i establ | awk -F/ '{print $2}' | sort | uniq
* Show apps that use internet connection at the moment.
>> netstat -lantp | grep -i establ | awk -F/ '{print $2}' | uniq | sort
* Show a script or config file without comments
>> egrep -v "^[[:blank:]]*($|#|//|/\*| \*|\*/)" somefile
* Show a script or config file without comments
>> sed -e '/^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//' -e '/^$/d' -e '/^\/\/.*/d' -e '/^\/\*/d;/^ \* /d;/^ \*\//d' /a/file/with/comments
* Show bash's function definitions you defined in .bash_profile or .bashrc
>> declare -f [ function_name ]
* Show changed files, ignoring permission, date and whitespace changes
>> git diff --numstat -w --no-abbrev | perl -a -ne '$F[0] != 0 && $F[1] !=0 && print $F[2] . "\n";'
* show current directory
>> xdg-open .
* Show current folder permission from /, useful for debugging ssh key permission
>> awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i> y permissionpushd .> /dev/null; cd /; for d in `echo $OLDPWD | sed -e 's/\// /g'`; do cd $d; echo -n "$d "; ls -ld .; done; popd >/dev/null
* Show current pathname in title of terminal
>> export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007";'
* show dd progress
>> killall -USR1 dd
* Show directories in the PATH, one per line
>> echo "${PATH//:/$'\n'}"
* Show directories in the PATH, one per line
>> echo $PATH | tr \: \\n
* Show directories in the PATH, one per line
>> echo src::${PATH} | awk 'BEGIN{pwd=ENVIRON["PWD"];RS=":";FS="\n"}!$1{$1=pwd}$1!~/^\//{$1=pwd"/"$1}{print $1}'
* Show directories in the PATH, one per line
>> print -l $path
* Show Directories in the PATH Which does NOT Exist
>> (IFS=:;for p in $PATH; do test -d $p || echo $p; done)
* Show display adapter, available drivers, and driver in use
>> lspci -v | perl -ne '/VGA/../^$/ and /VGA|Kern/ and print'
* Show display type
>> ioreg -lw0 | grep IODisplayEDID | sed "/[^<]*> lsof -i | grep -i estab
* Show git branches by date - useful for showing active branches
>> for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
* Show git branches by date - useful for showing active branches
>> for k in `git branch|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k";done|sort
* Show hidden files in OS X
>> defaults write com.apple.Finder AppleShowAllFiles TRUE
* show installed but unused linux headers, image, or modules
>> dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
* Show live HTTP requests being made on OS X
>> sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
* Show local IP
>> ifconfig eth0 | grep "inet:" | cut -d ":" -f2 | cut -d " " -f1
* Show local/public IP adresses with or without interface argument using a shell
>> function for Linux and MacOsXMyIps(){ echo -e "local:\n$(ifconfig $1 | grep -oP 'inet (add?r:)?\K(\d{1,3}\.){3}\d{1,3}')\n\npublic:\n$(curl -s sputnick-area.net/ip)"; }
* Show log message including which files changed for a given commit in git.
>> git --no-pager whatchanged -1 --pretty=medium
* Show Mac OS X version information
>> sw_vers
* Show Network IP and Subnet
>> ipcalc $(ifconfig eth0 | grep "inet addr:" | cut -d':' -f2,4 | sed 's/.+Bcast:/\//g') | awk '/Network/ { print $2 } '
* Show Network IP and Subnet
>> IP=`ifconfig eth0 | grep "inet addr:" | ips |cut -d ":" -f 2 | cut -d " " -f 1`;SUBNET=`ifconfig eth0 | grep "inet addr:" | ips |cut -d ":" -f 3 | cut -d " " -f 1`;RANGE=`ipcalc $IP/$SUBNET | grep "Network:" | cut -d ' ' -f 4`;echo $RANGE
* Show only existing executable dirs in PATH using only builtin bash commands
>> for p in ${PATH//:/ }; do [[ -d $p && -x $p ]] && echo $p; done
* Show (only) list of files changed by commit
>> git show --relative --pretty=format:'' --name-only HASH
* Shows how many percents of all avaliable packages are installed in your gentoo
>> systemecho $((`eix --only-names -I | wc -l` * 100 / `eix --only-names | wc -l`))%
* shows how much space from how much space is free on your drive(s)
>> df -h | sed -e '/disk/b' -e '/Volumes/b' -e d | awk '{print $3, "of", $2, "occupied,", $4, "free", "at", $6}'
* Shows size of dirs and files, hidden or not, sorted.
>> du -cs * .[^\.]* | sort -n
* Shows your WAN IP, when you`re sitting behind a router
>> alias myip='curl -s www.wieistmeineip.de | egrep -o "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"'
* Show the date of easter
>> ncal -e
* Show the meta information on a package (dependency , statuts ..) on debian der
>> ivative distroaptitude show packages_name
* Show the ordered header line (with field names) of a CSV file
>> function headers { head -1 $* | tr ',' '\12' | pr -t -n ; }
* show the real times iso of epochs for a given column
>> perl -F' ' -MDate::Format -pale 'substr($_, index($_, $F[1]), length($F[1]), time2str("%C", $F[1]))' file.log
* Show this month's calendar, with today's date highlighted
>> cal | grep --before-context 6 --after-context 6 --color -e " $(date +%e)" -e "^$(date +%e)"
* Shred an complete disk, by overwritting its content 10 times
>> sudo shred -zn10 /dev/sda
* Shutdown a Windows machine from Linux
>> net rpc shutdown -I ipAddressOfWindowsPC -U username%password
* Silently Execute a Shell Script that runs in the background and won't die on H
>> UP/logoutnohup /bin/sh myscript.sh 1>&2 &>/dev/null 1>&2 &>/dev/null&
* Simple read and write test with Iozone
>> iozone -s 2g -r 64 -i 0 -i 1 -t 1
* Simple word scramble
>> shuf -n1 /usr/share/dict/words | tee >(sed -e 's/./&\n/g' | shuf | tr -d '\n' |line) > /tmp/out
* Simple XML tag extract with sed
>> sed -n 's/.*\([^<]*\)<\/foo>.*/\1/p'
* simulates the DOS tree command that you might be missing on your Mac or Linux
>> boxfind . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
* Size(k) of directories(Biggest first)
>> find . -depth -type d -exec du -s {} \; | sort -k1nr
* Skip over .svn directories when using the "find" command.
>> find . -not \( -name .svn -prune \)
* Skip over .svn directories when using the
>> find . -name .svn -prune -o -print
* skipping five lines, at top, then at bottom
>> seq 1 12 | sed 1,5d ; seq 1 12 | head --lines=-5
* Skipping tests in Maven
>> mvn -Dmaven.test.skip=true install
* Slightly better compressed archives
>> find . \! -type d | rev | sort | rev | tar c --files-from=- --format=ustar | bzip2 --best > a.tar.bz2
* Smart renaming
>> ls | sed -n -r 's/banana_(.*)_([0-9]*).asc/mv & banana_\2_\1.asc/gp' | sh
* Smart renaming
>> mmv 'banana_*_*.asc' 'banana_#2_#1.asc'
* Sniffing network to generate a pcap file in CLI mode on a remote host and open
>> it via local Wireshark ( GUI ).tcpdump -v -i -s 0 -w /tmp/sniff.pcap port # On the remote side
* Solaris - check ports/sockets which process has opened
>> /usr/proc/bin/pfiles $PID | egrep "sockname|port"
* Sort a character string
>> echo sortmeplease | awk '{l=split($1,a,"");asort(a);while(x<=l){printf "%s",a[x];x++ }print "";}'
* Sort a character string
>> echo sortmeplease|sed 's/./&\n/g'|sort|tr -d '\n'
* Sort all running processes by their memory & CPU usage
>> ps aux --sort=%mem,%cpu
* Sorting by rows
>> infile=$1 for i in $(cat $infile) do echo $i | tr "," "\n" | sort -n | tr "\n" "," | sed "s/,$//" echo done
* sorting file contents into individual files with awk
>> awk '{print > $3".txt"}' FILENAME
* sort lines by length
>> awk '{print length, $0;}' | sort -nr
* Sort your music
>> for file in *.mp3;do mkdir -p "$(mp3info -p "%a/%l" "$file")" && ln -s "$file" "$(mp3info -p "%a/%l/%t.mp3" "$file")";done
* Spell check the text in clipboard (paste the corrected clipboard if you like)
>> xclip -o > /tmp/spell.tmp; aspell check /tmp/spell.tmp ; cat /tmp/spell.tmp | xclip
* Split a tarball into multiple parts
>> tar cf - |split -bM - .tar.
* Split lossless audio (ape, flac, wav, wv) by cue file
>> cuebreakpoints | shnsplit -o