The commands below make up about 90% of what I do on a Linux system. Most of what I do from the command line involves ssh’ing into a server, searching through log files, checking on processes, and editing configuration files. Since I am not doing most of my development work directly on a Linux box, I often find myself forgetting how to do certain tasks, or not knowing how to do something on a specific server. I put together the small guide below with commands that are available on almost any Linux system. By learning these few commands, I have been able to navigate around and get what I need done in almost any Linux environment.
#Login to a remote server ssh [-p port] [username@hostname]
#List files in a directory with file information ls -l
#See every process running on a system ps aux
#Print the last 100 lines of a file tail -100 [filename]
#Watch a log file as it grows tail -f [filename]
#Look for a pattern in a file grep [pattern] [file]
#Run an HTTP GET request to a url curl [url]
#Change file permissions to read/write for all chmod a+rw [filename]
Here is an example of a common way that I might chain commands together:
#Look in the last 1000 lines of a file for lines starting with ERROR #and print out the matching lines and the 5 lines above and below tail -1000 logs/logfile.txt | grep ^ERROR -A 5 -B 5