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