The top 30 Linux shell tricks
Run the last command as root | sudo !! |
Serve current directory tree at http://$HOSTNAME:8000/ | python -m SimpleHTTPServer |
Runs previous command but replacing | echo “Hello Morld” |
^Morld^World | |
echo “Hello World” | |
Rapidly invoke an editor to write a long command | [ctrl+x e] |
Place the argument of the most recent command on the shell | ‘ALT+.’ or ‘ .’ |
Salvage a borked terminal | reset |
List currently mounted filesystems in nice layout | mount | column -t |
Get your external IP address | curl ifconfig.me |
Execute a command at a given time | echo “ls -l” | at midnight |
Output your microphone to a remote computer’s speaker | dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp |
Type partial command, check something, resume typing | vi /etc/ssh/ [ctrl+u] |
ls -lisa /etc/ssh/ | |
[ctrl+y] vi /etc/ssh/ssh_config | |
Mount folder/filesystem through SSH | sshfs name@server:/path/to/folder /path/to/mount/point |
Mount a temporary ram partition | mount -t tmpfs tmpfs /mnt -o size=1024m |
Download an entire website | wget –random-wait -r -p -e robots=off -U mozilla http://www.example.com |
Clear the terminal screen | [ctrl+l] |
Compare a remote file with a local file | ssh user@host cat /path/to/remotefile | diff /path/to/localfile – |
Update twitter via curl | curl -u user:pass -d status=”Tweeting from the shell” http://twitter.com/statuses/update.xml` |
SSH connection through host in the middle | ssh -t reachablehost ssh unreachablehost |
Close shell keeping all subprocess running | disown -a && exit |
Make ‘less’ behave like ‘tail -f’ | less +F somelogfile |
Put a console clock in top right corner | while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done & |
Shutdown a Windows machine from Linux | net rpc shutdown -I ipAddressOfWindowsPC -U username%password |
List of commands you use most often | history | awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head |
32 bits or 64 bits? | getconf LONG_BIT |
Set audible alarm when an IP address comes online | ping -i 60 -a IP_address |
Reboot machine when everything is hanging | <alt> + <print screen/sys rq> + <R> – <S> – <E> – <I> – <U> – <B> |
Simulate typing | echo “You can simulate on-screen typing just like in the movies” | pv -qL 10 |
Quickly rename a file | mv filename.{old,new} |
Escape any command aliases | [command] |
Delete all files in a folder that don’t match a certain file extension | rm !(.foo|.bar|*.baz) |
Reuse all parameter of the previous command line | !* |
Sharing file through http 80 port | nc -v -l 80 < file.ext |
Display a block of text with AWK | awk ‘/start_pattern/,/stop_pattern/’ file.txt |
Kills a process that is locking a file | fuser -k filename |
Display all current terminal settings | stty -a |
Type a string, hit [ctrl+d] and see the ASCII codes | od -cx |
Similar Posts:
- how to export zimbra data cheat sheet
- Bash script Check If Host Is Reachable
- Add system user and generate RSA keypair + sudoers
818