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?
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.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.
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:
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