supermin: If disabled, don't compile in supermin code or check for supermin.
[libguestfs.git] / fish / guestfish.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 guestfish - the libguestfs Filesystem Interactive SHell
6
7 =head1 SYNOPSIS
8
9  guestfish [--options] [commands]
10
11  guestfish
12
13  guestfish [--ro|--rw] -a disk.img
14
15  guestfish [--ro|--rw] -a disk.img -m dev[:mountpoint]
16
17  guestfish -d libvirt-domain
18
19  guestfish [--ro|--rw] -a disk.img -i
20
21  guestfish -d libvirt-domain -i
22
23 =head1 WARNING
24
25 Using guestfish in read/write mode on live virtual machines can be
26 dangerous, potentially causing disk corruption.  Use the I<--ro>
27 (read-only) option to use guestfish safely if the disk image or
28 virtual machine might be live.
29
30 =head1 DESCRIPTION
31
32 Guestfish is a shell and command-line tool for examining and modifying
33 virtual machine filesystems.  It uses libguestfs and exposes all of
34 the functionality of the guestfs API, see L<guestfs(3)>.
35
36 Guestfish gives you structured access to the libguestfs API, from
37 shell scripts or the command line or interactively.  If you want to
38 rescue a broken virtual machine image, you should look at the
39 L<virt-rescue(1)> command.
40
41 =head1 EXAMPLES
42
43 =head2 As an interactive shell
44
45  $ guestfish
46  
47  Welcome to guestfish, the libguestfs filesystem interactive shell for
48  editing virtual machine filesystems.
49  
50  Type: 'help' for a list of commands
51        'man' to read the manual
52        'quit' to quit the shell
53  
54  ><fs> add-ro disk.img
55  ><fs> run
56  ><fs> list-filesystems
57  /dev/sda1: ext4
58  /dev/vg_guest/lv_root: ext4
59  /dev/vg_guest/lv_swap: swap
60  ><fs> mount /dev/vg_guest/lv_root /
61  ><fs> cat /etc/fstab
62  # /etc/fstab
63  # Created by anaconda
64  [...]
65  ><fs> exit
66
67 =head2 From shell scripts
68
69 Create a new C</etc/motd> file in a guest or disk image:
70
71  guestfish <<_EOF_
72  add disk.img
73  run
74  mount /dev/vg_guest/lv_root /
75  write /etc/motd "Welcome, new users"
76  _EOF_
77
78 List the LVM logical volumes in a disk image:
79
80  guestfish -a disk.img --ro <<_EOF_
81  run
82  lvs
83  _EOF_
84
85 List all the filesystems in a disk image:
86
87  guestfish -a disk.img --ro <<_EOF_
88  run
89  list-filesystems
90  _EOF_
91
92 =head2 On one command line
93
94 Update C</etc/resolv.conf> in a guest:
95
96  guestfish \
97    add disk.img : run : mount /dev/vg_guest/lv_root / : \
98    write /etc/resolv.conf "nameserver 1.2.3.4"
99
100 Edit C</boot/grub/grub.conf> interactively:
101
102  guestfish --rw --add disk.img \
103    --mount /dev/vg_guest/lv_root \
104    --mount /dev/sda1:/boot \
105    edit /boot/grub/grub.conf
106
107 =head2 Mount disks automatically
108
109 Use the I<-i> option to automatically mount the
110 disks from a virtual machine:
111
112  guestfish --ro -a disk.img -i cat /etc/group
113
114  guestfish --ro -d libvirt-domain -i cat /etc/group
115
116 Another way to edit C</boot/grub/grub.conf> interactively is:
117
118  guestfish --rw -a disk.img -i edit /boot/grub/grub.conf
119
120 =head2 As a script interpreter
121
122 Create a 100MB disk containing an ext2-formatted partition:
123
124  #!/usr/bin/guestfish -f
125  sparse test1.img 100M
126  run
127  part-disk /dev/sda mbr
128  mkfs ext2 /dev/sda1
129
130 =head2 Start with a prepared disk
131
132 An alternate way to create a 100MB disk called C<test1.img> containing
133 a single ext2-formatted partition:
134
135  guestfish -N fs
136
137 To list what is available do:
138
139  guestfish -N help | less
140
141 =head2 Remote control
142
143  eval "`guestfish --listen`"
144  guestfish --remote add-ro disk.img
145  guestfish --remote run
146  guestfish --remote lvs
147
148 =head1 OPTIONS
149
150 =over 4
151
152 =item B<--help>
153
154 Displays general help on options.
155
156 =item B<-h> | B<--cmd-help>
157
158 Lists all available guestfish commands.
159
160 =item B<-h cmd> | B<--cmd-help cmd>
161
162 Displays detailed help on a single command C<cmd>.
163
164 =item B<-a image> | B<--add image>
165
166 Add a block device or virtual machine image to the shell.
167
168 The format of the disk image is auto-detected.  To override this and
169 force a particular format use the I<--format=..> option.
170
171 =item B<-c URI> | B<--connect URI>
172
173 When used in conjunction with the I<-d> option, this specifies
174 the libvirt URI to use.  The default is to use the default libvirt
175 connection.
176
177 =item B<-d libvirt-domain> | B<--domain libvirt-domain>
178
179 Add disks from the named libvirt domain.  If the I<--ro> option is
180 also used, then any libvirt domain can be used.  However in write
181 mode, only libvirt domains which are shut down can be named here.
182
183 =item B<-D> | B<--no-dest-paths>
184
185 Don't tab-complete paths on the guest filesystem.  It is useful to be
186 able to hit the tab key to complete paths on the guest filesystem, but
187 this causes extra "hidden" guestfs calls to be made, so this option is
188 here to allow this feature to be disabled.
189
190 =item B<--echo-keys>
191
192 When prompting for keys and passphrases, guestfish normally turns
193 echoing off so you cannot see what you are typing.  If you are not
194 worried about Tempest attacks and there is no one else in the room
195 you can specify this flag to see what you are typing.
196
197 =item B<-f file> | B<--file file>
198
199 Read commands from C<file>.  To write pure guestfish
200 scripts, use:
201
202  #!/usr/bin/guestfish -f
203
204 =item B<--format=raw|qcow2|..> | B<--format>
205
206 The default for the I<-a> option is to auto-detect the format of the
207 disk image.  Using this forces the disk format for I<-a> options which
208 follow on the command line.  Using I<--format> with no argument
209 switches back to auto-detection for subsequent I<-a> options.
210
211 For example:
212
213  guestfish --format=raw -a disk.img
214
215 forces raw format (no auto-detection) for C<disk.img>.
216
217  guestfish --format=raw -a disk.img --format -a another.img
218
219 forces raw format (no auto-detection) for C<disk.img> and reverts to
220 auto-detection for C<another.img>.
221
222 If you have untrusted raw-format guest disk images, you should use
223 this option to specify the disk format.  This avoids a possible
224 security problem with malicious guests (CVE-2010-3851).  See also
225 L</add-drive-opts>.
226
227 =item B<-i> | B<--inspector>
228
229 Using L<virt-inspector(1)> code, inspect the disks looking for
230 an operating system and mount filesystems as they would be
231 mounted on the real virtual machine.
232
233 Typical usage is either:
234
235  guestfish -d myguest -i
236
237 (for an inactive libvirt domain called I<myguest>), or:
238
239  guestfish --ro -d myguest -i
240
241 (for active domains, readonly), or specify the block device directly:
242
243  guestfish --rw -a /dev/Guests/MyGuest -i
244
245 Note that the command line syntax changed slightly over older
246 versions of guestfish.  You can still use the old syntax:
247
248  guestfish [--ro] -i disk.img
249
250  guestfish [--ro] -i libvirt-domain
251
252 =item B<--keys-from-stdin>
253
254 Read key or passphrase parameters from stdin.  The default is
255 to try to read passphrases from the user by opening C</dev/tty>.
256
257 =item B<--listen>
258
259 Fork into the background and listen for remote commands.  See section
260 L</REMOTE CONTROL GUESTFISH OVER A SOCKET> below.
261
262 =item B<-m dev[:mountpoint]> | B<--mount dev[:mountpoint]>
263
264 Mount the named partition or logical volume on the given mountpoint.
265
266 If the mountpoint is omitted, it defaults to C</>.
267
268 You have to mount something on C</> before most commands will work.
269
270 If any I<-m> or I<--mount> options are given, the guest is
271 automatically launched.
272
273 If you don't know what filesystems a disk image contains, you
274 can either run guestfish without this option, then list the partitions
275 and LVs available (see L</list-partitions> and L</lvs> commands),
276 or you can use the L<virt-list-filesystems(1)> program.
277
278 =item B<-n> | B<--no-sync>
279
280 Disable autosync.  This is enabled by default.  See the discussion
281 of autosync in the L<guestfs(3)> manpage.
282
283 =item B<-N type> | B<--new type> | B<-N help>
284
285 Prepare a fresh disk image formatted as "type".  This is an
286 alternative to the I<-a> option: whereas I<-a> adds an existing disk,
287 I<-N> creates a preformatted disk with a filesystem and adds it.
288 See L</PREPARED DISK IMAGES> below.
289
290 =item B<--progress-bars>
291
292 Enable progress bars, even when guestfish is used non-interactively.
293
294 Progress bars are enabled by default when guestfish is used as an
295 interactive shell.
296
297 =item B<--no-progress-bars>
298
299 Disable progress bars.
300
301 =item B<--remote[=pid]>
302
303 Send remote commands to C<$GUESTFISH_PID> or C<pid>.  See section
304 L</REMOTE CONTROL GUESTFISH OVER A SOCKET> below.
305
306 =item B<-r> | B<--ro>
307
308 This changes the I<-a> and I<-m> options so that disks are added and
309 mounts are done read-only (see L<guestfs(3)/guestfs_mount_ro>).
310
311 The option must always be used if the disk image or virtual machine
312 might be running, and is generally recommended in cases where you
313 don't need write access to the disk.
314
315 Note that prepared disk images created with I<-N> are not affected by
316 the I<--ro> option.
317
318 See also L</OPENING DISKS FOR READ AND WRITE> below.
319
320 =item B<--selinux>
321
322 Enable SELinux support for the guest.  See L<guestfs(3)/SELINUX>.
323
324 =item B<-v> | B<--verbose>
325
326 Enable very verbose messages.  This is particularly useful if you find
327 a bug.
328
329 =item B<-V> | B<--version>
330
331 Display the guestfish / libguestfs version number and exit.
332
333 =item B<-w> | B<--rw>
334
335 This option does nothing at the moment.
336 See L</OPENING DISKS FOR READ AND WRITE> below.
337
338 =item B<-x>
339
340 Echo each command before executing it.
341
342 =back
343
344 =head1 COMMANDS ON COMMAND LINE
345
346 Any additional (non-option) arguments are treated as commands to
347 execute.
348
349 Commands to execute should be separated by a colon (C<:>), where the
350 colon is a separate parameter.  Thus:
351
352  guestfish cmd [args...] : cmd [args...] : cmd [args...] ...
353
354 If there are no additional arguments, then we enter a shell, either an
355 interactive shell with a prompt (if the input is a terminal) or a
356 non-interactive shell.
357
358 In either command line mode or non-interactive shell, the first
359 command that gives an error causes the whole shell to exit.  In
360 interactive mode (with a prompt) if a command fails, you can continue
361 to enter commands.
362
363 =head1 USING launch (OR run)
364
365 As with L<guestfs(3)>, you must first configure your guest by adding
366 disks, then launch it, then mount any disks you need, and finally
367 issue actions/commands.  So the general order of the day is:
368
369 =over 4
370
371 =item *
372
373 add or -a/--add
374
375 =item *
376
377 launch (aka run)
378
379 =item *
380
381 mount or -m/--mount
382
383 =item *
384
385 any other commands
386
387 =back
388
389 C<run> is a synonym for C<launch>.  You must C<launch> (or C<run>)
390 your guest before mounting or performing any other commands.
391
392 The only exception is that if any of the I<-i>, I<-m>, I<--mount>,
393 I<-N> or I<--new> options were given then C<run> is done
394 automatically, simply because guestfish can't perform the action you
395 asked for without doing this.
396
397 =head1 OPENING DISKS FOR READ AND WRITE
398
399 The guestfish (and L<guestmount(1)>) options I<--ro> and I<--rw>
400 affect whether the other command line options I<-a>, I<-c>, I<-d>,
401 I<-i> and I<-m> open disk images read-only or for writing.
402
403 In libguestfs E<lt> 1.6.2, guestfish and guestmount defaulted to
404 opening disk images supplied on the command line for write.  To open a
405 disk image read-only you have to do I<-a image --ro>.
406
407 This matters: If you accidentally open a live VM disk image writable
408 then you will cause irreversible disk corruption.
409
410 By libguestfs 1.8 we intend to change the default the other way.  Disk
411 images will be opened read-only.  You will have to either specify
412 I<guestfish --rw> or change a configuration file in order to get write
413 access for disk images specified by those other command line options.
414
415 This version of guestfish has a I<--rw> option which does nothing (it
416 is already the default).  However it is highly recommended that you
417 use this option to indicate that guestfish needs write access, and to
418 prepare your scripts for the day when this option will be required for
419 write access.
420
421 B<Note:> This does I<not> affect commands like L</add> and L</mount>,
422 or any other libguestfs program apart from guestfish and guestmount.
423
424 =head1 QUOTING
425
426 You can quote ordinary parameters using either single or double
427 quotes.  For example:
428
429  add "file with a space.img"
430
431  rm '/file name'
432
433  rm '/"'
434
435 A few commands require a list of strings to be passed.  For these, use
436 a whitespace-separated list, enclosed in quotes.  Strings containing whitespace
437 to be passed through must be enclosed in single quotes.  A literal single quote
438 must be escaped with a backslash.
439
440  vgcreate VG "/dev/sda1 /dev/sdb1"
441  command "/bin/echo 'foo      bar'"
442  command "/bin/echo \'foo\'"
443
444 =head1 OPTIONAL ARGUMENTS
445
446 Some commands take optional arguments.  These arguments appear in this
447 documentation as C<[argname:..]>.  You can use them as in these
448 examples:
449
450  add-drive-opts filename
451
452  add-drive-opts filename readonly:true
453
454  add-drive-opts filename format:qcow2 readonly:false
455
456 Each optional argument can appear at most once.  All optional
457 arguments must appear after the required ones.
458
459 =head1 NUMBERS
460
461 This section applies to all commands which can take integers
462 as parameters.
463
464 =head2 SIZE SUFFIX
465
466 When the command takes a parameter measured in bytes, you can use one
467 of the following suffixes to specify kilobytes, megabytes and larger
468 sizes:
469
470 =over 4
471
472 =item B<k> or B<K> or B<KiB>
473
474 The size in kilobytes (multiplied by 1024).
475
476 =item B<KB>
477
478 The size in SI 1000 byte units.
479
480 =item B<M> or B<MiB>
481
482 The size in megabytes (multiplied by 1048576).
483
484 =item B<MB>
485
486 The size in SI 1000000 byte units.
487
488 =item B<G> or B<GiB>
489
490 The size in gigabytes (multiplied by 2**30).
491
492 =item B<GB>
493
494 The size in SI 10**9 byte units.
495
496 =item B<T> or B<TiB>
497
498 The size in terabytes (multiplied by 2**40).
499
500 =item B<TB>
501
502 The size in SI 10**12 byte units.
503
504 =item B<P> or B<PiB>
505
506 The size in petabytes (multiplied by 2**50).
507
508 =item B<PB>
509
510 The size in SI 10**15 byte units.
511
512 =item B<E> or B<EiB>
513
514 The size in exabytes (multiplied by 2**60).
515
516 =item B<EB>
517
518 The size in SI 10**18 byte units.
519
520 =item B<Z> or B<ZiB>
521
522 The size in zettabytes (multiplied by 2**70).
523
524 =item B<ZB>
525
526 The size in SI 10**21 byte units.
527
528 =item B<Y> or B<YiB>
529
530 The size in yottabytes (multiplied by 2**80).
531
532 =item B<YB>
533
534 The size in SI 10**24 byte units.
535
536 =back
537
538 For example:
539
540  truncate-size /file 1G
541
542 would truncate the file to 1 gigabyte.
543
544 Be careful because a few commands take sizes in kilobytes or megabytes
545 (eg. the parameter to L</memsize> is specified in megabytes already).
546 Adding a suffix will probably not do what you expect.
547
548 =head2 OCTAL AND HEXADECIMAL NUMBERS
549
550 For specifying the radix (base) use the C convention: C<0> to prefix
551 an octal number or C<0x> to prefix a hexadecimal number.  For example:
552
553  1234      decimal number 1234
554  02322     octal number, equivalent to decimal 1234
555  0x4d2     hexadecimal number, equivalent to decimal 1234
556
557 When using the C<chmod> command, you almost always want to specify an
558 octal number for the mode, and you must prefix it with C<0> (unlike
559 the Unix L<chmod(1)> program):
560
561  chmod 0777 /public  # OK
562  chmod 777 /public   # WRONG! This is mode 777 decimal = 01411 octal.
563
564 Commands that return numbers usually print them in decimal, but
565 some commands print numbers in other radices (eg. C<umask> prints
566 the mode in octal, preceeded by C<0>).
567
568 =head1 WILDCARDS AND GLOBBING
569
570 Neither guestfish nor the underlying guestfs API performs
571 wildcard expansion (globbing) by default.  So for example the
572 following will not do what you expect:
573
574  rm-rf /home/*
575
576 Assuming you don't have a directory called literally C</home/*>
577 then the above command will return an error.
578
579 To perform wildcard expansion, use the C<glob> command.
580
581  glob rm-rf /home/*
582
583 runs C<rm-rf> on each path that matches (ie. potentially running
584 the command many times), equivalent to:
585
586  rm-rf /home/jim
587  rm-rf /home/joe
588  rm-rf /home/mary
589
590 C<glob> only works on simple guest paths and not on device names.
591
592 If you have several parameters, each containing a wildcard, then glob
593 will perform a Cartesian product.
594
595 =head1 COMMENTS
596
597 Any line which starts with a I<#> character is treated as a comment
598 and ignored.  The I<#> can optionally be preceeded by whitespace,
599 but B<not> by a command.  For example:
600
601  # this is a comment
602          # this is a comment
603  foo # NOT a comment
604
605 Blank lines are also ignored.
606
607 =head1 RUNNING COMMANDS LOCALLY
608
609 Any line which starts with a I<!> character is treated as a command
610 sent to the local shell (C</bin/sh> or whatever L<system(3)> uses).
611 For example:
612
613  !mkdir local
614  tgz-out /remote local/remote-data.tar.gz
615
616 will create a directory C<local> on the host, and then export
617 the contents of C</remote> on the mounted filesystem to
618 C<local/remote-data.tar.gz>.  (See C<tgz-out>).
619
620 To change the local directory, use the C<lcd> command.  C<!cd> will
621 have no effect, due to the way that subprocesses work in Unix.
622
623 =head1 PIPES
624
625 Use C<command E<lt>spaceE<gt> | command> to pipe the output of the
626 first command (a guestfish command) to the second command (any host
627 command).  For example:
628
629  cat /etc/passwd | awk -F: '$3 == 0 { print }'
630
631 (where C<cat> is the guestfish cat command, but C<awk> is the host awk
632 program).  The above command would list all accounts in the guest
633 filesystem which have UID 0, ie. root accounts including backdoors.
634 Other examples:
635
636  hexdump /bin/ls | head
637  list-devices | tail -1
638  tgz-out / - | tar ztf -
639
640 The space before the pipe symbol is required, any space after the pipe
641 symbol is optional.  Everything after the pipe symbol is just passed
642 straight to the host shell, so it can contain redirections, globs and
643 anything else that makes sense on the host side.
644
645 To use a literal argument which begins with a pipe symbol, you have
646 to quote it, eg:
647
648  echo "|"
649
650 =head1 HOME DIRECTORIES
651
652 If a parameter starts with the character C<~> then the tilde may be
653 expanded as a home directory path (either C<~> for the current user's
654 home directory, or C<~user> for another user).
655
656 Note that home directory expansion happens for users known I<on the
657 host>, not in the guest filesystem.
658
659 To use a literal argument which begins with a tilde, you have to quote
660 it, eg:
661
662  echo "~"
663
664 =head1 ENCRYPTED DISKS
665
666 Libguestfs has some support for Linux guests encrypted according to
667 the Linux Unified Key Setup (LUKS) standard, which includes nearly all
668 whole disk encryption systems used by modern Linux guests.  Currently
669 only LVM-on-LUKS is supported.
670
671 Identify encrypted block devices and partitions using L</vfs-type>:
672
673  ><fs> vfs-type /dev/sda2
674  crypto_LUKS
675
676 Then open those devices using L</luks-open>.  This creates a
677 device-mapper device called C</dev/mapper/luksdev>.
678
679  ><fs> luks-open /dev/sda2 luksdev
680  Enter key or passphrase ("key"): <enter the passphrase>
681
682 Finally you have to tell LVM to scan for volume groups on
683 the newly created mapper device:
684
685  vgscan
686  vg-activate-all true
687
688 The logical volume(s) can now be mounted in the usual way.
689
690 Before closing a LUKS device you must unmount any logical volumes on
691 it and deactivate the volume groups by calling C<vg-activate false VG>
692 on each one.  Then you can close the mapper device:
693
694  vg-activate false /dev/VG
695  luks-close /dev/mapper/luksdev
696
697 =head1 WINDOWS PATHS
698
699 If a path is prefixed with C<win:> then you can use Windows-style
700 paths (with some limitations).  The following commands are equivalent:
701
702  file /WINDOWS/system32/config/system.LOG
703
704  file win:/windows/system32/config/system.log
705
706  file win:\windows\system32\config\system.log
707
708  file WIN:C:\Windows\SYSTEM32\conFIG\SYSTEM.LOG
709
710 This syntax implicitly calls C<case-sensitive-path> (q.v.) so it also
711 handles case insensitivity like Windows would.  This only works in
712 argument positions that expect a path.
713
714 =head1 UPLOADING AND DOWNLOADING FILES
715
716 For commands such as C<upload>, C<download>, C<tar-in>, C<tar-out> and
717 others which upload from or download to a local file, you can use the
718 special filename C<-> to mean "from stdin" or "to stdout".  For example:
719
720  upload - /foo
721
722 reads stdin and creates from that a file C</foo> in the disk image,
723 and:
724
725  tar-out /etc - | tar tf -
726
727 writes the tarball to stdout and then pipes that into the external
728 "tar" command (see L</PIPES>).
729
730 When using C<-> to read from stdin, the input is read up to the end of
731 stdin.  You can also use a special "heredoc"-like syntax to read up to
732 some arbitrary end marker:
733
734  upload -<<END /foo
735  input line 1
736  input line 2
737  input line 3
738  END
739
740 Any string of characters can be used instead of C<END>.  The end
741 marker must appear on a line of its own, without any preceeding or
742 following characters (not even spaces).
743
744 Note that the C<-E<lt>E<lt>> syntax only applies to parameters used to
745 upload local files (so-called "FileIn" parameters in the generator).
746
747 =head1 EXIT ON ERROR BEHAVIOUR
748
749 By default, guestfish will ignore any errors when in interactive mode
750 (ie. taking commands from a human over a tty), and will exit on the
751 first error in non-interactive mode (scripts, commands given on the
752 command line).
753
754 If you prefix a command with a I<-> character, then that command will
755 not cause guestfish to exit, even if that (one) command returns an
756 error.
757
758 =head1 REMOTE CONTROL GUESTFISH OVER A SOCKET
759
760 Guestfish can be remote-controlled over a socket.  This is useful
761 particularly in shell scripts where you want to make several different
762 changes to a filesystem, but you don't want the overhead of starting
763 up a guestfish process each time.
764
765 Start a guestfish server process using:
766
767  eval "`guestfish --listen`"
768
769 and then send it commands by doing:
770
771  guestfish --remote cmd [...]
772
773 To cause the server to exit, send it the exit command:
774
775  guestfish --remote exit
776
777 Note that the server will normally exit if there is an error in a
778 command.  You can change this in the usual way.  See section
779 L</EXIT ON ERROR BEHAVIOUR>.
780
781 =head2 CONTROLLING MULTIPLE GUESTFISH PROCESSES
782
783 The C<eval> statement sets the environment variable C<$GUESTFISH_PID>,
784 which is how the I<--remote> option knows where to send the commands.
785 You can have several guestfish listener processes running using:
786
787  eval "`guestfish --listen`"
788  pid1=$GUESTFISH_PID
789  eval "`guestfish --listen`"
790  pid2=$GUESTFISH_PID
791  ...
792  guestfish --remote=$pid1 cmd
793  guestfish --remote=$pid2 cmd
794
795 =head2 REMOTE CONTROL DETAILS
796
797 Remote control happens over a Unix domain socket called
798 C</tmp/.guestfish-$UID/socket-$PID>, where C<$UID> is the effective
799 user ID of the process, and C<$PID> is the process ID of the server.
800
801 Guestfish client and server versions must match exactly.
802
803 =head1 PREPARED DISK IMAGES
804
805 Use the I<-N type> or I<--new type> parameter to select one of a set
806 of preformatted disk images that guestfish can make for you to save
807 typing.  This is particularly useful for testing purposes.  This
808 option is used instead of the I<-a> option, and like I<-a> can appear
809 multiple times (and can be mixed with I<-a>).
810
811 The new disk is called C<test1.img> for the first I<-N>, C<test2.img>
812 for the second and so on.  Existing files in the current directory are
813 I<overwritten>.
814
815 The type briefly describes how the disk should be sized, partitioned,
816 how filesystem(s) should be created, and how content should be added.
817 Optionally the type can be followed by extra parameters, separated by
818 C<:> (colon) characters.  For example, I<-N fs> creates a default
819 100MB, sparsely-allocated disk, containing a single partition, with
820 the partition formatted as ext2.  I<-N fs:ext4:1G> is the same, but
821 for an ext4 filesystem on a 1GB disk instead.
822
823 To list the available types and any extra parameters they take, run:
824
825  guestfish -N help | less
826
827 Note that the prepared filesystem is not mounted.  You would usually
828 have to use the C<mount /dev/sda1 /> command or add the
829 I<-m /dev/sda1> option.
830
831 If any I<-N> or I<--new> options are given, the guest is automatically
832 launched.
833
834 =head2 EXAMPLES
835
836 Create a 100MB disk with an ext4-formatted partition:
837
838  guestfish -N fs:ext4
839
840 Create a 32MB disk with a VFAT-formatted partition, and mount it:
841
842  guestfish -N fs:vfat:32M -m /dev/sda1
843
844 Create a blank 200MB disk:
845
846  guestfish -N disk:200M
847
848 =head1 PROGRESS BARS
849
850 Some (not all) long-running commands send progress notification
851 messages as they are running.  Guestfish turns these messages into
852 progress bars.
853
854 When a command that supports progress bars takes longer than two
855 seconds to run, and if progress bars are enabled, then you will see
856 one appearing below the command:
857
858  ><fs> copy-size /large-file /another-file 2048M
859  / 10% [#####-----------------------------------------] 00:30
860
861 The spinner on the left hand side moves round once for every progress
862 notification received from the backend.  This is a (reasonably) golden
863 assurance that the command is "doing something" even if the progress
864 bar is not moving, because the command is able to send the progress
865 notifications.  When the bar reaches 100% and the command finishes,
866 the spinner disappears.
867
868 Progress bars are enabled by default when guestfish is used
869 interactively.  You can enable them even for non-interactive modes
870 using I<--progress-bars>, and you can disable them completely using
871 I<--no-progress-bars>.
872
873 =head1 GUESTFISH COMMANDS
874
875 The commands in this section are guestfish convenience commands, in
876 other words, they are not part of the L<guestfs(3)> API.
877
878 =head2 help
879
880  help
881  help cmd
882
883 Without any parameter, this lists all commands.  With a C<cmd>
884 parameter, this displays detailed help for a command.
885
886 =head2 quit | exit
887
888 This exits guestfish.  You can also use C<^D> key.
889
890 @FISH_COMMANDS@
891
892 =head1 COMMANDS
893
894 @ACTIONS@
895
896 =head1 EXIT CODE
897
898 guestfish returns 0 if the commands completed without error, or
899 1 if there was an error.
900
901 =head1 ENVIRONMENT VARIABLES
902
903 =over 4
904
905 =item EDITOR
906
907 The C<edit> command uses C<$EDITOR> as the editor.  If not
908 set, it uses C<vi>.
909
910 =item GUESTFISH_PID
911
912 Used with the I<--remote> option to specify the remote guestfish
913 process to control.  See section
914 L</REMOTE CONTROL GUESTFISH OVER A SOCKET>.
915
916 =item HEXEDITOR
917
918 The L</hexedit> command uses C<$HEXEDITOR> as the external hex
919 editor.  If not specified, the external L<hexedit(1)> program
920 is used.
921
922 =item HOME
923
924 If compiled with GNU readline support, various files in the
925 home directory can be used.  See L</FILES>.
926
927 =item LIBGUESTFS_APPEND
928
929 Pass additional options to the guest kernel.
930
931 =item LIBGUESTFS_DEBUG
932
933 Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages.  This has the
934 same effect as using the B<-v> option.
935
936 =item LIBGUESTFS_MEMSIZE
937
938 Set the memory allocated to the qemu process, in megabytes.  For
939 example:
940
941  LIBGUESTFS_MEMSIZE=700
942
943 =item LIBGUESTFS_PATH
944
945 Set the path that guestfish uses to search for kernel and initrd.img.
946 See the discussion of paths in L<guestfs(3)>.
947
948 =item LIBGUESTFS_QEMU
949
950 Set the default qemu binary that libguestfs uses.  If not set, then
951 the qemu which was found at compile time by the configure script is
952 used.
953
954 =item LIBGUESTFS_TRACE
955
956 Set C<LIBGUESTFS_TRACE=1> to enable command traces.
957
958 =item PAGER
959
960 The C<more> command uses C<$PAGER> as the pager.  If not
961 set, it uses C<more>.
962
963 =item TMPDIR
964
965 Location of temporary directory, defaults to C</tmp>.
966
967 If libguestfs was compiled to use the supermin appliance then the
968 real appliance is cached in this directory, shared between all
969 handles belonging to the same EUID.  You can use C<$TMPDIR> to
970 configure another directory to use in case C</tmp> is not large
971 enough.
972
973 =back
974
975 =head1 FILES
976
977 =over 4
978
979 =item $HOME/.guestfish
980
981 If compiled with GNU readline support, then the command history
982 is saved in this file.
983
984 =item $HOME/.inputrc
985
986 =item /etc/inputrc
987
988 If compiled with GNU readline support, then these files can be used to
989 configure readline.  For further information, please see
990 L<readline(3)/INITIALIZATION FILE>.
991
992 To write rules which only apply to guestfish, use:
993
994  $if guestfish
995  ...
996  $endif
997
998 Variables that you can set in inputrc that change the behaviour
999 of guestfish in useful ways include:
1000
1001 =over 4
1002
1003 =item completion-ignore-case (default: on)
1004
1005 By default, guestfish will ignore case when tab-completing
1006 paths on the disk.  Use:
1007
1008  set completion-ignore-case off
1009
1010 to make guestfish case sensitive.
1011
1012 =back
1013
1014 =item test1.img
1015
1016 =item test2.img (etc)
1017
1018 When using the C<-N> or C<--new> option, the prepared disk or
1019 filesystem will be created in the file C<test1.img> in the current
1020 directory.  The second use of C<-N> will use C<test2.img> and so on.
1021 Any existing file with the same name will be overwritten.
1022
1023 =back
1024
1025 =head1 SEE ALSO
1026
1027 L<guestfs(3)>,
1028 L<http://libguestfs.org/>,
1029 L<virt-cat(1)>,
1030 L<virt-df(1)>,
1031 L<virt-edit(1)>,
1032 L<virt-list-filesystems(1)>,
1033 L<virt-list-partitions(1)>,
1034 L<virt-ls(1)>,
1035 L<virt-make-fs(1)>,
1036 L<virt-rescue(1)>,
1037 L<virt-resize(1)>,
1038 L<virt-tar(1)>,
1039 L<virt-win-reg(1)>,
1040 L<hexedit(1)>.
1041
1042 =head1 AUTHORS
1043
1044 Richard W.M. Jones (C<rjones at redhat dot com>)
1045
1046 =head1 COPYRIGHT
1047
1048 Copyright (C) 2009-2010 Red Hat Inc.
1049 L<http://libguestfs.org/>
1050
1051 This program is free software; you can redistribute it and/or modify
1052 it under the terms of the GNU General Public License as published by
1053 the Free Software Foundation; either version 2 of the License, or
1054 (at your option) any later version.
1055
1056 This program is distributed in the hope that it will be useful,
1057 but WITHOUT ANY WARRANTY; without even the implied warranty of
1058 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1059 GNU General Public License for more details.
1060
1061 You should have received a copy of the GNU General Public License
1062 along with this program; if not, write to the Free Software
1063 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.