Linux Commands
From Freespire
| Useful Linux Commands | |
|---|---|
| Home-->Documentation-->User Manual-->Advanced User Manual-->Useful Commands-->Linux Commands | < Back Forward > |
LINUX COMMANDS
Freespire, as any modern Linux system, has hundreds of available commands. This page introduces, categorizes and organizes the commands which are most significant and common. If you know what you want your computer to do, but do not yet know the right command to give, you can find the command here. For a more basic explanation, see Command Line Basics and read about the Konsole.
CLASSIFICATION AND TABLE OF CONTENTS
Application
Scope
Construction and Use
THE COMMANDS
0000. THE BASH SHELL
0100. Bash Shell Builtins
0110. Bash Directory Specification
0120. Bash Parameter Handling
0130. Bash Environment Management
0140. Bash Job Control
0150. Bash Command-line Control
0160. Bash Shell Control
0170. Bash Flow Control
0180. Bash Condition Testing
0190. Other Bash Shell Builtins
0200. Bash Shell Elements and Operators
0220. Bash Shell Parameters
0230. Bash Shell Variable Handling
0240. Bash Jobspecs
0250. Bash Text Expansion
0251. Bash Quoting
0252. Bash Character Escapes
0253. Bash Pattern Matching
0254. Bash Pathname Expansion
0270. Bash Flow-control and Redirection
0271. Bash Flow-control
0272. Bash Redirection
0280. Bash Tests
0281. Bash File Tests
0282. Bash String Tests
0290. Other Bash Shell Elements and Operators
- Examples Illustrating Bash's If, Case, For and While Builtins
1000. USER COMMANDS
1010. Shell Invocation and Related Commands
1020. Unbuiltins
1100. General Commands
1110. General File Commands
1111. File Listing and Finding
1112. Symbolic-link Management
1113. Directory Management
1119. Other General File Commands
1120. Text Commands
1121. General Text Commands
1122. Text Scanning and Filtering
1123. Text Formatting
1124. Text Sorting
1125. Text Comparison
1128. Byte Handling
1180. Date and Time
1190. Other General Commands
1200. Basic Tools
1210. Archivers, Compressors and Related Tools
1220. Basic Task-running and -coordinating Tools
1221. Cron and At: Execution Schedulers
1222. File-lockers and Related Commands
1230. Pagers, Documentation Tools and Text Editors
1231. Pagers and Documentation Tools
1232. Text Editors
1240. TTY- and Console-related Commands
1241. TTY-related Commands
1242. Console-related Commands
1300. Programming Tools
1310. C-compilers, Assemblers and Related Tools
1311. C
1312. C++
1313. Linking and Library Construction
1314. Assembly and Assembly Tools
1315. Make
1316. Lexing and Parsing
1318. Debugging
1320. The RCS Revision Control System
1330. Autoconf
1340. Large-Scale Interpreters
1400. User-level System Commands
1410. User-level System Commands: User-ID Control
1420. User-level System Commands: Process Control
1430. User-level System Commands: Filesystem Interface
1440. User-level System Commands: User-Account Administration
1450. User-level System Commands: Kernel Interface
1460. User-level System Commands: Debian Software Package Management
1490. Other User-Level System Commands
1600. Communications and Networking
1610. PPP (Point-to-Point Protocol)
1620. Technical Networking Tools
1621. TCP/IP
1622. DNS
1630. Network Clients
1631. General Network Clients
1632. FTP (File Transfer Protocol) Clients and Related Tools
1640. E-mail
1700. Other User Commands
1710. Printing
1711. Printer Management
1712. PostScript and PDF Laser-Printing
1713. The TeX Document Formatter and the Texinfo Documentation Sys
1714. The Groff Document Formatter
1715. SGML / XML
1720. Mathematics
1721. Geometry
1727. Other Mathematical Tools
1728. Plotting
1730. Image Filters, Sound Filters and Related Tools
1800. X Commands, Utilities and Tools
1810. The X Window System
1820. X Foundation
1821. Basic X Tools
1822. X TTY-Related Commands
1823. X Font Management
1824. X Image-handling Commands
1830. X Programming Tools
1840. X Applications
1841. X Line-Drawing Tools
1842. X Mathematical Tools
1843. X Graphics Tools
1847. X Desktop Clocks
1848. X Print Previewers
4000. DEVICES
5000. FILE FORMATS
5100. General File Formats
5200. File Formats Related to Basic Tools
5240. TTY- and Console-related File Formats
5300. Programming File Formats
5400. System-configuration File Formats
5410. Boot-control File Formats
5420. Process-control File Formats
5430. Filesystem-control File Formats
5440. User-account Administration File Formats
5450. Kernel-interface File Formats
5460. Debian File Formats
5490. Other System-configuration File Formats
5600. Communications and Networking File Formats
5620. Networking File Formats
5640. E-mail File Formats
5700. Other File Formats
5710. Printservice Configuration File Formats
5730. Image Formats
5800. X-configuration File Formats
7000. CONVENTIONS AND MISCELLANY
7100. System Conventions and Miscellany
7200. Character-set Conventions and Miscellany
7300. Groff Conventions and Miscellany
7700. Other Conventions and Miscellany
7800. Network Conventions and Miscellany
8000. ADMINISTRATIVE AND PRIVILEGED COMMANDS
8100. General Administration
8110. Boot Control
8120. Process Control
8130. Filesystem Control
8140. User-account Administration
8150. Kernel Administration
8151. Kernel-module Control
8152. Kernel Control
8153. Console Control
8190. Other Administrative and Privileged Commands
8200. Debian Software Package Management
8700. General Daemons
8800. Network Control and Daemons
8810. Network Control
8820. Network Daemons
Appendix
How To Learn More about a Specific Command
How To Find Other Commands
Work Still Needed
Document History
Acknowledgment
About the Author
Copyright and License
APPLICATION
The author has written this edition of the Howto with reference to Debian GNU/Linux 2.2r6 for easiest use with the upcoming Debian GNU/Linux 3.0. Nevertheless, most of the useful commands this Howto covers are found on most GNU/Linux systems everywhere; many of them are even found on most Unix-type systems everywhere. This Howto thus has general application.
SCOPE
This edition of the Command Selection Howto identifies and classifies 899 important GNU/Linux commands.
A large number of useful but specialized and obscure commands are deliberately omitted. New, unproven commands -- defined as commands making their first Debian appearance in Debian GNU/Linux 3.0 -- are also omitted. In some cases, even popular, well established, generally useful alternatives exist which are not covered: for example, although bash(1) is the only shell covered here, several other good shells exist; similarly, many good text editors exist of which this Howto covers only a few. The reason for such extensive omissions, of course, is to keep this Howto brief enough to be helpful both to the experienced GNU/Linux veteran and to the newcomer who wishes to grow into an experienced GNU/Linux veteran. The author has applied his own experience and his best subjective judgment in the matter.
Conspicuously missing from this Howto are hundreds of possible entries for NFS, Gnome, KDE, GGI, Berlin, DRI, Rplay, ALSA, OSS, HTML conversion, SVGAlib and the various X window managers. This Howto, while quite long enough, does seek to obtain some useful degree of brevity; thus the exclusions. The Howto, however, has also a philosophical reason for many of the exclusions: namely, that, when properly organized and used, GNU/Linux is at heart a text-driven system; the graphics and sound are extra. If you want to become a GNU/Linux expert, it is more important that you first learn well the text-driven core of the system than that you understand the generally more complex graphical and audio additions. Learn first many or most of the commands in this Howto: to do so will serve you well.
To obtain a more complete, less selective listing of available commands, see the section "How To Find Other Commands" at the end of this Howto.
CONSTRUCTION AND USE
A subtle feature of this Howto -- a feature which, perhaps, might turn out to be the most useful of them all -- is that it groups related commands together for common reference in a similar way as a public or university library groups related books together. For example, the Howto groups together, under category 1111, nine file-listing and
-finding commands, none of them new, all of them fairly important, and most of them widely used; furthermore, it places the whole category 1111 near categories 1112, 1113 and 1119, which contain other general file commands. One of the vexing problems of GNU/Linux manpages, after all, has always been that, while they often each include a "See Also" section referring to related commands, the "See Also" section frequently lacks reference to several of the most important available related commands. This is often simply because the related commands did not yet exist at the time the manpage was written. For example, while tree(1)'s manpage does indeed refer to the venerable ls(1), ls(1)'s documentation never refers to the newer tree(1); therefore, had you been using `ls -R' to list directories' contents recursively, how would you ever even have known that the fine tree(1) command were available for a similar purpose? With reference to this Command Selection Howto, you can know of tree(1) and hundreds of other useful commands of which you might never otherwise have known.
Besides the commands proper (as in man sections 1 and 8), this Howto also includes the devices (4), configuration files (5), and conventions and miscellany (7) that have man pages and seem most significant and common.
To learn more than the one-line summary this Howto gives each command, see the section "How To Learn More about a Specific Command" at the end of this Howto.
THE COMMANDS
0110.
BASH DIRECTORY SPECIFICATION
cd [builtin] - change the current directory dirs [builtin] - display the list of currently remembered dirs popd [builtin] - remove an entry from the directory stack pushd [builtin] - add a directory to the top of the directory stack pwd [builtin] - print name of current/working directory
0120.
BASH PARAMETER HANDLING
getopts [builtin] - parse positional parameters shift [builtin] - shift $2 to $1, $3 to $2, etc, discarding $1
0130.
BASH ENVIRONMENT MANAGEMENT
export [builtin] - prepare the environments of subsequent commands umask [builtin] - set the user file-creation mask unset [builtin] - remove the specified variable (or function)
0140.
BASH JOB CONTROL
% [builtin] - resume a stopped or background job bg [builtin] - place the specified job in the background disown [builtin] - remove a job from the table of active jobs fg [builtin] - place the specified job in the foreground jobs [builtin] - list the active jobs kill [builtin] - send the proc or job named the signal specified time [builtin] - run programs and summarize system resource usage times [builtin] - print a job's user- and system-time usage ulimit [builtin] - control resources avail to procs the shell starts wait [builtin] - wait for the given proc; report its exit status
0150.
BASH COMMAND-LINE CONTROL
alias [builtin] - define a command alias history [builtin] - display the history list with line numbers set -o vi [builtin] - use vi-style cmd line; `set -o emacs' countrmands type [builtin] - indicate how the given name would be interpreted unalias [builtin] - remove the specified names from the alias list
0160.
BASH SHELL CONTROL
exec [builtin] - replace this shell with the specified program exit [builtin] - exit the shell logout [builtin] - log out of a login shell (shortcut: ^D) set [builtin] - set shell flags set -e [builtin] - exit on an error; `set +e' countermands shopt [builtin] - toggle variables controlling optional behavior suspend [builtin] - suspend the execution of this shell until SIGCONT trap [builtin] - execute command when shell rcvs the given signal
0170.
BASH FLOW CONTROL
break [builtin] - exit from within a for, while or until loop case [builtin] - selectively execute commands continue [builtin] - resume the next iteration of the enclosing loop for [builtin] - execute commands for each member in a list function [builtin] - create a simple command if [builtin] - execute if exit status is zero local [builtin] - create a variable local to a function return [builtin] - exit a function with the return value specified until [builtin] - execute until zero exit status while [builtin] - execute while zero exit status
0180.
BASH CONDITION TESTING
[] [builtin] - check file types and compare values false [builtin] - return an unsuccessful result test [builtin] - check file types and compare values true [builtin] - return a successful result
0190.
OTHER BASH SHELL BUILTINS
. [builtin] - read and execute commands in the current environ : [builtin] - do nothing; this builtin has no effect echo [builtin] - display a line of text help [builtin] - display helpful info about builtin commands printf [builtin] - format and print source [builtin] - read and execute commands in the current environ
0220.
BASH SHELL PARAMETERS
$! [shell] - the last background command's process ID $# [shell] - the number of positional parameters remaining $$ [shell] - the shell's process ID $* [shell] - "$1 $2 ..." $1 $2 ... [shell] - positional parameters given by parent to shell $? [shell] - the last command's return status $@ [shell] - "$1" "$2" ... $HOME [shell] - the user's home directory $PATH [shell] - the search path for commands $PPID [shell] - the shell's parent's process ID $PS1 [shell] - string controlling the cmd prompt's appearance $PWD [shell] - the present working directory
0230.
BASH SHELL VARIABLE HANDLING
$var [shell] - evaluate the variable
${var} [shell] - evaluate the variable
${var:-text} [shell] - evaluate the variable; return text if empty
${var:=text} [shell] - evaluate the variable; assign text if empty
var=text [shell] - store the given text in the named shell variable
0240.
BASH JOBSPECS
%+ %% % [shell] - the current job %- [shell] - the previous job %n [shell] - job number n %jobname [shell] - the named job
0251.
BASH QUOTING
"text" [shell] - accept the enclosed text with interpolation 'text' [shell] - accept the enclosed text verbatim ` cmd ` [shell] - accept the text the enclosed command produces
0252.
BASH CHARACTER ESCAPES
\nnn [shell] - (three-digit octal character; see ascii(7)) \n [shell] - (newline character) \t [shell] - (tab character)
0253.
BASH PATTERN MATCHING
* [shell] - any zero or more characters
? [shell] - any one character
[chars] [shell] - any one of the enclosed characters
[^chars] [shell] - any character not enclosed
[A-Za-z] [shell] - any character `A' through `Z' or `a' through `z'
{a1,a2,...} [shell] - any one of the comma-separated alternatives
0254.
BASH PATHNAME EXPANSION
. [shell] - the present working directory .. [shell] - the present working directory's parent ~ [shell] - the user's home directory ~- [shell] - the previous directory ~user [shell] - the named user's home directory
0271.
BASH FLOW-CONTROL
! cmd [shell] - logically invert the command's exit status
cmd ; [shell] - syntactically terminate the command
cmd1 ; cmd2 [shell] - run the commands in sequence
cmd1 | cmd2 [shell] - pipe one cmd's stdout directly to another's stdin
cmd1 && cmd2 [shell] - run cmd2 if and only if cmd1 succeeds
cmd1 || cmd2 [shell] - run cmd2 if and only if cmd1 fails
{ cmd ; } [shell] - run the enclosed command in the current environ
{ c1 ; c2 ; }[shell] - run the enclosed cmds as a single cmd
( cmd ) [shell] - run the enclosed command in a subshell
( c1 ; c2 ) [shell] - run the enclosed cmds in subshell as a single cmd
cmd & [shell] - run the command in the background
0272.
BASH REDIRECTION
< file [shell] - let the named file provide stdin > file [shell] - redirect stdout to the named file >> file [shell] - append stdout to the named file 2> file [shell] - redirect stderr to the named file 2>> file [shell] - append stderr to the named file &> file [shell] - redirect both stdout and stderr to the named file &>> file [shell] - append both stdout and stderr to the named file 1>&2 [shell] - redirect stdout to stderr 2>&1 [shell] - redirect stderr to stdout
0281.
BASH FILE TESTS
(SEE TEST BUILTIN)
-O file [shell] - true if file exists and is yours -d file [shell] - true if file exists and is a directory -e file [shell] - true if file exists -f file [shell] - true if file exists and is a regular file -h file [shell] - true if file is a symbolic link -r file [shell] - true if file exists and is readable -w file [shell] - true if file exists and is writable -x file [shell] - true if file exists and is executable f1 -nt f2 [shell] - true if file 1 is newer than file 2 f1 -ot f2 [shell] - true if file 1 is older than file 2
0282.
BASH STRING TESTS
(SEE TEST BUILTIN)
-n text [shell] - true if text has non-zero length -z text [shell] - true if text has zero length t1 != t2 [shell] - true if text1 and text2 differ t1 == t2 [shell] - true if text1 and text2 are the same
0290.
OTHER BASH SHELL ELEMENTS AND OPERATORS
# comment [shell] - let the shell ignore the comment \ [shell] - continue this line on the next line
EXAMPLES ILLUSTRATING
BASH'S IF, CASE, FOR AND WHILE BUILTINS
The several examples which follow suffice to illustrate the use of the shell's important `if', `case', `for', and `while' builtins. Take some time to study the examples; even try them if needed or desired. Until you understand these basic examples, you probably will not be able to understand much of what goes on when you use GNU/Linux.
(Notice that, while the examples happen to demonstrate the conditional execution of the `echo' builtin, you could equally well substitute for the various `echo's any commands you wanted.)
IF
The shell command
if [ $A == foo ] ; then echo oof ; elif [ $A == bar ] ; then echo rab ; elif [ $A == baz ] ; then echo zab ; else echo nile ; fi
prints
oof
if $A is "foo"; prints
rab
if $A is "bar"; prints
zab
if $A is "baz"; and prints
nile
if $A is anything else. (To assign "foo" to $A before giving the `if' command, first give the command "A=foo".)
CASE
The shell command
case $A in
foo | bar ) echo barfoo ;;
eb?z* ) echo ebozbarren ; echo baz ;;
* ) echo default ;;
esac
prints
barfoo
if $A is "foo" or "bar"; prints
ebozbarren baz
if $A is "ebozbar", "ebazzy", or something similar; and prints
default
if $A is anything else.
FOR
The shell command
for X in foo bar baz ; do echo X is ; echo $X ; done
prints
X is foo X is bar X is baz
WHILE
If the shell received the commands
while cmd1 ; cmd2 ; do cmd3 ; cmd4 ; cmd5 ; done echo foo
where the various "cmdn" were any commands of your choosing, then, if cmd2 succeeded the first two times it were invoked but failed the third time, the shell would execute commands 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1 and 2 in sequence, then print "foo". The cycle would run round and round until cmd2 failed.
If the shell received similar commands, except with `until' instead of `while', then the cycle would run round and round, not until cmd2 failed, but rather until cmd2 succeeded. Otherwise it would work in the same way.
When a GNU/Linux command fails, incidentally, it returns 1 or some other status number besides 0; when it succeeds, it returns 0 (which is exactly opposite the way C operators work). The shell does not normally clutter the screen by showing you these status numbers: to view the last command's status, therefore, enter "echo $?".
This page is linked from the Freespire User Manual, please review the Editing Guidelines and follow the wiki Style Guide. Concerns about the topic should reside in the discussion tab.

