cat

 

cat [options] [files]

 

Read (concatenate) one or more files and print them on standard output. Read standard input if no files are specified or if - is specified as one of the files; input ends with EOF. You can use the > operator to combine several files into a new file, or >> to append files to an existing file.

 

To send data thru LPT port use: cat [filename] > lp0; Usb0 for USB, tty0 for COM1 etc;

 

 

cp

cp [options] file1 file2 cp [options] files directory

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).

 

 

 

chmod

chmod [options] mode files chmod [options] --reference=filename files

Change the access mode (permissions) of one or more files. Only the owner of a file or a privileged user may change the mode. mode can be numeric or an expression in the form of who opcode permission. who is optional (if omitted, default is a); choose only one opcode. Multiple modes are separated by commas.

Options

-c, --changes

Print information about files that are changed.

-f, --silent, --quiet

Do not notify user of files that chmod cannot change.

--help

Print help message and then exit.

-R, --recursive

Traverse subdirectories recursively, applying changes.

--reference=filename

Change permissions to match those associated with filename.

-v, --verbose

Print information about each file, whether changed or not.

--version

Print version information and then exit.

Who

u

User.

g

Group.

o

Other.

a

All (default).

Opcode

+

Add permission.

-

Remove permission.

=

Assign permission (and remove permission of the unspecified fields).

Permissions

r

Read.

w

Write.

x

Execute.

s

Set user (or group) ID.

t

Sticky bit; used on directories to prevent removal of files by non-owners.

u

User's present permission.

g

Group's present permission.

o

Other's present permission.

Alternatively, specify permissions by a three-digit octal number. The first digit designates owner permission; the second, group permission; and the third, other's permission. Permissions are calculated by adding the following octal values:

4

Read.

2

Write.

1

Execute.

Note that a fourth digit may precede this sequence. This digit assigns the following modes:

4

Set user ID on execution to grant permissions to process based on the file's owner, not on permissions of the user who created the process.

2

Set group ID on execution to grant permissions to process based on the file's group, not on permissions of the user who created the process.

1

Set sticky bit.

Examples

Add execute-by-user permission to file:

chmod u+x file

Either of the following will assign read/write/execute permission by owner (7), read/execute permission by group (5), and execute-only permission by others (1) to file:

chmod 751 file chmod u=rwx,g=rx,o=x file

Any one of the following will assign read-only permission to file for everyone:

chmod =r file chmod 444 file chmod a-wx,a+r file

The following makes the executable setuid, assigns read/write/execute permission by owner, and assigns read/execute permission by group and others:

chmod 4755 file

 

 

 

chkconfig

chkconfig [options] [service [flag] ]

System administration command. Manipulate symbolic links in the /etc/rc.d/rc[0-6] .d directories. chkconfig manages which services will run in a specified runlevel. Valid flags are on, off, or reset to reset the service to defaults given in its initialization script in /etc/rc.d/init.d. To specify defaults in an standard initialization script, add a comment line to the script beginning with chkconfig: followed by the runlevels in which the service should run, and the start and kill priority numbers to assign—e.g., chkconfig: 2345 85 15

Options

--add service

Create a start or kill symbolic link in every runlevel for the specified service according to default behavior specified in the service's initialization script.

--del service

Remove entries for specified service from all runlevels.

--level numbers

Specify by number the runlevels to change. Provide numbers as a numeric string: e.g., 016 for levels 0, 1 and 6. Use this to override specified defaults.

--list [service]

Print whether the specified service is on or off in each level. If no service is specified, print runlevel information for all services managed by chkconfig.

 

 

df

df [options] [name]

Report the amount of free disk space available on all mounted filesystems or on the given name. (df cannot report on unmounted filesystems.) Disk space is shown in 1 KB blocks (default) or 512-byte blocks (if the environment variable POSIXLY_CORRECT is set).

 

 

domainname

domainname [name]

NFS/NIS command. Set or display name of current NIS domain. With no argument, domainname displays the name of the current NIS domain.

 

 

 



dumpkeys

dumpkeys [options]

Print information about the keyboard driver's translation tables to standard output. Further information is available in the manual pages under keymaps(5).

Options

-1, --separate-lines

Print one line for each modifier/keycode pair, and prefix plain to each unmodified keycode.

-ccharset, --charset=charset

Specify character set with which to interpret character code values. The default character set is iso-8859-1. The full list of valid character sets is available with the --help option.

--compose-only

Print compose key combinations only. Requires compose key support in the kernel.

-f, --full-table

Output in canonical, not short, form: for each key, print a row with modifier combinations divided into columns.

--funcs-only

Print function-key string definitions only; do not print key bindings or string definitions.

-h, --help

Print help message and the version.

-i, --short-info

Print in short-info format, including information about acceptable keycode keywords in the keytable files; the number of actions that can be bound to a key; a list of the ranges of action codes (the values to the right of a key definition); and the number of function keys that the kernel supports.

--keys-only

Print key bindings only; do not print string definitions.

-l, --long-info

Print the same information as in --short-info, plus a list of the supported action symbols and their numeric values.

-n, --numeric

Print action code values in hexadecimal notation; do not attempt to convert them to symbolic notation.

-S num, --shape=num

Print using num to determine table shape. Values of num are:

0

Default.

1

Same as --full-table.

2

Same as --separate-lines.

3

One line for each keycode up to the first hole, then one line per modifier/keycode pair.

 

 

egrep

egrep [options] [regexp] [files]

Search one or more files for lines that match an extended regular expression regexp. egrep doesn't support the regular expressions \(, \), \n, \<, \>, \{, or \}, but it does support the other expressions, as well as the extended set +, ?, |, and ( ). Remember to enclose these characters in quotes. Regular expressions are described in Chapter 7. Exit status is 0 if any lines match, 1 if none match, and 2 for errors.

See grep for the list of available options. Also see fgrep.

Search for occurrences of Victor or Victoria in file:

egrep 'Victor(ia)*' file egrep '(Victor|Victoria)' file

Find and print strings such as old.doc1 or new.doc2 in files, and include their line numbers:

egrep -n '(old|new)\.doc?' files

 

 

ls

List dir in the folder;

 

 

insmod

insmod filename [module-options]

System administration command. Load the module filename into the kernel. Simpler but less flexible than the modprobe command. Error messages from insmod may be vague, because the kernel performs module operations internally and therefore sends error information to the kernel log instead of standard output; see dmesg.

 

 

ifconfig

ifconfig [interface] ifconfig [interface address_family parameters addresses]

TCP/IP command. Assign an address to a network interface and/or configure network interface parameters. ifconfig is typically used at boot time to define the network address of each interface on a machine. It may be used at a later time to redefine an interface's address or other parameters. Without arguments, ifconfig displays the current configuration for a network interface. Used with a single interface argument, ifconfig displays that particular interface's current configuration. Note that interfaces are numbered starting at zero: eth0, eth1, eth2, and so forth. In most cases, eth0 will be the primary PCI Ethernet interface, and wireless network interfaces will begin with ath0 or wlan0.

Arguments

interface

String of the form name unit: for example, en0.

address_family

Since an interface may receive transmissions in differing protocols, each of which may require separate naming schemes, you can specify the address_family to change the interpretation of the remaining parameters. You may specify inet (for TCP/IP, the default), ax25 (AX.25 Packet Radio), ddp (Appletalk Phase 2), or ipx (Novell).

parameters

The following parameters may be set with ifconfig:

add address/prefixlength

Add an IPv6 address and prefix length.

address address

Assign the specified IP address to the interface.

allmulti/-allmulti

Enable/disable sending of incoming frames to the kernel's network layer.

arp/-arp

Enable/disable use of the Address Resolution Protocol in mapping between network-level addresses and link-level addresses.

broadcast [address]

(inet only) Specify address to use to represent broadcasts to the network. Default is the address with a host part of all ones (i.e., x.y.z.255 for a class C network).

debug/-debug

Enable/disable driver-dependent debugging code.

del address/prefixlength

Delete an IPv6 address and prefix length.

down

Mark an interface "down" (unresponsive).

hw class address

Set the interface's hardware class and address. class may be ether (Ethernet), ax25 (AX.25 Packet Radio), or ARCnet.

io_addr addr

I/O memory start address for device.

irq addr

Set the device's interrupt line.

metric n

Set routing metric of the interface to n. Default is 0.

mem_start addr

Shared memory start address for device.

media type

Set media type. Common values are 10base2, 10baseT, and AUI. If auto is specified, ifconfig will attempt to autosense the media type.

mtu n

Set the interface's Maximum Transfer Unit (MTU).

multicast

Set the multicast flag.

netmask mask

(inet only) Specify how much of the address to reserve for subdividing networks into subnetworks. mask can be specified as a single hexadecimal number with a leading 0x, with a dot notation Internet address, or with a pseudo-network name listed in the network table /etc/networks.

pointopoint/-pointopoint [address]

Enable/disable point-to-point interfacing, so that the connection between the two machines is dedicated.

promisc/-promisc

Enable/disable promiscuous mode. Promiscuous mode allows the device to receive all packets on the network.

txqueuelen n

Specify the transmit queue length.

tunnel addr

Create an IPv6-in-IPv4 (SIT) device, tunneling to IPv4 address addr.

up

Mark an interface "up" (ready to send and receive).

addresses

Each address is either a hostname present in the hostname database (/etc/hosts), or an Internet address expressed in the Internet standard dot notation.

Examples

To list all interfaces:

ifconfig -a

To add a second IP address to wlan0:

ifconfig wlan0:1 192.168.2.41 netmask 255.255.255.0

To change the hardware address (MAC address) assigned to eth0 (useful when setting up a router for a DSL or cable modem):

ifconfig eth0 hw ether 01:02:03:04:05:06

 

 

hostname

hostname [option] [nameofhost]

Set or display name of current host system. A privileged user can set the hostname with the nameofhost argument.

Options

-a, --alias

Display the alias name of the host (if used).

-d, --domain

Display DNS domain name.

-f, --fqdn, --long

Display fully qualified domain name.

-F file, --file file

Consult file for hostname.

-h, --help

Display a help message and then exit.

-i, --ip-address

Display the IP address(es) of the host.

-n, --node

Display or set the DECnet node name.

-s, --short

Trim domain information from the display output.

-v, --verbose

Verbose mode.

-V, --version

Display version information and then exit.

-y, --yp, --nis

Display the NIS domain name. A privileged user can set a new NIS domain name with nameofhost.

 

 

fdisk

fdisk [options] [device]

fdisk displays information about disk

Options

-b sectorsize

Set the size of individual disk sectors. May be 512, 1024, or 2048. Most systems now recognize sector sizes, so this is not necessary.

-l

List partition tables and exit.

-u

Report partition sizes in sectors instead of cylinders.

-s partition

Display the size of partition, unless it is a DOS partition.

-v

Print version number, then exit.

-C cylinders

Specify the number of cylinders on the disk.

-H heads

Specify the number of heads per cylinder.

-S sectors

Specify sectors per track for partitioning.

Commands

a

Toggle a bootable flag on current partition.

b

Edit disklabel of a BSD partition.

c

Toggle DOS compatibility flag.

d

Delete current partition.

l

List all partition types.

m

Main menu.

n

Create a new partition; prompt for more information.

o

Create an empty DOS partition table.

p

Print a list of all partitions and information about each.

q

Quit; do not save.

t

Replace the type of the current partition.

u

Modify the display/entry units, which must be cylinders or sectors.

v

Verify: check for errors, and display a summary of the number of unallocated sectors.

w

Save changes and exit.

x

Switch to expert commands.

Example

To list all partitions currently on the system:

fdisk -l

 



   

Print.

Print

Email.

Email article link

find

find [pathnames] [conditions]

An extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. The default pathname is the current directory. The most useful conditions include -name and -type (for general use), -exec and -size (for advanced use), and -mtime and -user (for administrators).

Conditions may be grouped by enclosing them in \( \) (escaped parentheses), negated with !, given as alternatives by separating them with -o, or repeated (adding restrictions to the match; usually only for -name, -type, or -perm). Note that "modification" refers to editing of a file's contents, whereas "change" means a modification, or permission or ownership changes. In other words, -ctime is more inclusive than -atime or -mtime.

Conditions and actions

-amin +n| -n| n

Find files last accessed more than n (+n), less than n (-n), or exactly n minutes ago.

-anewer file

Find files that were accessed after file was last modified. Affected by -follow when after -follow on the command line.

-atime +n| -n| n

Find files that were last accessed more than n (+n), less than n (-n), or exactly n days ago. Note that find changes the access time of directories supplied as pathnames.

-cmin +n| -n| n

Find files last changed more than n (+n), less than n (-n), or exactly n minutes ago.

-cnewer file

Find files that were changed after they were last modified. Affected by -follow when after -follow on the command line.

-ctime +n| -n| n

Find files that were changed more than n (+n), less than n (-n), or exactly n days ago. A change is anything that changes the directory entry for the file, such as a chmod.

-daystart

Calculate times from the start of the day today, not 24 hours ago.

-depth

Descend the directory tree, skipping directories and working on actual files first, and then the parent directories. Useful when files reside in unwritable directories (e.g., when using find with cpio).

-empty

Continue if file is empty. Applies to regular files and directories.

-exec command{ } \ ;

Run the Linux command, from the starting directory on each file matched by find (provided command executes successfully on that file—i.e., returns a 0 exit status). When command runs, the argument { } substitutes the current file. Follow the entire sequence with an escaped semicolon (\;). In some shells, the braces may need to be escaped as well.

-false

Return false value for each file encountered.

-follow

Follow symbolic links and track the directories visited (don't use with -type l).

-fstype type

Match files only on type filesystems. Acceptable types include minix, ext, ext2, xia, msdos, umsdos, vfat, proc, nfs, iso9660, hpfs, sysv, smb, and ncpfs.

-gid num

Find files with numeric group ID of num.

-group gname

Find files belonging to group gname. gname can be a group name or a group ID number.

-ilname pattern

A case-insensitive version of -lname.

-iname pattern

A case-insensitive version of -name.

-inum n

Find files whose inode number is n.

-ipath pattern

A case-insensitive version of -path.

-iregex pattern

A case-insensitive version of -regex.

-links n

Find files having n links.

-lname pattern

Search for files that are symbolic links, pointing to files named pattern. pattern can include shell metacharacters and does not treat / or . specially. The match is case-insensitive.

-maxdepth num

Do not descend more than num levels of directories.

-mindepth num

Begin applying tests and actions only at levels deeper than num levels.

-mmin +n| -n| n

Find files last modified more than n (+n), less than n (-n), or exactly n minutes ago.

-mount, -xdev

Search only for files that reside on the same filesystem as pathname.

-mtime +n| -n| n

Find files that were last modified more than n (+n), less than n (-n), or exactly n days ago. A modification is a change to a file's data.

-name pattern

Find files whose names match pattern. Filename metacharacters may be used but should be escaped or quoted.

-newer file

Find files that were modified more recently than file; similar to -mtime. Affected by -follow only if it occurs after -follow on the command line.

-nogroup

The file's group ID does not correspond to any group.

-noleaf

Normally, find assumes that each directory has at least two hard links that should be ignored (a hard link for its name and one for "."--i.e., two fewer "real" directories than its hard link count indicates). -noleaf turns off this assumption, a useful practice when find runs on non-Unix-style filesystems. This forces find to examine all entries, assuming that some might prove to be directories into which it must descend (a time-waster on Unix).

-nouser

The file's user ID does not correspond to any user.

-ok command { }\;

Same as -exec, but prompts user to respond with y before command is executed.

-path pattern

Find files whose names match pattern. Expect full pathnames relative to the starting pathname (i.e., do not treat / or . specially).

-perm nnn

Find files whose permission flags (e.g., rwx) match octal number nnn exactly (e.g., 664 matches -rw-rw-r--). Use a minus sign before nnn to make a "wildcard" match of any unspecified octal digit (e.g., -perm -600 matches -rw-******, where * can be any mode).

-print

Print the matching files and directories, using their full pathnames. Return true. This is the default behavior.

-regex pattern

Like -path, but uses grep-style regular expressions instead of the shell-like globbing used in -name and -path.

-size n[c]

Find files containing n blocks, or if c is specified, n characters long.

-type c

Find files whose type is c. c can be b (block special file), c (character special file), d (directory), p (fifo or named pipe), l (symbolic link), s (socket), or f (plain file).

-user user

Find files belonging to user (name or ID).

Examples

List all files (and subdirectories) in your home directory:

find &dollar;HOME -print

List all files named chapter1 in the /work directory:

find /work -name chapter1

List all files beginning with memo owned by ann:

find /work -name 'memo*' -user ann -print

Search the filesystem (begin at root) for manpage directories:

find / -type d -name 'man*' -print

Search the current directory, look for filenames that don't begin with a capital letter, and send them to the printer:

find . \! -name '[A-Z] *' -exec lpr { }\;

Find and compress files whose names don't end with .gz:

gzip `find . \! -name '*.gz' -print`

Remove all empty files on the system (prompting first):

find / -size 0 -ok rm { } \;

Search the system for files that were modified within the last two days (good candidates for backing up):

find / -mtime -2 -print

Recursively grep for a pattern down a directory tree:

find /book -print | xargs grep '[Nn] utshell'

If the files kt1 and kt2 exist in the current directory, their names can be printed with the command:

&dollar; find . -name 'kt[0-9] ' ./kt1 ./kt2

Since the command prints these names with an initial ./ path, you need to specify the ./ when using the -path option:

&dollar; find . -path './kt[0-9] ' ./kt1 ./kt2

The -regex option uses a complete pathname, like -path, but treats the following argument as a regular expression rather than a glob pattern (although in this case the result is the same):

&dollar; find . -regex './kt[0-9] ' ./kt1 ./kt2

 

 

kill

kill [options] [pids | commands]

Send a signal to terminate one or more process IDs. You must own the process or be a privileged user. If no signal is specified, TERM is sent.

This entry describes the /bin/kill command, which offers several powerful features. There are also built-in shell commands of the same name; the bash and ksh versions are described in Chapter 6.

In particular, /bin/kill allows you to specify a command name, such as gcc or xpdf, instead of a process ID (PID). All processes running that command with the same UID as the process issuing /bin/kill will be sent the signal.

If /bin/kill is issued with a pid of 0, it sends the signal to all processes of its own process group. If /bin/kill is issued with a pid of -1, it sends the signal to all processes except process 1 (the system's init process).

Options

-a

Kill all processes of the given name (if privileges allow), not just processes with the same UID. To use this option, specify the full path (e.g., /bin/kill -a gcc).

-l

List all signals.

-p

Print the process ID of the named process, but don't send it a signal. To use this option, specify the full path (e.g., /bin/kill -p).

-s SIGNAL, -SIGNAL

The signal number (from /usr/include/sys/signal.h) or name (from kill -l). With a signal number of 9 (KILL), the kill cannot be caught by the process; use this to kill a process that a plain kill doesn't terminate. The default is TERM. The letter flag itself is optional: both kill -9 1024 and kill -s 9 1024 terminate process 1024.

 

 

link

link file1 file2

Create a link between two files. This is the same as the ln command, but it has no error checking because it uses the link( ) system call directly.

 

 

ls

ls [options] [names]

List contents of directories. If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name. names can include filename metacharacters. The options let you display a variety of information in different formats. The most useful options include -F, -R, -l, and -s. Some options don't make sense together (e.g., -u and -c).

Options

-1, --format=single-column

Print one entry per line of output.

-a, --all

List all files, including the normally hidden files whose names begin with a period.

-b, --escape

Display nonprinting characters in octal and alphabetic format.

-c, --time-ctime, --time=status

List files by status change time (not creation/modification time).

--color =when

Colorize the names of files depending on the type of file. Accepted values for when are never, always, or auto.

-d, --directory

Report only on the directory, not its contents.

-f

Print directory contents in exactly the order in which they are stored, without attempting to sort them.

--full-time

List times in full, rather than using the standard abbreviations.

-g

Long listing like -l, but don't show file owners.

-h

Print sizes in kilobytes and megabytes.

--help

Print a help message and then exit.

-i, --inode

List the inode for each file.

--indicator-style=none

Display filenames without the flags assigned by -p or -f (default).

-k, --kilobytes

If file sizes are being listed, print them in kilobytes. This option overrides the environment variable POSIXLY_CORRECT.

-l, --format=long, --format=verbose

Long format listing (includes permissions, owner, size, modification time, etc.).

-m, --format=commas

Merge the list into a comma-separated series of names.

-n, --numeric-uid-gid

Like -l, but use group ID and user ID numbers instead of owner and group names.

-o

Long listing like -l, but don't show group information.

-p, --filetype, --indicator-style=file-type

Mark directories by appending / to them.

-q, --hide-control-chars

Show nonprinting characters as ? (default for display to a terminal).

-r, --reverse

List files in reverse order (by name or by time).

-s, --size

Print file size in blocks.

--show-control-chars

Show nonprinting characters verbatim (default for printing to a file).

--si

Similar to -h, but uses powers of 1,000 instead of 1,024.

-t, --sort=time

Sort files according to modification time (newest first).

-u, --time=atime, --time=access, --time=use

Sort files according to file-access time.

--version

Print version information on standard output, then exit.

-x, --format=across, --format=horizontal

List files in rows going across the screen.

-v, --sort=version

Interpret the digits in names such as file.6 and file.6.1 as versions, and order filenames by version.

-w, --width=n

Format output to fit n columns.

-A, --almost-all

List all files, including the normally hidden files whose names begin with a period. Does not include the . and .. directories.

-B, --ignore-backups

Do not list files ending in ~ unless given as arguments.

-C, --format=vertical

List files in columns (the default format).

-D, --dired

List in a format suitable for Emacs dired mode.

-F, --classify, --indicator-style=classify

Flag filenames by appending / to directories, * to executable files, @ to symbolic links, | to FIFOs, and = to sockets.

-G, --no-group

In long format, do not display group name.

-H, --dereference-command-line

When symbolic links are given on the command line, follow the link and list information from the actual file.

-I, --ignore pattern

Do not list files whose names match the shell pattern pattern, unless they are given on the command line.

-L, --dereference

List the file or directory referenced by a symbolic link rather than the link itself.

-N, --literal

Display special graphic characters that appear in filenames.

-Q, --quote-name

Quote filenames with "; quote nongraphic characters.

-R, --recursive

List directories and their contents recursively.

-Rfile, --reload-state file

Load state from file before starting execution.

-S, --sort=size

Sort by file size, largest to smallest.

-U, sort=none

Do not sort files.

-X, sort=extension

Sort by file extension, then by filename.

 

 

 

lpr

lpr [options] [files]

Send files to be printed. If no files are given, accept standard input. We document the CUPS printing system here; the older LPRng and BSD systems will vary slightly. CUPS lpr, for example, does not accept the options c, d, f, g, i, m, n, t, v, or w, used by LPRng.

Options

-C, J, T name

Sets a name for the print job.

-E

Use encryption when connecting to a print server.

-l

Expect a binary or literal file on which minimal processing should be done. The same as -o raw.

-o option

Set printer-specific options. These vary by printer, but may include paper type and orientation, paper-tray selection, output order, and so forth. Check the complete CUPS user manual and your printer's PPD file for the full list.

-P printername

Print to the specified printer. If no printer is given, prints to the default printer, usually set with lpadmin.

-p

Pretty-print a text document. Provides a shaded header containing page numbers, the job name, and the time and date of printing. Equivalent to -o prettyprint.

-r

Delete files after printing them.

Example

Print a simple file:

lpr filename.txt

 

 

 

lpinfo

lpinfo options

System administration command. Print information on available printer devices and drivers.

Options

-E

Force the use of encryption connecting to the server.

-l

Show a long, or verbose, listing.

-m

List available printer drivers.

-v

List available printer devices.

 

 

 

lsusb

lsusb [options]

System administration command. List all Universal Serial Bus (USB) devices. This command has many options of use for debugging device drivers. Here we document some of the more common options.

Options

-b

Show IRQ and addresses as seen by the cards instead of the kernel.

-D device

Only show information about the specified device. This should be given as a file in the /proc/bus/usb directory—e.g., /proc/bus/usb/001/001.

-t

Print a tree showing connections between devices.

-v, -vv

List devices verbosely. Use the second form for very verbose listings.

 

 

 

lsmod

lsmod

System administration command. List all loaded modules: name, size (in 4 KB units), and, if appropriate, a list of referring modules. The same information is available in /proc/modules if the /proc directory is enabled on the system.

 

 

mdir

mdir [options] dir

List directory contents on an MS-DOS filesystem. See ls, dir, and mtools for more information.

Options

-/

Display output recursively, listing the contents of subdirectories.

-a

Include hidden files in the output.

-b

Produce a concise listing, showing each directory or file on a separate line, with no heading or summary information.

-f

Operate in fast mode, without determining the amount of free space. Not required on FAT32 filesystems, which store the free-space information explicitly.

-w

Produce wide output, printing filenames across the page with no file-size or creation-date information.

-V

Print version information and exit.

 

 

 

mkdir

mkdir [options] directories

Create one or more directories. You must have write permission in the parent directory in order to create a directory. See also rmdir. The default mode of the new directory is 0777, modified by the system or user's umask.

Options

-m mode, --mode mode

Set the access mode for new directories. See chmod for an explanation of acceptable formats for mode.

-p, --parents

Create intervening parent directories if they don't exist.

-v, --verbose

Print a message for each directory created.

--help

Print help message and then exit.

--version

Print version number and then exit.

-Z context, --context=context

Set security context in SELinux.

Examples

Create a read-only directory named personal:

mkdir -m 444 personal

The following sequence:

mkdir work; cd work mkdir junk; cd junk mkdir questions; cd ../..

can be accomplished by typing this:

mkdir -p work/junk/questions

 

 

 

modprobe

modprobe [options] [modules] [moduleoptions]

System administration command. With no options, attempt to load the specified module, as well as all modules on which it depends. If more than one module is specified, attempt to load further modules only if the previous module failed to load. When specifying a module, use only its name without its path or trailing .o. modprobe will pass to the kernel any options following the module name.

Options

-a, --all

Load all modules matching the given wildcard.

-c, --showconfig

Print modprobe's current configuration.

-f, --force

Ignore all versioning information during module insertion. Even if the module does not match the running kernel, modprobe will try to insert it anyway.

--force-modversion

Ignore module versioning mismatches.

--force-vermagic

Ignore kernel versioning mismatches.

--first-time

Return failure if told to insert a module that is already present or remove a module that is not loaded. Normally, modprobe will return success if asked to perform an unnecessary action.

-i, --ignore-install,--ignore-remove

Ignore any install and remove directives in the configuration file.

-l, --list

List modules matching the given wildcard (or "*" if no wildcard is given).

-n, --dry-run

Perform all of the actions except actually inserting or removing the module.

-q,--quiet

Suppress warnings during failure to load a module and continue processing other modules.

-r, --remove

Remove the specified modules, as well as the modules on which they depend.

-s, --syslog

Send error messages to syslogd instead of to standard error.

-ttype, --type type

Load only a specific type of module.

-v, --verbose

Print commands as they are executed.

-C file, --config file

Read additional configuration from file instead of /etc/modules.conf.

-V, --version

Print version, then exit.

 

 

 

sleep

sleep amount[units] sleep option

Wait a specified amount of time before executing another command. units may be s (seconds), m (minutes), h (hours), or d (days). The default for units is seconds.

Options

--help

Print usage information and exit.

--version

Print version information and exit.

 

 

 

rmmod

rmmod [options] modules

System administration command. Unload a module or list of modules from the kernel. This command is successful only if the specified modules are not in use and no other modules are dependent on them. This simplified program provides some backward compatibility. In general, use modprobe -r instead.

Options

-s, --syslog

Write messages to syslogd instead of to the terminal.

-v, --verbose

Verbose mode.

-V, --version

Print version number, then exit.

-w, --wait

If module is in use, disable it so no new processes can use it. Remove the module when it is no longer in use.

 

 

 

rmdir

rmdir [options] directories

Delete the named directories (not the contents). directories are deleted from the parent directory and must be empty (if not, rm -r can be used instead). See also mkdir.

Options

--help

Print a help message and then exit.

--ignore-fail-on-non-empty

Ignore failure to remove directories that are not empty.

-p, --parents

Remove directories and any intervening parent directories that become empty as a result. Useful for removing subdirectory trees.

--verbose

Verbose mode; print message for each directory as it is processed.

--version

Print version information and then exit.

 

 

pwd

pwd

Print the full pathname of the current working directory. See also the dirs shell command built into bash.

 

 

ps

ps [options]

Report on active processes. ps has three types of options. GNU long options start with two hyphens, which are required. BSD options may be grouped and do not start with a hyphen, while Unix98 options may be grouped and require an initial hyphen. The meaning of the short options can vary depending on whether or not there is a hyphen. In options, list arguments should either be comma-separated or space-separated and placed inside double quotes. In comparing the amount of output produced, note that e prints more than a and l prints more than f for each entry.

Options

nums, p nums, -p nums, --pid=nums

Include only specified processes, which are given in a space-delimited list.

-nums, -s nums, --sid=nums

Include only specified session IDs, which are given in a space-delimited list.

[-] a

As a, list all processes on a terminal. As -a, list all processes except session leaders and processes not associated with a terminal.

[-] c

As -c, show different scheduler information with -l. As c, show the true command name.

-C cmds

Select by command name.

--cols=cols, --columns=cols

Set the output width (the number of columns to display).

-d

Select all processes except session leaders.

-e, -A

Select all processes.

 

 

 

 

ping

ping [options] host

System administration command. Confirm that a remote host is online and responding. ping is intended for use in network testing, measurement, and management. Because of the load it can impose on the network, it is unwise to use ping during normal operations or from automated scripts.

Options

-a

Make ping audible. Beep each time response is received.

-A

Adapt to return interval of packets. Like -f ping, sends packets at approximately the rate at which they are received. This option may be used by an unprivileged user.

-b

Ping a broadcast address.

-B

Bind to original source address and do not change.

-c count

Stop after sending (and receiving) count ECHO_RESPONSE packets.

-f

Flood ping-output packets as fast as they come back or 100 times per second, whichever is greater. This can be very hard on a network and should be used with caution. Only a privileged user may use this option.

-i wait

Wait wait seconds between sending each packet. Default is to wait one second between each packet. This option is incompatible with the -f option.

-I name

Set source address to interface name. name may also be specified as an IP address.

-l preload

Send preload number of packets as fast as possible before falling into normal mode of behavior.

-L

If destination is a multicast address, suppress loopback.

-M hint

Specify Path MTU Discovery strategy. Accepted values are do, want, or dont.

-n

Numeric output only. No attempt will be made to look up symbolic names for host addresses.

-p digits

Specify up to 16 pad bytes to fill out packet sent. This is useful for diagnosing data-dependent problems in a network. digits are in hex. For example, -p ff will cause the sent packet to be filled with all 1s.

-q

Quiet output—nothing is displayed except the summary lines at startup time and when finished.

-Q tos

Set Quality of Service on ICMP datagrams.

-r

Bypass the normal routing tables and send directly to a host on an attached network.

-R

Set the IP record route option, which will store the route of the packet inside the IP header. The contents of the record route will be printed if the -v option is given, and will be set on return packets if the target host preserves the record route option across echoes or if the -l option is given.

-s packetsize

Specify number of data bytes to be sent. Default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

-S size

Set send buffer (SNDBUF) size. The default is the size of one packet.

-t n

Set the IP Time to Live to n seconds.

-T option

Set IP timestamp options. Accepted option values are:

tsonly

Timestamps only.

tsandaddr

Timestamps and addresses.

tsprespec hosts

Timestamps with prespecified hops of one or more hosts.

-U

Use older ping behavior and print full user-to-user latency instead of network round-trip time.

-v

Verbose; list ICMP packets received other than ECHO_RESPONSE.

-V

Print version, then exit.

-w n

Exit ping after n seconds.

-W n

When waiting for a response, time out after n seconds.

 

 

su

then enter password for admin privileges;

 

 

tar

tar [options] [tarfile] [other-files]

Copy files to or restore files from an archive medium. If any files are directories, tar acts on the entire subtree. Options need not be preceded by - (though they may be). The exception to this rule is when you are using a long-style option (such as --modification-time). In that case, the exact syntax is:

tar--long-option -function-options files

For example:

tar --modification-time -xvf tarfile.tar

Function options

You must use exactly one of these, and it must come before any other options:

-c, --create

Create a new archive.

-d, --diff, --compare

Compare the files stored in tarfile with other-files. Report any differences: missing files, different sizes, different file attributes (such as permissions or modification time).

--delete

Delete from the archive. This option cannot be used with magnetic tape.

-r, --append

Append other-files to the end of an existing archive.

-t, --list

Print the names of other-files if they are stored on the archive (if other-files are not specified, print names of all files).

-u, --update

Add files if not in the archive or if modified.

-x, --extract, --get

Extract other-files from an archive (if other-files are not specified, extract all files).

-A, --catenate, --concatenate

Concatenate a second tar file to the end of the first.

Options

[drive] [density]

Set drive (0-7) and storage density (l, m, or h, corresponding to low, medium, or high). Not available in all versions of tar.

--anchored

Exclude patterns must match the start of the filename (the default).

--atime-preserve

Preserve original access time on extracted files.

-b n, --blocking-factor=n

Set block size to n × 512 bytes.

--backup[=type]

Back up files rather than deleting them. If no backup type is specified, a simple backup is made with ~ as the suffix. (See also --suffix.) The possible values of type are:

t, numbered

Make numbered backups.

nil, existing

Make numbered backups if there are already numbered backups; otherwise make simple backups.

never, simple

Always make simple backups.

--checkpoint

List directory names encountered.

--exclude=pattern

Remove files matching pattern from any list of files.

-f file, --file=file

Store files in or extract files from archive file. Note that file may take the form hostname:filename.

--force-local

Interpret filenames in the form hostname:filename as local files.

-g file, --listed-incremental=file

Create new-style incremental backup.

--group=group

Use group as the group for files added to the archive.

-h, --dereference

Dereference symbolic links, and archive the files they point to rather than the symbolic link.

--help

Print help message and exit.

-i, --ignore-zeros

Ignore zero-sized blocks (i.e., EOFs).

--ignore-case

Ignore case when excluding files.

--ignore-failed-read

Ignore unreadable files to be archived. Default behavior is to exit when encountering these.

-j, --I, --bzip

Compress files with bzip2 before archiving them, or uncompress them with bunzip2 before extracting them.

-l, --one-file-system

Do not archive files from other filesystems.

-k, --keep-old-files

When extracting files, do not overwrite files with similar names. Instead, print an error message.

-m, --modification-time, --touch

Do not restore file modification times; update them to the time of extraction.

--mode=permissions

Use permissions when adding files to an archive. The permissions are specified the same way as for the chmod command.

--newer-mtime=date

Add only files whose contents have changed since date to the archive.

--no-anchor

Exclude patterns may match anything following a slash.

--no-ignore-case

Do not ignore case when excluding files.

--no-same-permissions

Do not extract permissions information when extracting files from the archive. This is the default for users, and therefore affects only the superuser.

--no-recursion

Do not move recursively through directories.

--no-same-owner

When extracting, create files with yourself as owner.

--no-wildcards

Don't use wildcards when excluding files; treat patterns as strings.

--no-wildcards-match-slash

Wildcards do not match / when excluding files.

--null

Allow filenames to be null-terminated with -T. Override -C.

--numeric-owner

Use the numeric owner and group IDs rather than the names.

-o, --old-archive, --portability

Create old-style archive in Unix V7 rather than ANSI format.

--overwrite

Overwrite existing files and directory metadata when extracting from archive.

--overwrite-dir

Overwrite existing directory metadata when extracting from archive.

--owner=owner

Set owner as the owner of extracted files instead of the original owner. owner is first assumed to be a username, then, if there is no match, a numeric user ID.

-p, --same-permissions, --preserve-permissions

Keep permissions of extracted files the same as the originals.

--posix

Create a POSIX-compliant archive.

--preserve

Equivalent to invoking both the -p and -s options.

--record-size=size

Treat each record as having size bytes, where size is a multiple of 512.

--recursion

Move recursively through directories.

--recursive-unlink

Remove existing directory hierarchies before extracting directories with the same name.

--remove-files

Remove originals after inclusion in archive.

--rsh-command=command

Do not connect to remote host with rsh; instead, use command.

-s, --same-order, --preserve-order

When extracting, sort filenames to correspond to the order in the archive.

--same-owner

When extracting, create files with the same ownership as the originals.

--show-omitted-dirs

List directories being omitted when operating on an archive.

--suffix=suffix

Use suffix instead of the default ~ when creating a backup file.

--totals

Print byte totals.

--use-compress-program=program

Compress archived files with program, or uncompress extracted files with program.

-v, --verbose

Verbose. Print filenames as they are added or extracted.

--version

Print version information and exit.

--volno-file=file

Use/update the volume number in file.

-w, --interactive, --confirmation

Wait for user confirmation (y) before taking any actions.

--wildcards

Use wildcards when excluding files.

--wildcards-match-slash

Wildcards match / when excluding files.

-z, --gzip, --gunzip, --ungzip

Compress files with gzip before archiving them, or uncompress them with gunzip before extracting them.

-B, --read-full-records

Reblock while reading; used for reading from 4.2BSD pipes.

-C directory, --directory=directory

cd to directory before beginning tar operation.

-F script, --info-script=script, --new-volume-script=script

Implies -M (multiple archive files). Run script at the end of each file.

-G, --incremental

Create old-style incremental backup.

-K file, --starting-file=file

Begin tar operation at file in archive.

-L length, --tape-length=length

Write a maximum of length × 1024 bytes to each tape.

-M, --multivolume

Expect archive to be multivolume. With -c, create such an archive.

-N date, --newer=date, --after-date=date

Ignore files older than date.

-O, --to-stdout

Print extracted files to standard output.

-P, --absolute-names

Do not remove initial slashes (/) from input filenames.

-R, --block-number

Display archive's block number in messages.

-S, --sparse

Treat sparse files more efficiently when adding to archive.

-T file, --files-from=file

Consult file for files to extract or create.

-U, --unlink-first

Remove each existing file from the filesystem before extracting from the archive.

-V name, --label=name

Name this volume name.

-W, --verify

Check archive for corruption after creation.

-X file, --exclude-from file

Consult file for list of files to exclude.

-Z, --compress, --uncompress

Compress files with compress before archiving them, or uncompress them with uncompress before extracting them.

Examples

Create an archive of /bin and /usr/bin (c), show the command working (v), and store on the tape in /dev/rmt0:

tar cvf /dev/rmt0 /bin /usr/bin

List the tape's contents in a format like ls -l:

tar tvf /dev/rmt0

Extract the /bin directory:

tar xvf /dev/rmt0 /bin

Create an archive of the current directory and store it in a file backup.tar:

tar cvf - `find . -print` > backup.tar

(The - tells tar to store the archive on standard output, which is then redirected.)

Filter an archive through gzip, extracting the contents but leaving the original file compressed:

tar xvfz chapters.tar.gz

 

 

 

 

useradd

useradd [options] [user]

System administration command. Create new user accounts or update default account information. Unless invoked with the -D option, user must be given. useradd will create new entries in system files. Home directories and initial files may also be created as needed.

Options

-c comment

Comment field.

-d dir

Home directory. The default is to use user as the directory name under the home directory specified with the -D option.

-e date

Account expiration date. Use the format MM/DD/YYYY. Two-digit year fields are also accepted. The value is stored as the number of days since January 1, 1970. This option requires the use of shadow passwords.

-f days

Permanently disable account this many days after the password has expired. A value of -1 disables this feature. This option requires the use of shadow passwords.

-g group

Initial group name or ID number. If a different default group has not been specified using the -D option, the default group is 1.

-G groups

Supplementary groups given by name or number in a comma-separated list with no whitespace.

-k [dir]

Copy default files to the user's home directory. Meaningful only when used with the -m option. Default files are copied from /etc/skel/ unless an alternate dir is specified.

-m

Make user's home directory if it does not exist. The default is not to make the home directory.

-M

Do not create a home directory for the user, even if the system default in /etc/login.defs is to create one.

-n

Red Hat-specific option. Turn off the Red Hat default that creates a group with the same name as the username and puts the user in that group.

-o

Override. Accept a nonunique uid with the -u option. (Probably a bad idea.)

-p passwd

The encrypted password, as returned by crypt(3).

-r

Red Hat-specific option. Create a system account with a non-expiring password and a UID lower than the minimum defined in /etc/login.defs. Do not create a home directory for the account unless -m is also specified.

-s shell

Login shell.

-u uid

Numerical user ID. The value must be unique unless the -o option is used. The default value is the smallest ID value greater than 99 and greater than every other uid.

-D [options]

Set or display defaults. If options are specified, set them. If no options are specified, display current defaults. The options are:

-b dir

Home directory prefix to be used in creating home directories. If the -d option is not used when creating an account, the user name will be appended to dir.

-e date

Expire date. Requires the use of shadow passwords.

-f days

Number of days after a password expires to disable an account. Requires the use of shadow passwords.

-g group

Initial group name or ID number.

-s shell

Default login shell.

 

 

 

userdel

userdel [option] user

System administration command. Delete all entries for user in system account files.

Option

-r

Remove the home directory of user and any files contained in it.