QuickRef Linux version 2.0.2 October 2003 usermount Executes graphical utility for Contents mounting and unmounting Topic Page filesystems. Mounting Filesystems...... 1 Finding Files and Text Within Files...... 1 exportfs -ra Re-apply NFS export directives as Move Copy, Delete and View Files...... 1-2 listed in /etc/exports. Meta Characters...... 2 Regular Expressions...... 2 Finding Files and Text Within Files File Permissions...... 2 Symbolic Links...... 2-3 find / -name filename Starting at the / directory, find the chmod Modes...... 3 file “filename”. User Administration...... 3 Printing...... 3 find / -name Starting at the / directory, find the man Pages...... 3-4 “*string*” file containing the word “string”. Shutdown & Reboot...... 4 Installing Software...... 4 find / -perm +4000 Find existing files on the system Modules...... 4 -user root -print that have their SUID root Configuration Files...... 4-5 permissions set. System Services...... 5 Crontab...... 5 find / -perm +2000 Find existing files on the system Networking...... 5 -group that have their SGID permissions Archiving...... 5 -print set. Bash Shell...... 5-6 Vim / Vi Editor...... 6 find / -nouser -print Find existing files on the system X Windows...... 6 that don't belong to any user listed ssh and GnuPG...... 6 in /etc/passwd. Tips & Tricks...... 6-7 GNU/Linux Links...... 7-8 info Lists the commands and utilities installed with brief description as to what they are used for, or do. Unless noted, all commands are to be entered on one line (use the " \" continuation character if needed). locate filename Locate a file “filename” using the updatedb database (see next).

Mounting Filesystems updatedb Create or update the database mount -t msdos Mount an MS-DOS formatted used by the locate command. /dev/fd0H1440 floppy disk at /mnt/floppy. /mnt/floppy apropos subject List man pages for “subject”, searches the whatis database for mount -t iso9660 Mount a CD-ROM drive at strings. /dev/cdrom /mnt/cdrom. /mnt/cdrom whatis Search the whatis database for complete words. mount -t vfat Mount a VFAT hard drive partition /dev/hda1 /mnt/win hda1 at /mnt/win. makewhatis Create or update the database used by whatis and apropos mount -t smbfs Mount a SMB share located at commands. //system/share/ //system/share at /mnt/samba. /mnt/samba which filename Show the subdirectory containing the executable file “filename”. mount -t iso9660 Mount an ISO image as a -o loop image.iso filesystem at /mnt/iso using the grep –r textstring Starting with the directory “/dir”, /mnt/iso loopback device. /dir recursively find and list all files containing the string “textstring”. mount -t ext2 Mount a Linux filesystem /dev/pda formatted SyQuest EZ-Drive Move Copy, Delete and View Files /mnt/ezdrive cartridge at /mnt/ezdrive. mv filename Move the file “filename” to the umount /mnt/cdrom Unmount the CD-ROM. /home/dirname directory /home/dirname. cp filename Copy the file “filename” to the /home/dirname directory /home/dirname.

Linux QuickRef 1 rm name Remove the file or directory + Match one or more repeated “name”. occurrences of the previous character. rm -rf dir Remove the entire directory “dir”, forcing the removal of included ? Match zero or one repeated files and subdirectories occurrences of the previous recursively as well. character. ls -l List files in current directory in ^ Matches an expression that long format. follows it at the beginning of a line. Needs double quotes when used ls -F List files in current directory and with grep. indicate the file types. $ Matches the regular expression ls -laC List all files in current directory in that precedes it at the end of a long format and display in line. Needs single quotes when columns. used with grep. cat filename Display the file “filename”. [a-z0-9] Single-character range (“a” through “z” or “0” through “0”). more filename Display the file “filename” one page at a time. Advance pages by [abc123] Single-character choice (“a”, “b”, pressing the spacebar. “c”, “1”, “2” or “3”). less filename Display the file “filename” one [^x,y,z] Single-character choice, but not page at a time. Advance pages by the characters “x”, “y” or “z”. pressing the spacebar, backup with the “b” key. (abc) Grouped characters “abc”. zless filename Same as above, only used with \ Used to escape regular files compressed with gzip. expression characters such as +, *, and ^ to include the literal head filename Display the first 10 lines of the file character in a match. “filename”. File Permissions head -25 filename Display the first 25 lines of the file “filename”. User Group Others d r w x r w x r w x tail filename Display the last 10 lines of the file “filename”. File Type Execute tail -25 filename Display the last 25 lines of the file “filename”. -=file Write d=directory Meta Characters l=link Read b/c=block/char device * Multiple-character wildcard.

? Single-character wildcard. When the command “ls –l” is used, a list of file names is displayed. The first column in this list details the file type and the [a-z0-9] Single-character character range permissions applied to the file. If a permission is denied for a set, (“a” through “z” or “0” through “0”). User (Owner), Group and Others, it is represented by a –.

[abc123] Single-character choice (“a”, “b”, File permissions are altered by giving the “c”, “1”, “2” or “3”). “chmod” command and the appropriate octal Read = 4 code for each set. Ex.: [!xyz] Single-character choice, but as Write = 2 chmod 764 filename not the characters “x”, “y” or “z”. Execute = 1 will make the file “filename” r-w-x for the user, Regular Expressions r-w for the group, and r for any others. . Match a single character (functionally equivalent to how the Symbolic Links '?' character works in glob symlink -r / List all the symbolic links on the expansions). system.

* Match zero or more repeated symlink -rv / | fgrep Find all symbolic links that are occurrences of the previous "dangling" "dangling", excluding other character. mounted filesystems.

ln -l linkname Display the link-path for a link.

Linux QuickRef 2 find . -type l Find all symbolic links and show lpr Print a file. -exec ls -l {} \; what they point to. lprm Remove jobs from print queue. chmod Modes lprm -a Remove all jobs from the print chmod 600 Read and write permissions for queue for the logged user. user only. lprm -a all Remove all jobs for all users from chmod 700 Read, write and execute the print queue (run as root). permissions for user only. lpc Printer control tool. chmod 755 Full permission for user, read and execute for group and others. printtool Run the X Windows printer setup utility. chmod 711 Full permission for user, execute for group and others. ma n Pages chmod 444 Read permissions only for man -k word Display man pages containing everybody. “word”. chmod +x filename Make the file “filename” man subject | Print the man page “subject” as executable for everybody; user, col -b | lpr plain text. group and others. man -t subject | Print the man page “subject” as chmod go-w filename Revoke write permissions for col -b | lpr Postscript. group and others on the file “filename”. Manual pages are organized into topics: /usr/man/man1 Commands - Commands you run from chmod ug=r filename Set the permissions to readable within a shell. only for user and group on the file “filename”. /usr/man/man2 System Calls - Documentation for kernel functions. chmod a=r,u+w Set the permissions to readable filename only for all (everybody) and add /usr/man/man3 Library Calls - Manual pages for libc write-able for user on the file functions. “filename”. /usr/man/man4 Special Files - Information about files in User Administration the /dev/ directory. useradd username Create a new user account named /usr/man/man5 File Formats - Details of formats for / “username”. etc/passwd and other files. passwd username Assign a password to “username”. /usr/man/man6 Games. su -or- su - Switch user to root, or root and to /usr/man/man7 Macro Packages - Descriptions of the Linux include root’s set environment file system, manual pages, and others. (must know root password to use). /usr/man/man8 System Management - Manual pages for su -c "command" Run “command” (include any root operator utilities. options within the quotes) as root. /usr/man/man9 Kernel Routines - Documentation on Linux su username Switch user to “username” . kernel source routines or kernel module specifications. exit Exit, logoff or logout of account. And each man page is organized into sections: Printing Name The name of the command and a brief /etc/rc.d/init.d/lpd Start the print daemon. description. start Synopsis How to use the command and command- /etc/rc.d/init.d/lpd Stop the print daemon. line options. stop Description An explanation of the program and its /etc/rc.d/init.d/lpd Display the status of the print options. status daemon. Files A list of files used by the command and their lpq Query and display jobs in print location. queue. See Also A list of related man pages. lpq -a As above, only for all printers controlled by the lpd daemon. Diagnostics A description of unusual output.

Linux QuickRef 3 Bugs Known problems. rpm -ql name Query for the installed version and list the files in the RPM package Author The program's main author and other “name”. contributors. rpm -Va Verify the integrity of all currently Shutdown & Reboot installed packages. shutdown -h now -or- Shutdown the system now and rpm -qai Query all installed packages, init 0 halt (no reboot). displaying details on each package. shutdown -r now -or- Shutdown the system now and init 6 reboot. rpm -i --force name Reinstall package “name”, forcing the installation of all files included. shutdown -r 5 Shutdown the system in 5 minutes and reboot. M odules halt Stop all processes and shutdown. insmod Inserts a module into the kernel. reboot Stop all processes and reboot. lsmod Lists the modules currently used by the kernel. Installing Software rmmod Removes a module (use 'lsmod' to ./configure ; make ; Execute the scripts preparing the determine module name). make install source files for compiling and installation on the system. depmod Creates a "Makefile" dependency file (modules.dep). apt-get update Update package list. modprobe Loads the modules.dep apt-get upgrade Upgrade installed packages. dependency file created by 'depmod'. apt-get upgrade -u Upgrade installed packages. Will not install new or remove old packages (they're put on “hold”). Co nfiguration Files /etc/inittab Specifies the runlevel that the apt-get install Install package ”name” (also system should boot into. name resolves any dependencies). /etc/fstab List of devices, mount points and apt-get remove Removes package “name” (also mount options (read, write, etc.). name removes any unneeded dependencies). /etc/exports Filesystems being exported by the NFS (Network File System) dpkg -i pkg.deb Install package “pkg.deb”. daemon. dpkg -r pkg.deb Removes package “pkg.deb”. /etc/motd Message Of The Day; displayed to all users at login. dpkg -iGRE temp Install all packages in the directory “temp” (including subdirectories) /etc/rc.d/rc.local Shell script that is executed at the that are newer or not already end of boot process. installed. /etc/profile Global environment variables. rpm -ivh name.rpm Install the RPM package “name.rpm”. /etc/bashrc Global functions and aliases. rpm -Uvh name.rpm Upgrade or install RPM package /etc/cron.* Directories that automatically “name.rpm”. execute scripts stored within at timed intervals. rpm -Fvh name.rpm Upgrade only previously installed RPM package “name.rpm”. /etc/HOSTNAME Contains full host name, including domain. rpm -e name Delete the RPM package “name” (do not include “.rpm” extension). /etc/hosts A list of known host names and IP addresses on the network. rpm -e name --nodeps Force deletion of RPM package “name, even if dependencies are /etc/resolv.conf Defines IP addresses of DNS present. servers. rpm -l name List the files in the RPM package /etc/samba/smb.conf Configuration file for the Samba “name”. server, allowing file/print sharing with MS Windows clients.

Linux QuickRef 4 /etc/httpd/conf/ Configuration file for the Apache httpd.conf web server. Ne tworking ifconfig -a List IP address for all devices on /etc/X11/XF86Config Configuration file for X Windows. system.

/usr/X11R6/lib/X11/ X Window application defaults. ifconfig eth0 Assign the IP address app-defaults 192.168.1.12 192.168.1.12 to the first Ethernet broadcast device (eth0), using standard ~/.Xdefaults Configuration file for some X 192.168.1.255 Class C broadcast and netmask. Window applications. netmask 255.255.255.0 ~/.xinitrc Defines the window manager loaded by X Windows. route add -net Adds a route for a default gateway default gw located at 192.168.1.100 for the ~/.Xclients Defines the window manager 192.168.1.100 system. loaded by X Windows (Red Hat). netmask 0.0.0.0 metric 1 System Services chkconfig --list Reports whether an xinetd system Ar chiving service has been started or tar -xvf archive.tar Decompress the files archived in stopped. the tarred file “archive.tar.gz”, listing the contents to the console. chkconfig --list Checks the status of a particular service. tar -xzvf Decompress the files archived in archive.tar.gz the gzipped and tarred file chkconfig --level 345 Turns “nscd” service off in “archive.tar.gz”. nscd off runlevels 3, 4, and 5. tar -xjvf Decompress the files archived in /etc/init.d/ Stop, start or restart the individual archive.tar.bz2 the bzip2 and tared file stop -or- start -or- service . “archive.tar.bz2”. restart tar -tvf archive.tar Display list of contents in file service stop Stop, start or restart the individual “archive.tar”. -or- start -or- restart service . (rh) tar -cvf filename Create a tar file, “filename.tar”, /etc/init.d/xinetd To stop, start or restart a service from file “filename”. stop -or- start -or- which is managed by xinetd. restart tar -cxvf filename Create a gzipped tar file, “filename.tar.gz”, from file service xinetd stop To stop, start or restart a service “filename”. -or- start -or- restart which is managed by xinetd. (rh) tar -cjvf filename Create a bzip2 tar file, Linux Runlevels 3 Multiuser mode (console) “filename.tar.bz2”, from file 0 Halt 4 unused “filename”. 1 Single-user mode 5 Multiuser mode (X Windows) 2 Multiuser, without NFS 6 Reboot tar -cMf /dev/fd0 Backup the contents of the current directory, including subdirectories, Crontab to multiple floppy disks. crontab -u Edit a user's crontab file directly bzip2 -dc Un-bzip2 and untar “file.tar.bz2” -e using the environment-specified | -tar -xvf - editor. crontab -u Read a file of cron job entries into Ba sh Shell a user's crontab file. history Search through the history file.

0,15,30,45 * * * * Run the command 'fetchmail' history 20 List the last 20 commands fetchmail every 15 minutes. entered.

* */4 * * * backup >> Run a backup job every 4 hours, history | grep Pipe the output of history though /root/backup-log writing all stdout and stderr to a variable the grep command, searching for 2>&1 log file. “variable”.

Crontab /etc/crontab format !! Executes the last command Entry Meaning * * * * * command entered in the history file. 0-59 Minute 0-23 Hour !# Executes the command numbered 1-31 Day of Month "#" in the history file. 1-12 Month 0-7 Day of Week

Linux QuickRef 5 !string Executes the command with the Ctrl-Alt+ -or- Increase or decrease screen most recent matching string Ctrl-Alt– resolution. “string”. Ctrl-Alt-Fn Switch to virtual console n, where env Display the shell environment n is a number from 1 to 6. variables. Ctrl-Alt-F7 Return to the current X session. printenv Display the environment variables in use. Shift-Ctrl-F8 Resize the selected window. Vim / Vi Editor Shift-Ctrl-r Refresh the screen. :q Quit, saving changes. Shift-Ctrl-x Start an xterm session.

:q! Absolute quit (no prompt). Ctrl-Alt-Esc Invoke the xkill cursor.

:wq Write file, then quit. Ctrl-Alt-BkSpace Kill the X-server. x Delete character at cursor. s sh and GnuPG dw -or- dd Delete word or delete line. ssh-keygen Generate a pair of public and private keys. D Delete from cursor to EOL. ssh -t myserver top Run the console program “top” on u Undo. “myserver” remotely.

. Repeat last edit command. gpg –gen-key Generate a pair of public and secret (private) keys. :set paste -and- Allows pasting indented lists :set nopaste without cascading the indents. gpg –output Generate a revocation certificate Use ':set nopaste” after pasting. revokedkey.asc for a private key, redirected to file --gen-revoke keyID "revokedkey.asc". vim `find . -name "*" Search for a pattern within the -exec grep -l files in the current directory, then gpg -r username Encrypt file "filename" for recipient "pattern" {} \; edit the file if found. -sea filename "username", creating signed -print` armored ASCII text file "filename.asc". X Windows gpg -o filename Decrypt the file "filename.asc", startx Start X Windows. -d filename.asc producing the original file "filename". startx -- :1 Run an X session on another terminal. Use Ctrl-Alt-F7 and gpg --import user.asc Import public key for user to your Ctrl-Alt-F8 to switch displays. public keyring from file "user.asc".

XF86Setup An X configuration utility with gpg --export –armor Export public key from your automatic probing of graphics username > key.asc keyring to an ASCII armored file cards. "key.asc".

Xconfigurator Another X configuration utility with gpg --list-keys List keys in your public keyring. automatic probing of graphics cards. gpg –fingerprint Display fingerprints for keys in username public keyring for "username". xf86config A text-based X configuration menu. gpg -c filename Symmetrically encrypt the file “filename”. xvidtune An X graphics tuning utility. tar -cf - /dir Create a tar file of a directory, gnome-session Starts GNOME in the .xinitrc or | gpg -c -o then symmetrically encrypt the file .Xclients files. encrypted_dir.gpg (GnuPG uses gzip compression natively). startkde Starts KDE in the .xinitrc or .Xclients files. T ips & Tricks fvwm95 Starts fvwm95 in the .xinitrc or df -h Displays disk filesystems .Xclients files. mounted, including space used and available, in “human- Alt-Esc Display a list of active windows. readable” form.

Linux QuickRef 6 /sbin/e2fsck hda5 Execute the filesystem check Alt-← Switch to the next lowest virtual utility on the hard drive partition console. hda5 (unmount hda5 first!). reset Resets your terminal console if a mkbootdisk –-device Creates a boot disk on the floppy binary file was displayed with cat. /dev/fd0 –2.4.20 drive with version 2.4.20 of the kernel. stty -s Display what special characters (such as ^C for interrupt, ^U for fdformat Format a floppy disk in device fd0 kill, ^Z to stop, ^Q to quit, etc.) /dev/fd0H1440 as high-density 1.44 MB. are used on the system.

/sbin/mke2fs -c Format a floppy disk with the split -b 1420k Split “bigfile” into smaller 1420k /dev/fd0 Linux ext2 filesystem, checking bigfile files, xaa, xab, xac, etc. that fit on for bad blocks. a floppy disk. dd if=/dev/hda Create a data dump of one hard cat xaa xab xac > Reassemble “bigfile” from smaller of=/dev/hdb drive onto another (ghosting). bigfile files created with 'split'. cat /var/log/messages Display the system log with rename .htm .html * Rename all files in the directory | less paging. with “.htm” extensions to “.html”. cat /var/log/dmesg Display the boot messages log for i in $1 ; do mv Rename all files in the directory, | less with paging; useful for "$i" `echo $i | replacing any spaces in filenames troubleshooting. sed 's/ /_/g'` ; with the underscore character. done dmesg | less Same as above. rdate -s ntpserver Synchronize your machine's linux single Issued at LILO prompt, will boot && hwclock system and hardware clocks with into single-user mode (if root --systohc a network time server (given as a password is lost, boot “linux hostname or IP address). single” and change password). ifconfig | awk Lists just the IP addresses ps List current running processes for '/inet/{print $2}' currently bound to the system. logged user. | awk -F: '{print $2}' ps -aux List all current running processes for all users and daemons. ldd /path/program List all of the shared library dependencies used by “program”. kill 1234 Kill (stop) a process with job ID of “1234”. GN U/Linux Links kill -9 `ps -fu uname Run as root, kills all processes http://www.kernel.org/ |awk '{ print $2 } being run by the user “uname”. Archives – The kernel sources. '|grep -v PID` http://www.fsf.org/ sysreport Collects detailed info on the Free Software Foundation – GNU General Public License system's hardware and setup, (GPL) and GNU software utilities and commands. creating a compressed tar file in the /tmp directory by that name. http://www.debian.org/ (rh) Linux – GNU/Linux distributor. ulimit -c Displays current limit on core file http://www.redhat.com/ size. Red Hat Linux – GNU/Linux distributor. ulimit -c 1000 Sets allowable size limit on core http://www.suse.com/ files to 512K (1000 x 512-byte SuSE – GNU/Linux distributor. blocks). http://www.mandrake.com/ uname -a Displays system info (OS, host Mandrake – GNU/Linux distributor. name, kernel version, date, time, time zone, year, processor type http://www.slackware.com/ and label). Slackware Linux Project – GNU/Linux distributor.

Alt-Fn Switch to virtual console n, where http://www.gentoo.org/ n is a number from 1 to 7 (the Gentoo Linux – GNU/Linux distributor. default maximum). http://www.apache.org/ Alt-→ Switch to the next highest virtual Apache Software Foundation – web server software. console.

Linux QuickRef 7 http://www.squid-cache.org/ http://www.perldoc.com/ Squid – web proxy cache software. PerlDoc – Perl documentation. http://www.samba.org/ http://www.ooodocs.org/ Samba – file sharing with Windows systems. OOo Docs – OpenOffice forums and docs. http://www.sendmail.org/ http://linux.oreilly.com/ Sendmail – email server software. O'Reilly Linux – Linux articles and books. http://www.mysql.com/ http://www-106.ibm.com/developerworks/linux/ MySQL – SQL database server software. IBM developerWorks – Linux articles and tutorials. http://www.perl.com/ http://www.nichedev.org/ Perl – software programming/scripting software. Niche Development – Linux and technical docs. http://wwwxfree86.org http://www.linuxgazette.com/ Xfree86 Project – X11 software. Linux Gazette – monthly . http://www.gnome.org/ http://www.linuxjournal.com/ GNOME Project – desktop environment software. – monthly Linux magazine. http://www.kde.org/ http://www.linux-mag.com/ K Desktop Environment – desktop software. Linux Magazine – monthly Linux magazine. http://www.openoffice.org/ http://www.linux.com/ OpenOffice.org – Office suite software. Linux.com – news, articles and resources. http://www.vim.org/ http://www.lwn.net/ Vim (Vi IMproved) – text editing software. Linux Weekly News – news and resources. http://www.mozilla.org/ http://www.rootprompt.org/ Mozilla – web browser software. RootPrompt – news and resources. http://www.mutt.org/ http://www.promote-opensource.org/ Mutt – email client software. Promote Open Source – news and resources. http://www.gnupg.org/ http://www.linuxguru.net/ GnuPG – GNU Privacy Guard personal encryption and digital LinuxGuru – news and articles. signature software. http://www.ugu.com/ http://www.gimp.org/ UNIX Guru Universe – tips and resources. GIMP – GNU Image Manipulation Program. http://www.sourceforge.net/ http://wwwroaringpenguin.com/ SourceForge – open-source software projects. Roaring Penguin – PPPoE software. http://www.rpmfind.net/ http://www.tldp.org/ RPMfind – online RPM package search. The Linux Documentation Project – HOWTOs, manuals and documentation. http://www.linuxsecurity.com/ Linux Security – alerts and patch resources. http://www.icon.co.za/~psheer/book/rute.html.gz RUTE Linux – book on Linux. http://www.linmodems.org/ LinModems – Linux modem compatibility list. http:// oreillynet.com/linux/cmd/ O'Reilly Linux Commands – online reference. http://freshmeat.net/ freshmeat – Linux and open-source software. http://www.pathname.com/fhs/ Filesystem Hierarchy Standard – filesystem layout and http://counter.li.org/ structure standards. Linux Counter – Registry of Linux users; get counted! http://www.dsl.org/book/ http://www.thelinuxshow.com/ Linux Cookbook – tips, tricks and recipes for Linux. The Linux Show – a weekly Linux talk show. http://www.oualline.com/vim-cook.html Vim Cookbook – tips, tricks and recipes for Vim. LINUX IS A REGISTERED TRADEMARK OF . COPYRIGHT 2000-2003 DAVID D. SCRIBNER. http://cvsbook.red-bean.com/ CVS Book – very good book on using CVS. THIS DOCUMENT MAY BE FREELY DISTRIBUTED IN ACCORDANCE WITH THE GNU FREE DOCUMENTATION LICENSE (A COPY WHICH IS PROVIDED IN THE OPENOFFICE FILE'S DOCUMENT PROPERTIES).

Linux QuickRef 8