linux shell tricks Cheat Sheet

0
(0)

The top 30 Linux shell tricks

Run the last command as rootsudo !!
Serve current directory tree at http://$HOSTNAME:8000/python -m Simple­HTT­PSe­rver
Runs previous command but replacingecho “­Hello Morld”
^Mor­ld­^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 terminalreset
List currently mounted filesystems in nice layoutmount | column -t
Get your external IP addresscurl ifconf­ig.me
Execute a command at a given timeecho “ls -l” | at midnight
Output your microphone to a remote computer’s speakerdd if=/de­v/dsp | ssh -c arcfour -C userna­me@host dd of=/de­v/dsp
Type partial command, check something, resume typingvi /etc/ssh/ [ctrl+u]
ls -lisa /etc/ssh/
[ctrl+y] vi /etc/s­sh/­ssh­_co­nfig
Mount folder/filesystem through SSHsshfs name@s­erv­er:­/pa­th/­to/­folder /path/­to/­mou­nt/­point
Mount a temporary ram partitionmount -t tmpfs tmpfs /mnt -o size=1­024m
Download an entire websitewget –rand­om-wait -r -p -e robots=off -U mozilla http:/­/ww­w.e­xam­ple.com
Clear the terminal screen[ctrl+l]
Compare a remote file with a local filessh user@host cat /path/­to/­rem­otefile | diff /path/­to/­loc­alfile –
Update twitter via curlcurl -u user:pass -d status­=”Tw­eeting from the shell” http:/­/tw­itt­er.c­om­/st­atu­ses­/up­dat­e.xml`
SSH connection through host in the middlessh -t reacha­ble­host ssh unreac­hab­le­host
Close shell keeping all subprocess runningdisown -a && exit
Make ‘less’ behave like ‘tail -f’less +F somelo­gfile
Put a console clock in top right cornerwhile sleep 1;do tput sc;tput cup 0 $(($(tput cols)-­29)­);d­ate­;tput rc;done &
Shutdown a Windows machine from Linuxnet rpc shutdown -I ipAddr­ess­OfW­ind­owsPC -U userna­me%­pas­sword
List of commands you use most oftenhistory | awk ‘{a[$2­]++­}EN­D{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 onlineping -i 60 -a IP_add­ress
Reboot machine when everything is hanging<a­lt> + <print screen/sys rq> + <R> – <S> – <E> – <I> – <U> – <B>
Simulate typingecho “You can simulate on-screen typing just like in the movies­” | pv -qL 10
Quickly rename a filemv filena­me.{­ol­d,new}
Escape any command aliases[com­mand]
Delete all files in a folder that don’t match a certain file extensionrm !(.fo­o|.ba­r|*.baz)
Reuse all parameter of the previous command line!*
Sharing file through http 80 portnc -v -l 80 < file.ext
Display a block of text with AWKawk ‘/star­t_p­att­ern­/,/­sto­p_p­att­ern/’ file.txt
Kills a process that is locking a filefuser -k filename
Display all current terminal settingsstty -a
Type a string, hit [ctrl+d] and see the ASCII codesod -cx

Similar Posts:

818

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top