Almost everyday I need to use the terminal in OS X, mostly for ssh connectivity to control other servers but also to alter system related stuff on my computer. It could be OS specific settings that is not normally exposed, it could be a quick way to change permission on files etc.
For some people this is a small black box and nothing that is ever touched or used. If the word “open up your terminal” comes up the user rage quits the browser, jumps out of it’s chair and curls up in a corner crying.
Well, no more. I intend on having a series of tutorials that is helping the user to overcome it’s primitive fear and despair for it and to coach along to be able to use it comfortably every now and then.
Why does this exist on my computer?
Ever heard of BSD, Linux or Unix? Those open-source operating systems that really experienced computer geeks use that no one understands? Well, if you are using OS X you are one of them as OS X is built on top of BSD and is basically just a very good flavour of it and is known and renowned for its flexibility and configurability. All those things came for free when Apple adopted the BSD v4.3 (Berkeley Software Distribution) operating system which was a derivative of Unix and made its own version of it. The Terminal app in OS X is just a GUI (Graphical User Interface) wrapper for the bash (Bourne-again shell) is tightly integrated with the core of the operating system. Bash is a really really really old software that is a successor to even more old software that had it’s initial release all the way back to 1971. The origin? A software called Thompson shell that came out 1971 and later in 1977 became Bourne shell and that in 1989 became Bourne-again shell which is the software you are using today. Can you imagine a software that is over 40 years old? Heck, I was not even born yet when it’s journey started.
So, the terminal is a legend on your computer, outdating all other software you have there and is one of the most widely used programs in the world.
So face it my friend. It’s time to learn some more things about it. We can go down to some pretty basic stuff, in example how to start the darn thing.
Press CMD+Space and write “Terminal” without quotes. Press enter. Voila.
Before we go ahead and start writing some commands to try out your new wings I would like to explain the very basic of how commands are built. Almost every single command is constructed like this:
It’s very rare to go outside of this format and if it does it is something very similar.
Okay, so now when we got that down lets continue on. You are currently located in your home folder. Try this out
and see what folders and files you see. I bet you will have a “Desktop” folder. Go down the rabbit hole and open up the folder with following command;
Now you are located in the desktop folder.. Feeling like you want to move back to your home folder? That would be:
and that my friend, is how you traverse the folders in the terminal. Not to shabby huh? So what does it stand for? ls is a short for list and cd for change directory.
Shall we go over some more basic commands that could be very useful? Here we go:
Creates a folder in the folder you currently resides in
Will remove a specific file in the folder you currently resides in
rmdir <folder name>
Removes a complete folder. Don’t know why they wanted to separate that into a different command but hey, I’m not complaining.
If you continue to tinker with the terminal, you will end up in a situation where you have the word sudo prepend to your command. What is this sudo thing?
Well, the system you are using has a couple of different users. There is the one user that is you. This account has some restrictions to it so hackers that gain control over your account can’t execute hard-core stuff easily. So everything the operating system does is done on a different account called root. Root means utter and complete access to everything. It’s the most fundamental and basic account of all and is a very, very powerful user.
Sudo is a command to allow your user to have the same privileges as the root but without changing the logged in account. Be a bit careful when using the sudo command since it really gives you access to a much deeper level that could be used to destroy the operating system. The sudo name is a contraction of “substitute user do” meaning to do something as a different user.