All good answers; Here is a tip for another situation.
If you are browsing your files using nautilus and you want the complete path of your current directory, then press CTRL+L. This changes the breadcrumb buttons temporarily back to the old-style address bar, allowing you to copy the path.
In addition to dragging the icon, there are a few ways to get the full path without nautilus (or thunar, konqueror, et al.). You would then triple-click or click-drag and copy, potentially saving this in your clipboard manager*, and paste it where you need.
(pastie, klipper, glippy, glipper, anamnesis)
You can use find in a directory above your file. (If you don't know where it is, start where your shell drops you, [generally] in the top of your home directory.) find . | egrep filename
You can use locate to get the filename. (Run sudo updatedb if that hasn't been done recently.)
A more realistic example of using find would be something like :
or (install it first)
Just drag and drop the file in the terminal.
All good answers; Here is a tip for another situation.
If you are browsing your files using nautilus and you want the complete path of your current directory, then press
CTRL+L
. This changes the breadcrumb buttons temporarily back to the old-style address bar, allowing you to copy the path.If it's an executable, then execute (in a terminal):
$ which your_executable
For example:
$ which ls
In addition to dragging the icon, there are a few ways to get the full path without nautilus (or thunar, konqueror, et al.). You would then triple-click or click-drag and copy, potentially saving this in your clipboard manager*, and paste it where you need.
(pastie, klipper, glippy, glipper, anamnesis)
You can use
find
in a directory above your file. (If you don't know where it is, start where your shell drops you, [generally] in the top of your home directory.)find . | egrep filename
You can use
locate
to get the filename. (Runsudo updatedb
if that hasn't been done recently.)A more realistic example of using find would be something like :
To cut out the ones you don't like, e.g.:
locate is used much the same way, though grep is frequently more necessary:
This isn't the most efficient way to type this, but usually if I've lost a file, I do this iteratively, adding grep clauses as I go.
Easily done in python using
os.realpath()
function:From a related answer,you can also use
readlink
If you simply copy a file in Nautilus, then the full path is copied.
Then paste it in the terminal. By simply pasting you get:
If you right-click and choose "Paste filenames" then you get:
with the quotes as shown.
This differs from Windows, that copies the file content instead of its name.