Are you making most out of the Linux? There are lots of helpful features which appears to be time saving Tips and Tricks for many of Linux Users. Sometimes these time saving Tips and Tricks become the need. They help you to get productive with the same set of commands yet with enhanced functionality.
Here are some of my favorites time-saving tips that every Linux user should know :
- Better way to change directory:
If you are a command-line user, autojump is a must have package. You can change directory by just specifying a part of directory name. You can also use jumpstat to get a statistics of your directory jumps.
$ j log /var/log $ j ard /home/ab/work/arduino
- Switching between Windows: The windows you create in screen are numbered starting from zero. You can switch to a window by its number. For example, jump to the first window with Ctrl-a 0, the second window with Ctrl-a 1 and so on. It’s also very convenient to switch to the next and previous windows with Ctrl-a n and Ctrl-a p respectively.
Ctrl-a 0 Ctrl-a 1
- Need to execute the last command with sudo, use sudo !!
ls -l /root sudo !! # This is equivalent to sudo ls -l /root
- Quickly locate a file on disk:
- System debugging:
- To know disk/cpu/network status, use iostat, netstat, top (or the better htop), and (especially) dstat. Good for getting a quick idea of what’s happening on a system.
- To know memory status, run and understand the output of free and vmstat. In particular, be aware the “cached” value is memory held by the Linux kernel as file cache, so effectively counts toward the “free” value.
- Java system debugging is a different kettle of fish, but a simple trick on Sun’s and some other JVMs is that you can run kill -3 and a full stack trace and heap summary (including generational garbage collection details,which can be highly informative) will be dumped to stderr/logs.
- Use mtr as a better traceroute, to identify network issues.
- For looking at why a disk is full, ncdu saves time over the usual commands like
du -sk *
- To find which socket or process is using bandwidth, try iftop or nethogs.
- Free up disk space: bleachbit is a neat utility to find and remove files based on application specific knowledge.
- Undelete for console: libtrash provides trashcan/recycle-bin like functionality for console users.
- Mute / Unmute Sound:
$ amixer set Master on|off
- Wireless network listing:
$iwlist INTERFACE scan Example: $ iwlist wlan0 scan | grep ESSID
- Finding the biggest files:
- Package search:
dpkg -S /path/to/file rpm -qf /path/to/file rpm -qa, apt-file are additional useful commands to take a look at.
- Getting help:
- man – Make this as habit and learn how to use man
- whatis – To know the short description of command
- type – Gives info whether the command is shell built-in, alias or actual path of command
- Splitting Files: Splits Files into 1024 Megabyte chunks
split -b 1024m filename
- Editing the Command Line:
Many highly practical shortcuts can make you faster and more efficient on the command line in different ways:
- Find and re-run or edit a long and complex command from the history.
- Edit much more quickly than just using the backspace key and retyping text.
- Move around much faster than just using the left- and right-arrow keys.
- Other tips for Everyday use:
- In bash, use Ctrl-R to search through command history.
- In bash, use Ctrl-W to kill the last word and Ctrl-U to kill the line.
- pstree -p is a helpful display of the process tree.
- Use pgrep and pkill to find or signal processes by name (-f is helpful).
- To go back to the previous working directory: cd –
This article is contributed by Vikas Acharya. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.