21

I need to know how the directory name in order to type it out in the terminal. How do I access the names of directories?

Windows Explorer used to have a title bar with the full path. Can someone please help me figure out how to see the full path of a certain file?

2
  • If you know the path and need to type it out quickly, nothing is better than Tab completion, especially with zsh.
    – Dillmo
    Mar 13, 2014 at 1:12
  • I figured out a way to delete files with BleachBit, thanks for your answer. But for the other query I still need to know how to see the FULL path of any certain file or folder. Mar 13, 2014 at 1:16

3 Answers 3

26

If you are using nautilus to browse your files, you can toggle the navigation bar by pressing Ctrl + L.

If you are using the terminal, just use pwd to know the absolute path of your current location.

1
  • 2
    And don't forget that space characters need to be escaped within the terminal. If you want to access /path/to/the force then you need to do cd /path/to/the\ force.
    – Buddyshot
    Mar 13, 2014 at 2:03
14

To display the full path of a file in the terminal just drag the file's icon into the terminal, and the full path of the file will be displayed enclosed by two apostrophes (single quotation mark characters). It's that simple.

In Ubuntu 20.04 and later drag and drop of files or directories doesn't work from the desktop, but does work in other locations including dragging from the desktop in Files file manager.

5

find can do this quite handily from the terminal. Here's an example in which I'm looking for the full path of the file Taxes-2013.pdf:

sudo find / -name Taxes-2013.pdf

Provides the output:

/home/me/Documents/Taxes-2013.pdf

I'm using sudo so that I can avoid all the permission denied output that I would otherwise get with find when searching from the root of the tree.

If you just want the pathname and want the filename stripped off you can use

sudo find / -name Taxes-2013.pdf | xargs -n1 dirname

Note: If you are in the habit of putting spaces in names this is relevant to you.

Some sources:

https://www.unixtutorial.org/commands/dirname/

http://www.commandlinefu.com/commands/using/dirname

http://man7.org/linux/man-pages/man1/xargs.1.html

Tested on Ubuntu 14.04

You must log in to answer this question.

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