With this little box, you can do almost anything.
There are a few quick commands you will need to know as we move forward with the terminal. In no particular order:
- CTRL-C – Close the process currently running. This is sort of like pressing the “X” on a GUI interface.
- CTRL-Z – Kill the process currently running. This puts the process in a sort of limbo while you go do better things.
- CTRL-SHIFT-T – Open a new tab in the terminal window. It can come in handy, but it only applies to some Linux terminals (to the best of my knowledge).
- TAB – Complete the current word using best logic. This is useful for typing extremely long file names.
You start the terminal in your home directory (/home/<YOUR NAME>/). This directory is referenced with a ~ character, which can be useful later on.
The root directory is the lowest level of your computer system. It contains all the file accesses required to make your system run, and anything NOT somewhere inside of the root directory will not work for you. The root directory is the / directory.
To navigate to root, we type the command:
Now you are in the root directory. There are a few sub-directories of particular interest to us:
- bin – the location for all your global programs. You’ll usually find things like vi, gcc, and the rest in this directory.
- home – the location for all of our personal files and environment variables.
- media – the location of your plugged-in media (flash drives, etc.).
- usr – the location of important files like C libraries.
To navigate from the root directory back to our home directory, we have shortcuts and direct paths. To get there directly, we can use:
cd home/<YOUR NAME>
And that takes us there. We can also get there with the shortcut:
Let’s see the contents of our current folder. To do this, we use the command:
This shows us the directories and files in our current directory. In my case, it looks something like this:
Yes, I have a lot of screenshots.
Suppose we want to go back, to see what users we’ve set up. We go up one directory with the command
That puts us in /home/, which should only contain the names of the users you set up for your system.
When we were working in C, you likely noticed a difference between how we called some programs and how we called others. For example, we called gcc and vi like this:
gcc -o helloworld helloworld.c
However, when we wanted to run helloworld, we called it like this:
This is because most programs are called out of the /bin directory. If we don’t tell the terminal the exact location of a program, that’s where it looks. Because the helloworld program was usually in the same directory we were in, we had to tell the terminal to look in this directory for the program.
.. tells the computer to go up one directory.
. tells the computer to stay in this directory.
We don’t have to call the helloworld program from ~/Documents/Programming (which is the location I encouraged you to develop when we started this series). We can call it from the ~ directory, for example, so long as we know the path from ~ to the program. In our case, that would look like this:
Making it crazy
Just for fun, figure out where we end up with the following cd calls:
(Where am I if I can say) cd ./Public