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