In the same vein as my previous question about bash aliases, what are your favorite command line tricks? What command has saved you the most time? What bash features did you never realize existed and now use daily and can’t live without?
Of course, there are the classics:
!!
- Re-runs the last command you enteredsudo !!
- Re-runs the last command you entered as a super userWhat are yours? (No cheating.)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
screen
is one of my favorites. You can do so many things with it. It’s really handy when you want something to keep running after you disconnect from SSH. To disconnect a runningscreen
pressctrl + a, ctrl + d
. To see your screensscreen -list
. To restore onescreen -r [somescreenname]
Ctrl+r i.e. reverse search is my favorite.
rsync
for moving stuffwget
is great (especially with the-c
(continue) flag)flock
for making sure your cron job is only running one instance at any given time$()
for getting the output from a command that was mentioned earlier is great, and you can alsorename
command is great for bulk-renaming jobs