8. Command Glossary

$Id: cmdgloss.xml 2331 2009-04-18 12:59:52Z rafi $

A glossary of the command presented in this article. For detailed information about the commands, refer to the manual pages of the respective command.

Switches enclosed in square brackets ([]) are optional. If not stated otherwise, the commands are available under FreeBSD, Linux, and Sun Solaris.

Glossary

bg

Resumes a suspended command in the background. Available only in shells that are capable of job control.

Related commands: fg, jobs.

Refer to Section 6.2, “Job Control”.

Syntax. 

bg [% jobnum]

Replace jobnum with the number of the suspended job to put in background. See also jobs. If you omit the number, the last suspended command will be put in the background.

cancel

The cancel utility cancels print requests.

Related commands: lp, lpq, lprm, lpstat.

Refer to Section 7.3.2, “Printing under Linux and Sun Solaris”.

Availability.  Linux, Sun Solaris

cat

The cat utility reads files sequentially, writing them to the standard output.

Related commands: grep, sort.

Syntax. 

cat file...

Cat processes the files specified by file....

cd

The cd utility changes the current directory.

Related commands: mkdir, rmdir, pwd.

Refer to Section 5, “The File System”.

Syntax. 

cd dirname

Replace dirname with either the absolute or relative path to the directory to change to.

chgrp

The chgrp command will set the group ID of the file named by each file operand to the group ID specified by the group. You are only allowed to change the group if you are the owner of the file or directory.

Related commands: chown, chmod.

Refer to Section 5.4.1, “Commands”.

Syntax. 

chgrp [-R] groupname file...

Replace groupname by the name of the group. You can specify one or more files or directories by replacing file.... Using the optional -R switch, it will recursively change the group of a directory.

chmod

The chmod command assigns or changes permissions of a file. You are only allowed to change permissions if you are the owner of the file or directory.

Related commands: chgrp, chown.

Refer to Section 5.4.1, “Commands”.

Syntax. 

chmod [-R] mode file...

Replace mode with the numerical value as described in Section 5.4.1, “Commands”. file... can be replaced by one or more files or directories. Use the -R switch to change permissions recursively in directories.

chown

Sets the owner of a file or directory. You are only allowed to change the owner if you are the owner of the file or directory.

Related commands: chgrp, chmod.

Refer to Section 5.4.1, “Commands”.

Syntax. 

chown [-R] username file...

Replace username with the name of the owner. file... can be replaced by one or more files or directories. Use the -R switch to change the owner recursively in directories.

cp

Copy files. Be careful, cp does not warn about overwriting existing target files.

Related commands: ls, mv, rm.

Refer to Section 5.3, “File and Directory Commands”.

Syntax. 

cp [-R] src... dest

cp copies the files specified as src... to the directory or file specified by dest. If you want to copy entire directories, use the -R option.

echo

echo can be used to print a message or the content of a shell variable to the screen.

fg

Resumes a suspended command in the foreground, or brings a process running in the background to the foreground. Available only in shells that are capable of job control.

Related commands: bg, jobs.

Refer to Section 6.2, “Job Control”.

Syntax. 

fg [% jobnum]

Replace jobnum with the number of the suspended or in the background running job to put in foreground. See also jobs. If you omit the number, the last suspended or to background sent command will be put to the foreground.

grep

Grep searches the named input files (or standard input if no files are named, or the file name - is given) for lines containing a match to the given patter. By default, grep prints the matching lines.

Related commands: cat, less, more, sort.

Refer to Section 4.1, “Piping”, Section 7.4, “Search for Text in Files”.

Syntax. 

grep [-n] pattern file...

The pattern may be a regular expression (not covered here) or a simple string. The -n option tells grep to print out the line number of matching line. Replace file... by one or more files to search. If omitted, grep expects the input from the standard input.

groups

The command groups prints on standard output the groups to which you belong.

Related commands: id.

Refer to Section 3, “Users”.

Syntax. 

groups [user...]

In addition to plainly call groups without option, you can specify user names, for which the group membership should be printed.

id

If no user name is provided, the id utility writes the user and group IDs and the corresponding user and group names of the invoking process to standard output.

Related commands: id.

Refer to Section 3, “Users”

Syntax. 

id [user]

If you don't specify an user name, your user and group id are printed. You can alternatively provide a user name as the [user] option, in which case you see the user and group id of that user.

jobs

When job control is enabled, jobs reports all jobs that are stopped or executing in the background.

Related commands: bg, fg.

Refer to Section 6.2, “Job Control”.

Syntax. 

jobs

kill

The kill utility sends a signal to the process or processes specified by each PID operand. You can only send signals to processes you own.

Related commands: killall, pkill.

Refer to Section 6.1, “Terminating Processes”.

Syntax. 

kill [-KILL] pid

The pid is the PID of the processes to which the terminate signal is sent. If the -KILL option is provided, the kill signal instead of the terminate signal is sent.

killall

The killall utility kills processes selected by name, as opposed to the selection by PID as done by kill. You can only send signals to processes you own.

Related commands: kill, pkill.

Refer to Section 6.1, “Terminating Processes”.

Syntax. 

killall [-KILL] procname

The syntax is the same as with kill, but it takes a process name instead of a PID.

Availability.  Linux, FreeBSD

less

Less is a program similar to more,but which allows backward movement in the file as well as forward movement.

Related commands: cat, more.

Refer to Section 4.3, “Pagers”.

Syntax. 

less [filename]

If filename is omitted, less expects the input from the standard input.

ln

Ln creates links to files and directories.

Related commands: cp.

Refer to Section 5.5.2, “Links”.

Syntax. 

ln -s file linkname

Replace file with the file or directory name of which you want to create the link to. linkname is the name of the link, as, for instance, seen by ls.

logout

Terminate a login shell.

Refer to Section 2.1, “The Shell”

Syntax. 

logout

lp

The lp utility submits print requests to a printer.

Related commands: cancel, lpq, lpr, lprm, lpstat.

Refer to Section 7.3.2, “Printing under Linux and Sun Solaris”.

Syntax. 

lp [-d dest] [file...]

Replace file... with the files to print. If omitted, it expects the input from the standard input. The -d dest option can be used to specify a printer other than the standard printer. If omitted, the standard printer is used.

Availability.  Linux, Sun Solaris

lpq

The lpq utility displays the information about the contents of a print queue.

Related commands: cancel, lp, lpr, lprm, lpstat.

Refer to Section 7.3.1, “Printing under FreeBSD”

Syntax. 

lpq [-P queue]

Prints the jobs in the print queue. You can specify the printer queue to list with the -P queue option.

Availability.  FreeBSD

lpr

The lpr utility submits print requests to a printer.

Related commands: cancel, lp, lpq, lprm, lpstat.

Refer to Section 7.3.1, “Printing under FreeBSD”.

Syntax. 

lpr [-P printer] [file...]

Replace file... with the files to print. If omitted, it expects the input from the standard input. The -P printer option can be used to specify a printer other than the standard printer. If omitted, the standard printer is used.

Availability.  FreeBSD

lprm

The lprm utility removes print job from the print queue.

Related commands: cancel, lp, lpq, lpr, lpstat.

Refer to Section 7.3.1, “Printing under FreeBSD”.

Syntax. 

lpr [-P printer]

Removes your last submitted print job from the print queue of the default printer. You can specify the print queue with -P printer option.

Availability.  FreeBSD

lpstat

The lpstat utility displays information about the current status of the printer queue.

Related commands: cancel, lp, lpq, lpr, lprm.

Refer to Section 7.3.2, “Printing under Linux and Sun Solaris”.

Syntax. 

lpstat

Availability.  Linux, Sun Solaris

ls

For each file that is a directory, ls lists the contents of the directory.For each file that is an ordinary file, ls repeats its name and any other information requested.

Related commands:

Refer to Section 5.2, “The ls Command”.

Syntax. 

ls [-l] [-a] [-d] [-h] [file...]

Called with no file... argument, ls lists the content of the current working directory. The -l option generates a long list containing the permissions, owner, group owner, size, last modified date, and file name. The -a make ls show also hidden files. The -h displays the file sizes in human readable format. The -d option advises ls to not dive into directories, but instead print the information of the directory in question.

man

The man command displays information from the reference manuals. It displays complete manual pages that you select by name.

Related commands: whatis.

Refer to Section 4.2, “Man Pages”.

Syntax.  On FreeBSD and Linux:

man [secnum] command

On Sun Solaris

man [-s secnum] command

You can request the manual page from a specific section by providing the secnum option.

mkdir

The mkdir command creates the named directory.

Related commands: rmdir.

Refer to Section 5, “The File System”.

Syntax. 

mkdir dirname

You can create only new directories in directories you have write access to the parent directory.

more

The more utility is a filter that displays the contents of a text file on the terminal, one screenful at a time. It pauses after each screenful. more then prints --More--.

Related commands: less.

Refer to Section 7.1, “Reading Text Files”.

Syntax. 

more [file...]

If you omit the file... option, more expects the input from the standard input.

mv

The mv utility moves the file named by the source operand to the destination specified by the target. Source and target file may not have the same name. If target does not exist, mv creates a file named target. If the target file exists, its contents are overwritten. If the target file is a directory, the source is moved to that directory.

Related commands: cp, rm.

Refer to Section 5, “The File System”.

Syntax. 

mv source... destination

passwd

The passwd command changes the password associated with the user's login name.

Related commands:

Refer to Section 3, “Users”.

Syntax. 

passwd

pkill

The pkill utility kills processes selected by name, as opposed to the selection by PID as done by kill. You can only send signals to processes you own.

Related commands: kill, killall.

Refer to Section 6.1, “Terminating Processes”

Syntax. 

pkill [-KILL] procname

The syntax is the same as with kill, but it takes a process name instead of a PID.

Availability.  Sun Solaris, FreeBSD

prstat

The prstat utility iteratively examines all active processes on the system and reports statistics.

Related commands: ps, top.

Refer to Section 6, “Processes”.

Syntax. 

prstat

Availability.  Sun Solaris

ps

The ps command prints information about active processes.

Related commands: prstat, top.

Refer to Section 6, “Processes”.

Syntax.  On Sun Solaris and Linux

ps [-e] [-f]

On FreeBSD

ps [a][x]

pwd

The pwd utility writes an absolute path name of the current working directory to standard output.

Related commands: cd.

Refer to Section 5, “The File System”

Syntax. 

pwd

rm

The rm utility removes the directory entry specified by each file argument. You can only remove files if you have write access to their parent directory.

Related commands: cp, mv, rmdir.

Refer to Section 5, “The File System”.

Syntax. 

rm [-r] file...

Removes the file(s) specified by the file... argument. You can recursively delete files and directories by providing the -r option. Warning! You must be careful using the -r switch of rm. It deletes everything in the directory specified including sub-directories without any confirmation question, such as known by Microsoft operating systems. So you once fired on the wrong directory, you have little chance of stopping it. Especially since the rm command deletes the files for real, and does not move them to some recycle bin or trashcan, where you can salvage the files from.

rmdir

The rmdir command removes empty directories.

Related commands: mkdir.

Refer to Section 5, “The File System”.

Syntax. 

rmdir dirname

sort

The sort command sorts lines of all the named files together and writes the result on the standard output.

Related commands: cat, grep.

Refer to Section 4.1, “Piping”.

Syntax. 

sort [file...]

If you omit file... sort expects the input from the standard input.

ssh

ssh (Secure Shell) is a program for logging into a remote machine It provides a secure encrypted communications between two untrusted hosts over an insecure network. X11 connections can also be forwarded over the secure channel.

Related commands:

Refer to Section 2, “The Terminal”, Appendix A, X Window System.

Syntax. 

ssh [-X] username@host

Replace username with your user name on the remote host and host with the remote host name. If X forwarding is enabled on the remote host, the -X enables the client to allow them.

su

The su command allows one to become another user without logging off.

Related commands:

Refer to Section 3, “Users”.

Syntax. 

su [-] [username]

If the username is omitted, the default user is root. The - makes the user switch behave like a login.

top

Top displays the processes on the system and periodically updates this information.

Related commands: ps, prstat

Refer to Section 6, “Processes”.

Syntax.  On Linux

top [-d sec]

On FreeBSD

top [-s sec]

The -d or -s take the update frequency in seconds.

Availability.  Linux, FreeBSD

whatis

Whatis looks up a given command and displays the header line from the manual section.

Related commands: man, which.

Refer to Section 4.2, “Man Pages”.

Syntax. 

whatis command

which

Which takes a list of names and looks for the files which would be executed had these names been given as commands. Each argument is searched for along the user's PATH environment variable.

Related commands: whatis.

Refer to Section 4, “Commands”.

Syntax. 

which file...

who

The who command lists the logged in users on the system.

Related commands:

Refer to Section 3, “Users”.

Syntax. 

who