This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Desktop Software

CLI Magic: Using GNOMEvfs to manipulate files

By Mayank Sharma on April 08, 2008 (9:00:00 AM)

Share    Print    Comments   

While KDE users get to boss KIO slaves for easier access to system and network resources, humble GNOME users can perform similar feats with its virtual file system, called GnomeVFS, which is an extension of the physical filesystem on a disk. Using GnomeVFS, users can work with non-local data that can come from unusual places, such as within compressed gzip archives.

CLI MagicGnomeVFS is an integral part of GNOME. It comprises several modules that work in the background and give GnomeVFS its functionality. In Ubuntu and Fedora distributions these modules are listed under the /usr/lib/gnome-vfs-2.0/modules/ directory. Some of the commonly included modules are http:, ftp:, file:, tar:, ssh:, fonts:, and burn:. You can add more modules via the distro's package manager. For instance, in Ubuntu, the libgnomevfs2-extra package adds the bzip2: and smb: modules.

You can use GnomeVFS from within the Nautilus file manager or from the command line. The most commonly used GnomeVFS modules are http:// and https://, which get data stored on a Web server. You can also use ftp:// to get data from a FTP server and smb:// to get data from a Samba share.

An interesting GnomeVFS module is burn://. You can use it within a Nautilus window by dragging and dropping files into the window to burn them onto a CD or DVD, depending on the media burner on your machine.

But the real fun of GnomeVFS comes from using it from the command line. The command eog file:///tmp/stuff.tar#tar:bookmarks.png will open the file bookmarks.png in GNOME's image viewer, Eye of GNOME. The command uses two GnomeVFS modules. The file:// module specifies the location of the file (/tmp/stuff.tar). The "#tar:bookmarks.png" part of the command tells GNOME that anything before it is a tar archive, and it should do what it needs to display the bookmarks.png file under it. You don't have to worry about untarring the archive and cleaning up afterward.

Similarly you can read files from a compressed archive without uncompressing it first. If you have a .tar.gz file, you'll have to combine two GnomeVFS modules to suck files out of it. For example, eog file:///tmp/stuff.tar.gz#gzip:#tar:forum.png will first treat the file (/tmp/stuff.tar.gz) as a compressed file and uncompress it, and then treat the resulting file (stuff.tar) as a tar archive and untar it to display the image (forum.png).

GnomeVFS can also handle bzip2 archives and read files from under directories as well. In gedit file:///tmp/old-docs.tar.bz2#bzip2:#tar:020207/writeup.txt we ask GNOME to display a text file from under a directory after extracting it from a bzip2 compressed archive.

There are also some GnomeVFS tools specifically designed for command-line use, such as gnomevfs-cat, gnomevfs-copy, gnomevfs-ls, gnomevfs-mkdir, and gnomevfs-info. These tools are GnomeVFSed versions of common command-line tools and are similar in function to them, with one advantage -- the ability to work on external non-local files.

For example, gnomevfs-cat http://www.example.net.net > /tmp/index.html performs the same copy function a normal cat command would, but on a remotely located file. Similarly, gnomevfs-ls smb://192.168.2.2/D/ displays the contents of a remote Windows directory over your network.

Using GnomeVFS, you can also browse files on Web sites via FTP. The command gnomevfs-ls ftp://username:password@ftp.example.net/public_html lists the contents of a remote directory along with the type, size, and permission of the files, in this format:

. (Directory, x-directory/normal) size 4096 .. (Directory, x-directory/normal) size 4096 .htaccess (Regular, application/octet-stream) size 413 .smileys (Directory, x-directory/normal) size 4096 WysiwygPro (Directory, x-directory/normal) size 4096 _private (Directory, x-directory/normal) size 4096 _vti_bin (Directory, x-directory/normal) size 4096 _vti_cnf (Directory, x-directory/normal) size 4096 _vti_inf.html (Regular, text/html) size 1754 _vti_log (Directory, x-directory/normal) size 4096 _vti_pvt (Directory, x-directory/normal) size 4096 _vti_txt (Directory, x-directory/normal) size 4096 contact.htm (Regular, text/html) size 2390 favicon.ico (Regular, image/x-ico) size 1406 images (Directory, x-directory/normal) size 4096 index.htm (Regular, text/html) size 2977

You can also upload a file to a remote site through FTP using GnomeVFS. The command gnomevfs-copy /tmp/moi.jpg ftp://username:password@ftp.example.net/public_html/images/ uses gnomevfs-copy to upload the source file (/tmp/moi.jpg) to the specified location (/public_html/images) on the site. You can also use ftp://username:password@ftp.example.net from within Nautilus to copy and paste files onto the site.

Once it has been uploaded, you can check on the file by using gnomevfs-info. The command gnomevfs-info ftp://username:password@ftp.example.net/public_html/images/moi.jpg produces the following output:

Name : moi.jpg Type : Regular MIME type : image/jpeg Default app : eog.desktop Size : 4321 Blocks : 9 I/O block size : 32768 Local : NO SUID : NO SGID : NO Sticky : NO Link count : 1 UID : 1000 GID : 1000 Access time : Tue Mar 8 00:00:00 2008 Modification time : Tue Mar 8 00:00:00 2008 Change time : Tue Mar 8 00:00:00 2008

Using GnomeVFS to look at remote files and under compressed folders can be a real time-saver.

Share    Print    Comments   

Comments

on CLI Magic: Using GNOMEvfs to manipulate files

Note: Comments are owned by the poster. We are not responsible for their content.

CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 86.159.155.111] on April 08, 2008 10:39 AM
gnome-vfs was recently deprecated with the release of GLib 2.16 and GNOME 2.22. application developers should use the GIO API, instead; there are command line utilities as well shipped inside the gvfs backend for GIO.

#

Re: CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 217.132.172.169] on April 08, 2008 01:29 PM
Yes. I was quite surprised to see an article about a deprecated system on Linux.com.

#

CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 84.44.177.21] on April 08, 2008 07:19 PM
Honestly, GVfs was released a few days ago and you post an article about the wonders of Gnome Vfs? Nothing to add...

#

CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 83.51.171.106] on April 09, 2008 03:51 AM
Although GNOMEvfs has been deprecated, I find the article very useful. It'll take a lot of time until all systems with GNOMEvfs disappear, so you still can take advantage of this information. I didn't know nothing of this and find it really interesting!

#

Thanks ..great article..very handy

Posted by: Anonymous [ip: 202.83.42.51] on April 09, 2008 05:18 AM
Deprecated!..phew!..news 4 me anyway..i wasnt aware of gnome vfs thing..and its cli and misc capabilitites ..
thumbs down to nick-pickers..guess they dont hav any other job than contaminate an articles with unwarranted negative comments!..negaholic ego-maniacs.$$#%#

#

CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 163.192.21.43] on April 09, 2008 07:48 PM
Too little too late. While these capabilities have been around for a while, they were never made to work in any usable sense. The gedit command you mention will display the file but will not write it. I can mount remote directories and archives using nautilus, but I cannot manipulate files beyond simple move/copy/delete. Bleh!

PS And the goddamn linux.com interface asks me to enter the goddamn captcha TWICE!

#

CLI Magic: Using GNOMEvfs to manipulate files

Posted by: Anonymous [ip: 80.6.172.219] on April 13, 2008 11:06 PM
I found this really useful. I still have gnome-vfs and when it gets upgraded, I'm sure I benefit from knowing it will also do something similar.

#

GVFS

Posted by: Anonymous [ip: 127.0.0.1] on April 14, 2008 08:04 PM
What Anonymous said, plus you probably should have at leased mentioned Gnome-vfs's deprecation in favor of GVFS. But thanks for the article, it might be useful until I'm fully updated to the newer software.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya