Today I am going to share most commonly used terminal commands for Backend Developers. I am a Backend developer and has been using these commands on a daily basis during development. I hope you will find some of them handy
grep
grep is one of the most commonly used terminal command, grep can be used in multiple ways to filter live logs, to filter text with in file or files, to filter process followings are mine daily uses of grep command
filter words from log
tail -f /path/to/log/file | grep 'word1 word2 word3'
filter process
ps aux | grep process_name
filter previous commands
history | grep command
grep can also be used to find a string within files in a folder. Although today you can search string within a folder with your favorite text editor as well. But you should also know this power of grep
grep -rnw 'path_to_file' -e "string_to_search"
For detail understanding of grep string search with in a folder please read this answer
Kill process
kill a process safely
kill -9 PID
Ctrl + R
Ctrl + R is not a command, but a very handy reverse search keyboard shortcut to filter commands you have previously typed in the terminal. keep this shortcut in your bag it might save your precious time while you work on production mode
chmod
while permissions is very broad topic in linux and unix operating system. You must have adequate know how of chmod to set permissions of files and folders
basic syntax of chmod is
chmod permissions file_or_folder_path
permissions in the chmod command requires special attention. Permission parameter is three digit integer first digit represents user, second digit represents group and third digit represents other. Each digit of three digits is further sum of read+write+executable where
4 stands for read
2 stands for write
1 stands for execute
0 stands for no permission
so permission 655 means user can read and write and can not execute ( 4+2+0), group can read but can not write and can execute ( 4+0+1) and others can read but can not write and can execute (4+0+1)
ssh-copy-id
If you consistently need to switch from local to server and vice versa, set up ssh-copy-id once to ssh to remote server again and again without password ( you can do same with by adding you ssh keys to your remote server )
ssh-copy-id username@remote_ip
apt-cache search
You may have used apt-get install a lot but apt-cache search let you search for apt packages
apt-cache search pacakage_to_search