21.5. Other Commands
This section describes tools that are simpler equivalents to using guestfish to view and edit guest virtual machine disk images.
virt-catis similar to the guestfishdownloadcommand. It downloads and displays a single file to the guest virtual machine. For example:virt-cat RHEL3 /etc/ntp.conf | grep ^server server 127.127.1.0 # local clock
# virt-cat RHEL3 /etc/ntp.conf | grep ^server server 127.127.1.0 # local clockCopy to Clipboard Copied! Toggle word wrap Toggle overflow virt-editis similar to the guestfisheditcommand. It can be used to interactively edit a single file within a guest virtual machine. For example, you may need to edit thegrub.conffile in a Linux-based guest virtual machine that will not boot:virt-edit LinuxGuest /boot/grub/grub.conf
# virt-edit LinuxGuest /boot/grub/grub.confvirt-edit LinuxGuest /boot/grub/grub.confvirt-edit LinuxGuest /boot/grub/grub.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow virt-edithas another mode where it can be used to make simple non-interactive changes to a single file. For this, the -e option is used. For example, the following command changes the root password in a Linux guest virtual machine to having no password:virt-edit LinuxGuest /etc/passwd -e 's/^root:.*?:/root::/'
# virt-edit LinuxGuest /etc/passwd -e 's/^root:.*?:/root::/'virt-edit LinuxGuest /etc/passwd -e 's/^root:.*?:/root::/'virt-edit LinuxGuest /etc/passwd -e 's/^root:.*?:/root::/'Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-lsis similar to the guestfishls,llandfindcommands. It is used to list a directory or directories (recursively). For example, the following command would recursively list files and directories under /home in a Linux guest virtual machine:virt-ls -R LinuxGuest /home/ | less
# virt-ls -R LinuxGuest /home/ | lessvirt-ls -R LinuxGuest /home/ | lessvirt-ls -R LinuxGuest /home/ | lessCopy to Clipboard Copied! Toggle word wrap Toggle overflow