Linux Commands

There are of course thousands of Linux related commands and procedures. I will give a few of the more common ones here but I assure you there is A LOT more to Linux than just these relatively simple commands. A few tips with Linux type man command to get an extensive help file. For example type 'man ls' to get the manual page for the ls command containing information on the various switches and uses of the ls command. You can also execute multiple commands by separating each one with a ; for example cd newdir; mkdir thatdir ; ls -la will first change directories to the newdir directory, then create a directory called thatdir, then list all the files in long format. You can string together as many commands as you like but caution should be used not to inadvertently do anything harmful. Contents (Select the command to go to the relevant section select BACK TO CONTENTS to get back here) cd chmod cp df dir du find head kill less ls mkdir more mv ps pwd rm rmdir tail top tree vdir vi xload

cd
This command is used to change the directory and using this command will change your location to what ever directory you specify cd hello will change to the directory named hello located inside the current directory cd /home/games will change to the directory called games within the home directory. As you can see you can specify any directory on the Linux system and change to that directory from any other directory. There are of course a variety of switches associated with the cd command but generally it is used pretty much as it is. Type man cd for more information on the cd command. See also ls dir vdir BACK TO CONTENTS

chmod
This command is used to change the mode for files to know more about this command go to the Permissions (Setting up the mode)section. You can get there by using this link chmod you will need to use the back button (or go through the linux home page menu) on your browser to get back here).

cp
The cp command copies files. You can copy a file in within the current directory or you can copy files to another directory. cp myfile.html /home/help/mynewname.html This will copy the file called myfile.html in the current directory to the directory

/home/help/ and call it mynewname.html. Simply put the cp command has the format of cp file1 file2 With file1 being the name (including the path if needed) of the file being copied and file2 is the name (including the path if needed) of the new file being created. Remember with the cp command the original file remains in place. Type man cp to see more about the cp command. BACK TO CONTENTS

df
The disk free command shows how much memory is being used and how much is free for every partition and mounted file system (including any Windows drive/s). Type man df for more information about the df command. BACK TO CONTENTS

dir
The dir command is similar to the ls command only with less available switches (only about 50 compared to about 80 for ls). By using the dir command you will get a listing of the contents in the current directory listed in columns. Type man dir to see more about the dir command. See also cd ls vdir BACK TO CONTENTS

du
The disk usage command shows how much memory is being used by each directory below that from which the command was given. If du is run from the root directory it will show the memory used by every directory on the system, including any mounted file systems (including other drives) such as any Windows related drives. Type man du for more information about the du command. BACK TO CONTENTS

find
The find command is used to find files and or folders within a Linux system. To find a file using the find command you type find /usr/bin -name filename this will search inside the /usr/bin directory (and any sub directories within the /usr/bin directory) for the file named filename. To search the entire filing system including any mounted drives use find / -name filename and the find command will search every file system beginning in the root directory. The find command can also be used to find command to find files by date and the find command happily understand wild characters such as * and ? Type man find for more information on the find command. BACK TO CONTENTS

head
The head command list the first lines of a file. By default it will display the first ten lines of a file. For example head filename will list the first ten lines of the file named filename. You can also select how many lines to show for example head -5 filename will list the first 5 lines of the file named filename. The format for the head command is head -n filename With the number of lines to be displayed being n and the file name of the file, including the path if needed, you wish to view being in place of filename. Type man head for more information on the head command. BACK TO CONTENTS

kill
The kill command is used to kill a process by using the associated PID (Process ID) number e.g. kill 381 This will kill the process with the PID of 381. Be careful using the kill command because it is easy to accidently kill an important process. To see the current list of processes that are running use the ps command. Typing ps au will display every process that is in operation including background processes and those being conducted by other users. See also ps top BACK TO CONTENTS

less
This command allows you to scroll through a file a page at a time. The less command is very similar to the more command only it is more advanced and has more features associated with it. less filename Type man less for more information on the less command. BACK TO CONTENTS

ls
The ls command lists the contents of a directory. In its simple form typing just ls at the command prompt will give a listing for the directory you are currently in. The ls command can also give listings of other directories without having to go to those directories for example typing ls /dev/bin will display the listing for the directory /dev/bin . The ls command can also be used to list specific files by typing ls filename this will display the file filename (of course you can use any file name here). The ls command can also handle wild characters such as the * and ? . For example ls a* will list all files

starting with lower case a ls [aA]* will list files starting with either lower or upper case a (a or A remember linux is case sensitive) or ls a? will list all two character file names beginning with lower case a . There are many switches (over 70) associated with the ls command that perform specific functions. Some of the more common switches are listed here.
• • • • • •

• • •

ls -a This will list all file including those beginning with the'.' that would normally be hidden from view. ls -l This gives a long listing showing file attributes and file permissions. ls -s Will display the listing showing the size of each file rounded up to the nearest kilobyte. ls -S This will list the files according to file size. ls -C Gives the listing display in columns. ls -F Gives a symbol next to each file in the listing showing the file type. The / means it is a directory, the * means an executable file, the @ means a symbolic link. ls -r Gives the listing in reverse order. ls -R This gives a recursive listing of all directories below that where the command was issued. ls -t Lists the directory according to time stamps.

Switches can be combined to produce any output you desire. e.g. ls -la This will list all the files in long format showing full file details. Type man ls for more details about the ls command. See also cd dir vdir BACK TO CONTENTS

mkdir
The mkdir command is used to create a new directory. mkdir mydir This will make a directory (actually a sub directory) within the current directory called mydir. Type man mkdir to see more about the mkdir command. BACK TO CONTENTS

more
This command allows you too scroll through a file one screen at a time allowing you to more easily read the files contents. Some files are very big and using this command allows you to view the contents of large files more efficiently. To go forward one screen use the space bar and to go back one screen use the B key more filename

Type man more for more information about the more command. BACK TO CONTENTS

mv
The mv command moves files from one location to another. With the mv command the file will be moved an no longer exist in its former location prior to the mv. The mv command can also be used to rename files. You can move files within the current directory or another directory. cp myfile.html /home/help/mynewname.html This will move the file called myfile.html in the current directory to the directory /home/help/ and call it mynewname.html. Simply put the mv command has the format of mv file1 file2 With file1 being the name (including the path if needed) of the file being moved and file2 is the name (including the path if needed) of the new file being created. Type man mv to see more about the mv command. BACK TO CONTENTS

ps
The ps (process status) will by default only show the processes that you as a user have started. However Linux is always running background tasks so you may want to use some of the common switches associated with the ps such as ps au to display the processes running for all users and in the user format hence we get to see every process that is running on the system. When a process is started it is given among other things a PID number that is unique to it. This PID number can be seen by using the ps command or top command. By knowing a Process ID number you may opt to kill the process if you choose. See also kill top BACK TO CONTENTS

pwd
The pwd command (print working directory) will display the current directory. e.g. typing pwd will display something similar to this /home/games/help being the details of the current directory. To get help with the pwd type /bin/pwd --help and a short help file will be displayed. Type man pwd to get more information about the pwd command. BACK TO CONTENTS

rm
The rm command is used to delete files. Some very powerful switches can be used with the rm command so be sure to check the man rm file before placing extra switches on the rm command.

rm myfile This will delete the file called mydir. You can include a path to delete a file in another directory for example rm /home/hello/goodbye.htm will delete the file named goodbye.htm in the directory /home/hello/. Some of the common switches for the rm command are
•

• •

rm -i this operates the rm command in interactive mode meaning it will prompt you before deleting a file. This gives you a second chance to say no do not delete the file or yes delete the file. Remember Linux is merciless and once something is deleted it is gone for good so the -i flag (switch) is a good one to get into the habit of using. rm -f will force bypassing any safeguards that may be in place such as prompting. Again this command is handy to know but care should be taken with its use. rm -r will delete every file and sub directory below that in which the command was given. Be very careful with this command as no prompt will be given in most linux systems and it will mean instant good bye to your files if misused.

Type man rm to see more about the rm command. BACK TO CONTENTS

rmdir
The rmdir command is used to delete a directory. rmdir mydir This will delete the directory (actually a sub directory) called mydir. Type man rmdir to see more about the rmdir command. BACK TO CONTENTS

tail
The tail command list the last lines of a file. By default it will display the last ten lines of a file. For example tail filename will list the last ten lines of the file named filename. You can also select how many lines to show for example tail -5 filename will list the last 5 lines of the file named filename. The format for the tail command is tail -n filename With the number of lines to be displayed being n and the file name of the file you wish to view, including the path if needed, being in place of filename. Type man tail for more information on the tail command. BACK TO CONTENTS

top
Either typing top at the command prompt or selecting top from the xwindows menu will activate the top application. Top simply lists all the operations in progress showing

memory usage by each process. You have the option to kill any process if you want to but be careful if you kill a vital system you will run into trouble and may at the very least have to reboot to fix it. Typically top is run in a spare xterm or x11 window while doing other tasks. To access the help in top use the ? or H key. To kill a task use the K key or change the priority of the task by using the R key. Type man top to see more detailed information about the top command. see also xload BACK TO CONTENTS

tree
This will give a graphical display of the structure of a particular directory and all sub directories, files and links within that directory. e.g. tree /var/lib will show something similar to this /var/lib |--games |--rpm | |--conflictsindex.rpm | |--fileindex.rpm | |--groupsindex.rpm | |--packages.rpm | `--require.rpm `--text 6 directories, 6 files Type man tree for more information on the tree command. BACK TO CONTENTS

vdir
The vdir command is similar to the ls -l command. When used the command acts very much like ls -l does by displaying the directory contents showing the file attributes and permissions. The amount of switches for vdir are a lot less than for the ls command (vdir has just over half the amount of available switches as the ls command) but vdir is still used and accepted. Type man vdir to see more about the vdir command. See also cd dir ls BACK TO CONTENTS

vi
The vi command is actually a text editor that comes as standard with most Linux

packages. Type man vi for more information on vi. More information on vi is in the Using the vi Editor section. Use this link vi to get there . BACK TO CONTENTS

xload
Either typing xload or selecting xload from the xwindows menu (if it is available) will activate the xload feature in a x11 window. The xload application provides a running graph of the system load. Often it is easier to tell if a system is overloaded by having a visual aid to see the load on the system. The xload command has eight different command line options and can be customized in regards to colour, scale and background. Typically xload is run as a background task to enable visual monitoring of the system load. Type man xload to see more detailed information about the xload command. see also top BACK TO CONTENTS

Description Show commands pertinent to string. See also threadsafe make a pdf of a manual page Show full path name of command See how long a command takes Start stopwatch. Ctrl-d to stop. See also sw Run a low priority command (The "info" reader in this case) Make shell (script) low priority. Use for non interactive tasks Go to previous directory Go to $HOME directory Go to dir, execute command and return to current dir Put current dir on stack so you can popd back to it

quick dir listing List files by date. See also newest and find_mm_yyyy Print in 9 columns to width of terminal Search 'expr' in this dir and below. See also findrepo Search all regular files for 'example' in this dir and below Search all regular files for 'example' in this dir Process each item with multiple commands (in while loop) Find files not readable by all (useful for web site) Find dirs not accessible by all (useful for web site) Search cached index for names. This re is like glob *file*.txt Quickly search (sorted) dictionary for prefix Highlight occurances of regular expression in dictionary

Display a calendar Display a calendar for a particular month year What date is it this friday. See also day exit a script unless it's the last day of the month What day does xmas fall on, this year Convert seconds since the epoch (1970-01-01 UTC) to date What time is it on West coast of US (use tzselect to find TZ) Email reminder Popup reminder Print number with thousands grouping appropriate to locale get ls to do thousands grouping appropriate to locale Extract info from locale database Lookup locale info for specific country. See also ccodes List fields available in locale database Show available conversions (aliases on each line) Windows "ansi" to local charset (auto does CRLF conversion) Windows utf8 to local charset Latin9 (western europe) to utf8 Base64 encode Quoted printable decode Text to HTML Lookup table of characters Show what a code represents in latin-9 charmap Show latin-9 encoding Show utf-8 encoding Save copy of data cdrom Create cdrom image from contents of dir Mount the cdrom image at /mnt/dir (read only) Clear a CDRW Burn cdrom image (use dev=ATAPI -scanbus to confirm dev) Rip audio tracks from CD to wav files in current dir Make audio CD from all wavs in current dir (see also cdrdao) Make ogg file from wav file

Show files by size, biggest last Show top disk users in current dir. See also dutop Show free space on mounted filesystems Show free inodes on mounted filesystems Show disks partitions sizes and types (run as root) List all packages by installed size (Bytes) on rpm distros List all packages by installed size (KBytes) on deb distros Create a large test file (taking no space). See also truncate truncate data of file or create an empty file Monitor messages in a log file Summarise/profile system calls made by command List system calls made by command List library calls made by command List paths that process id has open List processes that have specified path open Show network traffic except ssh. See also tcpdump_not_me List processes in a hierarchy

Changes password Queries Internet domain name servers Displays disk usage and limits Message of the Day User information lookup program Displays pages of online manual Displays System Manual in X Displays the contents of a file in the terminal one page at a time Displays information and documentation on shells, utilities and programs Clears the terminal window List contents of a directory Displays the contents of a file in the terminal Removes a file Opens and edits text files Copies a file Sends file to printer looks through files for strings Displays first 10 lines of file

Displays X logo Opens system sound controls Snowflakes are fallin' on your desktop Displays info about a window Starts an X Window System server Starts a text preview application Image viewer Set background color in X Starts a calculator in X Starts a clipboard in X Prints the route packets take to the host Displays system identity name Utility to connect to a remote system Utility to connect to a remote system (similar to rlogin but more interactive) Used to copy from a remote computer Utility to transfer files between systems on a network Utility to run a command on a remote system without logging in Utility used to test connection to a remote system Changes local machine directory while logged on to remote machine

Shared Directories
Directory / /bin /boot /dev /etc /home /lib /mnt /proc /root /sbin /tmp Description Root - The root directory is present in all Linux system file structures. It's the parent of all files in the system. Essential common binaries - Holds files needed to boot the system and run it when it comes up in single user mode. Static files of the boot loader. Device files - All files that represent peripheral devices. Machine-local system configuration - Holds administrative, config, and other system files. Holds /etc/passwd file that contains a list of all users who have permission to the system. User home directories - Contains each user's or client's home directory Shared libraries Mount point for temporary partitions Kernel and process information (virtual filesystem) Home directory for root Essential system binaries - Contains utilities for system administration. Temporary files

/usr /var

Second major hierarchy - Includes subdirectories that contain information used by the system. Variable data - Contains files whose contents change as system runs.

vi Commands
Command vi filename :q! p P yy :r !command i :set autoindent :set showmatch :set nu :set showmode ESCAPE Control-U Control-H Control-W h, j, k, l u x dw dd ZZ o Control-L :w filename Description Starts vi and creates a new file Quits vi without saving work Pastes data in buffer below current line Pastes data in buffer above current line Copies current line Reads in output of the command Puts vi in insert mode Sets vi to indent automatically Sets vi to show matching parenthesis Sets vi to display line numbers Sets vi to display the mode you're in Sets vi to command mode Erases current line (insert mode) Erases on letter (insert mode) Erases current word (insert mode) Moves cursor left, up, down, right respectively Undoes last action Deletes a single character Deletes a single word Deletes a single line Writes work buffer to disk and exits vi inserts line after cursor position Redraws screen Save work as filename and exits

Control Characters
Key Control-H or BACKSPACE Control-U Control-W Control-C COMMAND-Tab Control-L or CONtrOL-R Control-D, logout or exit Use Erases a character on the command line Deletes an entire command line Erases a word on the command line Aborts program execution Switches Programs Refreshes the screen Logs you off the system

/etc/crontab The syntax of each line in this file is: minute, hour, day of month, Month, day of week, (user name), command /etc/fstab Columns are: device file to mount, directory to mount on, filesystem type, options, backup frequency, and fsck pass number (To specify the order in which filesystems should be checked on boot; 0 means no check.) The noauto option stops this mount from being done automatically on boot. Below is a detailed list of what is on each column. 1. The name of the device such as "/dev/hda1" 2. The mount point. Use "/" for root. Other typical mount points are "/dos" for DOS, "swap" or "none" for the swap partition, and "/mnt/floppy" for "/dev/fd0" (the floppy drive). 3. The type of filesystem. They are: mini, ext, ext2(linux native), xiafs, msdos, hpfs, ntfs, fat32, iso9660(CD-ROM), NFS, swap (for swap space). 4. The mount options for use with the filesystem. Each filesystem type has different mount options. Read the mount man page to see possible options. ro= read only, user- allows normal users to mount the device. 5. The frequency the filesystem needs to be dumped (backed up) by the dump command. For ext2, normally make it 1, for others make it 0. 0 or nothing means it is not dumped. If 1, it is backed up during a system backup.

6. A number telling the order in which the filesystems should be checked at reboot time by the fsck program. Your root should be 1, others are in ascending order or 0 to not be checked. /etc/hosts Sets up host address information for local use. The format is: IPaddress name1 name2... /etc/inetd.conf Sets the services under the inetd daemon. The fields of this file are: 1. 2. 3. 4. 5. 6. service name socket type protocol wait or nowait user server program name

7. server program command line arguments /etc/inittab Sets the init configuration. An entry in the inittab file has the following format: id:runlevels:action:process /etc/lilo.conf Tells LILO how to boot The lilo.conf file below is for a system which has a Linux root partition on /dev/hda1 and a MS-DOS partition on /dev/hda2. See the "How Linux Works" guide and the "Linux User's Guidel" for more information. boot = /dev/hda vga = normal delay = 60 # Tell LILO to install the boot loader on the /dev/hda disk boot record # Set a normal video mode # The time in tenths of seconds to press <SHIFT> to get the LILO prompt # Equivalent would be "prompt" on one line, and "timeout=60" on # another line. # Sets the default boot to DOS, Without this line, the default is the first stanza # The file containing the boot sector to use # Have LILO perform some optimization. #Specifies the map file LILO creates when installed

# Section for Linux root partition on /dev/hda2. # Location of kernel # Name of the OS that is displayed in the LILO boot menu # Location of root partition, if this isn't here the kernel image must have # this set using the rdev command # Mount read only on startup, Can also be set by rdev # Section for MSDOS partition on /dev/hda1. # Location of partition # Location of partition table for /dev/hda2 # Name of OS (for boot menu)

if the command "vga= ask" is given, LILO will prompt the user for a video mode at boot time. /etc/passwd The file has one line per username, and is divided into seven colon-delimited fields: 1. 2. 3. 4. 5. 6. 7. Username. Password, in an encrypted form. Numeric user id. Numeric group id. Full name or other description of account. This is called gecos. The user's home directory. The user's login shell (program to run at login).

The format is explained in more detail on the passwd manual page. /usr/X11R6/lib/X11/XF86Config The main XFree86 configuration file. Type "man XF86Config"
•

• • •

• •

The first section is "Files" RgbPath Sets the path to the X11R6 RGB color database FontPath Sets the path to a directory containing X11 fonts The second section is "ServerFlags", all lines are commented out The third section is "Keyboard" The fourth section is "Pointer" Protocol Specifies the mouse protocol Device Specifies the device file by which the mouse can be accessed. The fifth section is "Monitor" which specifies the characteristics of your monitor ModeLine Specifies resolution modes for your monitor The file, VideoModes.doc describes in detail how to determine the ModeLine values for each resolution mode. Two files, modeDB.txt and Monitors,may have

•

ModeLine information for your monitor. They are located in /usr/X11R6/lib/X11/doc. The sixth section is "Screen" describing the video/monitor card configuration for the particular server. The Driver line specifies the X server that you will be using. Valid Driver values are: _ Accel: For the XF86 S3, XF86 Mach32, XF86 Mach8, XF86 8514, XF86 P9000, XF86 AGX,and XF86 W32 servers; _ SVGA: For the XF86 SVGA server; _ VGA16: For the XF86 VGA16 server; _ VGA2: For the XF86 Mono server; _ Mono: For the non-VGA monochrome drivers in the XF86 Mono and XF86 VGA16 servers. Be sure that /usr/X11R6/bin/X is a symbolic link to this server. The Device line specifies the Identifier of the Device section that corresponds to the video card to use for this server. Above, we created a Device section with the line Identifier "#9 GXE 64" Therefore, we use "#9 GXE 64" on the Device line here. Similarly, the Monitor line specifies the name of the Monitor section to be used with this server. Here, "CTX 5468 NI" is the Identifier used in the Monitor section described above.

•

Subsection "Display" defines several properties of the XFree86 server corresponding to your monitor/video card combination. The XF86Config file describes all of these options in detail. Most of them are not necessary to get the system working. The options that you should know about are: o _ Depth. Defines the number of color planes; that is, the number of bits per pixel. Usually, Depth is set to 16. For the VGA16 server, you would use a depth of 4, and for the monochrome server a depth of 1. If you use an accelerated video card with enough memory to support more bits per pixel, you can set Depth to 24, or 32. o _ Modes. This is the list of mode names that have been defined using the ModeLine directive(s) in the Monitor section. In the above section, we used ModeLines named "1024x768", "800x600",and "640x48"0. Therefore, we use a Modes line of Modes "1024x768" "800x600" "640x480" The first mode listed on this line is the default when XFree86 starts. After XFree86 is running, you can switch between the modes listed here using the keys Ctrl - Alt –Numeric + and Ctrl - Alt - Numeric - . It might be best, when you initially configure XFree86, to use lower resolution video modes like 640x480, which tend to work with most

systems. Once you have the basic configuration working, you can modify XF86Config to support higher resolutions.
o

o

_ Virtual. Set the virtual desktop size. XFree86 can use additional memory on your video card to extend the size of the desktop. When you move the mouse pointer to the edge of the display, the desktop scrolls, bringing the additional space into view. Even if you run the server at a lower video resolution like 800x600, you can set Virtual to the total resolution that your video card can support. A 1-megabyte video card can support 1024x768 at a depth of 8 bits per pixel; a 2-megabyte card 1280x1024 at depth 8, or 1024x768 at depth 16. Of course, the entire area will not be visible at once, but it can still be used. The Virtual feature is rather limited. If you want to use a true virtual desktop, fvwm and similar window managers allow you to have large, virtual desktops by hiding windows and using other techniques, instead of storing the entire desktop in video memory. See the manual pages for fvwm for more details about this. Some Linux systems use fvwm by default. _ ViewPort. If you are using the Virtual option that is described above, ViewPort sets the coordinates of the upper-left-hand corner of the virtual desktop when XFree86 starts up. Virtual 0 is often used. If this is unspecified, then the desktop is centered on the virtual desktop display, which may be undesirable to you.

Used to search a disk or partition for badblocks. Similar to fdisk but with a nicer interface. Allows direct access to filesystems data structure. Shows the disk free space on one or more filesystems. Check and repair MS-Dos filesystems. Shows how much disk space a directory and all its files contain. Used to back up an ext2 filesystem. Complement is restore. Dump filesystem superblock and blocks group information. Ex: dumpe2fs /dev/hda2 Check a Linux second extended filesystem. Change the label on an ext2 filesystem. Used to set up filesystems to export for nfs (network file sharing). Used to fix or create partitions on a hard drive. Formats a floppy disk. Used to add new blocks to a filesystem. Must not be run on a mounted file system. Get/set hard disk geometry parameters, cylinders, heads, sectors.

Initializes a Linux filesystem. This is a front end that runs a separate program depending on the filesystem's type. Create a Linux second extended filesystem. Sets up a Linux swap area on a device or file. Used to mount a filesystem. Complement is umount. Query/set image root device, swap device, RAM disk size of video mode. What this does is code the device containing the root filesystem into the kernel image specified. Same as dump. Remote magtape protocol module. Used to restore an ext2 filesystem. Set floppy drive parameters. Used to de-activate a swap partition. Used to activate a swap partition. Forces all unwritten blocks in the buffer cache to be written to disk. Adjust tunable filesystem parameters on second extended filesystems. Unmounts a filesystem. Complement is mount.

apropos bdflush cd

chmod

Search the whatis database for files containing specific strings. Kernel daemon that saves dirty buffers in memory to the disk. Change the current directory. With no arguments "cd" changes to the users home directory. chmod <specification> <filename> - Effect: Change the file permissions. Effect: change the file Ex: chmod 751 myfile permission to rwx for owner, re for group Effect: Add read permission Ex: chmod go=+r myfile for the owner and the group character meanings u-user, g-group, o-other, + add permission, - remove, r-read, w-write,x-exe Effect: Allow all users to Ex: chmod a +rwx myfile read, write or execute myfile Effect: Remove read Ex: chmod go -r myfile permission from the group and others chmod +s myfile - Setuid bit on the file which allows the program to run with user or group privileges of the file. chmod {a,u,g,o}{+,-}{r,w,x} (filenames) - The syntax of the chmod command.

chown chgrp cksum cp dd dir dircolors file

chown <owner1> <filename> Effect: Change ownership of a file to owner1. chgrp <group1> <filename> Effect: Change group. Perform a checksum and count bytes in a file. cp <source> <destination> Copy a file from one location to another. Convert and copy a file formatting according to the options. Disk or data duplication. List directory contents. Set colors up for ls. Determines file type. Also can tell type of library (a.out or ELF). Ex: find $Home –name readme Print search for readme starting at home and output full path. How to find files quickly using the find command: Ex: find ~ -name report3 –print
• • •

find

"~" = Search starting at the home directory and proceed through all its subdirectories "-name report3" = Search for a file named report3

install ln locate losetup

ls

"-print" = Output the full path to that file Copy multiple files and set attributes. Make links between files. File locating program that uses the slocate database. Loopback device setup. List files. Option -a, lists all, see man page "man ls" Ex: "ls Docum Projects/Linux" - The contents of the directories Docum and Projects/Linux are listed. To list the contents of every subdirectory using the ls command: 1. Change to your home directory.

mkdir mknod mktemp mv pathchk pwd

2. Type: ls -R Make a directory. Make a block or character special file. Make temporary filename. Move or rename a file. Syntax: mv <source> <destination> Ex: mv filename directoryname/newfilename Check whether filenames are valid or portable. Print or list the working directory with full path (present working directory).

Ex: "rm .*" - Effect: Delete system files (Remove files) –i is interactive option. rmdir <directory> - Remove a directory. The directory must be empty. Provides a secure way to index files and search for them. It builds a database of files on the system. Used to print out inode information on a file. Checksum and count the blocks in a file. Check file types and compare values. Change file timestamps to the current time. Make the file if it doesn't exist. Kernel daemon to flush dirty buffers back to disk. List directory contents. Search the whatis database for complete words. Locate the binary, source and man page files for a command. Show full path of commands where given commands reside.

File viewing and editing
ed emacs gitview head jed joe less more pico tail vi Editor Full screen editor. A hexadecimal or ASC file viewer. head linuxdoc.txt - Look at the first 10 lines of linuxdoc.txt. Editor Editor q-mandatory to exit, Used to view files. b-back q-quit h-help, Used to view files. Simple text editor. tail linuxdoc.txt - Look at the last 10 lines of linuxdoc.txt. Editor with a command mode and text mode. Starts in command mode.

Extra control and piping for files and other outputs
basename cat cmp colrm column comm csplit cut diff diff3 dirname echo egrep expand expr false fgrep fold Strip directory and suffix information from filenames. Ex: cat < filename --- Effect: put keyboard input into the file. CTRL-D to exit (end). Compare two files. Remove columns from a file. Columnate lists. Ex: comm file1 file2 --- Effect compare the contents of file1 and file2 produces 3 columns of output. Lines in the first file, lines in second file, lines in both files. Split a file into sections determined by context lines. Remove sections from each line of files. Show the differences between files. Ex: diff file1 file2 Find differences between 3 files. Strip the non-directory suffix from a filename. Display a line of text. Similar to grep -E, compatible with UNIX egrep. Convert tabs to spaces. Evaluate expressions. Do nothing. Exit with a status indicating failure. Same as grep -F. Wrap each input line to fit in specified width.

Join lines of two files in a common field. grep pattern filename. Ex: grep " R " --- Effect: Search for R with a space on each side Ex: ls –a |grep R --- Effect: List all files with an R in them or their info listing. asc, decimal, hex, octal dump. Print user's login name. Display lines beginning with a given string. Create named pipes with the given names. Write each file to standard output with line numbers added. Dump files in octal and other formats. Apply a diff file to an original. Combines from 2 or more files. Ex: paste file1 file 2 Print and format data. Reverses lines in a file. Make a typescript of a terminal session. Find differences between 2 files and merge interactively. A stream editor. Used to perform transformations on an input stream. Delay for a specified amount ot time. Sort a file alphabetically. Split a file into pieces. Print the strings of printable characters in files. Concatenate and print files in reverse. Read from standard input and write to standard output and files. Translate or delete characters. Do nothing. Exit with a status indicating success. Perform topological sort. Do underlining. Convert tabs to spaces. Remove duplicate lines from a sorted file. Used to transform files encoded by uuencode into their original form. Encode a binary file to be sent over a medium that doesn't support non-ASC data. Count lines, words, characters in a file. Ex: wc filename. Build and execute command lines from standard input. Output the string "y" until killed.

apropos help man man manpath info

apropos keyword - Show all commands with the keyword in their description. The same as the "man -k" command. Bash shell help for the bash builtin command list. The help command gets help for a particular command. Get help from the manual for a command. man -k keyword - Show all commands with the keyword in their description "man 2 kill" - Display page 2 of the kill command Determine user's searchpath for manpages. Documentation on Linux commands and programs similar to the man pages but navigation is organized different.

Linux Job Management
at atq atrm atrun batch cron nice nohup watch Similar to cron but run only once. Lists the user's pending jobs. If the user is the superuser, everybody's jobs are listed. Deletes at jobs. Run jobs queued for later execution Executes commands when system load levels drop below 0.8 or value specified in atrun invocation. A deamon used to set commands to be run at specific times. Starts the commands in the crontab file. Used to clean up temporary files periodically in the /var/tmp and /tmp directories. Run a program with modified scheduling priority. Run a command immune to hangups, with output to a nontty. Execute a program periodically showing output full screen.

Linux Process management
bg fg gitps jobs kill killall pidof ps Starts a suspended process in the background Starts a suspended process in the foreground A graphical process viewer and killer program. Lists the jobs running Ex: "kill 34" - Effect: Kill or stop the process with the process ID number 34. Kill processes by name. Can check for and restart processes. Find the process ID of a running program Get the status of one or more processes. Options:
•

u (more info)

• •

a (see all) -l (technical info)

Meanings:
• •

PPID-parent process ID PID-process ID

pstree sa skill snice top CTRL-C &

ps ax |more to see all processes including daemons Display the tree of running processes. Generates a summary of information about users' processes that are stored in the /var/log/pacct file. Report process status. Report process status. Display the processes that are using the most CPU resources. Kills the current job. At the end of the command makes it run in the background.

dnsdomainname domainname hostname nisdomainname nodename ypdomainname

Show the systems DNS domain name Show or set the systems domain name Used to show or set the name of your machine for networking Show or set systems NIS/YP domain name Show or set the systems DECnet node name Show or set the system's NIS/YP domain name

Network setup and commands
arp dig(1) finger ftp ifconfig This program lets the user read or modify their arp cache. Send domain name query packets to name servers for debugging or testing. Display information about the system users. File transfer program. Configure a network interface.

Shutdown a network interface. Brings a network interface up. Ex: ifup eth0 IP firewall administration used to set input, forward, and output rules. A GUI interactive program to let you configure a network on Redhat systems. Another GUI step by step network configuration program. Displays information about the systems network connections, including port connections, routing tables, and more. The command "netstar -r" will display the routing table. Used to query DNS servers for information about hosts. Same as ftp. Send ICMP ECHO_REQUEST packets to network hosts. DARPA port to RPC program number mapper. Must be running to make RPC calls. Manipulate the system's RARP table. Remote file copy. Copies files between two machines. Remote execution client for an exec server. The host uses the rexecd server. Query RIP gateways. Request all routes known by an RIP gateway by sending an RIP request. Starts a terminal session on a remote host. Show or manipulate the IP routing table. Executes command on remote host. Displays summary of current system status of a remote host or all hosts on the network. Show host status of local machines. System status server, maintains database used by rwho and ruptime. Show mount information for an NFS server. Access control facility for internet services. Can be set up to monitor requests for Telnet, finger, ftp, exec, rsh, rlogin, tftp, talk, comsat. It filters access for these requests. Tcp wrapper configuration checker. Dump traffic on a network. Prints out headers of packets that match the boolean expression. Predicts how the tcp wrapper will handle a specific request for a service.

Communications commands (includes mail)
biff comsat expire elm ftp mailx metasend nn pine sendmail smail talk telnet tin write Notifies the system if mail arrives and who it is from. Biff server to receive reports of incoming mail. Used to purge old news articles. Electronic mail. File transfer protocol. Berkley mail program. Interface for sending non-text mail. Net news. Program for internet news and e-mail, Can send documents, graphics, local & remote messages. A popular Unix, Linux mail message transfer agent. A popular mail message transfer agent which is easier to set up than sendmail. Lets two parties talk simultaneously. Allows a user to have a login session across a network on a remote host. Net news reader. Allows users to directly interact with other users via terminal number (one way at a time).

Environment
env export printenv Show all environment variables. Set the value of a variable so it is visible to all subprocesses that belong to the current shell. Print all or part of environment.

reset set

Restores runtime parameters for session to default values. Shows how the environment is set up. This is a builtin bash command.

Library management
ldconfig ldd ltrace trace Updates the necessary links for the run time link bindings. Tells what libraries a given program needs to run. A library call tracer. Same as ltrace.

Runtime level management
exit halt init initscript logout poweroff reboot runlevel setsid shutdown telinit Terminates the shell. Stop the system. Process control initialization. Script that executes inittab commands. Log the user off the system. Brings the system down. Reboot the system. List the current and previous runlevel. Run a program in a new session. If your system has many users, use the command "shutdown -h +time message", where time is the time in minutes until the system is halted, and message is a short explanation of why the system is shutting down. # shutdown -h +10 'We will install a new disk. System should be back on-line in three hours.' By requesting run level 1 a system can be taken to single user mode.

Set the function of the ctrl alt del combination. Configure ISA plug and play devices. A Redhat Linux tool which configures the /etc/sysconfig/keyboard file which specifies the location of the keyboard map file. This is a GUI based tool. Set the keyboard repeat rate and delay time. A Redhat GUI kernel configuration tool, Start X, then run it from a console session. Redhat's GUI linux system configuration tool. List all pci devices. Control write access to your terminal. A Redhat Linux tool used to configure the /etc/sysconfig.mouse file. This is a GUI tool. Script file used to restart, stop, start the DNS server. Redhat's GUI printer configuration tool. Display disk usage and limits. Scan a filesystem for disk usages. Turn file system quotas off. Turn file system quotas on. Script file used to stop, start, restart samba services when not run using inetd. Configure pci devices. Set/get serial port information. Set terminal attributes. Set up devices and file systems. Used to configure and print the console devices. Enable devices and files for paging and swapping. Disable devices and files for paging and swapping. A Redhat Linux tool used to configure the /etc/sysconfig/clock file. This is a GUI tool used to set timezone and whether or not the clock is set to GMT time. Used to initialize terminals.

List PCI devices . Lists ISA plug and play devices resource information. Display system status gathered from proc. Display a tree of processes. Find the current and previous system runlevel. Trace ssytem calls and signals for a binary program. Change and print terminal line settings. Prints a graphic representation of the system load average. Print the filename of the terminal connected to standard input. Print system information, Prints Linux. Report virtual memory statistics. Displays CPU states (idle, nice, system, kernel) statistics. Runs in X?

System Logging
klogd logger syslogd sysklogd Kernel log daemon which intercepts and logs Linux kernel messages. Make entries in the system log. Linux system logging utilities. Linux system logging utilities.

System Security System time
cal clock date hwclock timed timedc tzset uptime zdump zic Calendar. Used to change or get current time. The command "clock -–w" sets the hardware clock. Print or set the system date and time. Set or read the hardware CMOS clock. Time server daemon to synchronize the host's time with other machines, normally invoked at boot time from the rc(8) file. Timed control program. Used to change the users private time zone by setting the TZ environment variable. Reports how long the system has been running. Prints the current time in each zonename named on the command line. Reads text from files named on the command line and creates time conversion files.

X Management and programs
SuperProbe Xconfigurator Probe video hardware. The Redhat tool used during system setup to configure X.

xconsole xf86config XF86Setup xvidtune

Displays messages usually sent to /dev/console. Older version of XF86Setup. A newer X configuration program with a GUI interface which modifies the "/etc/X11/XF86Config" configuration file. This program will test video modes on the fly without modification to your X configuration. Read the usr/X11R6/lib/X11/doc/VideoModes.doc file before running this program.

Linux User Management
ac accton adduser chage chfn chgrp chown chpasswd chroot chsh edquota faillog finger gpasswd groupadd grpck grpconv grpunconv groupdel groupmod groups id last Print statistics about users' connect time. Turn on accounting of processes. To turn it on type "accton /var/log/pacct". Ex: adduser mark - Effect: Adds a user to the system named mark Used to change the time the user's password will expire. Change the user full name field finger information Changes the group ownership of files. Change the owner of file(s ) to another user. Update password file in batch. Run command or interactive shell with special root directory. Change the login shell. Used to edit user or group quotas. This program uses the vi editor to edit the quota.user and quota.group files. If the environment variable EDITOR is set to emacs, the emacs editor will be used. Type "export EDITOR=emacs" to set that variable. Examine faillog and set login failure limits. See what users are running on a system. Administer the /etc/group file. Create a new group. Verify the integrity of group files. Creates /etc/gshadow from the file /etc/group which converts to shadow passwords. Uses the files /etc/passwd and /etc/shadow to create /etc/passwd, then deletes /etc/shadow which converts from shadow passwords. Delete a group. Modify a group. Print the groups a user is in Print real and effective user id and group ids. Display the last users logged on and how long.

Shows failed login attempts. This command requires the file /var/log/btmp to exist in order to work. Type "touch /var/log/btmp" to begin logging to this file. Display information about previous commands in reverse order. Works only if process accounting is on. Formats and prints the contents of the last login. Print user's login name. Lets a suer log in to a new group. Update and create newusers in batch. Set a user's pass word. Verify integrity of password files. Convert to and from shadow passwords and groups. Display users' limits and current disk usage. Turns system quotas off. Turns system quotas on. Used to check a filesystem for usage, and update the quota.user file. Lists a summary of quota information on filesystems. Generates a summary of information about users' processes that are stored in the /var/log/pacct file. Works similar to an ftp client enabling the user to transfer files to and from a windows based computer. Allows a shared directory on a windows machine to be mounted on the Linux machine. Program to change users passwords for samba. Ex: su mark - Effect: changes the user to mark, If not root will need marks password. Single user login. A bash builtin command for setting the processes a user can run. Create a new user or update default new user information. Delete a user account and related files. Modify a user account. Print the user names of users currently logged in. Used for debugging. Edit the password or group files. Edit the password or group files. Display users logged in and what they are doing. Send a message to everybody's terminal. Display the users logged in. Print effective user id.

Linux Printing and Programming
Linux Printing
banner lpr lpc lpq lprm gs pr tunelp Print a large banner on printer. Print, submits a job to the printer. Ex: lpr -Pdest filename. Dest is the destination printer. the name of the file to print is filename. Lets you check the status of the printer and set its state. Shows the contents of a spool directory for a given printer. Removes a job from the printer queue. Ghostscript - A PostScript interpreter. Print a file. Ex: pr filename |pg. Set various parameters for the lp device.

Scripting Languages
Perl Python Tcl info Tk A command interpreter for the Practical Extraction and Report Language (perl). A report language. Tool command language shell. Enter by typing tclsh. Return information about the state of the Tcl interpreter. A graphical user extension to Tcl based on X windows. Commands are same as Tcl.