DEV Community

Cover image for Linux Terminal Commands
dotbehrens
dotbehrens

Posted on • Updated on

Linux Terminal Commands

My special skill is breaking things so I often find myself digging through the internet to find terminal commands having no idea if they will help or cause my computer to self destruct. A recent disaster led me to decide it was time to learn what these commands were actually commanding. I've put together a collection of commands I have run across and some that have helped me diagnose what is going on.

Something that has come up a lot is the file path "/etc". As someone who plays a lot of HOTS (Heroes of the Storm) I immediately think of E.T.C. (Elite Tauren Chieftain)

Alt Text

Though some may think of it as et cetera this file is really where the configurations for the applications on your computer are stored.

Another thing that has come up a bunch is daemons. Daemons, sometimes pronounced demons, are processed that run in the background. As a naming convention daemons typically end in the letter "d". This is why, while stumbling though mysql all of the sudden mysqld made an appearance.

Alt Text

pwd: This command stands for "print working directory". It prints what the absolute file from root is.

/: is the root file. if you "cd /", You will change directories to the root.

ps: "Process Status" prints a snapshot of the current running processes to the terminal.

free: This really handy command tells you how much space is free on your machine. On its own free will return the space in bits, which becomes overwhelming if you are working with larger files.

Alt Text

If "free" is paired with "-h", which stands for human readable, then the file sizes are returned in bytes which are more manageable.

kill: Will kill a process. Processes are usually preceded with a number if you use kill in conjunction with that number you will kill that specific process.

df: Similar to free but prints out how much space a file is using. Remember to add "-h" for friendlier units.

Two commands that I have run across that have led me to say things like "I guess I just have to trust you stack overflow" are chmod and chown.

sudo chown -R _mysql:mysql /usr/local/var/mysql

chown: Will change the ownership of the specific file. CHange OWNer.

chmod: will change the read and write permissions for a file.

While we have the example above lets talk about sudo.
Coming from Mac I was a little confused as to why my commands need to start with sudo. sudo is real nice in that it makes you the root user for that command. It is quicker than changing directories to root and changing back.

One of my current favorite commands is history. I should have known that it was an option but I just didn't. History will print a list of your command history. This is especially helpful when you have done so many things to try to fix a problem that you have forgotten what they are. Or when someone does magic on your computer and you want to know what happened.

A few fun commands to try:

cal: prints a mini calendar to the terminal
yes: just try it! Or, tell a friend to do it!

rev: will reverse the string given to it
cmatrix: will display a really nice matrix in your terminal.

Stay tuned for part two: Practicing Linux Terminal Commands with Cowsay!

Top comments (0)