57

In 10.10, when opening a directory in Nautilus, I was wondering how to copy the current path?

My address bar, pictured here, is not copyable:

enter image description here

  • I suppose that you want to cd to the directory Nautilus is in. A quick way to do that would be to right-click and select open in terminal (as long as your ~/.bashrc doesn't set your pwd) – DarkKnight Oct 21 '16 at 23:27
  • OP doesn't want to open a terminal there but wants to copy the current location to the clipboard which as the accepted answer shows is really easy. – UTF-8 Oct 22 '16 at 16:44
82

I'd say the quickest way is to press Ctrl+L, then you can copy it (Ctrl+C).

enter image description here

  • 1
    is it a feature or a bug? :-) – loonix Mar 1 '11 at 5:15
  • 3
    I don't really think it's a bug.... that's how it has been designed (wether we like it or not) – luri Mar 1 '11 at 8:28
  • 3
    Hehe it's a feature for sure and I believe it has been implemented for the same reason this question has been asked :P – danizmax Mar 1 '11 at 8:56
  • It used to show the location bar all the time, now breadcrumb style navigation is the default. Oh and +1 for keyboard shortcuts! – invert Mar 1 '11 at 9:11
  • 1
    And to toggle it back, strangely, you can't use Ctrl+L. You have to use Esc. (See my answer for other related tips about saving your preference for this, and about "terminal here".) – Jon Coombs Aug 2 '14 at 16:12
21

Ctrl+L. Very frustrating to not find an option in the View menu (which should then be clearly labeled Ctrl+L). Had to do a web search.

And then very frustrating to find that Ctrl+L doesn't toggle it back. Another web search... Drum roll... Esc

And then, how to set your preference? Web search... Have to install gconf-editor or dconf-editor or manually use a terminal command:

gsettings set org.gnome.nautilus.preferences always-use-location-entry true

http://ubuntuforums.org/showthread.php?t=1504058

Of course, this would be a little less painful if there were a 'terminal here' option in the context menu. Web search... Install nautilus-open-terminal

How do I open a terminal in the current location?

Sigh. Oversimplified interfaces are so hard to figure out. I appreciate all the helpful answers people have put on the web for us to find.

  • 1
    This answer will work on Ubuntu >12.04. Gconftool (answer below) is deprecated. – Glutanimate Apr 5 '13 at 0:27
  • 1
    Worth restating! "Oversimplified interfaces are so hard to figure out." – Machtyn May 3 '15 at 4:12
6

May I ask why you want the path?

If you want the path because you want to use it and navigate directly from the terminal, then you can simply install nautilus-open-terminal using synaptic.

Or

sudo apt-get install nautilus-open-terminal

After that, simply right click on any folder and use "Open in terminal"

If you simply want the path, then Ctrl + L would do just fine.

  • E: Unable to locate package nautilus-open-terminal. – kenorb Jan 25 at 23:30
  • The path is useful for making notes, writing user documentation, answering questions about "Where is file X located" and so on. – AlainD Aug 23 at 10:13
3

Navigate to the GO menu and choose Location....

2

Copy the file or folder. When you paste on terminal or text editor, it will paste the path, not the file or folder.

  • Drag from Nautilus and drop into Terminal works too! – user68186 Nov 18 '18 at 15:10
1

You can also type into your terminal gconftool-2 --type=Boolean --set apps/nautilus/preferences/always_use_location_entry true so that you always get a text based location bar.

1

You can use a Nautilus script:

Paste

#!/bin/bash
echo -n "${PWD}" | xclip -selection clipboard

into ~/.local/share/nautilus/scripts/Copy Directory Path.

(requires that xclip is installed)

You can now right-click on a file, mouse over "Scripts", and choose "Copy Directory Path" to copy the path of the directory that contains the file. Caveat: will not work in an empty directory.

Explanation

  • echo -n "${PWD}": Echoes the current working directory (Nautilus sets the working directory of the script to the one you had open in the window from which you ran the script) without a trailing newline. Initially I considered pwd | head -c -1, since pwd includes a trailing newline, but that was two unnecessary calls to external programs compared to echo.
  • xclip -selection clipboard: xclip by default copies to the X11 "primary" clipboard, but most desktop environments use the "clipboard" clipboard for their clipboard. I can't believe I just wrote that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.