These 10 Linux Commands Will Make You More Efficient
As developers we spend a lot of time in our Terminals. The more efficient we are, the more time we have to do the things we love. In this article, I will share some of the most useful Linux commands that I use on a daily basis that will make your life easier.
1. cd -
This command will take you to the previous directory you were in. This is a great command to use when you are navigating through directories and you want to go back to the previous directory.
2. ctrl + r
This shortcut will allow you to search through your command history. This is a great command to use when you are trying to remember a command you used in the past.
3. ctrl + a
Rather than using the arrow keys to move your cursor to the beginning of the line, you can use this shortcut to move your cursor to the beginning of the line.
4. ctrl + e
Now that you are at the beginning of the line, you can use this shortcut to move your cursor to the end of the line. This come extremely handy when you are trying to edit a command.
5. !!
This symbol will repeat the last command you ran. This command comes in handy when you forget to add sudo
to a command. You can simply run sudo !!
to run the last command with sudo
.
6. apropos
This is a lesser known one, but it is extremely useful. This command will search through the manual pages for a given keyword.
7. ctrl + l
This one is pretty simple yet handy. This clears the terminal screen. This is great when you are trying to clear the screen and you don't want to use the clear
command.
8. ctrl + U
and ctrl + K
Do not use the backspace key to delete parts of a command. Instead, use these shortcuts. ctrl + U
will delete everything before the cursor and ctrl + K
will delete everything after the cursor.
9 grep
This command comes extremely handy when you are trying to search through a file. You can use grep <keyword> <file>
to search for a keyword in a file. You can also use grep with a pipe to search through the output of another command. For example, ps aux | grep <keyword>
will search through the output of the ps aux
command(which outputs all running processes). Or, you can use ll | grep <keyword>
to search through the output of the ll
command(which outputs all files in the current directory).
10 tail -f
I use it every time when I need to monitor logs. This command will print the last 10 lines of a file and will continue to print new lines as they are added to the file.
Pro Tips
- You can use
tail -f <file1> <file2>
to monitor multiple files. - You can use
tail -f <file> | grep <keyword>
to monitor a file and filter the output by a keyword.
Bonus Commands
wc -l <file>
will count the number of lines in a file.df -h
will show you the disk usage of your system.du -h
will show you the disk usage of the current directory.ps aux
will show you all running processes.man
will show you the manual page for a given command.
Conclusion
I hope you found these commands helpful. Bookmark this article and go through it every once in a while to refresh your memory. If you want to be even faster check out my article on Linux aliases.