Tuesday, 31 March 2020

Some time-saving tips for Linux Users

LPI Cert Exam, LPI Tutorial and Material, LPI Learning, LPI User, Linux Guides

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.

Also Read: 101-500: Linux Administrator - 101 (LPIC-1 101)

Here are some of my favorites time-saving tips that every Linux user should know :

1. 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

2. 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

3. Need to execute the last command with sudo, use sudo !!

ls -l /root

sudo !!
# This is equivalent to sudo ls -l /root

4. Quickly locate a file on disk:

locate filename

5. 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.

6. Free up disk space: bleachbit is a neat utility to find and remove files based on application specific knowledge.

7. Undelete for console: libtrash provides trashcan/recycle-bin like functionality for console users.

8. Mute / Unmute Sound:  

$ amixer set Master on|off

9. Wireless network listing:

$iwlist INTERFACE scan
Example: $ iwlist wlan0 scan | grep ESSID

10. Finding the biggest files:

ls -lSrh

11. 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.

12. 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

13. Splitting Files: Splits Files into 1024 Megabyte chunks

split -b 1024m filename

14. 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.

15. 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 –

Related Posts

0 comments:

Post a Comment