Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move up a directory with Terminal in OS X

Tags:

terminal

macos

People also ask

How do you go up a directory in Mac Terminal?

To navigate from one directory or folder to another, you can use the "cd" command, which is short for "change directory." To return to the previous folder, you can use a special option in "cd" to do so.

How do I go up a directory in Terminal?

To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory"). For example, to move one directory upwards (into the current folder's parent folder), you can just call: $ cd ..

How do I move up a directory in Terminal with cd?

(two dots). The .. means “the parent directory” of your current directory, so you can use cd .. to go back (or up) one directory. cd ~ (the tilde). The ~ means the home directory, so this command will always change back to your home directory (the default directory in which the Terminal opens).

What is the command to move to one directory above?

Use the cd command to move from your present directory to another directory.


cd .. will back the directory up by one. If you want to reach a folder in the parent directory, you can do something like cd ../foldername. You can use the ".." trick as many times as you want to back up through multiple parent directories. For example, cd ../../Applications would take you to Macintosh HD/Applications


For Mac Terminal

cd ..   # one up
cd ../  # two up
cd      # home directory 
cd /    # root directory
cd "yaya-13" # use quotes if the file name contains punctuation or spaces

Typing cd will take you back to your home directory. Whereas typing cd .. will move you up only one directory (the direct parent of the current directory).


To move up a directory, the quickest way would be to add an alias to ~/.bash_profile

alias ..='cd ..'

and then one would need only to type '..[return]'.


Let's make it even more simple. Type the below after the $ sign to go up one directory:

../