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.)
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.
https://mosh.org/ instead of SSH! http://ohmyz.sh/ with several plugins.
A good one is: find . -type f -iname "*.something" -del
; which recursively finds and deletes files. find
has many neat tricks and is a good one to have handy.
du
for disk usage, along with the --max-depth
and -h
flags will give you a nice overview if you are trying to find what is taking up space. -c
will give you a grand total at the end.
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 jobsrsync
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 jobsrsync
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 jobsrsync
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 jobsrsync
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 jobsPrinting CRC checksum and byte count of a file
cksum foo.txt
File status output
stat foo.txt
Get the last modified date of a file
echo $(stat -c %y foo.bar)
Generating tar.gz files with current date/time name pattern
tar -czf $(date +%Y%m%d%H%M%S).tar.gz foo
Get the process list ordered by memory and cpu usage:
clear; ps -auxf | sort -nr -k 4 | head -10
Which :)
which name, for instance where is the dnf command on fedora… which dnf gives /usr/bin/dnf
Which :)
which name, for instance where is the dnf command on fedora… which dnf gives /usr/bin/dnf
Just typed
calendar
in Ubuntu, it brought a list of major events in history that happened today. Good general knowledge.Just typed
calendar
in Ubuntu, it brought a list of major events in history that happened today. Good general knowledge.You can even use sed (I think) to alter the command:
!!:s/foo/bar
@m1025 Forgot about
calendar
! Nice shout out.