Access gvfs mounts from the command line

In the past, having used the “Connect to server” feature in GNOME, you could easily access the remote server’s filesystem from within Nautilus, but it was impossible to access it from the command line (please correct me if I miss something here). Now GNOME uses gvfs. As soon as GNOME connects to the remote server, for instance an anonymous FTP server, you can effortlessly access the files on the server using command line tools by changing to the /home/<USER>/.gvfs/<server_connection_name> directory. This also gives us the chance to do some other cool things, like initiating file transfers from a remote server A to a remote server B using our desktop. Beautiful!

Access gvfs mounts from the command line by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2008 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

6 responses on “Access gvfs mounts from the command line

  1. Dimitris Glezos Permalink →

    Awesome idea about command-line access to GFVS mounted dirs, haven’t thought about it until I read your post.

    GVFS is one of the features I miss the most when I need to temporarily work on another desktop environment for any reason. Another one is, of course, package management.

  2. George Notaras Post authorPermalink →

    Actually, it is possible to use gvfs on a desktop environment other than GNOME, but you have to use the gvfs-mount utility directly as there is no graphical facility like the “Connect to server” feature of the GNOME desktop. For example, connecting to a remote SSH server requires the following:

    gvfs-mount s

    This will not work though if gvfsd and gvfs-fuse-daemon are not running in the background. I logged into fluxbox and both of those servers had been already running in the background. I didn’t have the time to investigate what had started them. I checked the system services but did not see any gvfs-related daemon being started on boot, so I guess they are started in the fluxbox loader script.

    Anyway, if those daemons are not up, you can start gvfs-fuse-daemon manually, which in turn starts gvfsd. Ensure that the mount point /home/johndoe/.mygvfsmounts exists prior to bringing the daemon up.

    /usr/libexec/gvfs-fuse-daemon /home/johndoe/.mygvfsmounts

    This is probably not the optimal way to start this service, because if I kill it and then restart it using the same mount point (.mygvfsmounts), I get an error.

    Anyway, if gvfsd and gvfs-fuse-daemon have successfully been started, then you can use gvfs-mount to connect to remote services and access their virtual filesystems inside .mygvfsmounts.

  3. happynix Permalink →

    Note: if you are not running a windows manager. (i.d. you have ssh-ed into the server/workstation) then you might need to launch gvfs-mount like so:
    #$ dbus-launch gvfs-mount

    This will take care of launching gvfs-fuse-daemon, etc. so you won’t have to do it manually.
    (At least on ubuntu w/ dbus installed)

  4. Jasmo Permalink →

    I discovered this same last night. And it’s great finally find the mount point..

    Why, why why for gods sake the mount point has to be hidden directory? What is the benefit of that? Is direct access (from shell or so) to .gfvs somehow thought undesireable?

  5. Harry Permalink →

    Is this normal?? Or do I have corruption or something else.
    -rw-r–r– 1 toto toto 143 2011-09-30 22:56 .gtkrc-2.0
    d????????? ? ? ? ? ? .gvfs/
    -rw——- 1 toto toto 3380 2011-10-25 17:29 .ICEauthority
    drwxr-xr-x 2 toto toto 4096 2011-08-06 19:31 .icons/

  6. BarbaraF Permalink →

    Update: as of Fedora 18 (maybe earlier too, but I didn’t use it then), the path is /run/user//gvfs/ (e.g in my case the service is sftp:host= and folder /home/ )