I want to add bookmarks to nautilus via the command line. These bookmarks can be directories on the boot drive or auto mounted external drives. I want to know how to do this from the command line instead of doing it manually via the GUI.

The reason I want to do this is every one or two months, I, a linux newcomer, use sudo too liberally or run into a problem that I don't know how to fix and end up having to reinstall my operating system. I've written a shell script that reinstalls my programs and now I want that script to do some configuring.

  • It is a valid question to want to create bookmarks via the command line without providing this stupid reason that you "use sudo too liberally", apparently without the intention to change this unthoughtful behaviour.
    – vanadium
    Jul 17, 2021 at 6:32
  • @vanadium, you are right. However, having a decent backup recovery mechanism is a good thing ;-)
    – pLumo
    Jul 17, 2021 at 8:26

1 Answer 1


Nautilus bookmarks are stored in a plain text file ~/.config/gtk-3.0/bookmarks. You can therefore easily add or remove lines from the file with the usual shell tricks to add or delete lines.

The format of the file is at the minimum the URI of the target, e.g. file:///home/login/Documents/Letters, or smb://files.server/scans. Special characters in this URI should be URI-encoded, e.g. a space should be represented as %20. After a space, you can add the label that should be displayed in Nautilus. Otherwise, the basename will be displayed.

Add lines with something like:

echo "file:///home/login/Documents/Letters" >> ~/.config/gtk-3.0/bookmarks


printf %s "file:///home/login/Documents/Letters" >> ~/.config/gtk-3.0/bookmarks

Delete lines with for example

sed -i '/Documents\/Letters/d' ~/.config/gtk-3.0/bookmarks


cat ~/.config/gtk-3.0/bookmarks | grep -v '/Documents/Letters' | tee ~/.config/gtk-3.0/bookmarks
  • This -> location=/path/to/dir; name=some_name; printf 'file://%s %s' "$location" "$name'' >> ~/.config/gtk-3.0/bookmarks
    – pLumo
    Jul 17, 2021 at 8:29
  • Great answer, thanks
    – hmontoliu
    Feb 24, 2023 at 11:40

You must log in to answer this question.

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