Appendix A: Linux Commands

Appendix A: Linux Commands

This appendix presents alphabetically arranged reference entries for the most important Linux commands. The goal here is to provide you with an overview of all commands needed to manage files and directories, start and stop processes, find files, work with text files, and access online help.

If you are looking for a command for a specific task, but don't know which command to use, you may find it helpful to browse through the commands by category. shows the Linux commands organized by categories.

Table A-1: Linux Commands

Command Name

Action

Getting Online Help

 

Finds man pages for a specified keyword

Displays online help information about a specified command

Displays online help information

Similar to , but searches for complete words only

Making Commands Easier

 

Defines an abbreviation for a long command

Shows the type and location of a command

Deletes an abbreviation defined using

Managing Files and Directories

 

Changes the current directory

Changes file attributes in Linux ext2 and ext3 file systems

Changes group ownership of file

Changes file permissions

Changes file owner and group

Copies files

Creates symbolic links to files and directories

Displays the contents of a directory

Creates a directory

Renames a file as well as moves a file from one directory to another

Deletes files

Deletes directories

Displays the current directory

Updates a file's time stamp

Finding Files

 

Finds files based on specified criteria such as name, size, and so on

List open files

Finds files using a periodically updated database

Finds files based in the typical directories where executable (also known as binary) files are located

Finds files in the directories listed in the PATH environment variable

Processing Files

 

Displays a file on standard output (can be used to concatenate several files into one big file)

Extracts specified sections from each line of text in a file

Copies blocks of data from one file to another (used to copy data from devices)

Compares two text files and finds any differences

Converts all tabs into spaces

Displays the type of data in a file

Wraps each line of text to fit a specified width

Searches for regular expressions within a text file

Displays a text file, one page at a time (can go backwards also)

Prints files

Displays a text file, one page at a time (goes forward only)

Numbers all nonblank lines in a text file and prints the lines to standard output

Concatenates corresponding lines from several files

Updates a text file using the differences between the original and revised copy of the file

Copies a file to standard output while applying specified editing commands

Sorts lines in a text file

Breaks up a file into several smaller files with specified size

Reverses a file (last line first and so on)

Displays the last few lines of a file

Substitutes one group of characters for another throughout a file

Eliminates duplicate lines from a text file

Counts the number of lines, words, and characters in a text file

zcat

Displays a compressed file (after decompressing)

zless

Displays a compressed file one page at a time (can go backwards also)

zmore

Displays a compressed file one page at a time

Archiving and Compressing Files

 

Compresses files

Copies files to and from an archive

Decompresses files compressed with GNU ZIP () or

Compresses files (more powerful than )

Creates an archive of files in one or more directories (originally meant for archiving on tape)

Decompresses files compressed with

Managing Processes

 

Runs an interrupted process in the background

Runs a process in the foreground

Displays the amount of free and used memory in the system

Shuts down Linux and halts the computer

Sends a signal to a process (usually used to terminate a process)

Displays the shared libraries needed to run a program

Runs a process with lower priority (referred to as nice mode)

Displays a list of currently running processes

Displays the current environment variables

Similar to , but shows parent-child relationships clearly

Stops Linux and then restarts the computer

Shuts down Linux

Displays a list of most processor- and memory-intensive processes

Displays information about the system and the Linux kernel

Managing Users

 

Changes the shell (command interpreter)

Prints the list of groups that includes a specified user

Displays the user and group ID for a specified user name

Changes the password

Starts a new shell as another user or root (when invoked without any argument)

 

Summarizes free and available space in all mounted storage devices

Displays disk usage information

Formats a diskette

Partitions a hard disk

Checks and repairs a file system

Creates a new file system

Creates a device file

Creates a swap space for Linux in a file or a disk partition

Mounts a device (for example, the CD-ROM) on a directory in the file system

Deactivates a swap space

Activates a swap space

Writes buffered data to files

Displays the device name for the current terminal

Unmounts a device from the file system

Working with Date and Time

 

Displays a calendar for a specified month or year

Shows the current date and time or sets a new date and time

The rest of this appendix covers individual reference entries for each command shown in . Each reference entry is organized as follows:

alias

Purpose

Define an abbreviation for a long command or view the current list of abbreviations.

Syntax

alias [abbrev=command]

Options

None

Description

If you type alias alone, you get a listing of all currently defined abbreviations. Typically, you use alias to define easy-to-remember abbreviations for longer commands. For example, if you type ls -l often, you might add a line with alias ll='ls -l' in the .bashrc file in your home directory. Then, you can type ll instead of ls -l to see a detailed listing of a directory. alias is a built-in command of the bash shell and is described in .