Linux tips and tricks

Why?

The terminal of UNIX based operating systems is insanely powerful, hence owning this power takes a lifetime. While learning it there are few tips and tricks that you can keep handy which will make you super productive. This document would be forever in Work in Progress mode and as I keep coming across any tips, I’ll be documenting them here.

tips

  • Sometimes we need super-user (sudo) privilege to run a command, but we realize it only after executing it. Hence when we try to run the command again we either rewrite the entire command or use the up arrow key to get it again then edit it. But there is a simple way to do it. Use sudo !! to run the previously executed command with sudo privilege.
  • How to list the last three newly created files in a directory?
    ls -ltr | head -3
  • How to send last three newly created files in a directory to a server?
    scp `ls -ltr | head -3` username@<ip>:<location>