Scroll to navigation

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'

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

これらの基本的な項目は常に表示されます:

ファイル形式。次のどれかです: "-" (通常のファイル), "d" (ディレクトリー), "c" (キャラクターデバイス), "b" (ブロックデバイス), "p" (名前付きパイプ), "l" (シンボリックリンク), "s" (ソケット) or "u" (不明)。
パーミッション
Unix パーティション。4 桁の8進数として表示されます。
容量
ファイルの容量。 読みやすい形式の数値として表示する -h または --human-readable オプションが指定されていなければ、バイト単位で表示されます。
パス
ファイルまたはディレクトリの完全パス。
リンク
シンボリックリンクのみに対して、リンク先。

-lR モードでは、追加のコマンドラインオプションにより、さらなる項目の表示を有効にします。

--uids フラグを用いると、これらの追加項目がパスの前に表示されます:

ファイルの所有者の UID および GID (数値表記)。 これらは Unix 系の仮想マシンにおいてのみ意味があることに注意してください。

--times フラグがあると、これらの追加項目が表示されます:

アクセス日時。
最終変更日時。
最終属性変更日時。

--time-t, --time-relative または --time-days フラグのどれかが指定されていなければ、日付と時間の文字列として time 項目が表示されます。

--extra-stats フラグを用いると、これらの追加項目が表示されます:

The device containing the file (displayed as major:minor). This may not match devices as known to the guest.
inode 番号。
ハードリンク数。
ブロックおよびキャラクタースペシャルファイルに対する、デバイス (メジャー:マイナーとして表示)。
ブロック
ファイルに割り当てられた 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.

オプション

簡単なヘルプを表示します。
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=.. オプションを使用します。

リモートディスクを追加します。 "リモートストレージの追加" in guestfish(1) 参照。
This parameter sets the sector size of the disk image. It affects all explicitly added subsequent disks after this parameter. Using --blocksize with no argument switches the disk sector size to the default value which is usually 512 bytes. See also "guestfs_add_drive_opts" in guestfs(3).
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.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

libvirt を使用していると、指定された URI に接続します。 省略すると、デフォルトの libvirt ハイパーバイザーに接続します。

ゲストのブロックデバイスを直接指定していると((-a))、libvirt は何も使用されません。

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.
名前付きの libvirt 仮想マシンからすべてのディスクを追加します。 名前の代わりに仮想マシンの UUID を使用できます。
キーやパスフレーズを入力するとき、通常 virt-ls はエコーを無効化します。 そのため、入力内容を確認できません。 テンペスト攻撃の心配がなく、 部屋に誰も居なければ、 入力内容を確認するためにこのフラグを指定できます。
Display extra stats.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

-a オプションは標準状態でディスクイメージの形式を自動検知します。 これを使用することにより、コマンドラインで後続の -a オプションのディスク形式を強制的に指定できます。 引数なしで --format を使用することにより、 後続の -a オプションに対して自動検知に戻せます。

例:

 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" 参照。

Specify a key for LUKS, to automatically open a LUKS device when using the inspection. "ID" can be either the libguestfs device name, or the UUID of the LUKS device.
Use the specified "KEY_STRING" as passphrase.
Read the passphrase from FILENAME.
Read key or passphrase parameters from stdin. The default is to try to read passphrases from the user by opening /dev/tty.

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 がファイルシステムを誤検知している場合、 これは有用です。

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

時間の項目を表示します。

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

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.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

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

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

Display time fields as seconds since the Unix epoch.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

UID と GID の項目を表示します。

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

デバッグ用の冗長なメッセージを有効にします。
バージョン番号を表示して、終了します。
libguestfs API 呼び出しのトレースを有効にします。

旧形式のコマンドライン引数

前のバージョンの 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.

互換性のため古い形式がまだサポートされています。

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.

神話: ただコンマで項目を区切る。 真実: これは正しく動き ません。この例は 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

Copyright (C) 2009-2020 Red Hat Inc.

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.
2021-03-31 libguestfs-1.44.2