virt-ls (1) Linux Manual Page
NAME
virt-ls – List files in a virtual machine
SYNOPSIS
virt - ls[--options] - d domname directory[directory...] virt - ls[--options] - a disk.img[-a disk.img...] directory[directory...]
Old style:
virt - ls[--options] domname directory virt - ls[--options] disk.img[disk.img...] directory
DESCRIPTION
"virt-ls" lists filenames, file sizes, checksums, extended attributes and more from a virtual machine or disk image.
Multiple directory names can be given, in which case the output from each is concatenated.
To list directories from a libvirt guest use the -d option to specify the name of the guest. For a disk image, use the -a option.
"virt-ls" can do many simple file listings. For more complicated cases you may need to use guestfish(1), or write a program directly to the guestfs(3) API.
EXAMPLES
Get a list of all files and directories in a virtual machine:
virt-ls -R -d guest /
List all setuid or setgid programs in a Linux virtual machine:
virt-ls -lR -d guest / | grep '^- [42]'
List all public-writable directories in a Linux virtual machine:
virt-ls -lR -d guest / | grep '^d ...7'
List all Unix domain sockets in a Linux virtual machine:
virt-ls -lR -d guest / | grep '^s'
List all regular files with filenames ending in ‘.png’:
virt-ls -lR -d guest / | grep -i '^-.*\.png$'
To display files larger than 10MB in home directories:
virt-ls -lR -d guest /home | awk '$3 > 10*1024*1024'
Find everything modified in the last 7 days:
virt-ls -lR -d guest --time-days / | awk '$6 <= 7'
Find regular files modified in the last 24 hours:
virt-ls -lR -d guest --time-days / | grep '^-' | awk '$6 < 1'
DIFFERENCES IN SNAPSHOTS AND BACKING FILES
Although it is possible to use virt-ls to look for differences, since libguestfs ≥ 1.26 a new tool is available called virt-diff(1).
OUTPUT MODES
"virt-ls" has four output modes, controlled by different combinations of the -l and -R options.
SIMPLE LISTING
A simple listing is like the ordinary ls(1) command:
$ virt-ls -d guest / bin boot [etc.]
LONG LISTING
With the -l (–long) option, the output is like the "ls -l" command (more specifically, like the "guestfs_ll" function).
$ virt-ls -l -d guest / total 204 dr-xr-xr-x. 2 root root 4096 2009-08-25 19:06 bin dr-xr-xr-x. 5 root root 3072 2009-08-25 19:06 boot [etc.]
Note that while this is useful for displaying a directory, do not try parsing this output in another program. Use “RECURSIVE LONG LISTING” instead.
RECURSIVE LISTING
With the -R (–recursive) option, "virt-ls" lists the names of files and directories recursively:
$ virt-ls -R -d guest /tmp foo foo/bar [etc.]
To generate this output, "virt-ls" runs the "guestfs_find0" function and converts "
