You are on page 1of 6

1.

Essential Linux Commands

To learn more about a particular command, view the manual page associated with it - simply type man followed by the name of the command you want to learn about. To exit from a manual page, press the q key (where q stands for quit). Most commands have options associated with them - dont try to guess the options ... read the manual page!

Working with Files and Directories


cat cd chmod chown cp find ftp grep gzip/gunzip head ispell less locate ln ls mkdir mv pwd rm rmdir sort tac tail wc zcat zmore type a disk-le to the screen change directory (or return to %HOME directory) change the mode of a disk-le (e.g., to make it executable) change the owner of a disk-le or directory copy a disk-le/directory to a new location search for a disk-le on the system (see locate) transfer disk-les from one system to another search for a text string in a group of disk-les compress/uncompress a disk-le or group of disk-les display the rst few lines of a disk-le on the screen spell-check a disk-le using the system dictionary type a disk-le to the screen one screen-full at a time locate a specic disk-le on the system (see find) create a symbolic link (alias/shortcut) to a disk-le list the contents of a directory to the screen create a new directory move or rename a currently existing disk-le/directory display the name of current working directory delete one or more disk-les delete a directory sort a disk-le (using various techniques) type a disk-le to the screen in reverse order (see cat) display the last few lines of a disk-le on the screen display the character, word, or line count of a disk-le type the contents of a compressed disk-le to the screen like zcat, only display the disk-le a screen-full at a time

Printing Commands
lpq lpr lprm check the status of your entries on the print queue add an entry to the print queue remove an entry from the print queue

Networking Commands
netstat ping traceroute show the network status for this system is there anybody out there? Check a host for existence show me how to get from here to there

Working with Processes


kill ps top w stop a process (program) from running report on the active processes who is doing what, and how much CPU are they using? display a summary of system usage on the screen

Working with Disks


df du how much free disk space is there? how is the disk space being used?

Miscellaneous Commands
cal clear date echo man passwd perl su telnet uname users vi whereis which who whoami Ctrl-D display a calendar on the screen clear the screen display the current date and time on the screen display a message on the screen read a manual page (type man man to learn more) change your password run Perl (a great programming language . . . ) create a shell under the ID of some other user log into a remote computer display the machine and operating system name list the current login sessions on the system run vi (a great text editor . . . ) locate a binary (executable), source, or manual page disk-le list the path to a particular binary disk-le (executable) who is currently logged in cause Ive forgotten . . . signal end-of-le to running process (key combination)

Essential Systems Administrator Commands


Note that you will need to be logged in as root to use these commands eectively. Remember, as root you have complete power over Linux (so be careful). cron dmesg e2fsck fdisk fdisk ifconfig kill lilo lpc mke2fs mount reboot rpm shutdown tar umount execute commands at scheduled times display the system control messages check the health of a disk ddle with disk partitions (be very, very careful) you are being careful with fdisk, arent you? congure your network interface card see kill above . . . much more fun as root . . . install the Linux Loader (read the man page) control a print queue create a disk-le system (i.e., format a disk) add a disk into the active disk-le system (read the man page) reboot now! the RedHat Package Manager perform a nice safe, graceful, shutdown of the system work with tarred disk-les (read the man page) remove a disk from the active disk-le system

1.2

vi Quick Reference

This quick reference will get you started. To learn more, from the Linux command-line, type: man vi.

Invoking the vi Text Editor


vi - start the vi editor with an empty edit buer vi le - edit a le called le vi +n le - edit a le called le and go to line n vi +/pattern le - edit a le called le and go to the rst line that matches the string pattern

vis modes
vi can be in one of three modes: edit mode - keys typed are added to the edit buer non-edit mode - keys typed adjust or move around the edit buer ex mode - commands are executed within vi, and the commands aect the edit buer To enter edit mode, press the Esc key then type i To enter non-edit mode, simply press Esc To enter ex mode, press Esc then type :

Non-edit mode keystrokes


0 $ w b o O i a A go go go go go to to to to to start of current line (rst non-blank character) start of current line end of current line next word previous word (back)

insert blank line below current one, enter edit mode insert blank line above current one, enter edit mode enter edit mode by inserting text at current location enter edit mode by appending text after current location enter edit mode by appending to the end of the current line 4

J Ctrl-G nG G

join the current line with that line immediately below it show current line number go to line n within the edit buer go to bottom of edit buer

Deleting text (in non-edit mode)


dd dw d d$ x delete delete delete delete delete current line next word to start of line to end of line a single character

Changing text (in non-edit mode)


cc cw r R change the current line, and enter edit mode change the current word, and enter edit mode replace a single character replace characters until Esc is pressed

Cutting and Pasting (in non-edit mode)


yy nyy ye p P copy current line (the line is now yanked ) copy n current lines (multi-yank) copy to the end of next word (little-yank) paste yanked text after or below cursor paste yanked text before or above cursor

Some ex mode commands


:w :w le :wq :q! :w! le write the edit buer (i.e., save the le) write a copy of the edit buer as le write the edit buer then quit quit without writing any changes (called force quit) overwrite le with current edit buer

:sh :help :help cmd :set :set all

temporarily exit vi to access a Linux shell access the vi on-line help access the on-line help for subject cmd used to set and unset vi settings display the entire list of vis current settings

Searching
/pattern / ?pattern ? n search forward in edit buer for a match to pattern repeat last forward search search backward in edit buer for a match to pattern repeat last backward search repeat previous search (regardless of direction)

You might also like