virt-ls(1) | Virtualization Support | virt-ls(1) |
virt-ls - 仮想マシンのファイルの一覧表示
virt-ls [--options] -d domname directory [directory ...] virt-ls [--options] -a disk.img [-a disk.img ...] directory [directory ...]
古い形式:
virt-ls [--options] domname directory virt-ls [--options] disk.img [disk.img ...] directory
"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 /
Linux 仮想マシンにある setuid または setgid プログラムを一覧表示します:
virt-ls -lR -d guest / | grep '^- [42]'
Linux 仮想マシンにあるすべての全体書き込み可能なディレクトリーを一覧表示します:
virt-ls -lR -d guest / | grep '^d ...7'
Linux 仮想マシンにあるすべての Unix ドメインソケットを一覧表示します:
virt-ls -lR -d guest / | grep '^s'
List all regular files with filenames ending in ‘.png’:
virt-ls -lR -d guest / | grep -i '^-.*\.png$'
ホームディレクトリにある 10MB より大きなファイルを表示するには:
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'
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" は 4 つの出力モードがあります。-l および -R オプションの異なる組み合わせにより制御されます。
簡単な一覧方法は通常の ls(1) コマンドと似ています:
$ virt-ls -d guest / bin boot [etc.]
-l (--long) オプションを用いると、出力は "ls -l" コマンドのようになります(より具体的には "guestfs_ll" 関数と似ています)。
$ 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.]
これはディレクトリーを表示するために有用ですが、他のプログラムにおいてこの出力を解析しないよう注意してください。代わりに "再帰的なロング形式の一覧方法" を使用してください。
-R (--recursive) オプションを用いると、"virt-ls" はファイルおよびディレクトリーを再帰的に一覧表示します:
$ virt-ls -R -d guest /tmp foo foo/bar [etc.]
この出力を生成するには、"virt-ls" が "guestfs_find0" 関数を実行して、"\0" 文字を "\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 [etc.]
これらの基本的な項目は常に表示されます:
-lR モードでは、追加のコマンドラインオプションにより、さらなる項目の表示を有効にします。
--uids フラグを用いると、これらの追加項目がパスの前に表示されます:
--times フラグがあると、これらの追加項目が表示されます:
--time-t, --time-relative または --time-days フラグのどれかが指定されていなければ、日付と時間の文字列として time 項目が表示されます。
--extra-stats フラグを用いると、これらの追加項目が表示されます:
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.
ディスクイメージの形式は自動検知されます。 これを上書きして強制的に特定の形式を使用する場合、 --format=.. オプションを使用します。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
ゲストのブロックデバイスを直接指定していると((-a))、libvirt は何も使用されません。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
例:
virt-ls --format=raw -a disk.img /dir
forces raw format (no auto-detection) for disk.img.
virt-ls --format=raw -a disk.img --format -a another.img /dir
forces raw format (no auto-detection) for disk.img and reverts to auto-detection for another.img.
仮想マシンのディスクイメージが信頼できない raw 形式である場合、 ディスク形式を指定するためにこのオプションを使用すべきです。 これにより、悪意のある仮想マシンにより起こり得る セキュリティ問題を回避できます (CVE-2010-3851)。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
Use the specified "KEY_STRING" as passphrase.
Note that if any such option is present on the command line, QEMU user networking will be automatically enabled for the libguestfs appliance.
If there are multiple encrypted devices then you may need to supply multiple keys on stdin, one per line.
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.
マウントパラメーターの三番目の (ほとんど使用されない) 項目は、 バックエンドのファイルシステムをマウントするために使用される マウントオプションの一覧です。 これが指定されていない場合、 マウントオプションは空文字列または "ro" (--ro フラグが使用されている場合) になります。
-m /dev/sda1:/:acl,user_xattr
このフラグを使用することは、 "mount-options" コマンドを使用することと同等です。
パラメーターの四番目の項目は使用するファイルシステムドライバー ("ext3" や "ntfs" など) です。 これはほとんど必要ありません。 しかし、複数のドライバーがファイルシステムに対して有効である場合 (例: "ext2" と "ext3")、 または libguestfs がファイルシステムを誤検知している場合、 これは有用です。
"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".
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
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.
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。
前のバージョンの virt-ls により、次のどちらも書くことができます:
virt-ls disk.img [disk.img ...] /dir
または
virt-ls guestname /dir
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.
互換性のため古い形式がまだサポートされています。
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.
神話: ただコンマで項目を区切る。 真実: これは正しく動き ません。この例は 2 つの列があります:
"foo,bar",baz
神話: 同時にファイルの 1 行を読み込みます。 真実: これは正しく動き ません。この例は 1 つの行があります:
"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 を、エラーがあると 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/
Copyright (C) 2009-2023 Red Hat Inc.
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:
2024-10-03 | guestfs-tools-1.52.2 |