85

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

Braiam
  • 67,791
  • 32
  • 179
  • 269
Tim
  • 25,177
  • 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
  • 1
    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

8 Answers8

120

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

enter image description here

Pablo Bianchi
  • 15,657
luri
  • 4,112
  • 2
    is it a feature or a bug? :-) – loonix Mar 01 '11 at 05: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 01 '11 at 08: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 01 '11 at 08: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 01 '11 at 09:11
  • 2
    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 02 '14 at 16:12
  • Ctrl+c on the file/directory and Ctrl+v in an editor. If you find this useful, vote on the answer below (not me!) – toto_tico Mar 31 '22 at 14:49
30

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.

7

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.

Kim Stacks
  • 1,076
6

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

Vijay
  • 8,056
5

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
Nonny Moose
  • 2,255
3

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

robin0800
  • 1,092
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.

0

Additional to the answer of Nonny Moose, you can create, and use a Shortcut for copy to the clipboard the Path to your file/folder. Thus, you select a folder or a file in Nautilus, and then press a shortcut, and you will have you Path to that folder/file in the Clipboard ready to be pasted.

You can do in the following manner:

  1. Install Xclip: $ sudo apt install xclip

  2. Create and save a script in ~/.local/share/nautilus/scripts as follow:

    • Name of the file: Nautilus-Copy-Path
    • Content:
      #!/bin/sh
      echo -n "${PWD}" | xclip -selection clipboard
      
    • Make this file an executable file. (Risght click -> properties -> permissions -> Alow executing file as program)
  3. Create the following file in /home/user_name/.config/nautilus

    • Name of the file: scripts-accels
    • Content: Note that F6 is the shortcut you want to assign to run this script, space and then the name of the script you want to run, in this case the file name you just have created in the previous step.
      F6 Nautilus-Copy-Path
      
    • Make it executable
  4. Restart Nautilus

Lucho
  • 391
  • In Nautilus versions later than the one that comes with 20.04, a simple Ctrl+C again will work as of old. Note that this also will not work like that on Wayland, the default display server of Ubuntu 22.04. – vanadium May 11 '22 at 16:41