Debian GNU/Linux Quick Reference Card ===================================== Prepared by Ben Pfaff , 2001-08-30. Conventions ----------- In commands: - Literal text is written as-is. - Make appropriate substitutions for words in . - Optional parts are written in [square brackets]. - Repetition is indicated by an ellipsis... Documentation ------------- - There is a "manual page" or "manpage" for every command. To view it, use the command "man ". The manual is divided into several sections, so sometimes you see the notation "name(#)", where # is a section number. To view manpage in a particular section, use the command "man
". - The GNU Info system has detailed documentation for GNU software. Use the command "info" to start up the Info viewer at its top-level table of contents, or "info " for Info documentation on a particular . Package Management ------------------ These programs allow software to installed and removed. apt is the high-level package manager. Downloads and installs complete sets of software with a simple, automated interface. Almost foolproof. dpkg is the low-level package manager. Installs and removes programs. Will prevent serious mistakes, most of the time, but not as easy to use as apt. apt uses dpkg internally to do most of its operations. These commands can be executed by any user: - To search the apt database for a program with a particular purpose, whether it's currently installed or not, think of an appropriate keyword or two, then: "apt-cache search []...". - To show detailed info on package(s) that might not be installed, but you're interested in (e.g., one that showed up in the search above): "apt-cache show []...". - To briefly list all the packages currently installed: "dpkg -l". You can pipe this list through `grep' if you want to look for something in particular: "dpkg -l | grep web", for instance, to list web browsers. (Note that this searches only the first line of descriptions, not full descriptions as would "apt-cache search".) - To list all the files in a package: "dpkg -L ". This can be useful to find out what programs a package has for you to run, or what documentation it includes, etc. - Sometimes you want the inverse operation, that is, to find out what package a particular file belongs to. Use "dpkg -S " to do this. should be a full filename starting at the root, e.g., "dpkg -S /usr/bin/vi". For executable programs you can use `which' to help out, e.g., "dpkg -S `which vi`" is equivalent to the previous command (note the double backquotes ``). - For the "status" of an installed package, which includes its version number, the other packages that it needs to properly function (its "dependencies"), packages it can't get along with (its "conflicts"), the files it includes that can be modified to configure it (its "conffiles"), its description, and more: "dpkg -s ". - If there's a command here that you don't have, you can find out what package it's in at . Scroll down to "Search the Contents of the Latest Release", type the command name in as "Keyword", select "unstable" as the Distribution, and click "Search". The PACKAGE column in the results should tell you what package to install; ignore everything before the slash and type the rest in as the argument to "apt-get install" (see below). These commands must be executed by root: - To install package(s) and all of their dependencies, remove their conflicts, etc.: "apt-get install []...". - To remove packages(s) with the same kind of checking: "apt-get remove []...". - If apt has trouble downloading, then it needs to grab a new list of packages: "apt-get update". - To upgrade everything to the latest and greatest software (after you've run "apt-get update"): "apt-get -u dist-upgrade". The `-u' option causes a list of upgraded packages to be printed. You can add `-d' to cause it to just download the necessary packages without installing them, then install them later by omitting `-d'. Normally apt will ask for confirmation before beginning; use `-y' to skip the confirmation. - To upgrade just a package or two to their latest and greatest versions (after "apt-get update"): "apt-get install []...". - apt does not automatically delete downloaded packages after it installs them, which can waste a lot of space. You can run "apt-get autoclean" every so often to take care of this. If you have any luck at all, you'll never need any commands but the above for package management, and maybe not even all of those. But I'll mention some others for a little more completeness. Many of these deal with `.deb' files, which store Debian packages. Typically these are named _-[_].deb, where: - is the package's name, such as `mozilla' or `dpkg'. This is the name as used on (for instance) "apt-get install". For packages that can have multiple versions installed at once this may include an abbreviation of the version number, e.g., `libc6' or `gimp1.2'. - is the full version number as assigned by the program's author; e.g., `dpkg' might version 1.9.17 or `gimp1.2' might be version 1.2.2. - is the Debian revision number, usually a single number like 1 or 23. This corresponds to the number of times the guy who made the package (the Debian maintainer) has fixed or changed the particular of the program. - is the computer architecture that the program is compiled for. For PCs this is `i386', for modern Macs it's `powerpc', and so on. It's often omitted. You can deal with these files individually with dpkg, but it's kind of a pain. You're far better off using apt if you can. Here's some of the commands if you want to try them anyway: - To show the files that would be installed by a `.deb' file: "dpkg-deb -c ". - To show info on the package in a `.deb' file: "dpkg-deb -I ". - To install software from `.deb' file(s): "dpkg -i []...". This will produce errors if any dependencies would be violated. Use "apt-get install" by preference. - If you've installed software with "dpkg -i" but some of it failed to install properly because of dependencies, then "dpkg --configure --pending" may be able to clean up, as long as you later installed the dependencies. - To directly uninstall software: "dpkg -r ". Again, dependencies may be a problem. Note that this uses the package name, not a filename. Use "apt-get remove" by preference. - To uninstall and "purge" software: "dpkg --purge ". To "purge" a program means to remove configuration files as well as other files. By default dpkg leaves configuration files so that if you reinstall later you don't have to reconfigure. System Administration --------------------- - To mount a disk, such as a floppy, Zip, CD-ROM, use "mount ". Typical s include /floppy, /zip, /cdrom. (This will only work with disks set up in /etc/fstab. See mount(8) and fstab(5) for more information.) - To umount a disk, use "umount ". You can't unmount a disk if it's in use; note that having the current directory under a disk's mount point counts as use. You can't eject many kinds of media (Zip disks and CD-ROMs for instance) when they're in use, and it's not a good idea even if you can. - `df': "disk free", displays amount of used and free disk space on all mounted disks/partitions. - `halt': Terminates all programs and shuts down the computer. - `reboot': Terminates all programs and reboots. Ctrl+Alt+Del from a console will do the same thing. - `passwd': Change your password. Root can use "passwd " to change another user's password. - `su': Start a shell as another user, root by default. Exit the shell with "exit" or "logout" to resume life as the previous user. File Management --------------- All of these commands can take the `-i' ("interactive") flag to warn you if you're about to delete an existing file. Its use is recommended in moments of doubt. There is also `-f' ("force") to prevent these commands from ever asking for confirmation. - To copy a file from to , use "cp ". You can also specify a bunch of files and a directory to copy them into: "cp []... ". - To move or rename a file, use `mv', with the same syntax as `cp'. - Files can have multiple names or `links'. Use `ln' with the same syntax as `cp' for this: "ln ". - Links don't work across disks, but you can use "symbolic links" ("symlinks") instead. Use "ln -s ". Note that a symbolic link is just a kind of text substitution or macro. It doesn't really create a second name for a file; the symlink can exist independently from the file. - To delete files: "rm []...". Deleting a link just deletes that name; the file will still exist as long as there's at least one name for it. Deleting a symlink never deletes the associated file, but deleting the associated file is permanent. To delete a directory and all of its contents, including nested directories and their contents, use "rm -r ". The command "rm -rf " is even more aggressive. These commands also exist, but don't take `-i' or `-f': - To list files, use "ls". Use `-l' to get extra info, `-a' to also list files whose names begin with `.'. - To create a directory: "mkdir ". - To remove an empty directory: "rmdir ". If the directory seems empty but can't be removed, try "ls -a " to check for hidden "dot-files" whose names begin with `.'. Use "rm -r " to delete a directory and all of its contents, including nested directories and their contents, use "rm -r ". - To create an empty file, or update the "last modified" time on an existing file: "touch ". To search for files with particular names: - The `locate' program keeps a database of files on the system, updated once a day. Use "locate " to search for a file whose name contains . - The `find' program searches within a directory tree. Its syntax is complex but basic usage is "find -name ''" to search in for files whose names contain . Use `-iname' instead of `-name' to search case insensitively. To adjust file ownership and permissions, use these commands. These only work on native Linux/Unix filesystems, not on MS-DOS disks, CD-ROMs, and so on. Use "ls -l" to view ownership and permissions. - `chmod': Change file permissions. See chmod(1) for details. - `chown': Change file owner and/or group. See chown(1) for details. - `chgrp': Change file group. See chgrp(1) for details. Compression and Archiving ------------------------- In the Windows world, a `.zip' file is a compressed archive. In Unix compression and archiving are separated. To get the equivalent of a compressed archive, first files are archived together into a `.tar' ("tape archive") file, then the `.tar' file is compressed to produce a `.tar.gz' (sometimes called a `.tgz'). - To produce an archive named consisting of the contents of and all its files and subdirectories, use "tar cf ". Typically should have a `.tar' extension. You can use `.' for to archive the current directory, but that's usually the wrong thing to do. - To compress a file (such as a `.tar' file): "gzip ". This will rename so it has a `.gz' extension. - To directly produce a `.tar.gz' named from : "tar cfz ", which combines both of the above into one step. You can of course unpack a compressed archive, too: - To uncompress a `.gz' file: "gunzip ". This will rename removing the `.gz' extension. If doesn't have a `.gz' extension then you may need to rename it before beginning. `gunzip' also understands a couple more compression formats, whose files generally have `.z' or `.Z' extensions. - To produce the contents of a gzipped file on stdout so that you can pipe it into something else, use `zcat'; e.g., `zcat foo.text.gz | less'. - To view a list of files in a `.tar' archive, use "tar tf ". If the archive is compressed, use "tar tfz ". For more information use "tfvv" or "tfzvv" in place of the second words in each command, respectively. - To extract the content from a `.tar' archive into the current directory, use "tar xf ", or "tar xfz " for a compressed archive. Besides `gzip' there is an archiver named `bzip2' as well, which has commands `bzip2', `bunzip2', and `bzcat'. bzipped files have `.bz2' extensions. You can use `bzip2' compression with tar by substituting `j' for `z' in the commands above. The `tar' program has a bazillion options. Start with `tar --help' for more information. Processes --------- - To list programs running from the current session, use "ps". To list all programs running anywhere, use "ps ax". For an interactive display of running programs, use "top". - To kill a running program, use "kill ", where is the program identifier from the PID column in the `ps' output. Text Files ---------- - To view a text file, use "less ". gzip-compressed files can be viewed directly with "zless ". - To search for a text string , use "fgrep []...". To search for a regular expression (see grep(1)), use "grep []...". These programs have lots of sometimes-useful options, refer to grep(1) for details. To search all the files within a directory and its nested subdirectories for a regular expression, use "grep -r ". - To display differences between text files, use "diff -u ". See diff(1) for details. The wdiff program is also useful for this, if installed. - `head': Outputs the first 10 lines in a file. - `tail': Outputs the last 10 lines in a file. "tail -f " watches a file and displays new contents as they are added to the end; this is occasionally useful for log files, for instance. - `uniq': Outputs a file, discarding duplicate lines that occur in sequence. Often used along with `sort'. - `sort': Outputs a sorted version of the lines in its input. Many options, see sort(1) for details. - `wc': Counts the lines, words, and characters in its input file(s). Network ------- - `pon': Dial out to the Internet. - `poff': Terminate dial-up connection. - `ftp': Basic command-line FTP client. - `lftp': Supercool command-line FTP client on steroids, featuring name completion with the Tab key, automatic recovery and resume on connection loss or modem hangup, and lots of other stuff. - `lynx': Basic console web browser with persistent cookie and SSL support. - `links': Console web browser with table and frame and SSL support. - `w3m': Console web browser comparable to `links' in features but a different style of interface. - `ping': "Packet INternet Groper", for testing connections. Use "ping " to see if your computer can talk to another in the most basic way. - `traceroute': (root only) List the Internet hosts directly between your computer and another: "traceroute ". - `telnet': Open an network terminal connection. - `ssh': "Secure SHell": encrypted telnet for the 21st century. - `wget': Retrieves the contents of specified URLs and stores them as files. "wget -r " will also retrieve the pages that that the specified URL references, so it is useful for downloading entire websites and storing them on the local computer for quick loading later. TeX/LaTeX --------- - "tex ": Process plain TeX file into a `.dvi' file. - "latex ": Process LaTeX file into a `.dvi' file. - "texi2dvi ": Process LaTeX file into a `.dvi' file and makes sure that tables of contents, indexes, cross-references, etc., are all properly up-to-date. - "texi2pdf ": Process LaTeX file into a `.pdf' file. - "dvips ": Print a `.dvi' file on the default printer. - "dvips -o ": Convert a `.dvi' file to a PostScript `.ps' file. - "dvipdfm ": Convert a `.dvi' file to a `.pdf' file. - "ps2pdf ": Convert a `.dvi' file to a `.pdf' file. - "xdvi ": Preview a `.dvi' file under X. There are several ways to produce a `.pdf' file from a LaTeX document: - Use texi2pdf. If this produces good results, this is the best way. It produces small files as a result. It doesn't work well with documents that contain graphics or unusual fonts. - Use texi2dvi, then dvips, then ps2pdf. This will almost always work, but the files it produces may be big and might not view well with Adobe Acrobat or `xpdf'. - Use texi2dvi, then dvipdfm (if you have it). This is intermediate: sometimes it works well, sometimes it doesn't. - Other ways. There are still other, more esoteric ways, but I don't remember them right now. PostScript and PDF ------------------ These tools deal with `.ps' and `.pdf' files. - `gv': The "GhostScript Viewer". Display and print entire PostScript or PDF documents or individual pages. - `xpdf': A viewer for `.pdf' files. Cannot deal with some kinds of fonts. - `ps2pdf', `pdf2ps': Convert PDF to PostScript and vice versa. - `pdftops': Another program to convert PDF to PostScript. - `pdftotext': Convert a PDF file to plain text format. - `pstotext', `ps2ascii': Convert a PostScript file to plain text format. Printing -------- This assumes you're using magicfilter or other smart printing system. - "lpr ": Print , which should be a text file or PostScript document. - "lpq": List currently queued print jobs. - "lprm ": Remove job numbered from the print queue. Odd Formats ----------- - `unzip', `zip': Deal with Windows-style `.zip' files. - `word2x': Attempts to convert Microsoft Word documents into other formats.