I’ve decided to blog my command line course. So here it is. The very very basic absolute beginners guide to using terminal on a Mac.
This will be an ongoing post so I will post as the course goes along.
Chapter 1: Navigating Directories
Where is the Terminal on the Mac?
Go to Applications, it is in the Utilities folder:
Open another tab (cmd T)
First steps – Navigating your directory structure.
Some very common commands you will be using a lot:
ls – List everything in a directory
You can provide ‘switches’ to a command that fine tunes your list.
l = list
t = sort by time modifies
r = reverse results
This is what appears:
drwx------+ 39 Dan staff 1056 22 May 22:49 Desktop
Breakdown of what these characters mean:
d = directory, the following characters are what permissions are avaliable:
r = read. The directory can be read.
w = Write. The directory can be changed.
x = Excecute. Programs can be executed from the directory.
The characters after these letters signify if other people sharing my computer can do things.
How do I get to another folder (directory)?
cd = change directory
Why would I want to go to another folder?
Programs can be used to perform actions on files within particular folders.
cd Documents to go to the documents folder
Press tab to autocomplete:
Start to type ‘Docu’ and press tab to autocomplete the command. So ‘cd Docu [tab].
Type just ‘
d’. Autocomplete advises which of the 2 folders: Documents or Downloads?
ls and autocomplete means that the full name of the directory doesn’t have to be typed, every time. Just ‘ls’, see the directory, then type the first few letters of the directory and press tab. This is a much quicker and simpler form of navigation.
How to get to the home directory?
Use the tilde character ‘
How to clear the terminal screen?
Or ctrl L.
How to navigate to a folder within a folder?
Just continue the path using a slash
How to find the path of the current located directory?
Pwd = show path of Present Working Directory
Terminal shows the path of the directory:
How to navigate up the directory tree?
Type 2 full-stops (periods):
cd .. = go to the parent directory
This saves from having to start from the home directory again, just to move up one level. So from the example above:
Typing cd ..
Will move to
This can be typed multiple times to move up to other levels:
cd ../../ etc.
Note that the slash directory system is the same for must websites. This is because Macs use a ‘unix’ file system, the same as websites.