Scroll to navigation

virt-ls(1) Virtualization Support virt-ls(1)

НАЗВА

virt-ls — програма для показу списку файлів у віртуальній машині

КОРОТКИЙ ОПИС

 virt-ls [--параметри] -d назва_домену каталог [каталог ...]

 virt-ls [--параметри] -a диск.img [-a диск.img ...] каталог [каталог ...]

Старий стиль:

 virt-ls [--параметри] назва_домену каталог

 virt-ls [--параметри] диск.img [диск.img ...] каталог

ОПИС

"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.

ПРИКЛАДИ

Отримати список всіх файлів і каталогів у віртуальній машині:

 virt-ls -R -d guest /

Показати список всіх програм з setuid або setgid у віртуальній машині Linux:

 virt-ls -lR -d guest / | grep '^- [42]'

Показати список всіх каталогів з відкритим для всіх доступом на запис у віртуальній машині Linux:

 virt-ls -lR -d guest / | grep '^d ...7'

Показати список всіх сокетів доменів Unix у віртуальній машині Linux:

 virt-ls -lR -d guest / | grep '^s'

Показати список всіх звичайних файлів, назви яких завершуються на «.png»:

 virt-ls -lR -d guest / | grep -i '^-.*\.png$'

Щоб переглянути список файлів у домашніх каталогах, розмір яких перевищує 10 МБ:

 virt-ls -lR -d guest /home | awk '$3 > 10*1024*1024'

Знайти всі об’єкти, які було змінено протягом попередніх 7 днів:

 virt-ls -lR -d guest --time-days / | awk '$6 <= 7'

Знайти звичайні файли, зміни до яких було внесено протягом попередніх 24 годин:

 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).

РЕЖИМИ ВИВЕДЕННЯ ДАНИХ

"virt-ls" has four output modes, controlled by different combinations of the -l and -R options.

ПРОСТИЙ СПИСОК

Простий список, подібний до списку звичайної команди ls(1):

 $ virt-ls -d guest /
 bin
 boot
 [тощо]

ДОВГИЙ СПИСОК

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
 [тощо]

Note that while this is useful for displaying a directory, do not try parsing this output in another program. Use "RECURSIVE LONG LISTING" instead.

РЕКУРСИВНИЙ СПИСОК

With the -R (--recursive) option, "virt-ls" lists the names of files and directories recursively:

 $ virt-ls -R -d guest /tmp
 foo
 foo/bar
 [тощо]

To generate this output, "virt-ls" runs the "guestfs_find0" function and converts "\0" characters to "\n".

РЕКУРСИВНИЙ ДОВГИЙ СПИСОК

Using -lR options together changes the output to display directories recursively, with file stats, and optionally other features such as checksums and extended attributes.

Most of the interesting features of "virt-ls" are only available when using -lR mode.

The fields are normally space-separated. Filenames are not quoted, so you cannot use the output in another program (because filenames can contain spaces and other unsafe characters). If the guest was untrusted and someone knew you were using "virt-ls" to analyze the guest, they could play tricks on you by creating filenames with embedded newline characters. To safely parse the output in another program, use the --csv (Comma-Separated Values) option.

Note that this output format is completely unrelated to the "ls -lR" command.

 $ virt-ls -lR -d guest /bin
 d 0555       4096 /bin
 - 0755        123 /bin/alsaunmute
 - 0755      28328 /bin/arch
 l 0777          4 /bin/awk -> gawk
 - 0755      27216 /bin/basename
 - 0755     943360 /bin/bash
 [тощо]

Ці основні поля буде показано завжди:

тип
The file type, one of: "-" (regular file), "d" (directory), "c" (character device), "b" (block device), "p" (named pipe), "l" (symbolic link), "s" (socket) or "u" (unknown).
права доступу
The Unix permissions, displayed as a 4 digit octal number.
розмір
The size of the file. This is shown in bytes unless -h or --human-readable option is given, in which case this is shown as a human-readable number.
шлях
Шлях до файла або каталогу повністю.
посилання
Лише для символічних посилань, призначення посилання.

In -lR mode, additional command line options enable the display of more fields.

With the --uids flag, these additional fields are displayed before the path:

uid
gid
The UID and GID of the owner of the file (displayed numerically). Note these only make sense in the context of a Unix-like guest.

With the --times flag, these additional fields are displayed:

atime
Час останнього доступу.
mtime
Час останнього внесення змін.
ctime
Час останньої зміни стану.

The time fields are displayed as string dates and times, unless one of the --time-t, --time-relative or --time-days flags is given.

With the --extra-stats flag, these additional fields are displayed:

пристрій
The device containing the file (displayed as major:minor). This may not match devices as known to the guest.
inode
Номер inode.
nlink
Кількість жорстких посилань.
rdev
For block and char special files, the device (displayed as major:minor).
блоки
Кількість 512-байтових блоків, виділених під файл.

With the --checksum flag, the checksum of the file contents is shown (only for regular files). Computing file checksums can take a considerable amount of time.

ПАРАМЕТРИ

--help
Показати коротку довідку.
-a файл
--add файл
Add file which should be a disk image from a virtual machine. If the virtual machine has multiple block devices, you must supply all of them with separate -a options.

Формат образу диска визначається автоматично. Щоб перевизначити його і примусово використати певний формат, скористайтеся параметром --format=...

-a адреса
--add адреса
Додати віддалений диск. Див. "ДОДАВАННЯ ВІДДАЛЕНОГО СХОВИЩА" in guestfish(1).
--checksum
--checksum=crc|md5|sha1|sha224|sha256|sha384|sha512
Display checksum over file contents for regular files. With no argument, this defaults to using md5. Using an argument, you can select the checksum type to use.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

-c адреса
--connect адреса
Якщо використовується libvirt, встановити з’єднання з вказаним URI. Якщо пропущено, з’єднання буде встановлено з типовим гіпервізором libvirt.

Якщо вказати блокові пристрої гостьових систем безпосередньо (-a), libvirt не буде використовуватися взагалі.

--csv
Write out the results in CSV format (comma-separated values). This format can be imported easily into databases and spreadsheets, but read "NOTE ABOUT CSV FORMAT" below.
-d гість
--domain гість
Додати всі диски з вказаної гостьової системи libvirt. UUID доменів можна використовувати замість назв.
--echo-keys
When prompting for keys and passphrases, virt-ls normally turns echoing off so you cannot see what you are typing. If you are not worried about Tempest attacks and there is no one else in the room you can specify this flag to see what you are typing.
--extra-stats
Показати додаткові дані.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--format=raw|qcow2|..
--format
Типовим значенням для параметра -a є автоматичне визначення формату образу диска. Використання цього параметра примусово визначає значення параметрів -a формату диска у наступному рядку команди. Використання параметра --format без аргументу перемикає програму у режим автоматичного визначення у наступних параметрах -a.

Приклад:

 virt-ls --format=raw -a диск.img /каталог
    

примусове встановлення формату без обробки (без автоматичного визначення) для disk.img.

 virt-ls --format=raw -a диск.img --format -a інший_диск.img /каталог
    

примусове встановлення формату без обробки (без автоматичного визначення) для diskimg і повернення до автоматичного визначення для another.img.

Якщо ви користуєтеся ненадійними образами гостьових систем у необробленому форматі, вам слід скористатися цим параметром для визначення формату диска. Таким чином можна уникнути можливих проблем з захистом для сформованих зловмисниками гостьових систем (CVE-2010-3851).

-h
--human-readable
Показати розміри файлів у зручному для читання форматі.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--keys-from-stdin
Read key or passphrase parameters from stdin. The default is to try to read passphrases from the user by opening /dev/tty.
-m dev[:mountpoint[:options[:fstype]]]
--mount dev[:mountpoint[:options[:fstype]]]
Змонтувати названий розділ або логічний том до вказаної точки монтування.

If the mountpoint is omitted, it defaults to /.

Specifying any mountpoint disables the inspection of the guest and the mount of its root and all of its mountpoints, so make sure to mount all the mountpoints needed to work with the filenames given as arguments.

If you don't know what filesystems a disk image contains, you can either run guestfish without this option, then list the partitions, filesystems and LVs available (see "list-partitions", "list-filesystems" and "lvs" commands), or you can use the virt-filesystems(1) program.

The third (and rarely used) part of the mount parameter is the list of mount options used to mount the underlying filesystem. If this is not given, then the mount options are either the empty string or "ro" (the latter if the --ro flag is used). By specifying the mount options, you override this default choice. Probably the only time you would use this is to enable ACLs and/or extended attributes if the filesystem can support them:

 -m /dev/sda1:/:acl,user_xattr
    

Using this flag is equivalent to using the "mount-options" command.

The fourth part of the parameter is the filesystem driver to use, such as "ext3" or "ntfs". This is rarely needed, but can be useful if multiple drivers are valid for a filesystem (eg: "ext2" and "ext3"), or if libguestfs misidentifies a filesystem.

-l
--long
-R
--recursive
Select the mode. With neither of these options, "virt-ls" produces a simple, flat list of the files in the named directory. See "SIMPLE LISTING".

"virt-ls -l" produces a "long listing", which shows more detail. See "LONG LISTING".

"virt-ls -R" produces a recursive list of files starting at the named directory. See "RECURSIVE LISTING".

"virt-ls -lR" produces a recursive long listing which can be more easily parsed. See "RECURSIVE LONG LISTING".

--times
Показати поля часу.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--time-days
Display time fields as days before now (negative if in the future).

Note that 0 in output means "up to 1 day before now", or that the age of the file is between 0 and 86399 seconds.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--time-relative
Display time fields as seconds before now (negative if in the future).

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--time-t
Display time fields as seconds since the Unix epoch.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

--uids
Показати поля UID і GID.

This option only has effect in -lR output mode. See "RECURSIVE LONG LISTING" above.

-v
--verbose
Увімкнути докладний показ повідомлень з метою діагностики.
-V
--version
Показати дані щодо версії і завершити роботу.
-x
Увімкнути трасування викликів програмного інтерфейсу libguestfs.

ПАРАМЕТРИ КОМАНДНОГО РЯДКА У ФОРМАТІ ПОПЕРЕДНІХ ВЕРСІЙ

У попередніх версіях virt-ls можна було використовувати або

 virt-ls диск.img [диск.img ...] /каталог

або

 virt-ls назва_гостьової_системи /каталог

whereas in this version you should use -a or -d respectively to avoid the confusing case where a disk image might have the same name as a guest.

З міркувань зворотної сумісності передбачено підтримку запису параметрів у застарілому форматі.

ЗАУВАЖЕННЯ ЩОДО ФОРМАТУ CSV

Comma-separated values (CSV) is a deceptive format. It seems like it should be easy to parse, but it is definitely not easy to parse.

Myth: Just split fields at commas. Reality: This does not work reliably. This example has two columns:

 "foo,bar",baz

Myth: Read the file one line at a time. Reality: This does not work reliably. This example has one row:

 "foo
 bar",baz

For shell scripts, use "csvtool" (https://github.com/Chris00/ocaml-csv also packaged in major Linux distributions).

For other languages, use a CSV processing library (eg. "Text::CSV" for Perl or Python's built-in csv library).

Most spreadsheets and databases can import CSV directly.

СТАН ВИХОДУ

Ця програма повертає значення 0 у разі успішного завершення і ненульове значення, якщо сталася помилка.

ТАКОЖ ПЕРЕГЛЯНЬТЕ

guestfs(3), guestfish(1), virt-cat(1), virt-copy-out(1), virt-diff(1), virt-tar-out(1), http://libguestfs.org/.

АВТОР

Richard W.M. Jones http://people.redhat.com/~rjones/

АВТОРСЬКІ ПРАВА

© Red Hat Inc., 2009–2016

LICENSE

BUGS

To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools

To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools

When reporting a bug, please supply:

  • The version of libguestfs.
  • Where you got libguestfs (eg. which Linux distro, compiled from source, etc)
  • Describe the bug accurately and give a way to reproduce it.
  • Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report.
2017-03-08 libguestfs-1.34.6