21

I'm really new to command line and I'm trying to access my Applications directory within Terminal.

By default, I am stuck in my user directory but Applications is a child of the "Macintosh HD".

Any tips on how to get to this directory as opposed to username>Applications?

39

In the Terminal you can type the absolute path...

cd /Applications

to access applications installed for all users.

If you want to access the root folder (named "Macintosh HD", in your case), it called / in Mac OS X (and other UNIX variants).

And cd, meaning change directory, is used to navigate.


Alternatively, you can use the shortcut ++G in the Finder and type...

/Applications

You do not need to type out the whole name. Tab-completion automatically adds the last letters. You can invoke tab-completion by pressing while typing /Applications.

  • 1
    You can also drag the applications folder from the Finder into the Terminal window which will automatically insert the path. – jaberg Mar 19 '12 at 17:26
  • @jaberg Yeah, but only in Lion, right? – gentmatt Mar 19 '12 at 17:26
  • 1
    It goes back way before Lion, but I can't remember exactly when that feature was added. 10.4? – jaberg Mar 19 '12 at 17:27
5

In terminal type:

cd /
cd Applications

Or you can just type:

cd /Applications

At this point, if you type pwd (print working directory) it should return /Applications

A great place to start with Terminal is http://linuxcommand.org/learning_the_shell.php even though it is aimed at Linux users

3

To navigate using the terminal you will use 2 commands; cd and ls.

To change directory you use cd. Ex: cd myfolder/anotherFolder.

You can type pwd to display the current directory you are in.

To list the content of a directory use ls. You can get more info about the content of a directory using ls -al.

You will notice that here are 2 directories which are always present wherever you list the content of a directory: . and ...

. is simply a reference to the current directory so typing cd ./somedir and cd somedir are equivalent.

.. is a reference to the parent directory. So using cd .. will move you back to the parent directory.

There are 2 ways to navigate. Either by using the full path or by using the relative path.

Let's say you are in /Users/user20378. If you want to get to /Applications you can either navigate there using the full path cd /Application or the relative path cd ../../Applications.

Depending on where you want to navigate the relative path can be more or less efficient than the full path.

Use tab while typing the name of a folder or a file to auto complete.

  • I would split these up into paragraphs for each idea. – CoffeeRain Mar 19 '12 at 21:21
1

The terminal app supports drag and drop if you are more comfortable in Finder.

The cd command of course changes the current directory to the one to type or paste / drop.

So type cd in terminal and then drag in the correct Applications folder from finder shortcut, from a save dialog or a finder window into the terminal window with your mouse and let go.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .