All UNIX COMMANDS
All UNIX COMMANDS
All UNIX COMMANDS
1 / 658
2 / 658
3 / 658
4 / 658
/' -e 's/-/|/'
5 / 658
6 / 658
7 / 658
8 / 658
9 / 658
10 / 658
11 / 658
12 / 658
the
last
argument
of
$file_source $user@$host:$destination_file
13 / 658
14 / 658
# Silently ensures that a FS is mounted on the given mount point (checks if it's OK,
otherwise unmount, create dir and mount)
(mountpoint -q "/media/mpdr1" && df /media/mpdr1/* > /dev/null 2>&1) || ((sudo umount
"/media/mpdr1" > /dev/null 2>&1 || true) && (sudo mkdir "/media/mpdr1" > /dev/null 2>&1 ||
true) && sudo mount "/dev/sdd1" "/media/mpdr1")
# Check if system is 32bit or 64bit
getconf LONG_BIT
# Limit the cpu usage of a process
sudo cpulimit -p pid -l 50
# send a circular
wall <<< "Broadcast This"
# Single use vnc-over-ssh connection
ssh -f -L 5900:localhost:5900 your.ssh.server "x11vnc -safer -localhost -nopw -once -display
:0"; vinagre localhost:5900
# The BOFH Excuse Server
telnet towel.blinkenlights.nl 666
# I finally found out how to use notify-send with at or cron
echo "export DISPLAY=:0; export XAUTHORITY=~/.Xauthority; notify-send test" | at now+1minute
15 / 658
16 / 658
17 / 658
18 / 658
19 / 658
20 / 658
21 / 658
22 / 658
23 / 658
24 / 658
25 / 658
# I hate `echo X | Y`
base64 -d <<< aHR0cDovL3d3dy50d2l0dGVyc2hlZXAuY29tL3Jlc3VsdHMucGhwP3U9Y29tbWFuZGxpbmVmdQo=
# Send keypresses to an X application
xvkbd -xsendevent -text "Hello world"
# Add calendar to desktop wallpaper
convert -font -misc-fixed-*-*-*-*-*-*-*-*-*-*-*-* -fill black -draw "text 270,260 \"
`cal` \"" testpic.jpg newtestpic.jpg
# create dir tree
mkdir -p doc/{text/,img/{wallpaper/,photos/}}
# Run any GUI program remotely
ssh -fX <user>@<host> <program>
# Browse system RAM in a human readable form
26 / 658
27 / 658
28 / 658
29 / 658
30 / 658
31 / 658
32 / 658
33 / 658
34 / 658
the
last
argument
of
# Update twitter via curl (and also set the "from" bit)
curl -u twitter-username -d status="Hello World, Twitter!" -d source="cURL"
http://twitter.com/statuses/update.xml
# Carriage return for reprinting on the same line
while true; do echo -ne "$(date)\r"; sleep 1; done
# command line calculator
calc(){ awk "BEGIN{ print $* }" ;}
# Backup a local drive into a file on the remote host via ssh
dd if=/dev/sda | ssh user@server 'dd of=sda.img'
# Kill processes that have been running for more than a week
find /proc -user myuser -maxdepth 1 -type d -mtime +7 -exec basename {} \; | xargs kill -9
# 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
# Show directories in the PATH, one per line
echo $PATH | tr \: \\n
# An easter egg built into python to give you the Zen of Python
python -c 'import this'
# Add prefix onto filenames
rename 's/^/prefix/' *
# Stream YouTube URL directly to mplayer
id="dMH0bHeiRNg";mplayer -fs http://youtube.com/get_video.php?video_id=$id\&t=$(curl -s
http://www.youtube.com/watch?v=$id | sed -n 's/.*, "t": "\([^"]*\)", .*/\1/p')
# Get all IPs via ifconfig
ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'
# Pick a random line from a file
shuf -n1 file.txt
# Get all these commands in a text file with description.
for x in `jot - 0 2400 25`; do curl "http://www.commandlinefu.com/commands/browse/sort-byvotes/plaintext/$x" ; done > commandlinefu.txt
35 / 658
# from within vi, pipe a chunk of lines to a command line and replace the chunk with the
result
!}sort
# Merge *.pdf files
gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf `ls *.pdf`
# Append stdout and stderr to a file, and print stderr to the screen [bash]
somecommand 2>&1 >> logfile | tee -a logfile
# quickly change all .html extensions on files in folder to .htm
for i in *.html ; do mv $i ${i%.html}.htm ; done
# Grep for word in directory (recursive)
grep --color=auto -iRnH "$search_word" $directory
# Unix alias for date command that lets you create timestamps in ISO 8601 format
alias timestamp='date "+%Y%m%dT%H%M%S"'
# Another Curl your IP command
curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z<>/ :]//g'
# count IPv4 connections per IP
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | sed s/::ffff:// | cut -d: -f1 | sort |
uniq -c | sort -n
# archive all files containing local changes (svn)
svn st | cut -c 8- | sed 's/^/\"/;s/$/\"/' | xargs tar -czvf ../backup.tgz
# Show which programs are listening on TCP and UDP ports
netstat -plunt
36 / 658
Link.*HWaddr//' ; }
37 / 658
38 / 658
# Displays the attempted user name, ip address, and time of SSH failed logins on Debian
machines
awk '/sshd/ && /Failed/ {gsub(/invalid user/,""); printf "%-12s %-16s %s-%s-%s\n", $9, $11,
$1, $2, $3}' /var/log/auth.log
# Quickly get summary of sizes for files and folders
du -sh *
# geoip information
curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>]
[^>]*>//g'
# Find the package a command belongs to on Debian
dpkg -S $( which ls )
# Simple multi-user encrypted chat server for 5 users
ncat -vlm 5 --ssl --chat 9876
# live ssh network throughput test
pv /dev/zero|ssh $host 'cat > /dev/null'
# Serve current directory tree at http://$HOSTNAME:8080/
twistd -n web --path .
# Generate Random Passwords
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6
# Files extension change
rename .oldextension .newextension *.oldextension
# Kill a broken ssh connection
<Return>~.
# Convert Shell Text to Upper/Lower Case
ALT-U / ALT-L
# Get all IPs via ifconfig
ifconfig | perl -nle'/dr:(\S+)/ && print $1'
# Get the canonical, absolute path given a relative and/or noncanonical path
readlink -f ../super/symlink_bon/ahoy
# List your MACs address
lsmac() { ifconfig -a | sed '/eth\|wl/!d;s/
Link.*HWaddr//' ; }
39 / 658
# Empty a file
:> file
# Generate a list of installed packages on Debian-based systems
dpkg --get-selections > LIST_FILE
# Redirect tar extract to another directory
tar xfz filename.tar.gz -C PathToDirectory
# Set your profile so that you resume or start a screen session on login
echo "screen -DR" >> ~/.bash_profile
# prevent accidents and test your command with echo
echo rm *.txt
# Convert camelCase to underscores (camel_case)
sed -r 's/([a-z]+)([A-Z][a-z]+)/\1_\l\2/g' file.txt
# Find recursively, from current directory down, files and directories whose names contain
single or multiple whitespaces and replace each such occurrence with a single underscore.
find ./ -name '*' -exec rename 's/\s+/_/g' {} \;
# Daemonize nc - Transmit a file like a http server
while ( nc -l 80 < /file.htm > : ) ; do : ; done &
# Convert .wma files to .ogg with ffmpeg
find -name '*wma' -exec ffmpeg -i {} -acodec vorbis -ab 128k {}.ogg \;
40 / 658
41 / 658
42 / 658
43 / 658
44 / 658
45 / 658
46 / 658
the
last
argument
of
47 / 658
48 / 658
- dummy.
49 / 658
50 / 658
# Re-read partition table on specified device without rebooting system (here /dev/sda).
blockdev --rereadpt /dev/sda
# Optimal way of deleting huge numbers of files
find /path/to/dir -type f -delete
# Search command history on bash
ctrl + r
# convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk format)
VBoxManage internalcommands converttoraw winxp.vdi winxp.raw && qemu-img convert -O vmdk
winxp.raw winxp.vmdk && rm winxp.raw
# find builtin in bash v4+
ls -l /etc/**/*killall
# Convert JSON to YAML
ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' < file.json > file.yaml
# Copy a folder tree through ssh using compression (no temporary files)
ssh <host> 'tar -cz /<folder>/<subfolder>' | tar -xvz
# Create a file of a given size in linux
truncate -s 1M file
# extract element of xml
xmlstarlet sel -t -c "/path/to/element" file.xml
# removes characters from cursor to the end of line
Ctrl+k
# Check disk for bad sectors
badblocks -n -s -b 2048 /dev/sdX
# Make redirects to localhost via /etc/hosts more interesting
sudo socat TCP4-LISTEN:80,bind=127.0.0.1,fork EXEC:'echo "HTTP/1.1 503 Service
Unavailable";'
51 / 658
52 / 658
53 / 658
54 / 658
55 / 658
56 / 658
57 / 658
58 / 658
59 / 658
60 / 658
61 / 658
62 / 658
'; echo -e
63 / 658
64 / 658
65 / 658
| grep -v deag
66 / 658
67 / 658
# Lets Tux say the random fact. [add it to .bashrc to see it in new terminal window]
wget randomfunfacts.com -O - 2>/dev/null|grep \<strong\>|sed "s;^.*<i>\(.*\)</i>.*$;\1;"|
cowsay -f tux
# Join lines
tr "\n" " " < file
# cpu and memory usage top 10 under Linux
ps -eo user,pcpu,pmem | tail -n +2 | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3}
END{printf("NPROC\tUSER\tCPU\tMEM\n"); for (user in cpu) printf("%d\t%s\t%.2f\t
%.2f\n",num[user], user, cpu[user], mem[user]) }'
# know the current running shell (the true)
echo $0
# Use mtr to create a text file report
mtr --report --report-cycles 10 www.google.com > google_net_report.txt
# List dot-files and dirs, but not . or ..
ls -A
# gzip compression with progress bar and remaining time displayed
pv file | gzip > file.gz
# which process has a port open
lsof -i :80
# Configure second monitor to sit to the right of laptop
xrandr --output LVDS --auto --output VGA --auto --right-of LVDS
# Use a decoy while scanning ports to avoid getting caught by the sys admin :9
sudo nmap -sS 192.168.0.10 -D 192.168.0.2
# quick input
alt + .
# Quickly analyze apache logs for top 25 most common IP addresses.
cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i],
i ); }' | sort -n | tail -25
# Determine what an process is actually doing
sudo strace -pXXXX -e trace=file
# command to change the exif date time of a image
exiftool -DateTimeOriginal='2009:01:01 02:03:04' file.jpg
# Show IP Address in prompt --> PS1 var
export PS1="[\u@`hostname -I` \W]$ "
# Removes file with a dash in the beginning of the name
rm -- --myfile
# Increase mplayer maximum volume
mplayer dvd:// -softvol -softvol-max 500
68 / 658
69 / 658
70 / 658
71 / 658
# Create date-based tgz of current dir, runs in the background, very very cool
alias tarred='( ( D=`builtin pwd`; F=$(date +$HOME/`sed "s,[/ ],#,g" <<< ${D/${HOME}/}`#%F.tgz); tar --ignore-failed-read --transform "s,^${D%/*},`date +${D%/*}.%F`,S" -czPf "$F"
"$D" &>/dev/null ) & )'
# get bofh excuse from a trusted source :-)
telnet bofh.jeffballard.us 666
# Apply permissions only to files
chmod 644 $(find . -type f)
# Create the oauth token required for a Twitter stream feed
step3() { s=$(echo -n $b | openssl dgst -sha1 -hmac $hmac -binary | openssl base64);
signature=`for((i=0;i<${#s};i++)); do case ${s:i:1} in +) e %2B;; /) e %2F;; =) e %3D;; *) e
${s:i:1};; esac ; done` ; } ; e() { echo -n $1; }
# Create the four oauth keys required for a Twitter stream feed
step1() { k1="Consumer key" ; k2="Consumer secret" ; k3="Access token" ; k4="Access token
secret" ; once=$RANDOM ; ts=$(date +%s) ; hmac="$k2&$k4" ; id="19258798" ; }
# List just the executable files (or directories) in current directory
ls *(.x)
# Create the signature base string required for a Twitter stream feed
step2(){ b="GET&https%3A%2F%2Fstream.twitter.com%2F1%2Fstatuses%2Ffilter.json&follow%3D${id}
%26oauth_consumer_key%3D${k1}%26oauth_nonce%3D${once}%26oauth_signature_method%3DHMACSHA1%26oauth_timestamp%3D${ts}%26oauth_token%3D${k3}%26oauth_version%3D1.0";}
# Create an SSH connection (reverse tunnel) through your firewall.
ssh -R 2001:localhost:22 [username]@[remote server ip]
# Create the authorization header required for a Twitter stream feed
step4() { oauth_header="Authorization: OAuth oauth_consumer_key=\"$k1\",
oauth_nonce=\"$once\", oauth_signature=\"$signature\", oauth_signature_method=\"HMAC-SHA1\",
oauth_timestamp=\"$ts\", oauth_token=\"$k3\", oauth_version=\"1.0\"" ; }
# find the 10 latest (modified) files
ls -1t | head -n10
# ROT13 using the tr command
alias rot13="tr a-zA-Z n-za-mN-ZA-M"
72 / 658
[%Y] %p\n'
73 / 658
74 / 658
75 / 658
76 / 658
77 / 658
78 / 658
79 / 658
0"'
# Print a cron formatted time for 2 minutes in the future (for crontab testing)
crontest () { date '-d +2 minutes' +'%M %k %d %m *'; }
80 / 658
81 / 658
# shush MOTD
touch ~/.hushlogin
# sort lines by length
perl -lne '$l{$_}=length;END{for(sort{$l{$a}<=>$l{$b}}keys %l){print}}' <
/usr/share/dict/words | tail
# Quick and dirty convert to flash
ffmpeg -i inputfile.mp4 outputfile.flv
# Verify MD5SUMS but only print failures
md5sum --check MD5SUMS | grep -v ": OK"
# generate random password
openssl rand -base64 6
# Compute running average for a column of numbers
awk '{avg += ($1 - avg) / NR;} END { print avg; }'
# Chage default shell for all users [FreeBSD]
cd /usr/home && for i in *;do chsh -s bash $i;done
# Avoids ssh timeouts by sending a keep alive message to the server every 60 seconds
echo 'ServerAliveInterval 60' >> /etc/ssh/ssh_config
# Unlock more space form your hard drive
tune2fs -m 1 /dev/sda6
# connects to a serial console
screen /dev/ttyS0 9600
# List open IPv4 connections
lsof -Pnl +M -i4
# Using mplayer to play the audio only but suppress the video
mplayer -novideo something.mpg
# Makes the permissions of file2 the same as file1
getfacl file1 | setfacl --set-file=- file2
# Show some trivia related to the current date
calendar
# ssh -A user@somehost
ssh -A user@somehost
82 / 658
# Find out which debian package a command (executable) belongs to on debian-based distros
function whichpkg() { readlink -f "$(which $1)" | xargs --no-run-if-empty dpkg -S; }
# Display the standard deviation of a column of numbers with awk
awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)**2)}' file.dat
# A fun thing to do with ram is actually open it up and take a peek. This command will show
you all the string (plain text) values in ram
strings /dev/mem|less
# Quickly CD Out Of Directories
up() { [ $(( $1 + 0 )) -gt 0 ] && cd $(eval "printf '../'%.0s {1..$1}"); }
# Get all mac address
ip link show
# Find out how old a web page is
wget -S --spider http://osswin.sourceforge.net/ 2>&1 | grep Mod
# generate 30 x 30 matrix
hexdump -v -e '"%u"' </dev/urandom|fold -60|head -n 30|sed 's/\(.\{2\}\)/\1 /g'
# Don't save commands in bash history (only for current session)
unset HISTFILE
# Find the process you are looking for minus the grepped one
83 / 658
On PC2:
84 / 658
85 / 658
86 / 658
87 / 658
88 / 658
89 / 658
90 / 658
| tr 0-8 \ | tr 9 \\n |
| fmt -u
91 / 658
92 / 658
# Get the total length of all videos in the current dir in H:m:s
mplayer -vo dummy -ao dummy -identify * 2>&1 | grep ID_LENGTH | sed 's/.*=\([0-9]*\)/\1/' |
xargs echo | sed 's/ /+/g' | bc | awk 'S=$1; {printf "%dh:%dm:%ds\n",S/(60*60),S
%(60*60)/60,S%60}'
# Replace duplicate files by hardlinks
fdupes -r -1 path | while read line; do j="0"; for file in ${line[*]}; do if [ "$j" ==
"0" ]; then j="1"; else ln -f ${line// .*/} $file; fi; done; done
# Graphically show percent of mount space used
for m in `df -P | awk -F ' ' '{print $NF}' | sed -e "1d"`;do n=`df -P | grep "$m$" | awk -F
' ' '{print $5}' | cut -d% -f1`;i=0;if [[ $n =~ ^-?[0-9]+$ ]];then printf '%-25s' $m;while [
$i -lt $n ];do echo -n '=';let "i=$i+1";done;echo " $n";fi;done
# Dump HTTP header using wget
wget --server-response --spider http://www.example.com/
# String to binary
perl -nle 'printf "%0*v8b\n"," ",$_;'
# Clone IDE Hard Disk
sudo dd if=/dev/hda1 of=/dev/hdb2
# scan folder to check syntax error in php files
find . -name "*.php" -exec php -l {} \;
# use vi key bindings at the command line
set -o vi
# lotto generator
shuf -i 1-49 | head -n6 | sort -n| xargs
# Rotate a single page PDF by 180 degrees
pdftk in.pdf cat 1S output out.pdf
# Shows cpu load in percent
sed -e 's/ .*//' -e 's/\.//' -e 's/^0*//' /proc/loadavg
# Show bash's function definitions you defined in .bash_profile or .bashrc
declare -f [ function_name ]
# Type a random string into a X11 window
sleep 3 && xdotool type --delay 0ms texthere
# PDF simplex to duplex merge
pdftk A=odd.pdf B=even.pdf shuffle A1-end Bend-1S output duplex.pdf
# cat large file to clipboard with speed-o-meter
pv large.xml | xclip
# urldecoding with one pure BASH builtin
VAR="%23%21%2fbin%2fbash" ; printf -v VAR "%b" "${VAR//\%/\x}" ; echo $VAR
# network usage per process
sudo nethogs eth0
93 / 658
94 / 658
95 / 658
96 / 658
97 / 658
# Pack up some files into a tarball on a remote server without writing to the local
filesystem
tar -czf - * | ssh example.com "cat > files.tar.gz"
# backup a directory in a timestamped tar.gz
tar -czvvf backup$(date "+%Y%m%d_%H%M%S").tar.gz /path/to/dir
98 / 658
99 / 658
" $0
100 / 658
101 / 658
102 / 658
103 / 658
# Simplification of "sed 'your sed stuff here' file > file2 && mv file2 file"
sed -i 'your sed stuff here' file
# List your MACs address
ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
# Create a thumbnail from a video file
thumbnail() { ffmpeg -itsoffset -20 -i $i -vcodec mjpeg -vframes 1 -an -f rawvideo -s
640x272 ${i%.*}.jpg }
# New command with the last argument of the previous command.
command !$
# need ascii art pictures for you readme text ?
boxes -d dog or
cowsay -f tux $M
# Update your OpenDNS network ip
wget -q --user=<username> --password=<password> 'https://updates.opendns.com/nic/update?
hostname=your_opendns_hostname&myip=your_ip' -O # Remove all files except list
rm -rf !(@(file1|file2|...))
# To play a file at 1.5 times normal speed
mplayer -af scaletempo=scale=1.5 foo.mp3
104 / 658
# Show sorted list of files with sizes more than 1MB in the current dir
du -hs * | grep '^[0-9,]*[MG]' | sort -rn
# Report all quota usage
quota -q $(cat /etc/passwd|cut -d ':' -f 1)
# Merge several pdf files into a single file
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf a.pdf b.pdf
c.pdf
# Check the status of a network interface
mii-tool [if]
# Skip over .svn directories when using the "find" command.
find . -not \( -name .svn -prune \)
105 / 658
106 / 658
# Find the process you are looking for minus the grepped one
ps -C command
# Mount proc
mount -t proc{,,}
# Display calendar with specific national holidays and week numbers
gcal -K -q GB_EN 2009 # display holidays in UK/England for 2009 (with week numbers)
# Display the number of connections to a MySQL Database
mysql -u root -p -BNe "select host,count(host) from processlist group by host;"
information_schema
# Group OR'd commands where you expect only one to work
( zcat $FILE || gzcat $FILE || bzcat2 $FILE ) | less
# Display text as though it is being typed out in real time
echo "text to be displayed" | pv -qL 10
# Install a basic FreeBSD system
dd if=mfsbsd.iso | ssh distant.server dd of=/dev/sda
# convert filenames in current directory to lowercase
for i in *; do mv "$i" "$(echo $i|tr A-Z a-z)"; done
# full memcache client in under 255 chars (uses dd, sed and nc)
mem(){ { case $1 in st*|[vgid]*) printf "%s " "$@";; *) dd if=$3 2>&1|sed '$!d;/^0/d;s/
.*//;s/^/'"$1"' '"$2"' 1 0 /; r '"$3"'' 2>/dev/null;;esac;printf "\r\nquit\r\n";}|nc -n
127.0.0.1 11211; }
# Watch the disk fill up
watch -n 1 df
# execute your commands and avoid history records
cat | bash
# Function to output an ASCII character given its decimal equivalent
chr () { printf \\$(($1/64*100+$1%64/8*10+$1%8)); }
# Convert a SVG file to grayscale
inkscape -f file.svg --verb=org.inkscape.color.grayscale --verb=FileSave --verb=FileClose
# for loop with leading zero in bash 3
seq -s " " -w 3 20
# vim read stdin
ls | vim +'set bt=nowrite' # Transcode .flac to .wav with gstreamer
for i in *.flac; do gst-launch filesrc location="$i" ! flacdec ! wavenc ! filesink
location="${i%.flac}.wav"; done
107 / 658
108 / 658
109 / 658
110 / 658
111 / 658
112 / 658
113 / 658
114 / 658
115 / 658
.svn)
116 / 658
117 / 658
# Sort on multiple dis-contiguous keys/fields (can even specify key number/field from the
end)
file /bin/* | msort -j -l -n-1 -n2 2> /dev/null
# Remove today's installed packages
grep "install " /var/log/dpkg.log | awk '{print $4}' | xargs apt-get -y remove --purge
# Print number of mb of free ram
grep '^MemFree:' /proc/meminfo | awk '{ mem=($2)/(1024) ; printf "%0.0f MB\n", mem }'
# Hear the mice moving
while true; do beep -l66 -f`head -c2 /dev/input/mice|hexdump -d|awk 'NR==1{print
$2%10000}'`; done
# Enable cd by variable names
shopt -s cdable_vars
# Find the processes that are on the runqueue. Processes with a status of
ps -eo stat,pid,user,command | egrep "^STAT|^D|^R"
# Edit file(s) that has been just listed
vi `!!`
# camelcase to underscore
echo thisIsATest | sed -E 's/([A-Z])/_\L\1/g'
# grep (or anything else) many files with multiprocessor power
find . -type f -print0 | xargs -0 -P 4 -n 40 grep -i foobar
# Perform a reverse DNS lookup
dig -x 74.125.45.100
118 / 658
119 / 658
120 / 658
# eavesdrop
ssh USER@REMOTESYSTEM arecord - | aplay # a for loop with filling 0 format, with seq
for i in `seq -f %03g 5 50 111`; do echo $i ; done
# Extract audio from start to end position from a video
mplayer -vc null -vo null -ao pcm <input video file> -ss <start> -endpos <end>
# Find a CommandlineFu users average command rating
wget -qO- www.commandlinefu.com/commands/by/PhillipNordwall | awk -F\> '/num-votes/{S+=$2;
I++}END{print S/I}'
# Identify name and resolution of all jpgs in current directory
identify -verbose *.jpg|grep "\(Image:\|Resolution\)"
# Format ps command output
ps ax -o "%p %U %u %x %c %n"
# Start another instance of X via SSH
startx -- /usr/X11R6/bin/Xnest :5 -geometry 800x600
# Batch rename extension of all files in a folder, in the example from .txt to .md
mmv "*.txt" "#1.md"
# Delete empty directories with zsh
rm -d **/*(/^F)
# Monitor cpu freq and temperature
watch --interval 1 "cat /proc/acpi/thermal_zone/THRM/*; cat /proc/cpuinfo | grep MHz; cat
/proc/acpi/processor/*/throttling"
# 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'
# Place the argument of the most recent command on the shell
<Esc> _
# Tail a log-file over the network
(echo -e "HTTP/1.1 200 Ok\n\r"; tail -f /var/log/syslog) | nc -l 1234
121 / 658
122 / 658
123 / 658
124 / 658
125 / 658
126 / 658
127 / 658
128 / 658
| grep mp3$
| xargs`
# Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id
cat ~/.ssh/id_rsa.pub | ssh <REMOTE> "(cat > tmp.pubkey ; mkdir -p .ssh ; touch
.ssh/authorized_keys ; sed -i.bak -e '/$(awk '{print $NF}' ~/.ssh/id_rsa.pub)/d'
.ssh/authorized_keys; cat tmp.pubkey >> .ssh/authorized_keys; rm tmp.pubkey)"
# Quick directory bookmarks
to() { eval dir=\$$1; cd "$dir"; }
# List all process running a specfic port
sudo lsof -i :<port>
# Mount a partition from within a complete disk dump
lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo
# Use AbiWord to generate a clean HTML document from a Microsoft Word document.
abiword --to=html file.doc --exp-props=
# netcat as a portscanner
nc -v -n -z -w 1 127.0.0.1 22-1000
# Let's make screen and ssh-agent friends
eval `ssh-agent`; screen
# Customize time format of 'ls -l'
ls -l --time-style=+"%Y-%m-%d %H:%M:%S"
# Create subdirectory and move files into it
(ls; mkdir subdir; echo subdir) | xargs mv
129 / 658
130 / 658
131 / 658
132 / 658
133 / 658
134 / 658
135 / 658
136 / 658
# For finding out if something is listening on a port and if so what the daemon is.
fuser -n tcp {0..65535}
# Piping Microphone Audio Over Netcat
port=3333;card=0;subdevice=0;arecord -D hw:${card},${subdevice} -f S16_LE -c2|nc -l $port
# Multiple variable assignments from command output in BASH
eval $(date +"day=%d; month=%m; year=%y")
# Rsync a directory excluding pesky .svn dirs
rsync -rv --exclude .svn src/dir/ dest/dir/
# Substitute spaces in filename with underscore
ls -1 | rename 's/\ /_/'
# phpinfo from the command line
php -r "phpinfo();"
# Create a 5 MB blank file
dd if=/dev/zero of=testfile bs=1024 count=5000
# commit message generator - whatthecommit.com
curl http://whatthecommit.com/index.txt
# removing syncronization problems between audio and video
ffmpeg -i source_audio.mp3 -itsoffset 00:00:10.2 -i source_video.m2v target_video.flv
# Show simple disk IO table using snmp
watch -n1 snmptable -v2c -c public localhost diskIOTable
# Easily decode unix-time (funtion)
utime { date -d @$1; }
# vim's pastetoggle: when you press f9 'paste' is on , press f9 again and 'paste' is off,
and so forth (works in insert-mode and command-mode)
:set pt=<f9>
# extracting audio and video from a movie
ffmpeg -i source_movie.flv -vcodec mpeg2video target_video.m2v -acodec copy target_audio.mp3
# Print a row of characters across the terminal
printf -v row "%${COLUMNS}s"; echo ${row// /#}
# Get IP from hostname
dig +short google.com
# Find out if a module is installed in perl
perldoc -l Module::Name 2>/dev/null
# Open a file explorer on a split screen inside your vim session
:Sex
# Search for packages, ranked by popularity
apt-popcon() { (echo \#rank; apt-cache search "$@" |awk '$1 !~ /^lib/ {print " "$1" "}') |
grep -Ff- <(wget -qqO- http://popcon.debian.org/by_inst.gz |gunzip); }
# Shows you how many hours of avi video you have.
137 / 658
# List the size (in human readable form) of all sub folders from the current location
du -sch ./*
# Binary clock
echo "10 i 2 o $(date +"%H%M"|cut -b 1,2,3,4 --output-delimiter=' ') f"|dc|tac|xargs printf
"%04d\n"|tr "01" ".*"
# Display HTTP-header using curl
curl -I g.cn
# Copy sparse files
cp --sparse=always <SRC> <DST>
# Mac OS-X-> copy and paste things to and from the clipboard from the shell
command | pbcopy && pbpaste
# Install an mpkg from the command line on OSX
sudo installer -pkg /Volumes/someapp/someapp.mpkg -target /
# Get information on your graphics card on linux (such as graphics memory size)
for I in `/sbin/lspci |awk '/VGA/{print $1}'`;do /sbin/lspci -v -s $I;done
# distribution specific information
lsb_release -a
# Lists all files and directories with modified time newer than a given date
touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.ts
# Resize A Mounted EXT3 File System
v=/dev/vg0/lv0; lvextend -L+200G $v && resize2fs $v
# Print current running shell, PID
ps -p $$
# Default value or argument
num_lines=${1:-42}
# Count number of Line for all the files in a directory recursively
for file in `find . -type f`; do cat $file; done | wc -l
# How to know the total number of packages available
apt-cache stats
# Turn shell tracing and verbosity (set -xv) on/off with 1 command!
xv() { case $- in *[xv]*) set +xv;; *) set -xv ;; esac }
# Mplayer save stream to file
mplayer -nolirc <Streaming_URL> -dumpstream -dumpfile output.mp3
# cd into another dir to run a one-liner, but implicitly drop back to your $OLD_PWD after
( cd $DIR; command; )
# Catch a proccess from a user and strace it.
x=1; while [ $x = 1 ]; do process=`pgrep -u username`; if [ $process ]; then x=0; fi;
strace -vvtf -s 256 -p $process
138 / 658
done;
139 / 658
140 / 658
/g'
141 / 658
142 / 658
143 / 658
144 / 658
145 / 658
146 / 658
# 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;
# Bingo-like raffle
for i in $(seq 1 100 | sort -R); do echo $i; sleep 5; done
# Do some learning...
147 / 658
148 / 658
# Run TOP in Color, split 4 ways for x seconds - the ultimate ps command. Great for init
scripts
G=$(stty -g);stty rows $((${LINES:-50}/2));top -n1; stty $G;unset G
# untar undo
tar tfz filename.tgz |xargs rm -Rf
# Random number generation within a range N, here N=10
echo $(( $RANDOM % 10 + 1 ))
# a find and replace within text-based files, for batch text replacement, not using perl
sed -i -e 's/SEARCH_STRING/REPLACE_STRING/g' `find . -iname 'FILENAME'`
# Disable WoL on eth0
sudo ethtool -s eth0 wol d
# Change Random Wallpaper on Gnome 3
gsettings set org.gnome.desktop.background picture-uri file://"$(find ~/Wallpapers -type f |
shuf -n1)"
# search google on os x
function google () { st="$@"; open "http://www.google.com/search?q=${st}"; }
# show all programs connected or listening on a network port
alias nsl 'netstat -f inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
# Colorize make, gcc, and diff output
colormake, colorgcc, colordiff
# Undo commit in Mercurial
hg diff -c $REV --reverse | hg patch --no-commit # 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
# Show the command line of a process that use a specific port (ubuntu)
cat /proc/$(lsof -ti:8888)/cmdline | tr "\0" " "
# Show account security settings
chage -l <user>
149 / 658
150 / 658
P=`ls -l
return
fi
ffmpeg
151 / 658
152 / 658
153 / 658
154 / 658
155 / 658
156 / 658
157 / 658
158 / 658
# Is it a terminal?
isatty(){ test -t $1; }
# Extract audio from Mythtv recording to Rockbox iPod using ffmpeg
ffmpeg -ss 0:58:15 -i DavidLettermanBlackCrowes.mpg -acodec copy
DavidLettermanBlackCrowes.ac3
# print crontab entries for all the users that actually have a crontab
for USER in `cut -d ":" -f1 </etc/passwd`; do crontab -u ${USER} -l 1>/dev/null 2>&1; if [ !
${?} -ne 0 ]; then echo -en "--- crontab for ${USER} ---\n$(crontab -u ${USER} -l)\n"; fi;
done
# Mac OS X: remove extra languages to save over 3 GB of space.
sudo find / -iname "*.lproj" -and \! -iname "en*" -print0 | tee /dev/stderr | sudo xargs -0
rm -rfv
# Get the size of all the directories in current directory
du -hd 1
# An alarm clock using xmms2 and at
at 6:00 <<< "xmms2 play"
# Display top Keywords from history
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n |
tail | sort -nr
# List all Windows services on the command line
159 / 658
160 / 658
161 / 658
162 / 658
163 / 658
164 / 658
165 / 658
166 / 658
167 / 658
168 / 658
# list and sort files by size in reverse order (file size in human readable output)
ls -S -lhr
# force a rescan on a host of scsi devices (useful for adding partitions to vmware on the
fly)
echo "- - -" > /sys/class/scsi_host/host0/scan
# mix video and audio
ffmpeg -i video.mp4 -i audio.mp3 -vcodec copy -acodec copy -map 0.0:0 -map 1.0:1 mix.mp4
# calulate established tcp connection of local machine
netstat -an | awk '$1 ~ /[Tt][Cc][Pp]/ && $NF ~ /ESTABLISHED/{i++}END{print "Connected:\t",
i}'
# replace strings in file names
rename 's/foo/bar/g' foobar
# disk space email alert
[ $(df / | perl -nle '/([0-9]+)%/ && print $1') -gt 90 ] && df -hP | mutt -s "Disk Space
Alert -- $(hostname)" admin@example.com
# Adjust gamma so monitor doesn't mess up your body's clock
xrandr | sed -n 's/ connected.*//p' | xargs -n1 -tri xrandr --output {} --brightness 0.7
--gamma 2:3:4
# Console clock
while [[ 1 ]] ; do clear; banner `date +%H:%M:%S` ; sleep 1; done
# find and grep Word docs
find . -iname '*filename*.doc' | { while read line; do antiword "$line"; done; } | grep -C4
search_term;
# Convert files from DOS line endings to UNIX line endings
perl -pi -e 's/\r\n?/\n/g'
# Get sunrise and sunset times
l=12765843;curl -s http://weather.yahooapis.com/forecastrss?w=$l|grep astronomy| awk -F\"
'{print $2 "\n" $4;}'
# Show all symlinks
169 / 658
170 / 658
{};
171 / 658
172 / 658
173 / 658
174 / 658
175 / 658
176 / 658
177 / 658
178 / 658
179 / 658
-size 100x100
-pointsize 24
180 / 658
181 / 658
# Download a new release of a program that you already have very quickly
zsync -i existing-file-on-disk.iso http://example.com/new-release.iso.zsync
# Does a traceroute. Lookup and display the network or AS names and AS numbers.
lft -NAS google.com
# Kick user
killall -u username
# Hypnosis
for count in $(seq 2 1001); do say "$count sheeps";sleep 2;done
# Get the number of days in a given month and year
: $(cal [$month $year]) ; echo $_
# Start a SOCKS proxy to avoid a restrictive firewall
autossh -N -D localhost:1080 myhome.example.net -p 443
# Do Google search from that command line opening into a new Firefox tab.
google() { gg="https://www.google.com/search?q="; ff="firefox"; if [[ $1 ]]; then "$ff"
-new-tab "$gg"$(echo ${1//[^a-zA-Z0-9]/+}); else echo 'Usage: google "[seach term]"'; fi }
# Ping a URL sending output to file and STDOUT
ping google.com | tee ping-output.txt
# Search inside a folder of jar/zip files
find . -name "*.jar" | xargs -tn1 jar tvf | grep --color "SearchTerm"
# Simple way to envoke a secure vnc session through ssh enabled router.
vncviewer -via root@your.dyndns.com 192.168.1.1
# Find all files with root SUID or SGID executables
sudo find / -type f \( -perm /4000 -a -user root \) -ls -o \( -perm /2000 -a -group root \)
-ls
# List your MACs address
sort -u < /sys/class/net/*/address
# bash: display disks by id, UUID and HW path
tree /dev/disk
# Create a html of information about you harddisk
lshw -C disk -html > /tmp/diskinfo.html
# Alternative size (human readable) of files and directories (biggest last)
du -ms * | sort -nk1
# 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
# Replace Caps-lock with Control-key
xmodmap -e 'remove Lock = Caps_Lock' && xmodmap -e 'add control = Caps_Lock'
# Extract IPv4 addressess from file
grep -Eo \([0-9]\{1,3\}[\.]\)\{3\}[0-9] file | sort | uniq
182 / 658
| grep ip | sed
# Search recursively to find a word or phrase in certain file types, such as C code
ack "search pharse" *.[ch]
# remove lines which are longer than 255
sed -n '/^.\{255\}/!p'
# Print today's date in ISO format without calling an external command (bash 4)
today() { printf '%(%Y-%m-%d)T\n' -1; } ## bash-4
# Alias to edit and source your .bashrc file
alias vb='vim ~/.bashrc; source ~/.bashrc'
# List all symbolic links in current directory
\ls -1 | xargs -l readlink
# make directory with current date
mkdir $(date +%F)
# Multi line grep using sed and specifying open/close tags
cat file.txt | sed -e /<opening tag>/d -e /<closing tag>/G | sed -e '/./{H;$!d;}' -e
'x;/<string to search>/!d;'
# send tweets to twitter (and get user details)
curl --basic --user "user:pass" --data-ascii "status=tweeting%20from%20%the%20linux
%20command%20line" http://twitter.com/statuses/update.json
# Show log message including which files changed for a given commit in git.
git --no-pager whatchanged -1 --pretty=medium <commit_hash>
# Slightly better compressed archives
find . \! -type d | rev | sort | rev | tar c --files-from=- --format=ustar | bzip2 --best >
a.tar.bz2
# Find the real procesor speed when you use CPU scaling [cpuspeed]
awk -F": " '/cpu MHz\ */ { print "Processor (or core) running speed is: " $2 }'
/proc/cpuinfo ; dmidecode | awk -F": " '/Current Speed/ { print "Processor real speed is: "
$2 }'
# copy from host1 to host2, through your host
ssh user@<source_host> -- tar cz <path> | ssh user@<destination_host> -- tar vxzC <path>
# Count accesses per domain
183 / 658
184 / 658
185 / 658
186 / 658
187 / 658
188 / 658
# Root shell
sudo -i
# check the filesystem and use
e2fsck -C -v /dev/device
a progress bar
# faster version of ls *
echo *
# vi a new file with execution mode
vix(){ vim +'w | set ar | silent exe "!chmod +x %" | redraw!' $@; }
# Move all files between to date
sudo find . -maxdepth 1 -cnewer olderFilesNameToMove -and ! -cnewer newerFileNameToMove
-exec mv -v {} /newDirectory/ \;
# Mutt - Change mail sender.
export EMAIL=caiogore@domain.com && mutt -s "chave webmail" destination@domain.com <
/dev/null
189 / 658
# find out which directories in /home have the most files currently open
lsof |awk ' {if ( $0 ~ /home/) print substr($0, index($0,"/home") ) }'|cut -d / -f 1-4|sort|
uniq -c|sort -bgr
# My Git Tree Command!
git log --graph --oneline --all
# Convert clipboard HTML content to markdown (for github, trello, etc)
xclip -selection clipboard -o -t text/html | pandoc -f html -t markdown_github # Ping sweep without NMAP
for i in `seq 1 255`; do ping -c 1 10.10.10.$i | tr \\n ' ' | awk '/1 received/ {print $2}';
done
# Make alias pemanent fast
PERMA () { echo "$@" >> ~/.bashrc; }
# dd with progress bar and statistics to gzipped image
export BLOCKSIZE='sudo blockdev --getsize64 /dev/sdc' && sudo dd if=/dev/sdc bs=1MB | pv -s
$BLOCKSIZE | gzip -9 > USB_SD_BACKUP.img.gz
# Output files without comments or empty lines
grep -v "^\($\|#\)" <filenames>
# Show what PID is listening on port 80 on Linux
netstat -alnp | grep ::80
# commandline dictionary
wn wonder -over
# lazy SQL QUERYING
psql
190 / 658
191 / 658
the
last
argument
of
192 / 658
# Better recursive grep with pretty colors... requires ruby and gems (run: "gem install
rak")
rak "what you're searching for" dir/path
# diff files while disregarding indentation and trailing white space
diff <(perl -wpl -e '$_ =~ s/^\s+|\s+$//g ;' file1) <(perl -wpl -e '$_ =~ s/^\s+|\s+$//g ;'
file2)
# Yet Another Rename (bash function)
rename(){ txtToReplace=${1} ; replacementTxt=${2} ; shift 2 ; files=${@} ; for file in
$files ; do mv ${file} ${file/${txtToReplace}/${replacementTxt}} ; done ; }
# Sort IP addresses
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 /file/of/ip/addresses
# A DESTRUCTIVE command to render a drive unbootable
dd if=/dev/zero of=/dev/fd0 bs=512 count=1
# run command on a group of nodes in parallel
seq 1 5 | parallel ssh {}.cluster.net uptime
# parse html/stdin with lynx
alias html2ascii='lynx -force_html -stdin -dump -nolist'
# Shows size of dirs and files, hidden or not, sorted.
du --max-depth=1 -h * |sort -n -k 1 |egrep 'M|G'
# find text in a file
find /directory/to/search/ -type f -print0 | xargs -0 grep "findtext"
# Convert AVI to iPhone MP4
ffmpeg -i [source].avi -f mp4 -vcodec mpeg4 -b 250000 -s 480?320 -acodec aac -ar 24000 -ab
64 -ac 2 [destination].mp4
# convert pdf into multiple png files
gs -sDEVICE=pngalpha -sOutputFile=<filename>%d.png -r<resolution> <pdffile>
# Stat each file in a directory
find . -maxdepth 1 -type f | xargs stat
# Find files and list them sorted by modification time
find -type f -print0 | xargs -r0 stat -c %y\ %n | sort
# Remove invalid key from the known_hosts file for the IP address of a host
ssh-keygen -R $(dig +short host.domain.tld)
# List of all vim features
vim --version | grep -P '^(\+|\-)' | sed 's/\s/\n/g' | grep -Pv '^ ?$'
193 / 658
# Backup a filesystem to a remote machine and use cstream to throttle bandwidth of the
backup
nice -n19 dump -0af - /<filesystem> -z9|gpg -e -r <gpg key id>|cstream -v 1 -t 60k|ssh
<user@host> "cat > backup.img"
# find out how much space are occuipied by files smaller than 1024K (sic) - improved
find dir -size -1024k -type f -print0 | du --files0-from - -bc
# Find Duplicate Files, excluding .svn-directories (based on size first, then MD5 hash)
find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d
| xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0
md5sum | sort | uniq -w32 --all-repeated=separate
# Get info about a GitHub project
curl http://github.com/api/v1/yaml/search/vim
# Reconstruct standard permissions for directories and files in current directory
chmod -R u=rwX,g=rX,o=rX .
# Server load and process monitoring
watch -n1 "uptime && ps auxw|grep http|grep -v grep | grep -v watch|wc -l && netstat -ntup|
grep :80 |grep ESTABLISHED|wc -l && netstat -ntup|grep :80|grep WAIT|wc -l && free -mo && ps
-ylC httpd --sort:rss|tail -3|awk '{print \$8}'"
# Count number of files in a directory
ls|wc -l
194 / 658
195 / 658
196 / 658
197 / 658
198 / 658
199 / 658
nc -l
# u can hear all .ogg files with vlc that thier link are in url
lynx -dump -listonly 'url' | grep -oe 'http://.*\.ogg' > 11 ; vlc 11 ; mv 11 /dev/null
# top svn committers (without awk)
svn log -q | grep '^r[0-9]' | cut -f2 -d "|" | sort | uniq -c | sort -nr
# Averaging columns of numbers
awk '{sum1+=$1; sum2+=$2} END {print sum1/NR, sum2/NR}' file.dat
# Lists installed kernels
dpkg --get-selections | grep linux-image
# Validating a file with checksum
md5 myfile | awk '{print $4}' | diff <(echo "c84fa6b830e38ee8a551df61172d53d7") # Say something out loud
curl -A "Mozilla" "http://translate.google.com/translate_tts?tl=en&q=$(echo "$@" | sed 's/ /
+/g')" | play -t mp3 # Run bash on top of a vi session (saved or not saved), run multiple commands, instead of
one at a time with :!(bashcommand), type exit and [enter] to get back to where you left off
in vi.
:!bash
# Set file access control lists
setfacl -m u:john:r-- myfile
# Generate SHA1 hash for each file in a list
find . -type f -exec sha1sum {} >> SHA1SUMS \;
# 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
200 / 658
201 / 658
202 / 658
203 / 658
204 / 658
205 / 658
206 / 658
207 / 658
| tail -1
1%
208 / 658
209 / 658
210 / 658
# 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
# Calculate N!
echo $(( $(echo 1 "* "{2..10}) ))
# Find broken symlinks and delete them
find . -type l -exec test ! -e {} \; -delete
# Unrar multiple directories into current working directory
for x in */*.rar; do unrar x $x; done
# Both view and pipe the file without saving to disk
cat /path/to/some/file.txt | tee /dev/pts/0 | wc -l
211 / 658
212 / 658
213 / 658
214 / 658
215 / 658
216 / 658
# Recover resolution when a fullscreen program crashes and you're stuck with a tiny X
resolution
xrandr -s 0
# List all the files that have been deleted while they were still open.
lsof | egrep "^COMMAND|deleted"
# Run skype using your GTK theme
skype --disable-cleanlooks -style GTK
# Determine space taken by files of certain type
find . -name <pattern> -ls | awk 'BEGIN {i=0}; {i=i+$7}; END {print i}'
# Double your disk read performance in a single command
blockdev --setra 1024 /dev/sdb
# force unsupported i386 commands to work on amd64
setarch i386 [command [args]]
# Find files recursively that were updated in the last hour ignoring SVN files and folders.
find . -mmin -60 -not -path "*svn*" -print|more
# Comma insertions
perl -pe '$_=reverse;s/\d{3}(?=\d)(?!.*?\.)/$&,/g;$_=reverse'
# Create subversion undo point
function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d '
'` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else
echo Missing .undo directory; fi }
217 / 658
echo
# Convert a string to
python -c "print 'this is a test'.title()"
# get a process list by listen port
218 / 658
219 / 658
# Download song from youtube for import into itunes (m4a format)
~/sbin/youtube-dl -t --extract-audio --audio-format=m4a http://www.youtube.com/watch?
v=DxL8X9mT90k
# finds the c files with lines containing 'mcs', in the folders under the current folder
find */*.c | xargs grep 'mcs'
# Print the last modified file
ls -t1 | head -n1
# 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
# Monitor RX/TX packets and any subsquent errors
watch 'netstat -aniv'
# convert wav files to flac
flac --best *.wav
# HTTP GET request on wireshark remotly
ssh USER@HOST "sudo tshark -i eth0 -f 'tcp port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] =
0x47455420' -w -" | wireshark -k -i # Watch active calls on an Asterisk PBX
watch "asterisk -vvvvvrx 'core show channels' | egrep \"(call|channel)\""
# convert wav files to ogg
oggenc *.wav
# Optimal way of deleting huge numbers of files
find /path/to/dir/ -type f -exec rm {} +
# Restart X11 with HUP signal
kill HUP `pidof '/usr/bin/X'`
# Unmount all CIFS drives
umount -a -t cifs
# Shell function to create a menu of items which may be inserted into the X paste buffer.
smenu() ( IFS=',' ; select x in $*; do echo "$x" | xsel -i; done )
220 / 658
221 / 658
222 / 658
223 / 658
224 / 658
225 / 658
226 / 658
227 / 658
228 / 658
229 / 658
# Make shell (script) low priority. Use for non interactive tasks
renice 19 -p $$
# 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 "
# Sort installed rpms in alphabetic order with their size.
rpm -qa --qf "%-30{NAME} %-10{SIZE}\n" | sort -n | less
# Print all environment variables, including hidden ones
for _a in {A..Z} {a..z};do _z=\${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!
_i}";done;done|cat -Tsv
# Show LAN IP with ip(8)
ip route show dev eth0 | awk '{print $7}'
# 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
# Show numerical values for each of the 256 colors in ZSH
for code in {000..255}; do print -P -- "$code: %F{$code}Test%f"; done
# Revert an SVN file to previous revision
svn up -rREV file
# make a list of movies(.m3u).
find $HOME -type f -print | perl -wnlaF'/' -e 'BEGIN{ print "#EXTM3U"; } /.+\.wmv$|.
+\.mpg$|.+\.vob$/i and print "#EXTINF:$F[-1]\nfile://$&";' > movies.m3u
# Check if a command is available in your system
type {command} >/dev/null
# fork performance test
while (true); do date --utc; done | uniq -c
# Start a terminal with three open tabs
gnome-terminal --tab --tab --tab
# Show permissions of current directory and all directories upwards to /
dir=$(pwd); while [ ! -z "$dir" ]; do ls -ld "$dir"; dir=${dir%/*}; done; ls -ld /
# Copy a directory recursively without data/files
find . -type d -exec mkdir /copy_location/{} \;
# Get all links from commandlinefu front page
mech-dump --links --absolute http://www.commandlinefu.com
230 / 658
# Write a listing of all directories and files on the computer to a compressed file.
sudo ls -RFal / | gzip > all_files_list.txt.gz
# Apache CLF access log format to CSV converter
#(see sample) $ cat x | perl -pe 'BEGIN{ print "TIME;...\n"; } s!(\S+) - (\S+) - \[(\d\d)/
(\S\S\S)/(\S+):(\d\d):(\d\d:\d\d) \S+\] "(\S+) (.*/)(\S+)(?:\.([^?]*)(\?\S*)?) HTTP/\S+"
(\d+) (\S+)!$3-$4-$5 $6:$7;$6;$2;$1;$8;$13;1;$14;$11;$10;$9;$12;!' > x.csv
# Change Gnome wallpaper
gconftool-2 -t string -s /desktop/gnome/background/picture_filename <path_to_image>
# Solaris - check ports/sockets which process has opened
/usr/proc/bin/pfiles $PID | egrep "sockname|port"
# Ultimate current directory usage command
find . -maxdepth 1 -type d|xargs du -a --max-depth=0|sort -rn|cut -d/ -f2|sed '1d'|while
read i;do echo "$(du -h --max-depth=0 "$i")/";done;find . -maxdepth 1 -type f|xargs du -a|
sort -rn|cut -d/ -f2|sed '$d'|while read i;do du -h "$i";done
# change dinosaur poop into gold
sqlite3 -list /home/$USER/.mozilla/firefox/*.default/places.sqlite 'select url from
moz_places ;' | grep http
# concatenate compressed and uncompressed logs
zgrep -h "" `ls -tr access.log*`
# Purge configuration files of removed packages on
231 / 658
232 / 658
233 / 658
234 / 658
235 / 658
236 / 658
-d $f ] ;
237 / 658
238 / 658
239 / 658
> ips.txt
240 / 658
241 / 658
242 / 658
243 / 658
3; $*); }
244 / 658
mem
# Alternative way to generate an XKCD #936 style 4 word password usig sed
shuf -n4 /usr/share/dict/words | sed -e ':a;N;$!ba;s/\n/ /g;s/'\''//g;s/\b\
(.\)/\u\1/g;s/ //g'
# Generate random number with shuf
echo $((RANDOM % 10 + 1))
245 / 658
246 / 658
247 / 658
# LVM2 Reduce
# umount /media/filesystem; e2fsck -f /dev/device ; resize2fs -p /dev/device 200G #actual
newsize#;lvreduce --size 200G /dev/device; mount /media/filesystem; df -h /media/filesystem
# Determine command type (alias, keyword, function, builtin, or file)
type -t $1
# Umount only the NFS related to 'string'
for i in `df -P |grep string|cut -f2 -d%|cut -c2-100`; do umount -l -f $i;done
# copy audio file from playlist to a floder
more xx.m3u |grep -v "^#" |xargs -i cp {} target
# Display the size of all your home's directories
du -sh ~/*
248 / 658
249 / 658
250 / 658
251 / 658
252 / 658
253 / 658
254 / 658
255 / 658
256 / 658
# Don't like the cut command? Tired of typing awk '{print $xxx}', try this
awp () { awk '{print $'$1'}'; }
# finding cr-lf files aka dos files with ^M characters
find $(pwd) -type f -exec grep -l "$(echo "\r")" {} \;
# Stripping ^M at end of each line for files
perl -pi -e 's:^V^M::g' <filenames>
# Change permissions of every directory in current directory
find . -type d -exec chmod 755 {} \;
# remove repeated pairs of characters e.g. "xtxtxtxt" will become "xt"
sed -ru 's/(..)\1{2,}/\1/g'
# Run command in an ftp session
ftp>!w
# find all open files by named process
lsof -c $processname | egrep 'w.+REG' | awk '{print $9}' | sort | uniq
# Google URL shortener
python -c 'import googl; print googl.Googl("<your_google_api_key>").shorten("'$someurl'")
[u"id"]'
# Use color grep by default
alias grep 'gnu grep -i --color=auto'
# Download and install the newest dropbox beta
257 / 658
258 / 658
parsing to a variable
259 / 658
260 / 658
261 / 658
262 / 658
| sed -e '2,$s/
263 / 658
264 / 658
265 / 658
*|_|g'`.wp.dg.cx; }
266 / 658
[[ -z $candidate || $i
# sync svn working copy and remote repository (auto adding new files)
svn status | grep '^?' | awk '{ print $2; }' | xargs svn add
# Find and delete oldest file of specific types in directory tree
find / \( -name "*.log" -o -name "*.mylogs" \) -exec ls -lrt {} \; | sort -k6,8 | head -n1 |
cut -d" " -f8- | tr -d '\n' | xargs -0 rm
# Verbosely delete files matching specific name pattern, older than 15 days.
find /backup/directory -name "FILENAME_*" -mtime +15 -exec rm -vf {};
# Display network pc "name" and "workgroup"
nmblookup -A <ip>
# Screen enable/disable loggin in all windows
bindkey ^l at "#" log on
bindkey ^o at "#" log off
# combining streams
ll /root/ 2>&1 | grep -E '(psw|password)'
# tell if a port is in use
netstat -a --numeric-ports | grep 8321
# Check if it's OK to spawn tmux. Bool's Rools.
[[ $DISPLAY != "" ]] && [[ ${TERM%screen*} != "" ]] && tmux attach
# Calculate pi with specific scale
echo 'scale=10; 4*a(1)' | bc -l
267 / 658
268 / 658
EOF'
269 / 658
270 / 658
271 / 658
272 / 658
273 / 658
274 / 658
275 / 658
276 / 658
277 / 658
find this not bad software to keep my files and folders safe! Even the free
has the fantastic functions to protect any private files from being seen by
me. With it I can encrypt, hide or lock anything I want, amazin
'[N-ZA-Mn-za-m]'
278 / 658
279 / 658
|tail -n 2
280 / 658
281 / 658
282 / 658
283 / 658
284 / 658
285 / 658
286 / 658
.svn)
287 / 658
288 / 658
289 / 658
myfile' | md5sum -c
290 / 658
291 / 658
292 / 658
-mc
293 / 658
294 / 658
"; $@ &>$tf& }
295 / 658
296 / 658
# Remove executable bit from all files in the current directory recursively, excluding other
directories
find . ! -type d -exec chmod -x {}\;
# Every Nth line position # (SED)
sed -n '1,${p;n;n;}' foo > foo_every3_position1; sed -n '2,${p;n;n;}' foo >
foo_every3_position2; sed -n '3,${p;n;n;}' foo > foo_every3_position3
# Squish repeated delimiters into one
echo "hello::::there" | tr -s ':'
# generate a random 10 character password
pwgen 10
# generate a table of 10 character random passwords
# apache statistics
grep "10/Sep/2013" access.log| cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort
-nk1 -nk2 | uniq -c | awk '{ if ($1 > 10) print $0}'
# Create full backups of individual folders using find and tar-gzip
297 / 658
298 / 658
299 / 658
300 / 658
301 / 658
302 / 658
# Router discovery
traceroute 2>/dev/null -n google.com | awk '/^ *1/{print $2;exit}'
# A command to post a message and an auto-shortened link to Twitter. The link shortening
service is provide by TinyURL.
curl --user "USERNAME:PASSWORD" -d status="MESSAGE_GOES_HERE $(curl -s
http://tinyurl.com/api-create.php?url=URL_GOES_HERE)" -d source="cURL"
http://twitter.com/statuses/update.json -o /dev/null
# Remove all unused kernels with apt-get
perl -e 'chomp($k=`uname -r`); for (</boot/vm*>) {s/^.*vmlinuz-($k)?//; $l.="linux-image-$_
";} system "aptitude remove $l";'
# Enable color pattern match highlighting in grep(1)
export GREP_OPTIONS='--color=auto'
# Opens files containing search term in vim with search term highlighted
303 / 658
304 / 658
|AUTO|
|OFF|"|osd_cat -p bottom
305 / 658
306 / 658
307 / 658
308 / 658
309 / 658
310 / 658
311 / 658
# See all the commits for which searchstring appear in the git diff
git log -p -z | perl -ln0e 'print if /[+-].*searchedstring/'
# Check if the Debian package was used since its installation/upgrade.
package=$1; list=/var/lib/dpkg/info/${package}.list; inst=$(stat "$list" -c %X); cat $list |
(while read file; do if [ -f "$file" ];then acc=$(stat "$file" -c %X); if [ $inst -lt
$acc ]; then echo used $file; exit 0; fi; fi; done; exit 1)
# find files ignoring .svn and its decendents
find . -type d -name .svn -prune -o -type f -print0 | xargs -r0 ...
# Count git commits since specific commit
git log --pretty=oneline b56b83.. | wc -l
# Dropbox login using only curl, sed and bash
link=https://www.dropbox.com/login ; curl -b a -c cookie -d "t=$(curl -c a $link | sed -rn
's/.*TOKEN: "([^"]*).*/\1/p')&login_email=me%40yahoo.com&login_password=my_passwd" $link
# GZip all files in a directory separately
for file in *.foo; do gzip "$file"; done
# convert wmv into xvid avi format
mencoder -ovc xvid -oac mp3lame -srate 44100 -af lavcresample=44100 -xvidencopts
fixed_quant=4 Foo.wmv -o Bar.avi
# Trim png files in a folder
mogrify -trim *png
# list services running (as root)
service --status-all | grep running
# Have netcat listening on your ports and use telnet to test connection
SERVER: nc -l p 666 CLIENT: telnet -l -p 666
# GZip all files in a directory separately
ls | xargs -n1 gzip
# DVD-Rip
mplayer dvd://1 -dumpstream -alang es -dumpfile "$dirDestino"/"$tituloDVD".mpg && ffmpeg -i
"$dirDestino/$tituloDVD.mpg" -acodec libmp3lame -alang spa -vcodec libx264 -crf 26 -vpre hq
-threads 0 "$dirDestino/$tituloDVD.mp4"
# Download an Entire website with wget
wget -m -k -K -E http://url/of/web/site
# Play radio stream with mplayer
mplayer -nolirc http://5253.live.streamtheworld.com/VIRGINRADIO_DUBAIAAC
# Execute matlab sentences from command line
echo 'magic(3)' | matlab -nodisplay
312 / 658
313 / 658
314 / 658
315 / 658
316 / 658
# Summary of disk usage, excluding other filesystems, summarised and sorted by size
du -xks * | sort -n
# Watch a dig in progress
watch -n1 dig google.com
# converts a directory full of source tarballs into a bzr repository so you can compare
different versions easily
bzr init .;for file in `ls *.bz2`; do bzr import $file; bzr ci -m $file; done
# Get free RAM in %
free -m | awk '/cache:/ { printf("%d%\n",$3/($3+$4)*100)}'
# Btrfs: Find file names with checksum errors
317 / 658
318 / 658
# MP3 player
find . -name '*.mp3' | sort | while read -r mp3; do echo -e "<h3>$mp3</h3>\n<audio controls
src=\"$mp3\"></audio>"; done > index.html; python -m http.server
# ps grep with header
psg () { ps auxwww | egrep "$1|PID" | grep -v grep }
# Display formatted routes
routel
# validate xml in a shell script using xmllint
xmllint --noout some.xml 2>&1 >/dev/null || exit 1
319 / 658
# Clean all .pyc files from current project. It cleans all the files recursively.
find . -type f -name "*.pyc" -delete;
# edit hex mode in vim
:%!xxd
# Download all images from a 4chan thread
curl -s $1 | grep -o -i '<a href="//images.4chan.org/[^>]*>' | sed -r 's%.*"//([^"]*)".*
%\1%' | xargs wget
# Mac OS X - List all of my machine's IP addresses
ifconfig | awk '/inet / {print $2}'
# 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`
# Copy files to a remote host with SFTP with a leading dot, then rename them to the real
file name
sftp-cp() { for each in "$@"; do echo "put \"$each\" \".$each\""; echo "rename \".
$each\" \"$each\""; done };
# Update twitter with curl
tweet(){ update=$(echo $*); [ ${#update} -lt 141 ] && curl -su user:pass -d source=curl -d
status="$update" http://twitter.com/statuses/update.xml ->/dev/null || echo $(( ${#update} 140 )) too many characters >&2; }
# Find & watch active IP and MAC addresses in a wireless network in real time. (IPv4 only)
sudo watch arp-scan --interface=wlan0 --localnet
320 / 658
Your_Audio_track.mp3
# Turn shell tracing and verbosity (set -xv) on/off with 1 command!
function setx(){ sed '/[xv]/!Q2' <<< $- && { set +xv; export PS4=">>> "; } || { export
PS4="`tput setaf 3`>>> `tput sgr0`"; set -xv; }; }
# List Threads by Pid along with Thread Start Time
ps -o pid,lwp,lstart --pid 797 -L
# set your screensaver as your desktop background MAC OSX
/
System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/Mac
OS/ScreenSaverEngine -background &
# Mark packages installed with build-dep for autoremove (on Debian/Ubuntu)
sudo aptitude markauto $(apt-cache showsrc PACKAGE | grep Build-Depends | perl -p -e 's/(?:
[\[(].+?[\])]|Build-Depends:|,|\|)//g')
# Find out when your billion-second anniversary is (was).
date -d12/31/1970+1000000000sec
# convert video format to youtube flv format
ffmpeg -i Your_video_file -s 320x240 FILE.flv
# Quick searching with less
zcat file.gz | less +/search_pattern
# Watch RX/TX rate of an interface in kb/s
while cat /proc/net/dev; do sleep 1; done | awk '/eth0/ {o1=n1; o2=n2; n1=$2; n2=$10; printf
"in: %9.2f\t\tout: %9.2f\r", (n1-o1)/1024, (n2-o2)/1024}'
# Check if a machine is online with better UI
echo -n "IP Address or Machine Name: "; read IP; ping -c 1 -q $IP >/dev/null 2>&1 && echo -e
"\e[00;32mOnline\e[00m" || echo -e "\e[00;31mOffline\e[00m"
# awk change field separator
awk '$1=$1' FS=" " OFS=":" file
# Get My Public IP Address
curl -s http://myip.dk/ | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
# Grab mp3 files from your favorite netcasts, mp3blog, or sites that often have good mp3s
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off -i ~/sourceurls.txt
# calulate established tcp connection of local machine
netstat -an | grep -Ec '^tcp.+ESTABLISHED$'
# Log colorizer for OSX (ccze alternative)
tail -f /var/log/system.log | colorizer
321 / 658
322 / 658
} pwd }
# Search for a <pattern> string inside all files in the current directory
find . -type f -exec grep -i <pattern> \;
# rotate the compiz cube via command line
wmctrl -o 1280,0
# Create commands to download all of your Google docs
google docs list |awk 'BEGIN { FS = "," }; {print "\""$1"\""}'|sed s/^/google\ docs\ get\ /|
awk ' {print $0,"."}'
# Set OS X X11 to use installed Mathematica fonts
323 / 658
324 / 658
325 / 658
326 / 658
327 / 658
-oac copy
328 / 658
329 / 658
| grep ipa
| sed -e
330 / 658
# How many world writeable files on your system? (Mandriva Linux msec)
# wc -l /var/log/security/writable.today
# Transfer Entire recursive from one host to another. Only copies files that are newer or do
not exist
rsync -azE -e "ssh -pPortnumber" src_dir user@hostB:dest_dir
# umount sshfs mounted directory
fusermount -u ~/sshfs_mounted_directory
# Title Case Files
rename 's/(^|[\s\(\)\[\]_-])([a-z])/$1\u$2/g' *
# Key binding to search commandlinefu.com
331 / 658
"
332 / 658
file
333 / 658
334 / 658
# list unique file extensions recursively for a path, include extension frequency stats
335 / 658
336 / 658
a directory contains softlinks, grep will give lot of warnings. So better use it along
find command so that softlinks are excluded. "Hn" operator will take care that both
number and filename is shown in grep output
/path/to/search/directory -exec grep -Hn "pattern" {} \;
337 / 658
ls -la $crt;
338 / 658
|xargs du -csh'
339 / 658
340 / 658
foreground color
",$2,"\t",$(NF-2),"\t",$(NF-1),"\t",$NF
341 / 658
342 / 658
343 / 658
344 / 658
345 / 658
nfslock
machine-0%t
346 / 658
347 / 658
- - - | awk -F'\t'
# encrypt, split and get ready for dvd a large file via tar and ccrypt
tar czf - /directory/to/tar | ccrypt -k yourpassword | split -b50m - /final/encrypted.cpt
# cpanel umount virtfs mounts
for i in `cat /proc/mounts | grep /home/virtfs | cut -d ? ? -f 2 ` ; do umount $i; done
# find . -name "*.txt" | xargs sed -i "s/old/new/"
find . -name "*.txt" | xargs sed -i "s/old/new/"
# Set the master volume to 90% (Ubuntu)
aumix -v 90
# Sometimes you just want a quick way to find out if a certain user account is locked
[Linux].
getent shadow | grep '^[^:]\+:!' | cut -d: -f1
# Get IPv4 of eth0 for use with scripts
/sbin/ifconfig eth0 | grep 'inet addr:' | awk {'print $2'} | sed 's/addr://'
# delete all leading and trailing whitespace from each line in file
sed 's/^[ \t]*//;s/[ \t]*$//' < <file> > <file>.out; mv <file>.out <file>
# Make sure your script runs with a minimum Bash version
if [ -z "${BASH_VERSINFO}" ] || [ -z "${BASH_VERSINFO[0]}" ] || [ ${BASH_VERSINFO[0]} -lt
4 ]; then echo "This script requires Bash version >= 4"; exit 1; fi
# controls mpg321 play/pause/stop by signals
pkill -{signal} mpg321
# copy public key
ssh-copy-id host
# Lists all clients of a Squid proxy
awk '{a[$3]++} END {for(i in a) print i}' /var/log/squid/access.log
348 / 658
4 -20'; sleep
349 / 658
with du -csh
350 / 658
351 / 658
# rename multiple files with different name, eg converting all txt to csv
zmv '(*).txt' '$1.csv'
# Losslessly combine all MP3s in a directory (e.g. an audiobook)
ffmpeg -i "concat:$(find . -name "*.mp3" | sort | tr '\n' '|')" -acodec copy ../$(basename $
(pwd)).mp3 && mp3val -f ../$(basename $(pwd)).mp3
# Add member to domain group
net group groupname username /add /domain
# Get the URL for the git-annex webapp
grep URL ~/annex/.git/annex/webapp.html | tr -d '">' | awk -F= '{print $4 "=" $5}'
# Dump an rpm's package details (besides the files)
rpm --querytags | egrep -v HEADERIMMUTABLE | sort | while read tag ; do rpm -q --queryformat
"$tag: [%{$tag} ]\n" -p $SomeRPMfile ; done
# change current directory permissions and only sub-directories recursively (not files)
find . -type d -exec chmod XXXX {} \;
# Top 10 commands used
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr |
head
# Change the primary group of a user
useradd -g linux anish && id
# convert unixtime to human-readable
cat log | perl -ne 'use POSIX; s/([\d.]+)/strftime "%y-%m-%d %H:%M:%S", localtime $1/e,print
if /./'
# macports update
sudo port selfupdate ; echo '---------' ; sudo port upgrade outdated
# Print file content in reverse order
tac filename.txt
# Start a random channel from the uk site tvcatchup.com
randchannelurl=$(lynx -dump http://www.tvcatchup.com/channels.html | grep watch | sed
's/^......//'| awk 'BEGIN { srand() } int(rand() * NR) == 0 { x = $0 } END { print x }') &&
firefox -new-window $randchannelurl
# Rewrap an AVCHD (MTS/M2TS) video as MOV
ffmpeg -i "input.mts" -vcodec copy -acodec pcm_s16le "output.mov"
# infile search and replace on N files
352 / 658
353 / 658
| tr '%' '\n' |
354 / 658
355 / 658
-r -e 's/\/.*?//g'
356 / 658
357 / 658
358 / 658
359 / 658
output.png
# Count unique lines in file sorted by instance count (descending) and alphabetically
(ascending)
sort file.txt | uniq -c | sort -k1nr -k2d
# how much time restart the wls service?
more restart_weblogic.log | grep "LISTEN" | awk '{ print $7 }' | uniq | wc -l
# List you configure's ip address in your system
ip addr list | grep global | awk '{print $7"\t"$2}'
# mercurial close branch
hg commit --close-branch -m 'close badbranch, this approach never worked'
# Find all PowerPC applications on OS X
360 / 658
361 / 658
362 / 658
-I {} tar rf
363 / 658
364 / 658
365 / 658
wget http://www.phrack.org/archives/tgz/phrack${i}.tar.gz
366 / 658
367 / 658
# Create a git archive of the latest commit with revision number as name of file
git archive HEAD --format=zip -o `git rev-parse HEAD`.zip
# Convert metasploit cachedump files to Hashcat format for cracking
cd ~/.msf4/loot && cat *mscache* | cut -d '"' -f 2,4 | sed s/\"/\:/g | tr -cd
'\11\12\40-\176' | grep -v Username | cut -d : -f 1,2 | awk -F':' '{print $2,$1}' | sed
's/ /:/g' > final.dcc.hash
# Find stock debian package config files that have been modified since installation
dpkg-query -Wf '${Package}\n' | xargs dpkg --status | sed '/^Conffiles:/,/^Description:/!
d;//d' | awk '{print $2 " " $1}' | md5sum -c 2>/dev/null | grep FAILED$ | cut -f1 -d':'
# shows history of logins on the server
last
# Migrate wordpress db between two hosts changing the URL on the fly with encryption and
compression
ssh -q ${SRC_HOST} "mysqldump --add-drop-database --create-options --databases wordpress |
sed -r \"s/${OLD_URL}/${NEW_URL}/g\" | gzip -9" | ssh ${DST_HOST} "gunzip | mysql"
# Download all items from a list of URLs copied to the clipboard on OS X
pbpaste | xargs wget
# highest resolution of your ouputs as screen resolution and scaled versions on other
outputs
xrandr --fb 1920x1080 --output LVDS1 --scale 1.5x1.35 --output HDMI1 --mode 1920x1080
# to get how many users logged in and logged out and how many times purely using awk
last | awk '$1!~/wtmp/{logs[$1]++}END{for (i in logs) print i, logs[i]}'
# Display the output of a command from the first line until the first instance of a regular
expression.
<command> | perl -pe '/<regex/ && exit;'
# Create a false directory structure for testing your commands
for i in /usr/bin/* ;do touch ${i##*/}; done
368 / 658
369 / 658
370 / 658
# Change your exported xml love list from last.fm, into Song: songname Artist: artistname
cat username_lovedtracks.xspf |perl -pe
"s/.*<title>(.*)<\/title><creator>(.*)<\/creator>.*/Song: \1 Artist: \2/gi"> titles
# Show git branches by date - useful for showing active branches
for k in $(git branch | sed /\*/d); do echo "$(git log -1 --pretty=format:"%ct" $k) $k";
done | sort -r | awk '{print $2}'
# Find resolvable hosts in subnet
nmap -sL 74.125.237.1/24
# Copy Current Command Line to Clipboard
bind '"\C-l": "\C-u cat <<EOT | pbcopy \n \C-y \nEOT\n"'
# Remove UTF-8 Byte Order Mark BOM
find . -type f -regex '.*html$' -exec sed -i 's/\xEF\xBB\xBF//' '{}' \;
# Extract audio from dvd vobs in current dir
for i in *.VOB; do mplayer "$i" -ao pcm:file="${i%.*}.wav"; done
# Generate entropy
rngd -f -r /dev/urandom
# Copy uncommitted changes from remote git repository
ssh HOST '(cd REPO_DIR && git diff --name-only HEAD | cpio -o -Hnewc --quiet)' | cpio -iduv
--quiet -Hnewc
# Get a PostgreSQL servers version
psql -X -A -t -c "SELECT version();"
# Update music info with public database data
eval echo $(echoprint-codegen "/path/to/file.mp3"| jq ' .[0].metadata | "mp3info -a \"" +
.artist + "\" -t \"" + .title + "\" -l \"" + .release + "\" \"" + .filename + "\"" ' ) |
bash
# printing with psnup
psnup -4 -pa4 -Pa4 file.ps file2.ps
# Log a command's votes
371 / 658
372 / 658
373 / 658
(OS FreeBSD)
374 / 658
375 / 658
/' -e 's/-/|/'
376 / 658
# OS X: clean up Windows and Classic Mac OS newlines from the text in the clipboard
pbpaste | tr '\r\n' '\n' | tr '\r' '\n' | pbcopy
# shows history of logins on the server
last -aiF | head
# Restore application on Openshift
rhc snapshot restore -a {appName} -f {/path/to/snapshot/appName.tar.gz}
# Simple server which listens on a port and prints out received data
nc -l -p portnumber
# Find files modified in the last N days; list sorted by time
find . -type f -mtime -14 -exec ls -ltd \{\} \; | less
# Join avi files
cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > output.avi; mencoder -forceidx -oac
copy -ovc copy output.avi -o output_final.avi; rm output.avi
# Get full directory path of a script regardless of where it is run from
STARTING_DIR=$(cd $(dirname $0) && pwd)
# Tar all files in a folder including hidden dot files
tar -zcvf file.tgz ./
# Increment next number in vim
CTRL + A
( in normal mode )
# Internet file transfer program for scripts that can be easily used to get files from a ftp
ncftpget -u Us3r -p Passw0rd ftp.backups.com . 'site.com.tar.gz'
# Count open file handles for a specific user ID
for x in `ps -u 500 u | grep java | awk '{ print $2 }'`;do ls /proc/$x/fd|wc -l;done
# calculate how many different lines between two files
grep -Fvxf $(file1) $(file2) | wc -l
# duckduckgo search to w3m browser
ddg(){ search=""; bang=""; for term in $@; do if [[ "$term" =~ -([A-Za-z0-9._%+-]*) ]]; then
bang="\!${BASH_REMATCH[1]}" ; else search="$search%20$term" ; fi ; done ; w3m
"https://www.duckduckgo.com/?q=$bang$search" ;}
377 / 658
# Find out the installation time of a linux system (when installed in a ext2/3/4 file
system)
tune2fs -l $(df -P / | awk 'NR==2 {print $1}') | sed -n 's/^.*created: *//p'
# Escape literal string for inclusion in an egrep regex
egrep_escape() { echo "$1" |sed -re 's/([\\.*+?(|)^$[])/\\\1/g' -e 's/\{/[{]/g';
378 / 658
379 / 658
380 / 658
# Find biggest 10 files in current and subdirectories and sort by file size
find . -type f -exec du -sh {} + | sort -hr | head
# find . -name "*" -print | xargs grep -s pattern
find . -name "*" -print | xargs grep -s pattern
# grep all pdf files in a folder
for i in *.pdf; do echo --------$i-------; echo; pdftotext $i - | grep -i Yourpattern; done
# See the members of a group
getent group <group>
# Get external IP address (supports IPv4 and IPv6)
curl ip.telize.com
# Replace php short open tags
find . -name '*.phtml' | xargs perl -pi -e 's/(?!(<\?(php|xml|=)))<\?/<\?php/g;'
# find out about a process
cat /proc/<PID>/environ
# Remove all directories less than 1 MB in size in or below current directory
find . -type d -execdir du -sh '{}' ';' | grep -E "[0-9]+K" | sed 's/^[0-9\.]\+K[\t ]\+//' |
tr "\n" "\0" | xargs -0 rm -rf
# Remove blank lines from a file
sed -i.bak '/^[[:space:]]*$/d' file_name
# stdin speaker via espeak
awk '{print}' | espeak -v pt -stdin
# show how much diskspace all images in a given directory need
find /home/bubo/ -type f \( -iname \*.jpg -print0 , -iname \*.png
-print0 \) | du -cm --files0-from - | tail -1
# Create a virtual disk (CD/DVD) in VirtualBox
VBoxManage openmedium dvd "/path/name.iso"
381 / 658
382 / 658
) ))
383 / 658
# Check if the files in current directory has the RPATH variable defined
for i in *; do file $i | grep -q ELF || continue; readelf -d $i | grep -q RPATH || echo $i;
done
# Launch an interactive shell with special aliases and functions.
bash --rcfile /a/special/bashrc
# Find duplicate UID in /etc/passwd
awk -F: '{print $3}' /etc/passwd | sort |uniq -d
# Regex to wrap lines to 75 characters.
s/(?=.{75,})(?:(.{0,75})(?:\r\n?|\n\r?)|(.{0,75}))[ ]/\1\2\n /g
# Search for java explicit incrementation
egrep "([_a-zA-Z][_a-zA-Z0-9]*) *= *\1 *[*/+-] *[0-9]+ *;"
# Incorporating a finished feature on develop : Deleted branch myfeature
git branch -d myfeature
# Remove / delete file with ? or special characters in filename
ls -il; find * \( -type d -prune \) -o -inum <NUM> -exec rm -i {} \;
# show help text only in Vim
:h `subject` | only
# ls -altr | grep ^d
ls -altr | grep ^d
# Set audio card 0 master volumn to maximum
amixer -c 0 set Master 100%
# SCP file from remote location to local directory
scp user@hostname:/remotedir/file.name /localdir
# Generate random password on Mac OS X
cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16; echo
# git log with color and path
alias gitlog='git log -10 --graph --date-order -C -M --pretty=format:"%C(yellow)%h%C(reset)
- %C(bold green)%ad%C(reset) - %C(dim yellow)%an%C(reset) %C(bold red)>%C(reset) %C(white)%s
%C(reset) %C(bold red)%d%C(reset) " --abbrev-commit --date=short'
# Switch on eeepc camera
sudo echo 1 > /proc/acpi/asus/camera
# Find out if MySQL is up and listening on Linux
netstat -tap | grep mysql
384 / 658
# Command to display how much resource is taken by cpu and which core is taking
pidstat -C "ffmpeg" -u
# Match a URL
echo "(Something like http://foo.com/blah_blah)" | grep -oP "\b(([\w-]+://?|www[.])[^\s()<>]
+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))"
# List last opened tabs in firefox browser
grep -Eo '"entries":\[{"url":"[^"]*"' "$HOME/.mozilla/firefox/*.default/sessionstore.js" |
sed 's/^.*:"//; s/"$//'
# let the cow suggest some commit messages for you
while true; do curl -s http://whatthecommit.com | perl -p0e '($_)=m{<p>(.+?)</p>}s' |
cowsay; sleep 2; done
# Sets performance CPU governer of all cores of a 4-core CPU.
for i in {0..3}; do cpufreq-set -c $i -g performance; done
# Find the package a command belongs to on rpm-based distros
whichpkg() { rpm -qf "$@"; }
# Startup Nessus and initialize plugins on backtrack5
sudo /opt/nessus/sbin/nessusd
# Regex snippet to do multi-character [^x]*
Opening_tag((?:(?!Unwanted_tag).)*)Closing_tag
# Sort by size all hardlinked files in the current directory (and subdirectories)
for a in $(find . -xdev -type f -printf '%i\n'|sort|uniq -d);do find . -xdev -inum $a
-printf '%s %i %m %n %U %G %AD %Ar %p\n';done|sort -n|awk '{if(x!=$2){print
"---"};x=$2;print $0}'
385 / 658
wc -l | tail -1
386 / 658
387 / 658
388 / 658
389 / 658
390 / 658
391 / 658
# Restart nautilus
nautilus -q
# use the short username by default for network authentication
defaults write /Library/Preferences/com.apple.NetworkAuthorization UseShortName -bool YES
# Stop Mac OSX from creating .DS_Store files when interacting with a remote file server with
the Finder
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
# simple du command to give size of next level of subfolder in MB
du --max-depth=1 -B M |sort -rn
# Dump MySql to File
mysqldump --opt -uUSERNAME -pPASSWORD -h mysql.host.com database > ~/filename.sql
392 / 658
xmodmap -e
393 / 658
# all out
pkill -9 -u username
# save manpage as html file
zcat `man -w manpage` | groff -mandoc -T html - > filename.html
# Opens up cached flash plugin video files(linux)
vlc $(for f in /proc/$(pgrep -f libflashplayer.so |head -n 1)/fd/*; do ;if $(file ${f} |
grep -q "broken symbolic link to \`/tmp/FlashXX"); then echo ${f};fi;done)
# send an email through linux command line van be achieved by
mail -s "myip" youremail@domain.com
# Get the number of open sockets for a process
ps aux | grep [process] | awk '{print $2}' | xargs -I % ls /proc/%/fd | wc -l
# number kill your terminal
for ((i=0; i>-1000; --i)); do echo "${!i}"; done
# Erase empty files
find . -size 0 -exec rm '{}' \;
# generate random password
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | sed 1q
# Check if zip files from current directory are good
find . -maxdepth 1 -name "*.zip" -exec unzip -tqq {} \;
# Merge various PDF files
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH first.pdf second.pdf
# Find all PowerPC applications on OS X
system_profiler SPApplicationsDataType | grep -A3 -B4 "Kind: PowerPC"
# Which PATH variable should I use for this scirpt?
whichpath() { local -A path; local c p; for c; do p=$(type -P "$c"); p=${p%/*}; path[$
{p:-/}]=1; done; local IFS=:; printf '%s\n' "${!path[*]}"; }
# Report summary of string occurrence by time period (hour)
cat z.log | grep Timeout | cut -d ':' -f1 | sort | uniq -c
# open manpage in browser
man -HBrowser manpage
# Gets directory size on sub directories in current dir with human readable size
du -h --max-depth=1
# count & sort one field of the log files
394 / 658
-A 2 -B 2 --color
"pHtmlHome" .
395 / 658
396 / 658
Useful in scripting.
# Get the amount of users currently registered at the DudaLibre.com Linux Counter.
curl --silent http://www.dudalibre.com/gnulinuxcounter?lang=en | grep users | head -2 | tail
-1 | sed 's/.*<strong>//g' | sed 's/<\/strong>.*//g'
# List your MACs address
echo | ifconfig | grep HWaddr
# reverse order of file
printf "g/^/m0\nw\nq"|ed $FILE
# Put at the end of the rsa public key an comment(default value is the hostname)
ssh-keygen -C hello@world
# Multi (file)source SSH host tab-completion
complete -W "$( { awk '/^Host / { print $2 }' ~/.ssh/config | egrep -v '\*|,'
echo $
( grep '^ssh ' .bash_history | sort -u | sed 's/^ssh //' )
while IFS=' ,' read host t;
do echo $host; done < ~/.ssh/known_hosts ;} )" ssh
# mount remote directory
sshfs user@host:/path/to/remote/dir local-mount-point
# Screenshot in $1 seconds, upload and retrieve URI from ompdlr.org
scrotit(){ echo "Screenshot in $1 seconds...";scrot -d $1 '%Y%m%d%h.png' -e 'curl -sF
file1=@- http://ompldr.org/upload < $f | grep -P -o "(?
<=File:).*(http://ompldr.org/.*)\<\/a\>";rm $f'| sed -r
's@.*(http://ompldr.org/\w{1,7}).*@\1@';}
# find potentially malicious PHP commands used in backdoors and aliked scripts
find ./public_html/ -name \*.php -exec grep -HRnDskip "\(passthru\|shell_exec\|system\|
phpinfo\|base64_decode\|chmod\|mkdir\|fopen\|fclose\|readfile\) *(" {} \;
# SSH folder with progress bar and faster encryption with compression
cd /srcfolder; tar -czf - . | pv -s `du -sb . | awk '{print $1}'` | ssh -c
arcfour,blowfish-cbc -p 50005 root@destination.com "tar -xzvf - -C /dstfolder"
# LDAP list of users and their details
ldapsearch -x -LLL uid=*
# Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id
brew install ssh-copy-id; ssh-copy-id user@host
# Send a message to Kodi (XBMC)
curl -X POST -H "Content-Type: application/json" -d
'{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"This is the title of
the message","message":"This is the body of the message"},"id":1}'
http://i3c.pla.lcl:8080/jsonrpc
# List all packages with no dependencies (yum based system)
package-cleanup --leaves --all
397 / 658
# changing permissions to many folders, sub folders and files in the current directory.
for i in * ; do chmod -R 777 $i;done
# Rename many files in directories and subdirectories
find . -type d -print0 | while read -d $'\0' dir; do cd "$dir"; echo " process $dir"; find .
-maxdepth 1 -name "*.ogg.mp3" -exec rename 's/.ogg.mp3/.mp3/' {} \; ; cd -; done
# Send SNMP traps
sudo snmptrap -m ALL -v 2c -c public trapserver "" UCD-DEMO-MIB::ucdDemoPublic SNMPv2MIB::sysLocation.0 s "Just here"
# make directory
398 / 658
Useful in scripting.
399 / 658
400 / 658
/' -e 's/-/|/'
# hello, world
perl -e "''=~('(?{'.('-^@.]|(;,@/{}/),[\\\$['^'],)@)[\`^@,@[*@[@?}.|').'})')"
# recursively change file name extensions
find . -type f -name \*.c | while read f; do mv $f "`basename $f .c`".C; done
# Compare a file with the output of a command or compare the output of two commands
vimdiff foo.c <(bzr cat -r revno:-2 foo.c)
# Spoof your wireless MAC address on OS X to 00:e2:e3:e4:e5:e6
sudo ifconfig en1 ether 00:e2:e3:e4:e5:e6
# Iterate through a file where instead of Newline characters, values are separated with a
non-white space character.
while [[ COUNTER -le 10 && IFS=':' ]]; do for LINE in $(cat /tmp/list); do some_command(s)
$LINE; done; COUNTER=$((COUNTER+1)); done
# File without comments or blank lines.
gawk '!/^[\t\ ]*#/{print $0}' filename | strings
# for all who don't have the watch command
watch() { if [ -z "$1" ]; then echo "usage: watch interval command" return fi sec=$1 shift
while test :; do clear; date=$(date); echo -e "Every "$sec"s: $@ \t\t\t\t $date"; echo $@;
sleep $sec; done }
# You can't do that on sed
perl -p -e 's/\\n/\n/g'
# Open a different file for edition on a vertical split screen inside your vim session
:vsplit filename
# Count words in a TeX/LaTeX document.
pdftotext file.pdf - | wc -w
# get the current weather in NYC, in human readable form
curl -s poncho.is/forecast/new_york/today/ | grep -E 'og:title|og:description' | cut -d\"
-f4 | awk '{print $0,"<p>"}' | lynx -stdin -dump
# Schedule one job after another (running).
401 / 658
gnu screen
# YouTube Convert and Download All User's Videos to MP3s on the fly
Command in description (Your command is too long - please keep it to less than 255
characters)
# Kill a process by its partial name
killall -r 'a regular expression'
# Add DuckDuckGo Search as search provider on gnome-shell
cd /usr/share/gnome-shell/search_providers/ && cat google.xml | sed
"s/www.google.com\/search/duckduckgo.com\//; s/Google/DuckDuckGo/g" > duckduckgo.xml
# make directory
$ mkdir -p /tmp/dir1/{0..20}
# view all console fonts
#!/bin/bash cd /usr/share/consolefonts/; for i in * ; do setfont; echo "testing >> $i <<
font" ; setfont $i ; showconsolefont ; sleep 5 ; clear ; done
# Graphical tree of sub-directories
find . -type d |sed 's:[^-][^/]*/:--:g; s:^-: |:'
# make a central proxy access from where it's high speed link available.
socat TCP4-LISTEN:3128,reuseaddr,fork TCP6:[xxxx:xxxx::xxxx]:3128
402 / 658
w=${w^}; w=${w//\'/};
403 / 658
| parallel
# add a change in git that you have just checked using git diff
^diff^add
# Search recursively to find a word or phrase in certain file types, such as C code
find . -name "*.[ch]" -exec grep -i /dev/null "search pharse" {} \;
# Create a package list for offline download
sudo apt-get <apt-get command and options> --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\
+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > dowload_deb_list.txt
# SSH Auto-login with password
SSHPASS='your_password' sshpass -e ssh me@myhost.com
# find php command backdoor
grep -RPl --include=*.{php,txt,asp} "(passthru|shell_exec|system|phpinfo|base64_decode|
chmod|mkdir|fopen|fclose|readf?ile) *\(" /var/www/
# Opens up a background session within an existing fron-end session
screen
# Annoy everyone on your system
tmpIFS=IFS; IFS='\n'; users=`who | awk '{print $1}'`; for u in users; do; write $u <
/dev/urandom &; done; IFS=tmpIFS
# Passwordless mysql{,dump,admin} via my.cnf file
echo -e "[client]\nuser = YOURUSERNAME\npassword = YOURPASSWORD" > ~/.my.cnf
# Test network performance, copying from the mem of one box, over the net to the mem of
another
dd if=/dev/zero bs=256M count=1 | nc [remoteIP] [remotePort] and on the other host nc -l
port >/dev/null
# 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 }
# Recursively grep thorugh directory for string in file.
find directory/ -exec grep -ni phrase {} +
# Convert an ISO file to DMG format in OS X Terminal
hdiutil convert /path/imagefile.iso -format UDRW -o /path/convertedimage.dmg
404 / 658
# Grap all images with the tags 'bitch' and 'bw' from a flickr photofeed
for URL in `wget -O - http://api.flickr.com/services/feeds/photos_public.gne?tags=bitch,bw
2>/dev/null | grep -E -o "http[^ ]+?jpg" | grep -v "_m" | uniq | grep -v 'buddy' `; do
FILE=`echo $URL | grep -E -o "[0-9a-z_]+\.jpg"`; curl $URL > $FILE; done;
# lists contents of a tar file
tar -tf /path/to/file.tar
# Enable NetworkManager (in KDE)
dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager
/org/freedesktop/NetworkManager org.freedesktop.NetworkManager.Enable boolean:true
# see what traffic is mostly hitting you
tcpdump -i eth0 -n | head
405 / 658
406 / 658
# Strip out time difference entries when verifying rpms on x86_64 RHEL systems
rpm -Va | grep -v "\.\.\.\.\.\.\.T"
# 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
# Consistent Oracle Datapump Export
expdp user/password FLASHBACK_SCN=$(echo -e "select current_scn from v\$database;" | sqlplus
/ as sysdba 2>/dev/null| grep [0-9][0-9][0-9][0-9][0-9][0-9]*)
# Disaster Snapshot (procmail)
for x in `grep server /tmp/error.log | awk '{print $3}'`; do \ t=`date "+%d-%m-%H%M%S"` ;
ssh -q -t admin@$x.domain.com 'pstree -auln' > ~/snapshots/$x-$t.out \ done
# Calculate the size in MB of all files of a certain extension
find . -type f -iname '*.msh' -exec ls -lG {} \; | awk '{total = total + $4}END{print
"scale=2;" total "/2^20"}' | bc
# Check in current directory to SVN with commical/terrible commit message. (Please don't
actually run this command!)
svn ci -m "$(curl -s http://whatthecommit.com | sed -n '/<p>/,/<\/p>/p' | sed '$d' | sed
's/<p>//')"
# Run query on remote database and output results as csv
mysql -u[user] -p[password] -h [hostname] -D [database] -ss -e "select * from mysql_tbl " |
sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > dump.csv
# Boot block devices as virtual devices in Virtual Box
VBoxManage internalcommands createrawvmdk -filename [path/to/file/name.vmdk] -rawdisk /dev/
[block_device]
# Find all FAT-invalid filenames in "."
find . | grep -E "(\||\\|\?|\*|<|\"|:|>|\+|\[|\])"
# List users in a group
lid -g <group>
# Show the source code of a LaTeX class or package or a TeX file in general
less `kpsewhich scrartcl.cls`
# DB2 Load command instead of truncate or delete command, to get rid of table rows
db2 CONNECT TO stgndv2; db2 'load from /dev/null of del replace into
STMOT.ST_MORT_ARRG_DELTA nonrecoverable'
# List recursively only empty folders on present dir
407 / 658
cp --parents
# Yardstick static analysis report sorted by which JavaScript files have the highest ratio
of comments to code.
find . -name *js -type f | xargs yardstick | sort -k6 -n
# total number of files inside current directory
ls -R | wc -l
# Simplest web server ever!
nc -k -l 5432 -c 'echo My Web Server is Alive'
# Grant read-only permissions to user or group
icacls directory_or_file /grant user_or_group:(OI)(CI)rx /t / l /q
# Create a random file of a certain, and display progress along the way.
SIZE=1; dd if=/dev/zero bs=1M count=$((SIZE*1024)) | pv -pters $((SIZE*1024*1024*1024)) |
openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null |
base64)" -nosalt > randomfile
# Easily move around many directories
a() { alias $1=cd\ $PWD; }
# Lazy man's vim
function v { if [ -z $1 ]; then vim; else vim *$1*; fi }
# Drag A Dashboard Widget Onto OS X Desktop
defaults write com.apple.dashboard devmode YES
# let a cow tell you your fortune
fortune | cowsay -f tux
# Get the latest ftp file from ftp server on local machine with lftp and bash. (Piped
commands inside lftp).
ftp-latest <<< "cd /; cls -1 | tail -1 | xargs -I% echo get % | /PATH/TO/ftp-latest"
408 / 658
|cut -d : -f 1`; do
409 / 658
410 / 658
411 / 658
412 / 658
413 / 658
414 / 658
415 / 658
416 / 658
417 / 658
# Recursive search inside the content of files under current directory - then view the
result paginated with 'pess'
find . -exec grep -Hn what \{\} \; | less
# command for converting wav files to mp3
find . -iname "*wav" > step1 ; sed -e 's/\(^.*\)wav/\"\1wav\" \"\1mp3\"/' step1 > step2 ;
sed -e 's/^/lame /' step2 > step3 ; chmod +x step3 ; ./step3
# List all rpms on system by name, version and release numbers, and architecture
rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'
418 / 658
419 / 658
420 / 658
# remove old index.html if you download it again and organiaz the java script tag on the
file index.html
rm index.html | wget www.google.com;cat index.html | sed 's/<script>/\n\n\<script>\n\n/g' |
sed 's/<\/script>/>\n\n/g'
# Force delete of Google Chrome Google-related local storage, make Gmail Offline work again
/bin/rm -f ~/Library/Application\ Support/Google/Chrome/Default/Local\ Storage/*google*
# Quick and dirty list of installed packages on deb based system
apt-cache -n dumpavail | grep 'Package:' | awk '{print $2 }'
# Remove all installed packages from a python virtualenv
for i in $(pip freeze | awk -F== '{print $1}'); do pip uninstall $i; done
# strace -T -f -p <PID>
Show syscalls for parent and all child threads with execution time
# remove comments from xml
cat <filename> | perl -e '$/ = ""; $_ = <>; s/<!--.*?-->//gs; print;'
# recursive grep of text files
grep -Ir foo *
# generate the moduli file for openssh if lost
ssh-keygen -G /tmp/moduli-2048.candidates -b 2048
# OSX Expand URL and Copy to Clipboard
function expand_url() {
curl -sI $1 | grep Location: | cut -d " " -f 2 | tr -d "\n" |
pbcopy }
421 / 658
# List the size (in human readable form) of all sub folders from the current location
du -hs * | sort -h
422 / 658
423 / 658
424 / 658
425 / 658
426 / 658
427 / 658
428 / 658
# sort a csv file according to a particular n th field numerically (quicker than excel)
sort -t"," -n -k5 file.csv # according to the 5th field NUMERICALLY!!
# monitor the last command run
$ history
# add border to image
convert input.png -mattecolor gold -frame 10x10+5+5 output.png
# Disable rm, use trash instead
alias rm='echo "rm is disabled, use trash or /bin/rm instead."'
# Delete/Archive easily old mails using find.
find . -path ".*/cur/*" -type f ! -newermt "1 week ago" -delete
# scan subnet for used IPs
nmap -T4 -sn 192.168.1.0/24
# Extract audio stream from an video file using mencoder
429 / 658
# Atualizar Ubuntu
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -y
&& apt-get autoclean -y
# How to Find the Block Size
/sbin/dumpe2fs /dev/hda2 | grep 'Block size'
# scp a good script from host A which has no public access to host C, but with a hop by host
B
ssh middlehost "ssh -a root@securehost '> nicescript'" < nicescript
# Router discovery
awk 'NR==2 {print $1}' /proc/net/arp
# a simple interactive tool to convert Simplified Chinese (typed by pinyin) to Traditional
Chinese 简繁中文转换
echo "Simplied Chinese:"; while read -r line; do echo "Traditional Chinese:"; echo $line |
iconv -f utf8 -t gb2312 | iconv -f gb2312 -t big5 | iconv -f big5 -t utf8; done
# showing opened ports on machine
netstat -tulpnc
# SVN Status log to CSV (Mac OSX friendly)
svn log | tr -d '\n' | sed -E 's/-{2,}/\'$'\n/g' | sed -E 's/ \([^\)]+\)//g' | sed -E
's/^r//' | sed -E "s/[0-9]+ lines?//g" | sort -g
# remove border of image
convert input.png -shave 10x10 output.png
# pacman install list of packages
pacman -Q | grep -v pacman | cut -d' ' -f1 > packages.txt && pacman -Sy `cat packages.txt`
--noconfirm
# converts video to ascii art (txt) by mplayer and aa|caca lib
mplayer -vo aa:eight:driver=curses video.avi >video.txt
# Quick syntax highlighting with multiple output formats
pygmentize -l sh ~/.bashrc | less -R
# Find files and list them sorted by modification time
find . -type f -exec stat -f '%m %N' {} \; | sort -n
# Find processes stuck in dreaded
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
# Monitor open connections for httpd including listen, count and sort it per IP
watch "netstat -plan | grep -v LISTEN | grep \":80 \" | awk {'print \$5'} | cut -d: -f 1 |
uniq -c | sort -nk 1"
# View facebook friend list [hidden or not hidden]
php -r "echo ini_get('allow_url_fopen');" php -r "echo function_exists('curl_init');" php -r
"echo function_exists('json_decode');"
430 / 658
431 / 658
432 / 658
433 / 658
434 / 658
435 / 658
436 / 658
| html2text
437 / 658
# vi sudo access
:w !sudo tee %
# transpose a file
awk '{ for (f = 1; f <= NF; f++)
a[NR, f] = $f } NF > nf { nf = NF } END {
for (f = 1;
f <= nf; f++) for (r = 1; r <= NR; r++)
printf a[r, f] (r==NR ? RS : FS) }'
# Determine configure options used for MySQL binary builds
cat `whereis mysqlbug | awk '{print $2}'` | grep 'CONFIGURE_LINE='
438 / 658
439 / 658
440 / 658
# Count the number of pages of all PDFs in current directory and all subdirs, recursively
find -iname "*.pdf" -exec pdfinfo -meta {} \;|awk '{if($1=="Pages:"){s+=$2}}END{print s}'
# Remove hidden CVS merge helper files
find . -name ".#*" -exec rm {} \;
# Get all links of a website
lynx -dump http://www.cooks4arab.com | awk '/http/{print $2}' | egrep "^https{0,1}"
# Number of connections per IP with range 24
netstat -tn | grep :80 | awk '{print $5}'| grep -v ':80' | cut -f1 -d: |cut -f1,2,3
sort | uniq -c| sort -n
# Clone all github repos of a user
curl -s "https://api.github.com/users/${USERNAME}/repos" | ruby -rubygems -e 'require
"json"; JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["ssh_url"]} ]}'
-d. |
441 / 658
442 / 658
# multimedia ping
continuar=true; while $continuar; do
if ping -c 3 [target_IP_address] 2>&1> /dev/null ;
then
mplayer [sound_file];
continuar=false; break;
fi; done
# Show package dependencies with apt
apt-cache depends <packagename>
# Monitoring a port connections
watch -n1 'netstat -tn | grep -P :22'
# dd with nice progress bar
dcfldd if=/dev/zero of=/dev/null
# Kill google chrome process
killall "Google Chrome"
# SSH with debug to troubleshoot any connection issues
ssh -v jsmith@remotehost.example.com
# Network Interfaces
awk '{print $1}' /proc/net/dev|grep :|sed "s/:.*//g"
# Filtering IP address from ifconfig usefule in scripts
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
# strace alternative for Mac OS X
dtruss [ -p <pid> | -n <pname> ]
# Run skype using your GTK theme
sudo sed -i 's/Exec=skype %U/Exec=skype --disable-cleanlooks -style GTK %U/'
/usr/share/applications/skype.desktop
# XKCD "now" wallpaper (http://xkcd.com/now)
convert http://imgs.xkcd.com/comics/now.png -negate /tmp/now.png ; DISPLAY=:0.0 awsetbg
-c /tmp/now.png
# Strip out Hungarian notation from a PHP file
cat file.php | perl -p -e 's/(\$|->)(str|arr|obj|int|flt|boo|bool|mix|res)([A-Z])/$1\L$3/g'
# Use the page up key to complete the command.
echo "\"\e[5~\": history-search-backward" >> ~/.inputrc
# Show the ordered header line (with field names) of a CSV file
function headers { head -1 $* | tr ',' '\12' | pr -t -n ; }
# Move all files untracked by git into a directory
git clean -n | sed 's/Would remove //; /Would not remove/d;' | xargs mv -t stuff/
# Open the last modified file of a certain type
open-command $(ls -rt *.type | tail -n 1)
443 / 658
444 / 658
my_home
ln -s -f
-b 100
# Remove branches that no longer exist from being shown via 'git branch -a'
git remote prune origin
# List contents of jar
LESSOPEN="| /usr/bin/lesspipe %s" less file.jar
# Find Files over 20Meg
find . -type f -size +20000k -print0 | xargs -0 du -h | awk -F"\t" '{printf "%s : %s\n", $2,
$1}'
445 / 658
446 / 658
447 / 658
448 / 658
449 / 658
"namespace\s.*\W"|less
450 / 658
451 / 658
452 / 658
453 / 658
human readable
# display directory
ls -d .*"/" *"/"
# Replace all environment variable references in files with environemnt variable values
perl -p -e 's/\$(\w+)/$ENV{$1}/g;' <files...>
# Prints out, what the users name, notifyed in the gecos field, is
getent passwd `whoami` | cut -d ':' -f 5
# Rename with regular expression and leading zeros
rename 's/result_([0-9]+)_([0-9]+)_([0-9]+)\.json\.txt/sprintf("%d%02d%02d.txt",
$3,$2,$1)/ge' result_*.txt
454 / 658
455 / 658
456 / 658
457 / 658
# Use wbinfo to output a table with basic user information from the default domain
controller.
for DOMAIN in $(wbinfo -m); do WBSEP=$(wbinfo --separator); ADSERVER=$(wbinfo ... (Read
description for full command)))
# Grep the process excluding the grep itself.
ps -ef | grep [t]clsh
# prints line numbers
458 / 658
459 / 658
460 / 658
461 / 658
462 / 658
# fomat/encode/escape xml
xml fo -e utf-8 file.xml | xml esc
# ll for mac
alias ll='ls -lisaG'
# Delete all files in folder without affecting load
find . -type f -exec echo echo rm {} '|' batch ';'|bash
# Show OSX Login Screen
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
# Space used by files listed by ls -lt
ls -lt | awk '{sum+=$5} END {print sum}'
# Add members of one group to another
dsquery group -samid "group_name" | dsmod group "cn=group_name",dc=example,dc=com" -addmbr
# Prevent overwriting file when using redirection
set -o noclobber
# Update the working tree to the latest git commit
git log -g --pretty=oneline | grep '}: commit' | awk '{print $1}' | head -1 | xargs git
checkout -f
# fix nvidia-settings display error
nvidia-settings -a AssociatedDisplays=0x00010000
# Which files/dirs waste my disk space
du -h / | grep -w "[0-9]*G"
# edit a executable script
vie(){vi $(which $1)}
# Execute git submodule update in parallel with xargs
git submodule status | awk '{print $2}' | xargs -P5 -n1 git submodule update --init
# Java app with dynamic classpath
java -jar app.jar -cp $(echo lib/*.jar | tr ' ' ':')
# Simple calendar from google spanning the width of the terminal
gcalcli --mon --width $((COLUMNS/8)) calw 2
# Show the network stats for a given day
sar -n DEV -f /var/log/sa/sa05 |awk '{if ($3 == "IFACE" || $3 == "eth0" || $2 == "eth0")
{print}}'
# Delete posts from MyBB Board as User
curl --cookie name=<cookie_value> --data-urlencode
name=my_post_key=<post_key>\&delete=1\&submit=Delete+Now\&action=deletepost\&pid=$c --useragent Firefox\ 3.5 --url http://url/editpost.php?
my_post_key=<post_key>\&delete=1\&submit=Delete+Now\&action=dele
# Export usernames and passwords from sslstrip log
grep -i -f password_tokens sslstrip.log | awk ' BEGIN { RS="&" } { print $1 }' | grep -i -f
tokens_file
463 / 658
464 / 658
465 / 658
';
466 / 658
467 / 658
468 / 658
469 / 658
470 / 658
471 / 658
472 / 658
473 / 658
474 / 658
475 / 658
476 / 658
| sed 's/[^ ]*
477 / 658
478 / 658
479 / 658
480 / 658
481 / 658
# Wait for Web service to spin up, aka alert me when the server stops returning a 503
while curl -dsL example.com 2>&1 | grep 503;do sleep 8;done;echo server up
# JVM Garbage Collector Stats
jstat -gc [jvmpid]
# Adds characters at the beginning of the name of a file
rename 's/.*/[it]$&/' *.pdf
# Convert Raw pictures to jpg
for img in $( ls *.CR2 ); do convert $img $img.jpg; done
# for loop with leading zero in bash 3
printf "%02u " {3..20}; echo
# Recursively search a directory tree for all .php .inc .html .htm .css .js files for a
certain string
find -type f -regex ".*\.\(js\|php\|inc\|htm[l]?\|css\)$" -exec grep -il 'searchstring' '{}'
+
# Convert DOS newlines (CR/LF) to Unix format
dos2unix <file>
# archlinux: clear the package cache of all packages
sudo pacman -Scc
# Copy files from one tree to another (say, project to project) while preserving their
directory structure.
cd ~/ruby/project_a ; find . -name "*profile*" -exec pax -rw {} ~/ruby/project_b/ \;
# extract element of xml
xmlstarlet sel -t -v "/path/to/element" file.xml
# Create a RAM Disk in OSX
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://8000000`
# mn ub
hbuu@
# Delete large amount of files matching pattern
sudo find . -name "*.csv" | xargs /bin/rm
# make a bunch of files based on a template file
echo "template file: ";read tpl;echo "new file(s separated w. space):"; read fl;touch
$fl;find $fl -exec cp -ap $tpl "{}" \;
# Recompress all files in current directory from gzip to bzip2
for gz in `find . -type f -name '*.gz' -print`; do f=`basename $gz .gz` && d=`dirname $gz`
&& echo -n `ls -s $gz` "... " && gunzip -c $gz | bzip2 - -c > $d/$f.bz2 && rm -f $gz && echo
`ls -s $d/$f.bz2`; done
# warped and shagadelic webcam view with gstreamer
gst-launch-0.10 v4l2src ! ffmpegcolorspace ! warptv ! ffmpegcolorspace ! autovideosink
482 / 658
# function for copy files with progress bar (using pv - pipe viewer)
cp_p() { if [ `echo "$2" | grep ".*\/$"` ]; then pv "$1" > "$2""$1"; else pv "$1" >
"$2"/"$1"; fi; }
# find files ending in *.log that contain both 'foo' and 'error'
grep -l foo $(grep -l error *.log)
# count processes with status
ps axu | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total
status D: "count}'
# Arch Linux sort installed packages by size
pacman -Qi $(pacman -Qq)|grep 'Name\|Size'| cut -d: -f2 | paste - - | column -t | sort -nk2
# Add spacer to left side of Dock
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacertile";}'; killall Dock
# Uptime in minute
uptime | awk -F ',' ' {print $1} ' | awk ' {print $3} ' | awk -F ':' ' {hrs=$1; min=$2;
print hrs*60 + min} '
# Convert from hexa to decimal
hexdec() { bc <<< "obase=10; ibase=16; $1"; }
# shorten one URL with an alias that you choose; type "tinyurl URL ALIAS"
tinyurl () { URL="$1";ALIAS="$2"; curl -s 'http://tinyurl.com/create.php?
source=indexpage&url='"$URL"'&submit=Make+TinyURL%21&alias='"$ALIAS" >/dev/null ;}
# Retry the previous command until it exits successfully
483 / 658
# tar+pbzip2 a dir
tar -c directory_to_compress/ | pbzip2 -vc > myfile.tar.bz2
484 / 658
485 / 658
486 / 658
487 / 658
*//' -e 's/
# Create a tar archive from a text list without trailing slash in directories
star -c -v -f myarchive.tar -no-dirslash list=list.txt
# Count the number of pages of all PDFs in current directory and all subdirs, recursively
find . -name "*.pdf" -exec pdftk {} dump_data output \; | grep NumberOfPages | awk '{s+=$2}
END {print s}'
# zip all folders separate zip files with named the folder's name.
eval `ls -1d * | awk '{print "zip -r "$1".zip "$1";"}'`
# turn on knoppix 7 touchpad Tap function (mouse clicks)
synclient TapButton1=1 TapButton2=2 TapButton3=3
# Grant sendas permission to a mailbox
Add-ADPermission "username_mailbox" -User "Domain\User" -Extendedrights "Send As"
# colored tail
tail -f FILE | grep --color=always KEYWORD
# Get the date field from syslog for a certain set of events
grep xxxx messages | cut -d ' ' -f 1,2,3
# List contact infomation for Domain list
whois -H $(cat ./list_of_domains) | awk 'BEGIN{RS=""}/Registrant/,/Registration Service
Provider:/ {print} END{print "----------------\n"}'
# Watch RX/TX rate of an interface in kb/s
488 / 658
489 / 658
490 / 658
# Replace all occurences of a pattern with another one from previous command
!!:gs/foo/bar
# Copy buffer from tmux into OS X clipboard
tmux show-buffer | pbcopy
# Visualize directory structure
tree
# Short Information about loaded kernel modules
lsmod | tail -n +2 | cut -d' ' -f1 | xargs modinfo | egrep '^file|^desc|^dep' | sed
-e'/^dep/s/$/\n/g'
# chef ssh
knife ssh name:* -x ec2-user -i ~/.ssh/aws-west.pem "hostname"
# find top 20 results in apache statistics for a specific month
awk '/Dec\/2012/ {print $1,$8}' logfile | grep -ivE '(.gif|.jpg|.png|favicon|.css|.js|
robots.txt|wp-l|wp-term)' | sort | uniq -c | sort -rn | head -n 20
# Opening & evaluating a SuperCollider file from commandline (Mac)
/Applications/SuperCollider/SuperCollider.app/Contents/Resources/sclang
~/path/to/your/scfile.scd
# Count music files in each directory
find . -type d -maxdepth 1 -print0 | xargs -0 -I{} sh -c 'find "{}" -type f | grep "ogg\|
mp3\|wav\|flac$" | wc -l | tr -d "\n"; echo " {}"'
# Get a PostgreSQL servers version
psql -h <SERVER NAME HERE> -c 'SELECT version();' | grep -v 'version\|---\|row\|^ *$' | sed
's/^\s*//'
# save a manpage to plaintext file
man -P cat ls > man_ls.txt
# amixer : raise volume and unmute if necessary
amixer -c 0 set Master 1+ unmute
491 / 658
# Create a tunnel from a remote server to the local machine using a specific source port
socat TCP-LISTEN:locport,fork TCP:XXX.XXX.XXX.XXX:YYY,sourceport=srcport
# How many lines in your PHP project without comments
find . -type f -name '*.php' | xargs cat | sed -re ':top /\/\*.*\*\// { s/\/\*.*\*\///g ; t
top }; /\/\*/ { N ; b top }' | awk '$0 !~ /^[\t[:space:]]*($|(\/\/)|(#))/' | wc -l
# Get the rough (german) time from Twitter by @zurvollenstunde
curl -s "http://search.twitter.com/search?from=zurvollenstunde&rpp=1" | grep -E '(Es ist
jetzt|ago)' | sed 's/<[^>]*>//g;s/[^[:digit:]]//g' | xargs | sed -e 's#\ #:#'
# progress bar for cp
progr
# Paste hardware list (hwls) in html format into pastehtml.com directly from console and
return URI.
$ pastebin(){ curl -s -S --data-urlencode "txt=$(cat)" "http://pastehtml.com/upload/create?
input_type=txt&result=address";echo;}
# check a list
for i in `wget
class="[^"]\+"
(whois $i|grep
492 / 658
493 / 658
494 / 658
# Create a csv file with '5-digits prefix' phone numbers, as well as occurrences per prefix
cut -d, -f1 /var/opt/example/dumpfile.130610_subscriber.csv | cut -c3-5 | sort | uniq -c |
sed -e 's/^ *//;/^$/d' | awk -F" " '{print $2 "," $1}' > SubsxPrefix.csv
# Convert multi layered TIFF file to multi page PDF document
convert multi_layer.tif -compress jpg multi_page.pdf
# simple single-lined git log
git log --pretty=oneline --abbrev-commit
# Sort lines on clipboard
pbpate | sort | pbcopy
# Search filenames with given pattern; each one is transfered via scp and if succesfull the
file is locally deleted. Ideal for filesystem quick maintenance
'ls -1 *<pattern>* | while read file; do scp $file user@host:/path/; if [[ $? -eq 0 ]]; then
rm $file; fi; done'
# avi to ogv (Ogg Theora)
ffmpeg2theora input.avi
# Add user to group on OS X 10.5
sudo dscl localhost -append /Local/Default/Groups/admin GroupMembership username
# Unix timestamp Solaris
/usr/bin/truss /usr/bin/date 2>&1 |
# Fix all the commit log messages from a user of a bad subversion client
for R in `svn log file:///path/repo | grep ^r | grep dude | cut -d' ' -f1 | cut -dr -f2`; do
svn ps svn:log --revprop -r $R "`svn pg svn:log --revprop -r $R file:///path/repo; perl -e
'print ".\n";' | fromdos`" file:///path/repo; done
# Remove all unused kernels with apt-get
apt-get remove $(dpkg -l | awk "/^ii linux-(image|headers)/ && ! /`uname -r`/ {print \$2}")
# Get the dir listing of an executable without knowing its location
ls -l =gcc
# DNS spoof with ettercap (etter.dns configured)
ettercap -i wlan0 -T -q -P dns_spoof -M ARP:remote // //
# Converts the output of disklabel from bytes to Gigabytes on FreeBSD
echo `disklabel mfid1s4 | sed -n '$p' | awk '{print $2}'` / 1024 / 1024 | bc -l
# Generate Qr code from contact file (or any other ASCII file)
qrencode -o contact.png ?`cat contact.vcs`?
# Grep recursively your Python project with color highlighting the result and line numbers
grep --color=always -nr 'setLevel' --include=*py | less -SRqg
# Convert red-cyan 3D anaglyph to side-by-side
convert infile.png \( +clone -channel GB -evaluate set 0 +channel \) +append -region
50%x100% -channel R -evaluate set 0 +channel outfile.png
# urldecoding
echo "q+werty%3D%2F%3B" | php -r "echo urldecode(file_get_contents('php://stdin'));"
495 / 658
496 / 658
# Mount a truecrypt drive from a file from the command line non-interactively
su -c "truecrypt --non-interactive truecrypt-file cryptshare -p PASSWORD"
# Emulate perl 'print "#" x 20, "\n"'
printf '%*s\n' 20 | tr ' ' '#'
497 / 658
498 / 658
$(find {} | wc -l)' \|
499 / 658
# Shows how many percents of all avaliable packages are installed in your gentoo system
echo $(echo 'scale=2; ' '100 * ' $(eix --only-names -I | wc -l) / $(eix --only-names | wc
-l) | bc -l)%
# Console clock
watch -n 1 :
# Use tcpdump to monitor all DNS queries and responses
sudo tcpdump -i en0 'udp port 53'
500 / 658
# compile source & then remove the dev tools you needed to install
dpkg-query -l > 1.lst; sudo apt-get install -y build-essential; ./configure; make; sudo
checkinstall -D make install; dpkg-query --list > 2.lst; diff 1.lst 2.lst | grep '^>' | awk
'{print $3}' | xargs sudo apt-get remove -y --purge
# A child process which survives the parent's death (Zsh version)
command &!
# Add all unversioned files to svn
svn add *
# Monitor specific process (ie apache) using Top
top -p `pidof apache2 | awk '{gsub(/[ ]/,",");print}'`
# Grep all your PDFs in a row
find -iname \*.pdf -print0 | xargs -0 pdfgrep -i "my search text"
# the system will display device manager command line utility, cte.
<devcon/>, <dnsstat/>, <dsget>, <dsmod>, <enml>dloal>,/<html></>
# grep directory and sub-directories
501 / 658
502 / 658
503 / 658
504 / 658
505 / 658
506 / 658
507 / 658
}; pwd; };
508 / 658
# Show numerical values for each of the 256 colors in bash for bold and normal fonts
for code in $(seq -w 0 255); do for attr in 0 1; do printf "%s-%03s %bTest%b\n" "${attr}" "$
{code}" "\e[${attr};38;05;${code}m" "\e[m"; done; done | column -c $((COLUMNS*2))
# Ensure path permissions from '.' prior to root
pwd|grep -o '/'|perl -ne '$x.="./.";print`readlink -f $x`'|xargs -tn1 chmod 755
# Backup all MySQL Databases to individual files
mysql -e 'show databases' -s --skip-column-names | egrep -v "^(test|mysql|
performance_schema|information_schema)$" | parallel --gnu "mysqldump --routines {} >
{}_daily.sql"
# Print out the contents of a Git repository (useful for broken repositories)
find .git/objects -type f -printf "%P\n" | sed s,/,, | while read object; do echo "=== $obj
$(git cat-file -t $object) ==="; git cat-file -p $object; done
# Show total cumulative memory usage of a process that spawns multiple instances of itself
ps -eo pmem,comm | grep chrome | cut -d " " -f 2 | paste -sd+ | bc
# Update obsolete CVS Root files
find cvsdir -name Root -exec sed -i 's/oldserver/newserver/' {} \;
# Remove/replace newline characters.
sed ':a;N;$!ba;s/\n/ /g'
# Create a symbolic link tree that shadows a directory structure
find /home/user/doc/ -type d -printf "mkdir -vp '/home/user/Dropbox%p'\n" -o -type f -printf
"ln -vs '%p' '/home/user/Dropbox%p'\n" | sh
# Record Alexa Traffic Stats of your Website
x=1 ; while [ $x -le 10 ] ; do lynx -dump http://www.alexa.com/siteinfo/http://[YOUR
WEBSITE] | grep Global | sed 's/
\|Global\|\,//g' >> /var/log/alexa-stats.txt ; sleep 5h ;
done &
509 / 658
510 / 658
511 / 658
512 / 658
513 / 658
514 / 658
515 / 658
516 / 658
517 / 658
518 / 658
# Find the 10 lusers winners of the "I take up the most disk space" award
du -sh /home/*|sort -rh|head -n 10
# avoid ssh hangs using jobs
for host in $MYHOSTS; do ping -q -c3 $H 2>&1 1>/dev/null && ssh -o 'AllowedAuthe ntications
publickey' $host 'command1; command2' & for count in 1 2 3 4 5; do sleep 1; jobs | wc -l |
grep -q ^0\$ && continue; done; kill %1; done
# Get the /dev/disk/by-id fragment for a physical drive
ls -l /dev/disk/by-id/ | grep '/sda$' | grep -o 'ata[^ ]*'
# Go get those photos from a Picasa album (full size)
wget -O - "[PICASA ALBUM RSS LINK]" |sed 's/</\n</g' | grep media:content |sed
's/.*url='"'"'\([^'"'"']*\)'"'"'.*$/\1/' |awk -F'/' '{gsub($NF,"d/"$NF); print $0}'|wget -i
# List your largest installed packages (on Debian/Ubuntu)
dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' `aptitude --displayformat '%p' search '?installed!?automatic'` | sort -k 2 -n | grep -v deinstall | awk
'{printf "%.3f MB \t %s\n", $2/(1024), $1}'
# vi show line numbers
519 / 658
printf "\b\b
520 / 658
521 / 658
522 / 658
523 / 658
524 / 658
525 / 658
526 / 658
527 / 658
528 / 658
# creates a bash function to remove certain lines from SSH known_hosts file
function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }
# Save and merge tcsh history across windows and sessions
Use history -S in your .logout file
# use perl instead of sed
echo "sed -e"|perl -pe 's/sed -e/perl -pe/'
# Join lines
cat file | tr -d "\n"
# List your installed Firefox extensions
$grep -hIr -m 1 em:name ~/.mozilla/firefox/*.default/extensions|sed 's#\s*##'|tr '<>='
'"""'|cut -f3 -d'"'|sort -u
# Length of longest line of code
wc -L files
# grep compressed log files without extracting
529 / 658
530 / 658
531 / 658
awk -e '{}'
532 / 658
533 / 658
534 / 658
| grep
# Replace all the spaces in all the filenames of the current directory and including
directories with underscores.
ls -1 | while read file; do new_file=$(echo $file | sed s/\ /_/g); mv "$file" "$new_file";
done
# Replaces every ocurrences of 'old' for 'new' in all files specified
perl -i -pe "s/old/new/g" *
# Reverse DNS lookups
sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).in-addr.arpa domain name pointer\
(.*\)\./\4.\3.\2.\1\5/' \ lookups.txt
# FInd out what branches a specific commit belongs to
git branch --contains <commit sha1 id> | sed -e 's/^[ *]*//'
# Switch to windows using gpicker
wmctrl -i -a `wmctrl -l -x | gpicker -d "\n" -n "\n" - | awk '{print $1}'`
# List of syscalls (for 32/64 bits systems)
egrep '__NR_' /usr/include/asm/unistd_`getconf -a | awk '$1~/^WORD/{print $2}'`.h | sed -e
's/^#define __NR_//' | column -t
# retrieve GMT time from websites ( generally accruate )
w3m -dump_head www.fiat.com | awk '/Date+/{print $6, $7}'
# intersection between two files
sort file1 file2 | uniq -d
# Remove a line from a file using sed (useful for updating known SSH server keys when they
change)
perl -p -i -e 's/.*\n//g if $.==2' ~/.ssh/known_hosts
# List OSX applications and versions.
535 / 658
536 / 658
537 / 658
538 / 658
539 / 658
540 / 658
541 / 658
# Deletes all branches in a git repository except next and master (clean git repo)
git branch -D `git branch | awk '{ if ($0 !~ /next|master/) printf "%s", $0 }'`
# show physical disk using
df -x tmpfs | grep -vE "(gvfs|procbususb|rootfs)"
# Batch Convert MP3 Bitrate
mkdir save && for f in *.mp3; do lame -b xxx "$f" ./save/"${f%.mp3}.mp3"; done
# Generate an XKCD #936 style 4 word password
Amharic software
# reverse order of file
tac $FILETOREVERSE
# Notify by text-message when command completes
sleep 15 ; `echo "done" | mail -s "done" 4158575309@txt.att.net`
# find forms in a symfony 1.2 project
find apps/ -name "*.svn-base" -prune -o -print -name "*.php" | xargs grep -E 'new .+Form\('
# Kill processes hogging up CPU (Flash after resume)
top -bn 1 | awk '{if($1 ~ /^[0-9]+$/ && $9 > 97) {print $1;exit}}'|xargs kill
542 / 658
543 / 658
544 / 658
545 / 658
# Find and delete thunderbird's msf files to make your profile work quickly again.
find ~/.thunderbird/*.default/ -name *.msf | sed 's/ /\\ /g' | xargs rm {} \;
# delete duplicate files
fdupes -rdN $folder
# Convert a PKCS#8 private key to PEM format
openssl pkcs8 -inform DER -nocrypt -in [priv key] -out [pem priv key]
546 / 658
547 / 658
548 / 658
549 / 658
550 / 658
551 / 658
552 / 658
# Use curl on Windows to bulk-download the Savitabhabhi Comic Strip (for Adults)
for /L %%x in (1,1,16) do mkdir %%x & curl -R -e http://www.kirtu.com -o %%x/#1.jpg
http://www.kirtu.com/toon/content/sb%x/english/sb%x_en_[001-070].jpg
# Unlock and access an ssh key keychain entry from CLI
security unlock-keychain; security find-generic-password -ga "/Users/mruser/.ssh/id_dsa"
2>&1 > /dev/null
553 / 658
554 / 658
555 / 658
$I ENGINE
556 / 658
557 / 658
| python
558 / 658
-query localhost :5
559 / 658
560 / 658
561 / 658
_TITLEMSG=`printf "%$(($
_X=$(((_X+1)%$
m=$d/*.mp4
f=$d/*.flv
if [ "$1" ==
ls -1t $m $f >$p
fi
mplayer
562 / 658
563 / 658
-center
# free some harddrive space by garbage collecting in all your git repos
find . -maxdepth 2 -type d -name '.git' -print0 | while read -d ''; do (cd "$REPLY"; git
gc); done
# Import an entire directory into clearcase
ct mkelem -nc `find ./ -name "*" | xargs`
# Windows person acting like an idiot in Linux?
export PS1="C:\\>"; clear
# bash function to "highlight" tabs and linebreaks
hl-nonprinting () { local C=$(printf '\033[0;36m') R=$(printf '\033[0m'); sed -e "s/\t/$
{C}▹&$R/g" -e "s/$/${C}⁋$R/";}
# Btrfs: Find file names with checksum errors
dmesg | grep -Po 'csum failed ino\S* \d+' | sort | uniq | xargs -n 3 find / -inum 2>
/dev/null
# webcam player in ascii art
gst-launch v4l2src ! aasink
# gmail safe folder
find | egrep "\.(ade|adp|bat|chm|cmd|com|cpl|dll|exe|hta|ins|isp|jse|lib|mde|msc|msp|mst|
pif|scr|sct|shb|sys|vb|vbe|vbs|vxd|wsc|wsf|wsh)$"
# Get the rough (german) time from Twitter
echo -e "Berlin Date/Time is" `TZ=GMT-2 /bin/date \+%c`
# bash function to highlight non-printing characters: tab, newline, BOM, nbsp
hl-nonprinting () { local C=$(printf '\033[0;36m') B=$(printf '\033[0;46m') R=$(printf
'\033[0m') np=$(env printf "\u00A0\uFEFF"); sed -e "s/\t/${C}▹&$R/g" -e "s/$/$
{C}⁋$R/" -e "s/[$np]/${B}& $R/g";}
# Transforms a file to all uppercase.
perl -i -ne 'print uc $_' $1
# Remove all the files except abc in the directory
find * ! -name abc | xargs rm
# Easily find an old command you run
cat $HISTFILE | grep command
# Disable graphical login on Solaris
svcadm disable cde-login
# Prints files
lpr file
# revert one or more changesets in svn
svn merge -r 1337:1336 PATH PATH
564 / 658
{} -c
# Parse logs for IP addresses and how many hits from each IP
cat "log" | grep "text to grep" | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -n
100
# Bold matching string without skipping others
sed 's/pattern/^[[1m&^[[0m/g'
# Length of longest line of code
perl -ne 'push(@w, length); END {printf "%0d\n" , (sort({$b <=> $a} @w))[0]}' *.cpp
# View external IP
wget -q ip.nu && cat index.html
# Rip audio tracks from CD to wav files in current dir
cdparanoia -B
# Continue a current job in the background
<ctrl+z> %1 &
# Give information about your graphic chipset
lshw -C display
# Email if you disk is over 90%
HDD=$(df | awk ' NR>3 (S=$5) (M=$6) { if (S>90) print "Your Systems "M" is """S" Full" }
') ; [[ $HDD ]] && echo "$HDD" | mail -s "Hard-Drives Full" TO@EMAIL.com -- -f
FROM@EMAIL.com >/dev/null
# Print line numbers
565 / 658
566 / 658
567 / 658
# Filenames ROT13
for each in *; do file="$each."; name=${file%%.*}; suffix=${file#*.}; mv "$each" "$(echo
$name | rot13)${suffix:+.}${suffix%.}"; done
# Sort files in $PWD by year in filename
ls --color=never -1| grep -E "[0-9]{4}"|sed -re "s/^(.*)([0-9]{4})(.*)$/\2 \1\2\3/" | sort
-r
# display only tcp
netstat -4tnape
# wget, tar xzvf, cd, ls
wtzc () { wget "$@"; foo=`echo "$@" | sed 's:.*/::'`; tar xzvf $foo; blah=`echo $foo | sed
's:,*/::'`; bar=`echo $blah | sed -e 's/\(.*\)\..*/\1/' -e 's/\(.*\)\..*/\1/'`; cd $bar; ls;
}
# Split a file into equal size chunks and archive to (e)mail account.
split -b4m file.tgz file.tgz. ; for i in file.tgz.*; do SUBJ="Backup Archive"; MSG="Archive
File Attached"; echo $MSG | mutt -a $i -s $SUBJ YourEmail@(E)mail.com
# Find Out My Linux Distribution Name and Version
if [ -x /etc/*-release ]; then cat /etc/*-release ; else cat /etc/*-version ; fi
# Transfer files with rsync over ssh on a non-standard port.
rsync -P -e 'ssh -p PORT' SRC DEST
# Print environment information.
perl -e 'print "$_=$ENV{$_}\n" for keys %ENV'
# Delete Text Editor's Backup
find . -name "*~" -exec rm {} \;
# Greets the user appropriately
echo -e "12 morning\n15 afternoon\n24 evening" | awk '{if ('`date +%H`' < $1) print "Good "
$2}'
# convert uppercase to lowercase
tr '[:upper:]' '[:lower:]' < input.txt > output.txt
# ...if you have sudo access, you could just install ssh-copy-id (Mac users: take note.
this is how you install ssh-copy-id )
568 / 658
-l 5; sleep 1; done
569 / 658
570 / 658
571 / 658
572 / 658
573 / 658
574 / 658
575 / 658
head -1037
+%s)) | toilet -f
576 / 658
577 / 658
# Extract all 7zip files in current directory taking filename spaces into account
7za x \*.zip
# NMAP_UNDERGROUND_VECTRA
nmap -sS -O -v -oS - 192.168.2.0/24
# Quick alias for playing music.
alias mux='clear && cd ~/Music/ && ls && echo -n "File> " && read msi && mplayer ~/Music/
$msi'
# convert Unix newlines to DOS newlines
sed 's/$'"/`echo \\\r`/"
# What is my ip?
lynx --dump "http://checkip.dyndns.org"
# What is my ip?
w3m miip.cl | grep ip
# A little bash daemon =)
echo "Starting Daemon"; ( while :; do sleep 15; echo "I am still running =]"; done ) &
disown -h $!
# Generate an XKCD #936 style 4 word password
cat /usr/share/dict/words | grep -P ^[a-z].* | grep -v "'s$" | grep -Pv ^.\{1,15\}$ | shuf
-n4 | tr '\n' ' ' | sed 's/$/\n/'
# cd canonical (resolve any symlinks)
alias cdc='cd `pwd -P`'
# What is my ip?
w3m http://amit-agarwal.co.in/mystuff/getip_txt.php will return the ip in text format.
# Burn an ISO on commandline with wodim instead cdrecord
wodim foo.iso
# Show live HTTP requests being made on OS X
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
578 / 658
579 / 658
580 / 658
581 / 658
582 / 658
583 / 658
584 / 658
---
585 / 658
586 / 658
587 / 658
--password="pass"
588 / 658
589 / 658
# MS-DOS only: Loop over array of system variable with each var containing multiple values
FOR /F "tokens=3* delims=[]=," %A IN ('SET ARRAY[') DO ( echo %A -- %B )
# Convert files with CR-terminated lines (as created by Mac OS X programs) into NLterminated lines suitable for Unix programs
function crtonl { perl -i -ape 's/\r/\n/g;' $* ; }
# Read just the IP address of a device
/sbin/ifconfig eth0 | grep "inet addr" | sed -e 's/.*inet addr:\(.*\) B.*/\1/g'
# Ruby - nslookup against a list of IP`s or FQDN`s
ruby -e 'File.foreach("list") {|i| print `nslookup #{i}`}'
590 / 658
591 / 658
592 / 658
593 / 658
594 / 658
595 / 658
596 / 658
597 / 658
598 / 658
599 / 658
mysql>source FILENAME
600 / 658
601 / 658
602 / 658
603 / 658
604 / 658
605 / 658
606 / 658
607 / 658
| sh |
608 / 658
609 / 658
610 / 658
611 / 658
612 / 658
613 / 658
/'\'' -e
done
614 / 658
/g'
615 / 658
616 / 658
-e '/^$/d' -e '/^\/\/.*/d' -e
617 / 658
618 / 658
from
619 / 658
# show you the time when you lost the remote server.
ssh remotehosts;date
# sorts /dev/random
find /dev/ -name random -exec bash -c '[ -r $0 -a -w $0 ] && dd if=$0 | sort | dd of=$0'
{} \;
# Remove executable bit from all files in the current directory recursively, excluding other
directories, firm permissions
find . -type f -exec chmod a-x {} \;
# remove unneeded configuration files in debian
dpkg-query -l| grep -v "ii " | grep "rc " | awk '{print $2" "}' | tr -d "\n" | xargs
aptitude purge -y
# Are the two lines anagrams?
s(){ sed 's/./\n\0/g'<<<$1|sort;};cmp -s <(s foobar) <(s farboo)||echo -n "not ";echo
anagram
# Print last modified time in 'date -- file' format
ls -alt /directory/ | awk '{ print $6 " " $7 " -- " $9 }'
# mount a folder tmpfs
tmpfs(){ cd /;for i in $@;do tar czvf /tmp/$i $i;mount -t tmpfs tmpfs /$i;tar xvzf /tmp/
$i;cd ~ ;}# usage: tmpfs etc var
# Kill process by searching something from 'ps' command
ps h -o pid,command | grep 'TEXT' | sed 's/^ \+//' | cut -d ' ' -f 1 | xargs -n 1 kill
# tty columns
col1(){ case $# in 0)echo col1 col-length;;*) sed 's/\(.\{'"$1"'\}\)\(.*\)/\1/' esac;}
# Enable Hibernate in OS X
sudo pmset -a hibernatemode 1
# Kill process by searching something from 'ps' command
ps ux|grep <process name>|awk '{print $2}'|xargs -n 1 kill
# Remove current directory
removedir () { echo "Deleting the current directory $PWD Are you sure?"; read human; if
[[ "$human" = "yes" ]]; then blah=$(echo "$PWD" | sed 's/ /\\ /g'); foo=$(basename "$blah");
rm -Rf ../$foo/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
# ssh Publickey auf remote Rechner anh?ngen
cat .ssh/id_rsa.pub | ssh user@server "cat >>.ssh/authorized_keys2"
# Ignore the specified signal
trap '' 1 2 20 24(signal number)
620 / 658
# journaling directories
mkdir `date | sed 's/[: ]/_/g'`
# 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# Play random playlist
gst123 -z **/*
# Remove all files previously extracted from a tar(.gz) file.
for i in $(tar -tf <file.tar.gz>); do rm $i; done;
# greps the man pages to find utilities
apropos keyword
# Combining text files into one file
cat file1 ... fileN > combinedFile;
# Show the number of current httpd processes
621 / 658
622 / 658
# show ip
ip a
# Creating a pseudo-random password
perl -e 'print crypt("PASSWORD",int(rand(128))).$/;'
# 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}'
# extract a certain number of lines from a file and dump them to another file
grep '' -m X file1 > file2
# See smbstatus all the time
while (( $i != 0 )) { smbstatus; sleep 5; clear }
# !$ - The last argument to the previous command
svn status app/models/foo.rb; svn commit -m "Changed file" !$
# Display default values on Foundry (Brocade) RX and MLX BigIron L3 (routers & switches)
sh default values
# kill all pids from $PID
PID=httpd ; ps aux | grep $PID | grep -v grep | awk '{print $2}'
| xargs kill -9
623 / 658
# Replace spaces with tabs & format file source recursively within a directory
find . -type f -name \*.php | while IFS="" read i; do expand -t4 "$i" > "$i-"; mv "$i-"
"$i"; done
# Find which version of Linux You are Running
lsb_release -d
# Display RSTP (802.1W) Info. on on Foundry (Brocade) RX and MLX BigIron L3 (routers &
switches)
show 802-1w
# Counting the source code's line numbers C/C++ Java
find /usr/include/ -name '*.[c|h]pp' -o -name '*.[ch]' -exec cat {} \;|wc -l
# A death cow thinking in your fortune cookie
fortune -s -c -a | cowthink -d -W 45
# zip all files in a directory, one file per zip
for i in $( find . ); do
echo zipping file: $i
624 / 658
(encode.sh)
# Remove everyting in a text file. Useful to fix ssh host key warnings
> ~/.ssh/known_hosts
# Graphical display of wireless links
wmwave
# Press Any Key to Continue
read enterKey
# verify a file using its detached signature
gpg --verify file.txt.asc file.txt
# Google Tasks webapp using Chromium Browser
alias gtasks='chromium-browser --app=https://mail.google.com/tasks/ig'
# decrypt file.txt.gpg using my private key
gpg -d file.txt.gpg -o file.txt
# colorize and continuously tail two files
tail -f to.log | colorize.pl +l10:".*" &
# Quick findstring recursively in dirs (Alias from long find with xargs cmd)
alias findstring="find . -type f -print | xargs grep $1"
625 / 658
626 / 658
627 / 658
-e 's/r-x/5/g' -e
# Calculate the the last day of a month +/- from current month
date -j -v1d -v-0m -v-1d +'%m %d %Y'
# Random Number Between 1 And X
echo "$(od -An -N4 -tu4 /dev/urandom) % 5 + 1" | bc
# Super Paste
(echo "" | xsel -o) ; (programa | wgetpaste -s dpaste | awk '{print $7}' | xsel -ai)
# Get your external IP address
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
# Press Any Key to Continue
echo -n "Press any key to continue..." && read
# Show the meta information on a package (dependency , statuts ..) on debian derivative
distro
aptitude show packages_name
# Unzip multi-part zip archive
tar -xfv archive.zip
# clean up memory on linux (fedora)
sync; echo 3 > /proc/sys/vm/drop_caches
628 / 658
`; done
629 / 658
630 / 658
bytes
ever
two seconds.
631 / 658
632 / 658
633 / 658
634 / 658
635 / 658
636 / 658
637 / 658
638 / 658
639 / 658
640 / 658
641 / 658
642 / 658
643 / 658
644 / 658
645 / 658
646 / 658
# Check syntax of cron files (by restarting the service and checking the logs)
/etc/init.d/cron restart && tail -100 /var/log/syslog
# Search for available software on a debian package system (Ubuntu)
aptitude search NAME
# Private Character Editor (Windows 2000+XP)
eudcedit
# download a specific file
curl -f -O http://pcbsd.fastbull.org/7.0.2/i386/PCBSD7.0.2-x86-DVD.iso
# Download all files under http://codeigniter.com/user_guide/ to the current directory
svn co http://svn.ellislab.com/CodeIgniter/trunk/user_guide
# Simple calculus
read c; while [ -n "$c" ]; do clear; echo -e "$c = "$(echo "$c" |bc -l)"\n"; read c; done
# Flip from one directory to another
cd # Kill all processes matching a given name
ps axww | grep SomeCommand | awk '{ print $1 }' | xargs kill
# Go to the created directory after using mkdir
mkdir() { /bin/mkdir $@ && eval cd "\$$#"; }
647 / 658
# emptying a file
cat /dev/null >filename
# Creating ISO Images from Audio CD
cat /dev/scd0 > ~/audio_image.iso
# analyze traffic remotely over ssh w/ wireshark
sudo ssh -Y remoteuser@remotehost sudo wireshark
648 / 658
649 / 658
650 / 658
| grep broken
651 / 658
652 / 658
653 / 658
654 / 658
655 / 658
# find out who you logged onto the machine as -- and not just who you are now
who am i
# Eject the CD Rom Device
while true; do eject /dev/cdrom && eject -t /dev/cdrom; done
# To display a listing of files and directory
ls -l
# To list all files in your home directory
ls ~
# listar arquivos com permiss?o de acesso
656 / 658
657 / 658
# creates balls
touch balls
# ls short hand
l
# To list all files in your home directory
ls -l ~
# Convert Windows/DOS Text Files to Unix
Convert Windows/DOS Text Files to Uni
# test
w3m
# List all files & directories in the current directory
ls -la
# hello Command-line-fu
perl -e 'print "Hello World!", "\n";'
# Install Apache 2 on centOS.
yum install httpd
# test haha
du -sh
# Get back to the root directory of a Windows drive (like c:\)
cd \
# How to send parameters to a batch file
test.bat parm1 parm2 parm3
# Mass Suspends Cpanel Users and Redirects to Rick Roll
/scripts/rickrollyes
# get all the data about your IP configuration across all network cards
ipconfig /all
# facebook
ping www.facebook.com
# The 1 millionth fibonacci number
time echo 'n=1000000;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--)
{c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
# The absolutely fastest nth fibonacci number
time echo 'n=70332;m=(n+1)/2;a=0;b=1;i=0;while(m){e[i++]=m%2;m/=2};while(i--)
{c=a*a;a=c+2*a*b;b=c+b*b;if(e[i]){t=a;a+=b;b=t}};if(n%2)a*a+b*b;if(!n%2)a*(a+2*b)' | bc
# The end of time
date -ud @$[2**31-1]
658 / 658