The first thing that should be said about the Terminal on OS X is that it isn’t as scary as it seems. You can’t beat the Hitch Hikers Guide to the Galaxy for putting what you should do now into a clear Statement. Don’t Panic.
I’ll talk though everything you need to know and explain where each of these commands comes in helpful and how it will help you. Here are the commands we’ll look at in detail today;
- killAll
- cd
- mv/cp
- ls
- touch/mkdir
Before we begin you’ll need a terminal window in order follow this tutorial, in order to do this navigate to Finder, Applications, Utilities (folder), and then Terminal.
Alternatively use your favourite application launcher, such as Spotlight or Alfred, in order to launch Terminal.
killAll
killAll does only part of what it sounds like it will do, it doesn’t “kill” everything, but it does “kill” a specific application.
Using the “killAll” command is exactly the same as pressing Cmd + Opt + Esc and getting the “Force Quit Applications” window open, accept you gain more control.
Let say, for example, your dock has stopped responding. In this situation you could restart you Mac forcing it to relaunch, but your in the middle of working. You don’t want to waste valuable time waiting for it to reboot. Instead you could use the “killAll” command.
Open your Terminal, using Spotlight (you can’t use your Dock, it’s stopped responding, remember) and type killAll Dock then press return. You’ll see your dock vanish for a second and then reappear again like normal.
Go ahead and try it now, their nothing to fear by doing this as your Dock will simply relaunch, and it’s a good idea to be completely sure of what you need to do in the event that you need to use this in the future.
cd
The next three commands are all best used if you can use them in a folder other than your home directory, and this is where cd comes into play. cd stands for “change directory”, and on OS X their is more than one way of using it to navigate. Before we look at applying it to the terminal though, their a few things that would pay to know.
../– This means “Up One Level”, it the same as going into the folder that contains that one you are currently in./– This means “This Directory”, useful when navigating from your current location.- Locations beginning with
/– This means root, if you use a/at the beginning of a location it will assume you are navigating from the root of your hard drive. - Locations beginning with
~/– This means home folder, using this at the start of a location is like a little shortcut through your file system.
In order to use the cd command all you need to do is type cd, notice the space afterwards followed by a command.
For example to access my “Documents” folder I would type cd ~/Documents. It is worth noting that if you have just launched Terminal, it defaults to your home directory, so if I had only just launched my terminal window I could have just typed cd Documents/.
Say for example I now wanted to move from my “Documents” directory to my music directory their are now a few different ways of doing so. I could type ../Music, in this case this a fast way of going up a level and then going into the Music folder, but it’s not practical if I am in a deep series of folders, so a better command would be ~/Music.
Once you have got the hand of using these they can make a fast way of navigating around your filesystem, assuming your a fast typer. I final way to use the cd command is to type cd into a Terminal window and then click and drag a folder from a Finder window onto your Terminal window. You will notice that this automatically places the location in the window for you, making it faster to you the Terminal for people who are slower at typing.
mv/cp
mv/cp isn’t actually a Terminal command, it is interface two separate commands that do two very similar functions. mv moves a folder or a directory, and cp copies a folder or directory.
The syntax for each of these is pretty much identical, but when moving, or copying, large amounts of data I find that they often deal with the data quicker than the UI of OS X.
In order to move an individual file simple type mv /path/to/file.jpg /path/to/new/place.jpg. You may notice as well that I changed the name of a the file in the example above, this is something you can freely do with the cp and mv commands.
If you want to use the copy command, use the same syntax but with cp in the place of mv.
These commands can also be used to move directories, but in this situation we need to perform a recursive task so that it will go into the folder, and all it’s sub directories, and move or copy everything.
This is a pretty simple task, in order to do it to just need to use the -R extension. From example to copy my Dropbox public directory into my Documents folder I would use cp -R ~/Dropbox/Public ~/Documents
ls
ls stands for “list”. It is used to literally lis the contents of a directory within the Terminal. It is particularly useful when you want to view hidden files are file permissions quickly.
In order to use it simply navigate to a folder using any of the methods discussed previously in the article and then type ls. At this point you will notice that it will list everything in the directory, but it still doesn’t list any hidden files.
To show hidden files you need to use the -a extension, so it would read ls -a. Now you will notice some of the items begin with a dot (“.”), these are you hidden files.
touch/mkdir
Perhaps the most useful of these commands is touch. Primarily I’m a Web Designer, and when I’m starting out on a new project I need to create a new file structure in order to set-up this new project. In order to do this I can type touch index.html, and in this case an empty new file called “index.html” would be created.
The second command worth pairing this with it mkdir. This is used in order to create a new directory. For example mkdir css would make a new folder called “css”.
These two commands combined with each other mean it can be very fast to set-out my new file structures.
Final Thoughts
As you can see form this article using the Terminal on Mac OS X, or any other UNIX based system for that matter, can really help to boost your productivity.
With just these five initial commands you can easily boost your productivity, just remember when you open up a terminal window DON’T PANIC!
You can’t do any real system damage without using the sudo command, something that I will not go into here.
What are your favourite terminal commands? Can you see yourself using it in the future?






