Entering File and Folder Paths on the macOS Command Line


The one thing that trips me up time and again when using the command line in Terminal or other terminal emulator is being able to navigate the directory structure and target files or folders. After struggling getting the correct file or folder path I’m usually greeted with No such file or directory reminding me that the command line doesn’t like spaces in file and folder paths.

With that in mind here are a few ways to enter file and folder paths on the command line.

I’m going to change the current directory to /Users/steve/Library/Application Support using the cd command.

The first method is to enclose the full path in single quotes…:

Dummy Content
cd '/Users/steve/Library/Application Support'



…or double quotes:

Dummy Content
cd "/Users/steve/Library/Application Support"



The second is to escape any space with a backslash \. The backslash should be placed immediately before each space:

Dummy Content
cd /Users/steve/Library/Application\ Support



If the file or folder exists in the current user’s home folder we can use ~/ as shorthand to denote the user’s home folder:

Dummy Content
cd ~/Library/Application\ Support



If we want to use single or double quotes, the opening quote must come after the ~/ shorthand:

Dummy Content
cd ~/"Library/Application Support"



The one I tend to use most is to first type the command at the command line with a trailing space. Then locate the file or folder in the Finder and drag it to the open Terminal window:

Dragging an item from the Finder to a Terminal window

Dragging an item from the Finder to a Terminal window



The full path is copied at the Terminal window’s current cursor position:

Terminal window showing the full path of the Finder item

Terminal window showing the full path of the Finder item



About the author

A native Brit exiled in Japan, Steve spends too much of his time struggling with the Japanese language, dreaming of fish & chips and writing the occasional blog post he hopes others will find helpful.

6 responses


  • I am trying to access a folder on my external drive. The name of the folder is “Story Telling”

    I am not able to access this folder using Terminal. Although this folder very much exists.
    It says no such file or directory.

    Now there another folder called “Story” without the space in between and when I try to open this directory I can open it.

    Only when there is a particular folder with the ‘White space” in between i am not able to access it.
    Would appreciate your help.

    • Khushal B

      If none of the methods I’ve outlined in this post work for you, try this:

      Select the Story Telling folder in the Finder. Ctrl-click and select Services > New Terminal at Folder from the resulting menu. This should open a Terminal window at the Story Telling folder location.

      Regards, Steve.

1 Pingback


Recent Comments

Recent Posts