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

2
  • 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, 2016 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, 2016 at 16:44

8 Answers 8

119

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

enter image description here

6
  • 2
    is it a feature or a bug? :-)
    – loonix
    Mar 1, 2011 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, 2011 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, 2011 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, 2011 at 9: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 2, 2014 at 16:12
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.

2
  • 1
    This answer will work on Ubuntu >12.04. Gconftool (answer below) is deprecated. Apr 5, 2013 at 0:27
  • 2
    Worth restating! "Oversimplified interfaces are so hard to figure out."
    – Machtyn
    May 3, 2015 at 4:12
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.

2
  • E: Unable to locate package nautilus-open-terminal.
    – kenorb
    Jan 25, 2019 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, 2019 at 10:13
6

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

1
  • 1
    Drag from Nautilus and drop into Terminal works too!
    – user68186
    Nov 18, 2018 at 15:10
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
3

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

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

1
  • 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, 2022 at 16:41

You must log in to answer this question.

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