Sie sind auf Seite 1von 294

PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information.

PDF generated at: Thu, 03 Apr 2014 05:36:13 UTC


Unix commands
Contents
Articles
File system
1
cat 1
cd 5
Chmod 7
Chown 12
Chgrp 13
Cksum 14
cmp 15
cp 16
dd 19
du 24
df 26
file 29
Fsck 32
fuser 34
ln 35
Ls 36
Lsattr 39
Lsof 40
Mkdir 42
mount 43
Mv 45
pax 47
Pwd 50
rm 51
Rmdir 54
size 56
split 57
tee 58
touch 61
type 64
Umask 65
Processes
72
at 72
bg 73
Chroot 73
Cron 76
fg 82
kill 82
Killall 85
nice 86
Pgrep 87
Pidof 88
Pkill 89
ps 90
Pstree 92
time 92
top 94
User environment
96
clear 96
Env 96
exit 97
finger 98
history 101
id 102
Logname 103
Mesg 103
passwd 104
su 107
Sudo 109
uptime 111
talk 115
Tput 117
Uname 119
w 123
wall 124
who 125
Whoami 126
write 127
Text processing
128
awk 128
banner 138
Basename 140
Comm 141
Csplit 143
cut 144
Dirname 146
ed 147
ex 150
fmt 151
head 152
Iconv 153
join 154
less 155
more 158
paste 160
Sed 163
sort 169
spell 172
strings 173
tail 174
tr 176
Uniq 177
Vi 178
wc 185
Xargs 186
s
189
alias 189
echo 193
Expr 195
Printf 196
sleep 203
test 205
true and false 207
Unset 209
wait 209
yes 210
212
dig 212
Inetd 214
host 217
Ifconfig 217
Netstat 220
Nslookup 223
Ping 224
Rdate 225
Rlogin 225
Netcat 229
ssh 234
Traceroute 238
Searching
241
Find 241
Grep 247
locate 250
Whatis 251
Whereis 251
which 252
Documentation
253
apropos 253
help 254
info 256
man 257
Miscellaneous
261
bc 261
dc 267
cal 271
date 273
lp 279
Lpr 279
References
Article Sources and Contributors 280
Image Sources, Licenses and Contributors 287
Article Licenses
License 288
1
File system
cat
The cat program is a standard Unix utility that concatenates and lists files. The name is an abbreviation of catenate,
a synonym of concatenate.
Usage
The Single Unix Specification specifies that when the "cat" program is given files in a sequence as arguments, it will
output their contents to the standard output in the same sequence. It mandates the support of one option flag, u
(unbuffered), by which each byte is written to standard output without buffering as it is read. Many operating
systems do this by default and ignore the flag.
If one of the input filenames is specified as a single hyphen (-), then cat reads from standard input at that point in the
sequence. If no files are specified, cat reads from standard input only.
The cat command-syntax is:
cat [options] [file_names]
cat will concatenate (put together) the input files in the order given, and if no other commands are given, will print
them on the screen as standard output. It can also be used to print the files into a new file as follows:
cat [options] [file_names] > newfile.txt
You can also use a pipe to send the data to a different program. For example to view two files in sequence line by
line using the less command, you would use the following command:
cat file1 file2 | less
Options
Both the BSD versions of cat (as per the OpenBSD manpage) and the GNU coreutils version of cat specify the
following options:
b (GNU only: --number-nonblank), number non-blank output lines
n (GNU only: --number), number all output lines
z (GNU only: --squeeze-blank), squeeze multiple adjacent blank lines
v (GNU only: --show-nonprinting), displays nonprinting characters as if they were visible, except for tabs and the end of line character
t on BSD, -T on GNU, implies -v but also display tabs as ^I
e on BSD, -E on GNU, implies -v but also display end-of-line characters as $
A show all characters, also tabs and end-of-line characters as ^I and $
cat
2
Use cases
cat can be used to pipe a file to a program which only expect data on its input stream.
As cat simply catenates streams of bytes, it can be also used to concatenate binary files, where it will just
concatenate sequence of bytes.
As such, the two main use cases are text files and other cases.
Text use
As a simple example, to concatenate 2 text files and write them to a new file, you can use the following command:
cat file1.txt file2.txt > newcombinedfile.txt
With option -n, cat can also number lines as follows:
cat -n file1.txt file2.txt > newnumberedfile.txt
Concatenation of text is limited to text files using a same legacy encoding such as ASCII, and BOM might be not
supported. However, cat does not provide a way to concatenate unicode text files which have a Byte Order Mark. In
the same way, files using different text encodings cannot be concatenated properly with only cat.
Other files
For many structured binary data sets, the result may not be parsed properly however, for example, if a file has a
unique header or footer, and this use of cat is not especially useful in many cases. For some multimedia container
formats the resulting file is valid and this provides an effective means of appending files, particularly video streams.
Significantly, the MPEG program stream (MPEG-1 and MPEG-2) and DV (Digital Video) formats can be
concatenated such a stream is fundamentally a stream of packets.
Further, any other video format can be concatenated by transcoding to one of these privileged formats, concatenating
via cat, and then transcoding back.
Unix culture
Jargon File definition
The Jargon File version 4.4.7 lists this as the definition of cat:
1. 1. To spew an entire file to the screen or some other output sink without pause (syn. blast).
2. By extension, to dump large amounts of data at an unprepared target or with no intention of browsing it carefully. Usage:
considered silly. Rare outside Unix sites. See also dd, BLT.
Among Unix fans, cat(1) is considered an excellent example of user-interface design, because it delivers the file contents
without such verbosity as spacing or headers between the files, and because it does not require the files to consist of lines of text,
but works with any sort of data.
Among Unix critics, cat(1) is considered the canonical example of bad user-interface design, because of its woefully
unobvious name. It is far more often used to blast a single file to standard output than to concatenate two or more files. The name
cat for the former operation is just as unintuitive as, say, LISP's cdr.
cat
3
Useless use of cat
UUOC (from comp.unix.shell on Usenet) stands for "useless use of cat". comp.unix.shell observes: "The purpose of
cat is to concatenate (or catenate) files. If it is only one file, concatenating it with nothing at all is a waste of time,
and costs you a process." This is also referred to as "cat abuse". Nevertheless the following usage is common:
cat filename | command arg1 arg2 argn
This can be rewritten using redirection of stdin instead, in either of the following forms (the latter is more
traditional):
<filename command arg1 arg2 argn
command arg1 arg2 argn < filename
Beyond other benefits, the input redirection forms allow command to seek in the file, whereas the cat examples do
not: cat will prevent the command from seeking in the file.
Another common case where cat is unnecessary is where a command defaults to operating on stdin, but will read
from a file, if the filename is given as an argument. This is the case for many common commands; the following
examples:
cat $file | grep $pattern
cat $file | less
can instead be written as:
grep $pattern $file
less $file
A common interactive use of cat for a single file is to output the content of a file to standard output. However, if
the output is piped or redirected, cat is unnecessary.
Without two named files, the use of cat has no significant benefits. A UUOC campaign will eliminate the
inefficiency from shell scripts by using redirection instead.
A similar but less significant issue is the use of echo to start a pipeline, as this can often be replaced by redirection
from a string (a here string), as in:
echo -e 'user\npass' | ftp localhost
ftp localhost <<< $'user\npass'
This is less significant as echo is often internally implemented in the shell, and in any case is lighter-weight than cat.
Benefits of using cat
The primarily benefits of using cat, even when unnecessary, are to avoid human error and for legibility. cat with
one named file is safer where human error is a concern one wrong use of the default redirection symbol ">"
instead of "<" (often adjacent on keyboards) may permanently delete
[1]
the file you were just needing to read.
[2]
In
terms of legibility, a sequence of commands starting with cat and connected by pipes has a clear left-to-right flow
of information, in contrast with the back-and-forth syntax and backwards-pointing arrows of using stdin redirection.
Contrast:
command < in | command2 > out
<in command | command2 > out
with:
cat
4
cat in | command | command2 > out
Culture
Since 1995, occasional awards for UUOC have been given out, usually by Perl programmer Randal L. Schwartz.
There is a web page devoted to this and other similar awards.
[3]
In British hackerdom the activity of fixing instances
of UUOC is sometimes called demoggification.
[4]
Other operating systems
The equivalent command in the VMS, CP/M, DOS, OS/2, and Microsoft Windows operating system command
shells is type.
In DOS/Windows multiple files may be combined with the "copy /b" command syntax, for example:
copy /b file1.txt + file2.txt file3.txt
This copies file1.txt and file2.txt in binary mode to one file, file3.txt.
References
[1] More accurately stated ">" will truncate the file.
[2] The default behavior for redirection is to clobber the file to its immediate right.
[3] Useless Use of Cat Award (http:/ / partmaps.org/ era/ unix/ award. html)
[4] moggy is a chiefly British word for "(mongrel) cat", hence demoggification literally means "removal of (non-special) cats".
External links
cat (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ cat. html):concatenate and print
filesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
UNIX Style, or cat -v Considered Harmful (http:/ / harmful. cat-v. org/ cat-v/ ) - A paper by Rob Pike on proper
Unix command design using cat as an example.
Manual pages
cat(1) original manual page (http:/ / man. cat-v. org/ unix-1st/ 1/ cat) in the First Edition of Unix.
cat(1) (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ cat-invocation. html):concatenate and
write filesGNU Coreutils reference
cat(1) (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=cat& section=1):concatenate and print
filesOpenBSD General Commands Manual
cat(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=cat& sektion=1)FreeBSD General Commands
Manual
cat(1) (http:/ / man. cat-v. org/ plan_9/ 1/ cat):catenate filesPlan 9 from Bell Labs manual
Other
Useless Use Of Cat Award (http:/ / www. iki. fi/ era/ unix/ award. html)
cd
5
cd
The cd command, also known as chdir (change directory), is a command-line OS shell command used to
change the current working directory in operating systems such as Unix, DOS, OS/2, AmigaOS (where if a bare path
is given, cd is implied), Windows, and Linux. It is also available for use in shell scripts and batch files. The system
call that effects the command in most operating systems is chdir(2) that is defined by POSIX.
Usage
A directory is a logical section of a file system used to hold files. Directories may also contain other directories. The
cd command can be used to change into a subdirectory, move back into the parent directory, move all the way back
to the root directory or move to any given directory.
Consider the following subsection of a Unix filesystem, which shows a user's home directory (represented as ~)
with a file (text.txt) and three subdirectories.
A user's view of the file system in Unix-like
systems begins with the home directory (often
abbreviated to ~). From there, the tree can spread
into more subdirectories and/or files.
If the user's current working directory is the home directory (~), then entering the command ls followed by cd
games might produce the following transcript:
user@wikipedia:~$ ls
workreports games encyclopedia text.txt
user@wikipedia:~$ cd games
user@wikipedia:~/games$
The user is now in the games directory.
A similar session in DOS (though the concept of a home directory may not apply, depending on the specific
versionWikipedia:Vagueness) would look like this:
C:\> dir
workreports <DIR> Wed Oct 9th 9:01
games <DIR> Tue Oct 8th 14:32
encyclopedia <DIR> Mon Oct 1st 10:05
text txt 1903 Thu Oct10th 12:43
C:\> cd games
C:\games>
DOS maintains separate working directories for each lettered drive, and also has the concept of a current working
drive. The cd command can be used to change the working directory of the working drive or another lettered drive.
Typing the drive letter as a command on its own changes the working drive, e.g. C:; alternatively, cd with the /d
switch may be used to change the working drive and that drive's working directory in one step. Modern versions of
Windows simulate this behaviour for backwards compatibility under cmd.exe.
[1]
cd
6
Note that executing cd from the command line with no arguments has different effects in different operating
systems. For example, if cd is executed without arguments in DOS, OS/2, or Windows, the current working
directory is displayed. If cd is executed without arguments in Unix, the user is returned to the home directory.
Executing the cd command within a script or batch file also has different effects in different operating systems. In
DOS, the caller's current directory can be directly altered by the batch file's use of this command. In Unix, the
caller's current directory is not altered by the script's invocation of the cd command. This is because in Unix, the
script is usually executed within a subshell.
Options (version specific)
no attributes Return to the home directory (UNIX) or print the full path of the current directory (DOS and
Windows)
-p Print the final directory stack, just like dirs.Wikipedia:WikiProject Countering systemic bias
-l Wikipedia:WikiProject Countering systemic bias '~' (UNIX only) or '~name' (UNIX only) in the output
is expanded explicitly to home or the pathname of the home directory for user name.
-n Entries are wrapped before they reach the edge of the screen. Wikipedia:WikiProject Countering systemic bias
-v entries are printed one per line, preceded by their stack positions. Wikipedia:WikiProject Countering systemic
bias
cd\ (DOS and Windows only) returns to the root dir. Consequently, command cd\subdir always takes the
user to the named subdirectory on the root directory, regardless of where they are located when the command is
issued.
Application of some options (UNIX)
[2]
"cd" by itself or cd ~ will always put you in your home directory.
"cd ." will leave you in the same directory you are currently in (i.e. your current directory won't change)
"cd ~username" will put you in username's home directory.
"cd dir" (without a /) will put you in a subdirectory. for example, if you are in /usr, typing cd bin will put you in
/usr/bin, while cd /bin puts you in /bin.
"cd .." will move you up one directory. So, if you are /usr/bin/tmp, cd .. moves you to /usr/bin, while cd ../.. moves
you to /usr (i.e. up two levels). You can use this indirection to access subdirectories too. So, from /usr/bin/tmp, you
can use cd ../../local to go to /usr/local.
"cd -" will switch you to the previous directory (UNIX only). For example, if you are in /usr/bin/tmp, and go to /etc.,
you can type cd - to go back to /usr/bin/tmp. You can use this to toggle back and forth between two directories.
How it works
cd is frequently included built directly into a command-line interpreter. This is the case in most of the Unix shells
(Bourne shell, tcsh, bash, etc.), cmd.exe and Windows PowerShell on Windows and COMMAND.COM on DOS.
Command line shells on Windows usually use the Windows API to change the current working directory, whereas
on Unix systems cd calls the chdir() POSIX C function. This means that when the command is executed, no
new process is created to migrate to the other directory as is the case with other commands such as ls. Instead, the
shell itself executes this command. This is because, when a new process is created, child process inherits the
directory in which the parent process was created. If the cd command inherits the parent process' directory, then the
objective of the command cd will never be achieved.
Windows PowerShell, Microsoft's object-oriented command line shell and scripting language, executes the cd
command (cmdlet) within the shell's process. However, since PowerShell is based on the .NET Framework and has a
different architecture than previous shells, all of PowerShell's cmdlets like ls, rm etc. run in the shell's process. Of
cd
7
course, this is not true for legacy commands which still run in a separate process.
Interpreters other than an operating systems shell
In the File Transfer Protocol, the respective command is spelled CWD in the control stream, but is available as cd in
most client command-line programs. Some clients also have the lcd for changing the working directory locally.
The command also pertains to command-line interpreters of various application software.
References
[1] Why does each drive have its own current directory? (http:/ / blogs. msdn. com/ b/ oldnewthing/ archive/ 2010/ 10/ 11/ 10073890. aspx)
[2] Unix Change Directory Commands (http:/ / unix-simple. blogspot. com/ 2006/ 12/ unix-change-directory-commands. html)
External links
Windows XP > Command-line reference A-Z > Chdir (Cd) (http:/ / technet. microsoft. com/ en-us/ library/
bb490875. aspx) from Microsoft TechNet
cd (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ cd. html):change the working
directoryCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Chmod
In Unix-like operating systems, chmod is the name of a Unix shell command and a system call, which both change
the access permissions to file system objects (including files and directories), as well as specifying special flags.
[1]
The name is an abbreviation of change mode.
History
A chmod command first appeared in AT&T Unix version 1.
Command syntax
chmod [options] mode[,mode] file1 [file2 ...]
[2]
Usual implemented options include:
-R recursive, i.e. include objects in subdirectories
-f force, forge ahead with all objects even if errors occur
-v verbose, show objects processed
If a symbolic link is specified, the target object is affected. File modes directly associated with symbolic links
themselves are typically never used.
To view the file mode, the ls or stat commands may be used:
$ ls -l findPhoneNumbers.sh
-rwxr-xr-- 1 dgerman staff 823 Dec 16 15:03 findPhoneNumbers.sh
$ stat -c %a findPhoneNumbers.sh
754
Chmod
8
The r, w, and x specify the read, write, and execute access, respectively. This script can be read, written to, and
executed by the user, read and executed by other members of the staff group and can also be read by others.
Octal modes
The chmod numeric format accepts up to four octal digits. The rightmost three refer to permissions for the file
owner, the group, and other users. The next digit (fourth from the right) specifies special setuid, setgid, and
sticky flags.
Numerical permissions
# Permission rwx
7 full 111
6 read and write 110
5 read and execute 101
4 read only 100
3 write and execute 011
2 write only 010
1 execute only 001
0 none 000
Numeric example
In order to permit all users who are members of the programmers group to update a file
$ ls -l sharedFile
-rw-r--r-- 1 jsmith programmers 57 Jul 3 10:13 sharedFile
$ chmod 664 sharedFile
$ ls -l sharedFile
-rw-rw-r-- 1 jsmith programmers 57 Jul 3 10:13 sharedFile
Since the setuid, setgid and sticky bits are not specified, this is equivalent to:
$ chmod 0664 sharedFile
Symbolic modes
The chmod command also accepts a finer-grained symbolic notation, which allows modifying specific modes while
leaving other modes untouched. The symbolic mode is composed of three components, which are combined to form
a single string of text:
$ chmod [references][operator][modes] file ...
The references (or classes) are used to distinguish the users to whom the permissions apply. If no references are
specified it defaults to all but modifies only the permissions allowed by the umask. The references are represented
by one or more of the following letters:
Chmod
9
Reference Class Description
u user the owner of the file
g group users who are members of the file's group
o others users who are neither the owner of the file nor members of the file's group
a all all three of the above, same as ugo
The chmod program uses an operator to specify how the modes of a file should be adjusted. The following
operators are accepted:
Operator Description
+ adds the specified modes to the specified classes
- removes the specified modes from the specified classes
= the modes specified are to be made the exact modes for the specified classes
The modes indicate which permissions are to be granted or removed from the specified classes. There are three basic
modes which correspond to the basic permissions:
Mode Name Description
r read read a file or list a directory's contents
w write write to a file or directory
x execute execute a file or recurse a directory tree
X special
execute
which is not a permission in itself but rather can be used instead of x. It applies execute permissions to directories regardless of
their current permissions and applies execute permissions to a file which already has at least one execute permission bit already
set (either user, group or other). It is only really useful when used with '+' and usually in combination with the -R option
for giving group or other access to a big directory tree without setting execute permission on normal files (such as text files),
which would normally happen if you just used "chmod -R a+rx .", whereas with 'X' you can do "chmod -R a+rX
." instead
s setuid/gid details in Special modes section
t sticky details in Special modes section
Multiple changes can be specified by separating multiple symbolic modes with commas (without spaces).
Symbolic examples
Add write permission (w) to the group's(g) access modes of a directory,
allowing users in the same group to add files:
$ ls -ld shared_dir # show access modes before chmod
drwxr-xr-x 2 teamleader usguys 96 Apr 8 12:53 shared_dir
$ chmod g+w shared_dir
$ ls -ld shared_dir # show access modes after chmod
drwxrwxr-x 2 teamleader usguys 96 Apr 8 12:53 shared_dir
Remove write permissions (w) for all classes (a),
preventing anyone from writing to the file:
$ ls -l ourBestReferenceFile
-rw-rw-r-- 2 teamleader usguys 96 Apr 8 12:53 ourBestReferenceFile
$ chmod a-w ourBestReferenceFile
Chmod
10
$ ls -l ourBestReferenceFile
-r--r--r-- 2 teamleader usguys 96 Apr 8 12:53 ourBestReferenceFile
Set the permissions for the user and the group (ug) to read and execute (rx) only (no write permission) on
referenceLib,
preventing anyone other than the owner to add files.
$ ls -ld referenceLib
drwxr----- 2 teamleader usguys 96 Apr 8 12:53 referenceLib
$ chmod ug=rx referenceLib
$ ls -ld referenceLib
dr-xr-x--- 2 teamleader usguys 96 Apr 8 12:53 referenceLib
Special modes
The chmod command is also capable of changing the additional permissions or special modes of a file or directory.
The symbolic modes use s to represent the setuid and setgid modes, and t to represent the sticky mode. The modes
are only applied to the appropriate classes, regardless of whether or not other classes are specified.
Most operating systems support the specification of special modes using octal modes, but some do not. On these
systems, only the symbolic modes can be used.
Command line examples
command explanation
chmod a+r file read is added for all
chmod a-x file execute permission is removed for all
chmod a+rw file change the permissions of the file file to read and write for all.
chmod +rwx file On some UNIX platforms such as BSD, this will restore the permission of the file file to default:
-rwxr-xr-x.
chmod u=rw,go= file read and write is set for the owner, all permissions are cleared for the group and others
chmod -R u+w,go-w docs change the permissions of the directory docs and all its contents to add write access for the user, and
deny write access for everybody else.
chmod = file removes all privileges for all.
chmod 777 file change the permissions of the file file to read, write, and execute for all.
chmod 664 file sets read and write and no execution access for the owner and group, and read, no write, no execute
for all others.
chmod 0755 file equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies no special modes.
chmod 1755 file the 1 specifies [stickybit set] and the rest is equivalent to u=rwx (4+2+1),go=rx (4+1 &
4+1).
chmod 4755 file the 4 specifies set user ID and the rest is equivalent to u=rwx (4+2+1),go=rx (4+1 &
4+1).
chmod 2755 file the 2 specifies set group ID and the rest is equivalent to u=rwx (4+2+1),go=rx (4+1 &
4+1).
chmod -R u+rwX,g-rwx,o-rwx
directory
set a directory tree to rwx for owner directories, rw for owner files, --- for group and others.
chmod -R a-x+X directory remove the execute permission on all files in a directory tree, while allowing for directory browsing.
Chmod
11
System call
The POSIX standard defines the following function prototype:
int chmod(const char *path, mode_t mode);
The mode parameter is a bitfield composed of various flags:
Flag Octal value Purpose
S_ISUID 04000 Set user ID on execution
S_ISGID 02000 Set group ID on execution
S_ISVTX 01000 Sticky bit
S_IRUSR, S_IREAD 00400 Read by owner
S_IWUSR, S_IWRITE 00200 Write by owner
S_IXUSR, S_IEXEC 00100 Execute/search by owner
S_IRGRP 00040 Read by group
S_IWGRP 00020 Write by group
S_IXGRP 00010 Execute/search by group
S_IROTH 00004 Read by others
S_IWOTH 00002 Write by others
S_IXOTH 00001 Execute/search by others
Where alternate flag names are given, one of the pair of names might not be supported on some OSs. The octal
values of the flags are summed or combined in a bitwise OR operation to give the desired permission mode.
The function returns an error code.
References
[1] Tutorial for chmod (http:/ / catcode. com/ teachmod/ )
[2] chmod (http:/ / ss64.com/ bash/ chmod. html)
External links
chmod(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=chmod& sektion=1):change file modesFreeBSD
General Commands Manual
chmod (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ chmod-invocation. html) manual page
from GNU coreutils.
GNU "Setting Permissions" manual (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/
Setting-Permissions. html)
Solaris 9 chmod man page (http:/ / docs. sun. com/ app/ docs/ doc/ 817-0689/ 6mgfkpckn?q=chmod& a=view)
CHMOD-Win 3.0 (http:/ / neosmart. net/ dl. php?id=4) Freeware Windows' ACL CHMOD converter.
Beginners tutorial with on-line "live" example (http:/ / catcode. com/ teachmod/ index. html)
Chown
12
Chown
The chown command (abbreviation for change owner) is used on Unix-like systems to change the owner of a file.
Unprivileged (regular) users who wish to change the group of a file that they own may use chgrp.
From the BSD man page for chown:
For obvious security reasons, the ownership of a file may only be altered by a super-user. Similarly,
only a member of a group can change a file's group ID to that group.
[1]
Usage examples
These examples illustrate typical syntax and use. Modifying permissions requires you are either root or have write
access to the file. Changing owner requires root privilege.
Change the owner of /var/run/httpd.pid to 'root' (the standard name for the Superuser).
$ chown root /var/run/httpd.pid
Change the owner of strace.log to 'rob' and the group identifier to 'developers'.
$ chown rob:developers strace.log
Change the owner of /tmp and /var/tmp to nobody (not a good idea), and change the group of /tmp and
/var/tmp to nogroup
$ chown nobody:nogroup /tmp /var/tmp
Change the group identifier of /home to 512 (regardless of whether a group name is associated with the
identifier 512 or not).
$ chown :512 /home
Change the ownership of base to the user foouser and make it recursive (-R)
$ chown -R foouser base
Change the ownership to newuser and group to newgroup for all of the files and directories in current directory,
and all subdirectories (recursively).
$ chown -R newuser:newgroup .
External links
chown
[2]
Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
chown manual page
[3]
The chown Command
[4]
by The Linux Information Project (LINFO)
[1] BSD Man page for chown, March 31, 1994 (https:/ / developer. apple. com/ library/ mac/ documentation/ Darwin/ Reference/ ManPages/
man8/ chown. 8. html)
[2] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ chown. html
[3] http:/ / nersp.nerdc. ufl.edu/ ~dicke3/ nerspcs/ chown.html
[4] http:/ / www. linfo.org/ chown. html
Chgrp
13
Chgrp
The chgrp (from change group) command may be used by unprivileged users on Unix-like systems to change the
group associated with a file system object (such as a file, directory, or link) to one of which they are a member. A
file system object has 3 sets of access permissions, one set for the owner, one set for the group and one set for others.
Changing the group of an object could be used to change which users can write to a file.
Syntax
chgrp [options] group FSO
Frequently implemented options
-R recurse through subdirectories
-v verbosely output names of objects changed. Most useful when "FSO" is a list.
-f force or forge ahead with other objects even if an error is encountered.
The group parameter specifies the new group with which the files or directories should be associated. It may
either be a symbolic name or an identifier.
The FSO specifies one or more file system objects, which may be the result of an expression like *.conf
Example
$ ls -l *.conf
-rw-rw-r-- 1 gbeeker wheel 3545 Nov 04 2011 prog.conf
-rw-rw-r-- 1 gbeeker wheel 3545 Nov 04 2011 prox.conf
$ chgrp staff *.conf
$ ls -l *.conf
-rw-rw-r-- 1 gbeeker staff 3545 Nov 04 2011 prog.conf
-rw-rw-r-- 1 gbeeker staff 3545 Nov 04 2011 prox.conf
The above command changes the group associated with file prog.conf from 'wheel to staff (provided the executing
user is a member of that group). This could be used to allow members of staff to modify the configuration for
programs prog and prox.
External links
chgrp
[1]
:change the file group ownershipCommands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
chgrp(1)
[2]
:change group ownershipLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ chgrp. html
[2] http:/ / linux.die. net/ man/ 1/ chgrp
Cksum
14
Cksum
cksum is a command in Unix-like operating systems that generates a checksum value for a file or stream of data.
The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and
outputs the file's CRC checksum and byte count.
The cksum command can be used to verify that files transferred by unreliable means arrived intact.
[1]
However, the
CRC checksum calculated by the cksum command is not cryptographically secure: While it guards against accidental
corruption (it is unlikely that the corrupted data will have the same checksum as the intended data), it is not difficult
for an attacker to deliberately corrupt the file in a specific way that its checksum is unchanged. Unix-like systems
typically include other commands for cryptographically secure checksums, such as sha1sum.
Interoperability
The standard cksum command, as found on most UNIX-like OS (including GNU/Linux, *BSD, Mac OS X, and
Solaris) uses a CRC algorithm based on the ethernet standard frame check and is therefore interoperable between
implementations. It is not however compatible with the CRC-32 calculation. This is in contrast to the sum command,
which is not as interoperable. On Tru64 operating systems, the cksum command returns a different CRC value,
unless the environment variable CMD_ENV is set to xpg4.
Syntax
cksum [ File ... ]
Usage example
$ cksum test.txt
4038471504 75 test.txt
where "4038471504" represents the checksum value and "75" represents the file size of test.txt.
References
[1] GNU cksum manual page available with most Unix-like distributions; invoked via man cksum (http:/ / www. gnu. org/ software/ coreutils/
manual/ html_node/ cksum-invocation.html)
External links
cksum (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ cksum. html):write file checksums and
sizesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
cksum/ (http:/ / src. gnu-darwin. org/ src/ usr. bin/ cksum/ ) - complete source code, including Makefile, for an
implementation written in C
cmp
15
cmp
cmp is a command line utility for computer systems that use Unix or a Unix-like operating system. It compares two
files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if
they differ, the byte and line number at which the first difference occurred is reported.
Switches
cmp may be qualified by the use of command-line switches. The switches supported by the GNU version of cmp are:
-b, --print-bytes
Print the differing bytes. Display control bytes as a '^' followed by a letter of the alphabet and precede bytes
that have the high bit set with 'M-' (which stands for "meta").
-i SKIP, --ignore-initial=SKIP
Skip the first SKIP bytes of input.
-i SKIP1
SKIP2, --ignore-initial=SKIP1:SKIP2 : Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of
FILE2.
-l, --verbose
Output the (decimal) byte numbers and (octal) values of all differing bytes, instead of the default standard
output. Also, output the EOF message if one file is shorter than the other.
-n LIMIT, --bytes=LIMIT
Compare at most LIMIT bytes.
-s, --quiet, --silent
Output nothing; yield exit status only.
-v, --version
Output version info.
--help
Outputs a help file.
Operands that are byte counts are normally decimal, but may be preceded by '0' for octal and '0x' for hexadecimal.
A byte count can be followed by a suffix to specify a multiple of that count; in this case an omitted integer is
understood to be 1. A bare size letter, or one followed by 'iB', specifies a multiple using powers of 1024. A size
letter followed by 'B' specifies powers of 1000 instead. For example, '-n 4M' and '-n 4MiB' are equivalent to '-n
4194304', whereas '-n 4MB' is equivalent to '-n 4000000'. This notation is upward compatible with the SI
prefixes
[1]
for decimal multiples and with the IEC 60027-2 prefixes for binary multiples.
[2]
cmp
16
Return values
0 files are identical
1 files differ
2 inaccessible or missing argument
References
[1] http:/ / www. bipm.fr/ enus/ 3_SI/ si-prefixes.html
[2] http:/ / physics. nist.gov/ cuu/ Units/ binary. html
External links
cmp (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ cmp. html):compare two
filesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Comparing and Merging Files: Invoking cmp (http:/ / www. gnu. org/ software/ diffutils/ manual/ html_node/
Invoking-cmp. html) The section of the manual of GNU cmp in the diffutils free manual.
cp
cp is a UNIX command for copying files and directories. The command has three principal modes of operation,
expressed by the types of arguments presented to the program for copying a file to another file, one or more files to a
directory, or for copying entire directories to another directory.
The utility further accepts various command line option flags to detail the operations performed. The two major
specifications are POSIX cp and GNU cp. GNU cp has many additional options over the POSIX version.
[1]
Operating modes
Cp has three principal modes of operation. These modes are inferred from the type and count of arguments presented
to the program upon invocation.
When the program has two arguments of path names to files, the program copies the contents of the first file to
the second file, creating the second file if necessary.
When the program has one or more arguments of path names of files and following those an argument of a path to
a directory, then the program copies each source file to the destination directory, creating any files not already
existing.
When the program's arguments are the path names to two directories, cp copies all files in the source directory to
the destination directory, creating any files or directories needed. This mode of operation requires an additional
option flag, typically r, to indicate the recursive copying of directories. If the destination directory already exists,
the source is copied into the destination, while a new directory is created if the destination does not exist.
cp
17
Usage
Copying a file to another file:
cp [-fHip][--] sourcefile targetfile
Copying file(s) to a directory
cp [-fHip] [--] sourcefile... targetdirectory
Copying a directory to a directory (-r or -R must be used)
cp -r|-R [-fHip] [--] sourcedirectory... targetdirectory
Option flags
f (force) specifies removal of the target file if it cannot be opened for write operations. The removal precedes
any copying performed by the cp command.
H (dereference) makes the cp command follow symbolic links (symlinks) so that the destination has the target
file rather than a symlink to the target.
i (interactive) prompts you with the name of a file to be overwritten. This occurs if the TargetDirectory or
TargetFile parameter contains a file with the same name as a file specified in the SourceFile or SourceDirectory
parameter. If you enter y or the locale's equivalent of y, the cp command continues. Any other answer prevents
the cp command from overwriting the file.
p (preserve) the p flag preserves the following characteristics of each source path in the corresponding target:
The time of the last data modification and the time of the last access, the ownership (only if it has permissions to
do this), and the file permission bits.
R or r (recursive) copy directories recursively
Examples
Creating a copy of a file in the current directory:
cp prog.c prog.bak
This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp command creates it. If it does exist,
the cp command replaces its contents with the contents of the prog.c file.
Copy two files in the current directory into another directory:
cp jones smith /home/nick/clients
This copies the files jones to /home/nick/clients/jones and smith to /home/nick/clients/smith.
Copy a file to a new file and preserve the modification date, time, and access control list associated with the source
file:
cp -p smith smith.jr
This copies the smith file to the smith.jr file. Instead of creating the file with the current date and time stamp, the
system gives the smith.jr file the same date and time as the smith file. The smith.jr file also inherits the smith file's
access control protection.
Copy a directory, including all its files and subdirectories, to another directory:
cp -R /home/nick/clients /home/nick/customers
cp
18
This copies the directory clients, including all its files, subdirectories, and the files in those subdirectories, to the
directory customers/clients. Some Unix systems behave differently in this mode, depending on the termination of
directory paths. Using cp -R /home/nick/clients/ /home/nick/customers on a GNU system it
behaves as expected; however, on a BSD system, it copies all the contents of the "clients" directory, instead of the
directory clients itself. The same happens in both GNU and BSD systems if the path of the source directory ends in .
or .. (with or without trailing slash).
The copying of a file to an existing file is performed by opening the existing file in update mode, thereby preserving
the files inode, which requires write access and results in the target file retaining the permissions it had originally.
Related Unix commands
cpio copy an entire directory structure from one place to another
tar create an archive of files
link system call to create a link to a file or directory
ln create a link to a file or directory
mv move a file or directory
rm remove a file or directory
unlink system call to remove a file or directory
chmod change the mode (aka permissions) on a file or directory
chown change ownership on a file or directory
chgrp change group on a file or directory
uucp unix to unix copy
scp secure copy over SSH
References
[1] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ cp-invocation. html#cp-invocation
dd
19
dd
dd is a command on Unix and Unix-like operating systems whose primary purpose is to convert and copy a file.
On Unix, device drivers for hardware (such as hard disks) and special device files (such as /dev/zero and
/dev/random) appear in the file system just like normal files; dd can also read and/or write from/to these files,
provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as
backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also
perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII
and EBCDIC text encodings.
The name dd may be an allusion to the DD statement found in IBM's Job Control Language (JCL), where the
initials stand for "Data Description."
[1]
The command's syntax resembles the JCL statement more than it does other
Unix commands, so the syntax may have been a joke. Another explanation for the command's name is that "cc" (for
"convert and copy", as in the command's description) was already taken by the C compiler.
[citation needed]
The dd command is specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification.
Usage
The command line syntax of dd differs from many other Unix programs, in that it uses the syntax
option=value for its command line options, rather than the more-standard --option value or
-option=value formats. By default, dd reads from STDIN and writes to STDOUT, but these can be changed by
using the if (input file) and of (output file) options.
Usage varies across different operating systems. Also, certain features of dd will depend on the computer system
capabilities, such as dd's ability to implement an option for direct memory access. Sending a SIGINFO signal (or a
USR1 signal on Linux) to a running dd process makes it print I/O statistics to standard error once and then continue
copying (note that signals may terminate the process on OSX). dd can read standard input from the keyboard.
When end-of-file (EOF) is reached, dd will exit. Signals and EOF are determined by the software. For example,
Unix tools ported to Windows vary as to the EOF: Cygwin uses <ctrl-d> (the usual Unix EOF) and MKS Toolkit
uses <ctrl-z> (the usual Windows EOF).
In spirit with the Unix philosophy, dd does one thing (and may be considered to do it "well" ). Unlike a
sophisticated and highly abstracted utility, dd has no algorithm other than in the low-level decisions of the user
concerning how to vary the run options. Often, the options are changed for each run of dd in a multi-step process to
solve a computer problem.
Output messages
The GNU variant of dd as supplied with coreutils on Linux does not describe the format of the messages displayed
on standard output on completion. However, these are described by other implementations, e.g. that with BSD.
Each of the "Records in" and "Records out" lines shows the number of complete blocks transferred + the number of
partial blocks, e.g. because the physical medium ended before a complete block was read, or a physical error
prevented reading the complete block.
dd
20
Block size
A block is a unit measuring the number of bytes that are read, written, or converted at one time. Command line
options can specify a different block size for input/reading (ibs) compared to output/writing (obs), though the
block size (bs) option will override both ibs and obs. The default value for both input and output block sizes is
512 bytes (the traditional block size of disks, and POSIX-mandated size of "a block"). The count option for
copying is measured in blocks, as are both the skip count for reading and seek count for writing. Conversion
operations are also affected by the "conversion block size" (cbs).
For some uses of the dd command, block size may have an effect on performance. For example, when recovering
data from a hard disk, a small block size will generally cause the most bytes to be recovered. Issuing many small
reads is an overhead and may be non-beneficial to execution performance. For greater speed during copy operations,
a larger block size may be used. However, because the amount of bytes to copy is given by bscount, it is impossible
to copy a prime number of bytes in one go without going with one of two bad choices, bs=N count=1 (memory
use) or bs=1 count=N (read request overhead). Alternative programs (see below) permit specifying bytes rather
than blocks.
When dd is used for network transfers, the block size may have also an impact on packet size, depending on the
network protocol used.
The value provided for block size options is interpreted as a decimal (base 10) integer and can also include suffixes
to indicate multiplication. The suffix w means multiplication by 2, b means 512, k means 1024, M means 1024
1024, G means 1024 1024 1024, and so on. Additionally, some implementations understand the x character as
a multiplication operator for both block size and count parameters.
For example, a block size such as bs=2x80x18b is interpreted as 2 80 18 512 = 1474560 bytes, the exact
size of a 1440 KiB floppy disk.
Uses
The dd command can be used for a variety of purposes.
Data transfer
dd can duplicate data across files, devices, partitions and volumes. The data may be input or output to and from any
of these; but there are important differences concerning the output when going to a partition. Also, during the
transfer, the data can be modified using the conv options to suit the medium.
An attempt to copy the entire disk using cp may omit the final block if it is of an unexpected length
[citation needed]
;
whereas dd may succeed. The source and destination disks should have the same size.
Data transfer forms of dd
dd if=/dev/sr0 of=myCD.iso bs=2048 conv=noerror,sync create an ISO disk image from a CD-ROM.
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror Clone one partition to another
dd if=/dev/ad0 of=/dev/ad1 bs=1M conv=noerror Clone a hard disk "ad0" to "ad1".
The noerror option means to keep going if there is an error. The sync option means to pad the output blocks.
dd
21
Master boot record backup and restore
It is possible to repair a master boot record. It can be transferred to and from a repair file.
To duplicate the first two sectors of a floppy drive:
dd if=/dev/fd0 of=MBRboot.img bs=512 count=2
To create an image of the entire x86 master boot record (including a MS-DOS partition table and MBR magic bytes):
dd if=/dev/sda of=MBR.img bs=512 count=1
To create an image of only the boot code of the master boot record (without the partition table and without the magic
bytes required for booting):
dd if=/dev/sda of=MBR_boot.img bs=446 count=1
Data modification
dd can modify data in place.
Overwrite the first 512 bytes of a file with null bytes:
dd if=/dev/zero of=path/to/file bs=512 count=1 conv=notrunc
The notrunc conversion option means do not truncate the output file that is, if the output file already exists,
just replace the specified bytes and leave the rest of the output file alone. Without this option, dd would create an
output file 512 bytes long.
To duplicate a disk partition as a disk image file on a different partition:
dd if=/dev/sdb2 of=partition.image bs=4096 conv=noerror
Disk wipe
For security reasons, it is sometimes necessary to have a disk wipe of a discarded device.
To check to see if a drive has data on it, send the output to standard out.
dd if=/dev/sda
To wipe a disk by writing zeros:
dd if=/dev/zero of=/dev/sda bs=4k
When compared to the data modification example above, notrunc conversion option is not required as it has no
effect when the dd's output file is a block device.
The bs=4k option makes dd read and write 4 kilobytes at a time. For modern systems, an even greater block size
may be beneficial due to the transport capacity (think RAID systems). Note that filling the drive with random data
will always take a lot longer than zeroing the drive, because the random data must be rendered by the CPU and/or
HWRNG first, and different designs have different performance characteristics. (The PRNG behind
/dev/urandom may be slower than libc's.) On most relatively modern drives, zeroing the drive will render any
data it contains permanently irrecoverable.
Zeroing the drive will render any data it contains irrecoverable by software; however it still may be recoverable by
special laboratory techniques.
The shred program provides an alternate method for the same task, and finally, the wipe program present in many
Linux distributions provides an elaborate tool (the one that does it "well", going back to the Unix philosophy
mentioned before) with many ways of clearing.
dd
22
Data recovery
The history of open-source software (OSS) for data recovery and restoration of files, drives, and partitions started
with GNU dd in 1984, with one block size per dd process, and no recovery algorithm other than the user's
interactive session running one form of dd after another. Then, a C program was authored October 1999 called
dd_rescue
[2]
. It has two block sizes in its algorithm. But the author of the 2003 shell script dd_rhelp
[3]
that
enhances dd_rescue's data recovery algorithm, now recommends GNU ddrescue
[4]
, a C++ program that was
initially released in 2004 and is now in most Linux distributions. GNU ddrescue has the most sophisticated
block-size-changing algorithm available in OSS. (The names ddrescue and dd_rescue are similar, yet they are
different programs. Because of this, alternate names for more unambiguous distinguishing is used; names used are
"addrescue" (name on freecode.com), "gddrescue" (Debian package name) and "gnu_ddrescue" (openSUSE package
name).)
GNU ddrescue is stable and safe.
Another open source program called savehd7 uses a sophisticated algorithm, but it also requires the installation of
its own programming-language interpreter.
Benchmarking drive performance
To make drive benchmark test and analyze the sequential (and usually single-threaded) system read and write
performance for 1024-byte blocks :
dd if=/dev/zero bs=1024 count=1000000 of=file_1GB
dd if=file_1GB of=/dev/null bs=1024
Generating a file with random data
To make a file of 100 random bytes using the kernel random driver:
dd if=/dev/urandom of=myrandom bs=100 count=1
Converting a file to upper case
To convert a file to uppercase:
dd if=filename of=filename1 conv=ucase
Creating empty files of arbitrary size
Create a 1 GiB sparse file, or resize an existing file to 1 GiB without overwriting:
dd if=/dev/zero of=mytestfile.out bs=1 count=0 seek=1G
(A more modern tool for this is fallocate or truncate, both shipped with GNU coreutils.)
dd
23
Limitations
Seagate documentation warns, "Certain disc utilities, such as DD, which depend on low-level disc access may not
support 48-bit LBAs until they are updated".
[5][citation needed]
Using ATA harddrives over 128 GiB requires 48-bit
LBA. However, in Linux, dd uses the kernel to read or write to raw device files.
[6]
Support for 48-bit LBA has been
present since version 2.4.23 of the kernel, released in 2003.
[7]
It is jokingly said that dd stands for "destroy disk" or "delete data", since when used for low-level operations on
hard disks, a small mistake such as reversing the input file and output file parameters could result in the loss of some
or all data on a disk.
Dcfldd
dcfldd is a fork of dd that is an enhanced version developed by Nick Harbour; who at the time was working for the
United States' Department of Defense Computer Forensics Lab. Compared to dd, dcfldd allows for more than one
output file, supports simultaneous multiple checksum calculations, provides a verification mode for file matching,
and can display of the percentage progress of an operation.
Notes
[1] [1] See this old discussion
[2] http:/ / www. garloff. de/ kurt/ linux/ ddrescue/
[3] http:/ / www. kalysto. org/ utilities/ dd_rhelp/ index. en. html
[4] http:/ / www. gnu. org/ software/ ddrescue/ ddrescue.html
[5] Windows 137GB (128 [[GiB (http:/ / web. archive.org/ web/ 20070316080228/ http:/ / www. seagate. com/ support/ kb/ disc/ tp/ 137gb.
pdf)]) Capacity Barrier - Seagate Technology] (March 2003)
[6] This is verifiable with strace.
[7] Linux-2.4.23 released (http:/ / lkml. indiana. edu/ hypermail/ linux/ kernel/ 0311. 3/ 0942. html) Linux kernel mailing list, 2003.
References
External links
dd (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ dd. html):convert and copy a
fileCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
dd (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ dd-invocation. html): manual page from the
GNU Core Utilities.
dd(1) (http:/ / developer. apple. com/ documentation/ Darwin/ Reference/ ManPages/ man1/ dd. 1.
html)Darwin and Mac OS X General Commands Manual
dd for Windows (http:/ / www. chrysocome. net/ dd).
savehd7 - Save a potentially damaged harddisk partition (http:/ / seed7. sourceforge. net/ scrshots/ savehd7. htm)
GNU ddrescue (http:/ / www. gnu. org/ software/ ddrescue/ ddrescue. html).
Manual for GNU ddrescue (http:/ / www. gnu. org/ software/ ddrescue/ manual/ ddrescue_manual. html).
dd_rescue (http:/ / www. garloff. de/ kurt/ linux/ ddrescue/ )
dd_rhelp (http:/ / www. kalysto. org/ utilities/ dd_rhelp/ index. en. html)
Softpanorama dd page (http:/ / www. softpanorama. org/ Tools/ dd. shtml).
DD at Linux Questions Wiki (http:/ / wiki. linuxquestions. org/ wiki/ Dd).
How to use ddrescue to image a damaged harddisk partition and mount it in Windows. (http:/ / www. myfixlog.
com/ fix. php?fid=21)
Forensics (DD) Dcfldd (http:/ / www. forensicswiki. org/ wiki/ Dcfldd)
du
24
du
example screenshot of du in a terminal
du (abbreviated from disk usage) is a standard Unix program used to
estimate file space usagespace used under a particular directory or
files on a file system.
History
The du utility first appeared in version 1 of AT&T UNIX.
Specification
By default, the Single Unix Specification (SUS) specifies that du is to display the file space allocated to each file
and directory contained in the current directory. Links will be displayed as the size of the link file, not what is being
linked to; the size of the content of directories is displayed, as expected.
As du reports allocation space and not absolute file space, the amount of space on a file system shown by du may
vary from that shown by df if files have been deleted but their blocks not yet freed. Also the minfree setting that
allocates datablocks for the filesystem and the super user processes creates a discrepancy between total blocks and
the sum of used and available blocks. The minfree setting is usually set to about 5% of the total filesystem size. For
more info see core utils faq
[1]
.
Usage
du takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is
used. The SUS mandates for du the following options:
-a, display an entry for each file (and not directory) contained in the current directory
-c, display a grand total of the disk usage found by the other arguments
-d #, the depth at which summing should occur. -d 0 sums at the current level, -d 1 sums at the subdirectory,
-d 2 at sub-subdirectories, etc.
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each file
-x, only traverse files and directories on the device on which the pathname argument is specified.
Other Unix and Unix-like operating systems may add extra options. For example, BSD and GNU du specify a -h
option, displaying disk usage in a format easier to read by the user, adding units with the appropriate SI prefix (e.g.
10 MB)..
du
25
Examples
Sum of directories (-s) in kilobytes (-k):
$ du -sk *
152304 directoryOne
1856548 directoryTwo
Sum of directories (-s) in human-readable format (-h : Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte):
$ du -sh *
149M directoryOne
1.8G directoryTwo
disk usage of all subdirectories and files including hidden files within the current directory (sorted by filesize) :
$ du -sk .[!.]* *| sort -n
disk usage of all subdirectories and files including hidden files within the current directory (sorted by reverse
filesize) :
$ du -sk .[!.]* *| sort -nr
The weight (size) of each subdirectory under the current directory (-d 1) with a sum total at the end (-c) all displayed
in human-readable format (-h):
$ du -d 1 -c -h
or with du from GNU:
$ du --max-depth=1 -c -h
The weight (size) of subdirectories under the root directory (-d 1, trailing /) with a sum total at the end (-c), all
displayed in human-readable format (-h) without traversing into other filesystems (-x). Useful when /var /tmp or
other directories are on separate storage from the root directory:
$ du -d 1 -c -h -x /
or with du from GNU:
$ du --max-depth=1 -c -h -x /
External links
du
[2]
:estimate file space usageCommands & Utilities Reference, The Single UNIX Specification, Issue 7
from The Open Group
Manual pages
du
[3]
manual page from GNU coreutils
du
[4]
manual page from OpenBSD
du
[5]
manual page from Dragonflybsd
du
26
Other
Disk space-related utilities
[6]
at Freshmeat.net
References
[1] http:/ / www. gnu. org/ software/ coreutils/ faq/ coreutils-faq. html#df-Size-and-Used-and-Available-do-not-add-up
[2] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ du. html
[3] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ du-invocation. html
[4] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=du
[5] http:/ / leaf.dragonflybsd. org/ cgi/ web-man?command=du& section=ANY
[6] http:/ / freshmeat. net/ search/ ?q=disk+ space
df
df (abbreviation for disk free) is a standard Unix computer program used to display the amount of available disk
space for filesystems on which the invoking user has appropriate read access. df is usually implemented by reading
the mtab file or using statfs.
df first appeared in Version 1 AT&T UNIX.
Usage
The Single UNIX Specification specifications for df are:
df [-k] [-P|-t] [-del] [file...]
-k
Use 1024-byte units, instead of the default 512-byte units, when writing space figures.
-P
Use a standard, portable, output format
-t
If XSI compliant, show allocated space as wellWikipedia:Disputed statement
-h
Display in KB, MB, or GB
file
Write the amount of free space of the file system containing the specified file
Most Unix and Unix-like operating systems add extra options. The BSD and GNU coreutils versions include -h,
where free space is listed in human readable format, adding units with the appropriate SI prefix (e.g. 10MB), -i,
listing inode usage, and -l, restricting display to only local filesystems. GNU df includes -T as well, listing
filesystem type information, but the GNU df shows the sizes in 1K blocks by default.
df
27
Specification
The Single Unix Specification (SUS) specifies by default space is reported in blocks of 512 bytes, and that at a
minimum, the file system names and the amount of free space.
The use of 512-byte units is historical practice and maintains compatibility with ls and other utilities. This does not
mandate that the file system itself be based on 512-byte blocks. The -k option was added as a compromise
measure. It was agreed by the standard developers that 512 bytes was the best default unit because of its complete
historical consistency on System V (versus the mixed 512/1024-byte usage on BSD systems), and that a -k option
to switch to 1024-byte units was a good compromise. Users who prefer the more logical 1024-byte quantity can
easily alias df to df -k without breaking many historical scripts relying on the 512-byte units.
The output with -P shall consist of one line of information for each specified file system. These lines shall be
formatted as follows:
<fs name>, <total space>, <space used>, <space free>, <percentage used>, <fs root>
In the following list, all quantities expressed in 512-byte units (1024-byte when -k is specified) shall be rounded up
to the next higher unit. The fields are:
<fs name>
The name of the file system, in an implementation-defined format.
<total space>
The total size of the file system in 512-byte units. The exact meaning of this figure is implementation-defined,
but should include <space used>, <space free>, plus any space reserved by the system not normally available
to a user.
<space used>
The total amount of space allocated to existing files in the file system, in 512-byte units.
<space free>
The total amount of space available within the file system for the creation of new files by unprivileged users,
in 512-byte units. When this figure is less than or equal to zero, it shall not be possible to create any new files
on the file system without first deleting others, unless the process has appropriate privileges. The figure
written may be less than zero.
<percentage used>
The percentage of the normally available space that is currently allocated to all files on the file system. This
shall be calculated using the fraction:
<space used> / (<space used>+ <space free>)
expressed as a percentage. This percentage may be greater than 100 if <space free> is less than zero. The
percentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to
the next highest integer.
<fs root>
The directory below which the file system hierarchy appear
df
28
Example
$ df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd4 32768 16016 52% 2271 14% /
/dev/hd2 4587520 1889420 59% 37791 4% /usr
/dev/hd9var 65536 12032 82% 518 4% /var
/dev/hd3 819200 637832 23% 1829 1% /tmp
/dev/hd1 524288 395848 25% 421 1% /home
/proc - - - - - /proc
/dev/hd10opt 65536 26004 61% 654 4% /opt
External links
df
[1]
:report free disk spaceCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from
The Open Group
Manual pages
df
[2]
manual page from GNU coreutils
df(1)
[3]
:display free disk spaceOpenBSD General Commands Manual
The df Command
[4]
- by The Linux Information Project (LINFO)
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ df. html
[2] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ df-invocation. html
[3] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=df& section=1
[4] http:/ / www. linfo.org/ df. html
file
29
file
File (command)
Initial release 1973 as part of Unix Research Version 4
Operating system Unix, Unix-like
Type file type detector
file is a standard Unix program for recognizing the type of data contained in a computer file.
History
The original version of file originated in Unix Research Version 4
[1]
in 1973. System V brought a major update with
several important changes, most notably moving the file type information into an external text file rather than
compiling it into the binary itself.
All major BSD and Linux distributions use a free, open-source reimplementation which was written in 1986-87 by
Ian Darwin
[2]
from scratch. It was expanded by Geoff Collyer in 1989 and since then has had input from many
others, including Guy Harris, Chris Lowth and Eric Fischer; from late 1993 onward its maintenance has been
organized by Christos Zoulas.
Specification
The Single Unix Specification (SUS) specifies that a series of tests are performed on the file specified on the
command line:
1. if the file cannot be read, its status undetermined, or its type undetermined, file will indicate that the file was
processed and its type was undetermined.
2. file must be able to determine the types directory, FIFO, socket, block special file, and character special file
3. 3. zero-length files are identified as such
4. an initial part of file is considered and file is to use position-sensitive tests
5. the entire file is considered and file is to use context-sensitive tests
6. the file is identified as a data file
file's position-sensitive tests are normally implemented by matching various locations within the file against a
textual database of magic numbers (see the Usage section). This differs from other simpler methods such as file
extensions and schemes like MIME.
In most implementations, the file command uses a database to drive the probing of the lead bytes. That database
is implemented in a file called magic, whose location is usually in /etc/magic, /usr/share/file/magic
or a similar location.
file
30
Usage
The SUS mandates the following options:
-M file, specify a file specially formatted containing position-sensitive tests; default position-sensitive tests
and context-sensitive tests will not be performed
-m file, as for -M, but default tests will be performed after the tests contained in file.
-d, perform default position-sensitive and context-sensitive tests to the given file; this is the default behaviour
unless -M or -m is specified
-h, do-not-dereference symbolic links that point to an existing file or directory
-L, dereference the symbolic link that points to an existing file or directory
-i, do not classify the file further than to identify it as either: nonexistent, a block special file, a character
special file, a directory, a FIFO, a socket, a symbolic link, or a regular file
Other Unix and Unix-like operating systems may add extra options than these.
The command tells only what the file looks like, not what it is (in the case where file looks at the content). It is easy
to fool the program by putting a magic number into a file the content of which does not match it. Thus the command
is not usable as a security tool other than in specific situations.
Examples
$ file file.c
file.c: C program text
$ file program
program: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked
(uses shared libs), stripped
$ file /dev/wd0a
/dev/wd0a: block special (0/0)
$ file -s /dev/hda1
/dev/hda1: Linux/i386 ext2 filesystem
$ file -s /dev/hda5
/dev/hda5: Linux/i386 swap file
$ file compressed.gz
compressed.gz: gzip compressed data, deflated, original filename, `compressed', last
modified: Thu Jan 26 14:08:23 2006, os: Unix
$ file data.ppm
data.ppm: Netpbm PPM "rawbits" image data
$ file /Applications/Safari.app/Contents/MacOS/Safari
/Applications/Safari.app/Contents/MacOS/Safari: Mach-O universal binary with 2 architectures
/Applications/Safari.app/Contents/MacOS/Safari (for architecture ppc7400): Mach-O executable ppc
/Applications/Safari.app/Contents/MacOS/Safari (for architecture i386): Mach-O executable i386
file
31
Libmagic library
As of version 4.00 of the Ian Darwin/Christos Zoulas version of file, the functionality of file is incorporated
into a libmagic library that is accessible via C (and C-compatible) linking; file is implemented using that
library.
References
[1] See (http:/ / www. darwinsys.com/ file/ file-v4. 1. txt) this copy of the UNIX V4 man page
[2] The history of this program is recorded in its private CVS repository; see (http:/ / www. darwinsys. com/ file/ file. c. log. txt) the log of the
main program
External links
file (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ file. html):determine file
typeCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Manual pages
file(1) (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=file& section=1)OpenBSD General
Commands Manual
file(1) (http:/ / linux. die. net/ man/ 1/ file)Linux User Commands Manual
libmagic(3) (http:/ / netbsd. gw. com/ cgi-bin/ man-cgi?libmagic+ 3+ NetBSD-current)NetBSD Library
Functions Manual
libmagic(3) (http:/ / linux. die. net/ man/ 3/ libmagic)Linux Library Functions Manual
Other
Fine Free File Command (http:/ / darwinsys. com/ file/ ) homepage for version of file used in major BSD
and Linux distributions.
The libmagic-dev package (http:/ / packages. debian. org/ unstable/ libdevel/ libmagic-dev) on
packages.debian.org (http:/ / packages. debian. org)
TrID (http:/ / mark0. net/ soft-trid-e. html), an alternative providing ranked answers (instead of just one) based on
statistics.
Fsck
32
Fsck
fsck in action on a Linux system.
The system utility fsck (for "file system check") is a tool for checking
the consistency of a file system in Unix and Unix-like operating
systems, such as Linux and Mac OS X.
Use
Generally, fsck is run automatically at boot time. There are two
common triggers for automatically executing fsck. Either the operating
system detects that a file system is in an inconsistent state (likely due
to a non-graceful shutdown such as a crash or power loss), or after a
certain number of times that the file system is mounted (to prevent
small, undetected inconsistencies from becoming exacerbated).
The fsck command works directly on data-structures that are internal,
and intrinsically specific to a file system implementation. A matching
fsck command that is tailored specifically to the design of the file
system is often provided by the authors of a file system. The exact
behaviors of various fsck implementations vary, but they typically
follow a common order of internal operations and provide a common
command-line interface to the user.
Most fsck utilities provide options for either interactively repairing damaged file systems (the user must decide how
to fix specific problems), automatically deciding how to fix specific problems (so the user does not have to answer
any questions), or reviewing the problems that need to be resolved on a file system without actually fixing them.
Partially recovered files where the original file name cannot be reconstructed are typically recovered to a
"lost+found" directory that is stored at the root of the file system.
A system administrator can also run fsck manually if they believe there is a problem with the file system. Because
running fsck to repair a file system which is mounted for read/write operations can potentially cause severe data
corruption/loss, the file system is normally checked while unmounted, mounted read-only, or with the system in a
special maintenance mode that limits the risk of such damage. A journaling file system is designed such that tools
such as fsck do not need to be run after unclean shutdown (i.e. crash).
The UFS2 Filesystem in FreeBSD has a background fsck, so it is usually not necessary to wait for fsck to finish
before accessing the disk. The modern and faster ZFS in FreeBSD, FreeNAS and PC-BSD has no "fsck" repair tool;
instead, it has a repair tool called "scrub" which examines and repairs Silent Corruption and other problems.
Additionally ZFS uses copy-on-write, intelligent data scrubbing and resilvering (resyncing). While fsck must be run
on an unmounted and therefore unusable filesystem, scrub does not need the ZFS filesystem to be taken offline.
scrub is designed to be used on a mounted filesystem. While fsck usually only checks metadata, such as the journal
log, but never checks the data itself, scrub checks everything, including metadata and the data. It is also possible to
simply swap a harddisk drive to a larger drive and resilver (repair) the zpool of disks. The ZFS file system was
designed from the ground up with a focus on data integrity and protection against silent data corruption caused by bit
rot, current spikes, bugs in disk firmware, ghost writes, and so on.
The equivalent programs on Microsoft Windows are CHKDSK and SCANDISK.
Fsck
33
Use as profanity
Before the rise of journaling file systems, it was common for an improperly shut-down Unix system's file system to
develop a corrupted superblock. This possibly-serious problem could only be resolved by running fsck, which could
take anywhere from a few seconds to hours, depending on the volume's size and disk I/O throughput. Because of the
severity of fsck not being able to resolve this error, the terms "fsck" and "fscked" have come into use among Unix
system administrators as a minced oath.
A report from a question and answer session at USENIX 1998 claims that "fsck" originally had a different name.
Dennis Ritchie: So fsck was originally called something else
Question: What was it called?
Dennis Ritchie: "Well, the second letter was different"
[1][2]
Another online use of the term, not really profanity but a curt way of dismissing someone, was "Go fsck yourself",
meaning to go and correct your issue (attitude, ignorance of the subject matter, etc.) before posting again. This takes
the fsck process as a metaphor, since running fsck involves fixing fundamental errors on the file system before
continuing work on it.
Examples
The following example checks the file system on the first partition of the second hard disk on a Linux system:
fsck /dev/sdb1
The following example checks the JFS file system on a mdadm software raid device:
fsck.jfs /dev/md0
References
[1] https:/ / groups. google.com/ forum/ #!msg/ alt.sysadmin. recovery/ tsGbbkvHo2c/ 6T-Pj9d3A6wJ
[2] http:/ / www. c2. com/ cgi/ wiki?MindFsck
External links
man fsck (http:/ / www. manpagez. com/ man/ 8/ fsck/ )
Checking and Repairing File system with fsck (http:/ / www. adminschoice. com/ repairing-unix-file-system-fsck)
Jargon File entry: fscking (http:/ / www. catb. org/ jargon/ html/ F/ fscking. html)
The many faces of fsck (http:/ / lwn. net/ Articles/ 248180)
fuser
34
fuser
fuser is a UNIX command used to show which processes are using a specified file, file system, or unix socket. For
example, to check process IDs and users accessing a USB drive:
$ fuser -m -u /mnt/usb1
/mnt/usb1: 1347c(root) 1348c(guido) 1349c(guido)
fuser displays the PIDs of processes using the specified files or file systems. In the default display mode, each file
name is followed by a letter denoting the type of access:
c
current directory.
e
executable being run.
f
open file.
F
open file for writing.
r
root directory.
m
mmap'ed file or shared library
fuser can also be used to check what processes are using a network port:
$ fuser -v -n tcp 80
USER PID ACCESS COMMAND
80/tcp: root 3067 F.... (root)httpd
apache 3096 F.... (apache)httpd
apache 3097 F.... (apache)httpd
fuser returns a non-zero code if none of the files are accessed or in case of a fatal error. If at least one access has
succeeded, fuser returns zero. The output of "fuser" may be useful in diagnosing "resource busy" messages arising
when attempting to unmount filesystems.
Options
-k
kills all process accessing a file. For example fuser -k /path/to/your/filename kills all
processes accessing this directory without confirmation. Use -i for confirmation
-i
interactive mode. Prompt before killing process
-v
verbose.
-u
append username
fuser
35
-a
display all files
-m
name specifies a file on a mounted file system or a block device that is mounted. All processes accessing files
on that file system are listed. If a directory file is specified, it is automatically changed to name/. to use any
file system that might be mounted on that directory.
Also note that -k sends a SIGKILL to all process. Use the -signal to send a different signal. For a list of signals
supported by the fuser run 'fuser -l'
Related commands
The list of all open files and the processes that have them open can be obtained through the lsof command.
The equivalent command on BSD operating systems is fstat(1)
External links
fuser(1)
[1]
:identify processes using files or socketsLinux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ fuser
ln
ln is a standard Unix command used to create links (link) to files.
Link files
Links allow more than one file name to refer to the same file, elsewhere.
There are two types of links, both of which are created by ln:
1. symbolic links, which refer to a symbolic path indicating the abstract location of another file; and
2. hard links, which refer to the specific location of physical data.
These links behave differently when the source of the link (what is being linked to) is moved or removed. Symbolic
links are not updated (they merely contain a string which is the pathname of its target); hard links always refer to the
source, even if moved or removed.
Specification
The Single Unix Specification (SUS) specifies the behaviour that a link or links (either symbolic or hard) will be
created where specified that will link to the target file (or directory) specified.
More precisely, ln can be invoked in one of two ways: two argumentsfirst an argument specifying the source file
then the target, or multiple (greater than two) arguments, specifying firstly a number of source files, then a directory
in which all the links are to be created. In the latter invocation, the names of the links will be that of the source file.
This invocation will be assumed if the last argument is a directory. If invoked in the latter form, ln's behaviour is
not specified (it is implementation-defined).
ln is specified to use behaviour identical to that of the standard unlink() and link() functions. The original
file can still be accessed through the hardlink:
ln
36
$ cat hardlink.file
This is a file
When the original file was deleted, the hardlink remained. Similarly, if the softlink had been deleted, the original file
would have remained.
External links
ln
[1]
specification from the Single Unix Specification
Simple guide to ln
[2]
Manual pages
ln
[3]
manual page from GNU coreutils
ln
[4]
manual page from OpenBSD
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ ln. html
[2] http:/ / en. wikibooks. org/ wiki/ Guide_to_Unix/ Commands/ File_System_Utilities#ln
[3] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ ln-invocation. html
[4] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=ln
Ls
A long file listing with "ls -l" in OpenBSD 5.3
In computing, ls is a command to list files in Unix and Unix-like
operating systems. ls is specified by POSIX and the Single UNIX
Specification.
History
An ls utility appeared in the original version of AT&T UNIX.
Today, two popular versions of ls are the Free Software Foundation's
(part of the GNU coreutils package) and the one released by various
BSD variants, such as FreeBSD, OpenBSD, NetBSD, and Apple's Darwin. Both are free software and open source.
The name 'ls' comes from a similar command in Multics
Behavior
Unix and Unix-like operating systems maintain the idea of a current working directory, that is, where one is
currently positioned in the hierarchy of directories.
When invoked without any arguments, ls lists the files in the current working directory. A directory that is not the
current working directory can be specified and ls will list the files there. The user also may specify any list of files
and directories. In this case, all files and all contents of specified directories will be listed.
Files whose names start with "." are not listed, unless the -a flag is specified, the -A flag is specified, or the files
are specified explicitly.
Without options, ls displays files in a bare format. This bare format however makes it difficult to establish the
type, permissions, and size of the files. The most common options to reveal this information or change the list of
files are:
Ls
37
-l long format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified
date and filename
-f do not sort. Useful for directories containing large numbers of files.
-F appends a character revealing the nature of a file, for example, * for an executable, or / for a directory.
Regular files have no suffix.
-a lists all files in the given directory, including those whose names start with "." (which are hidden files in
Unix). By default, these files are excluded from the list.
-R recursively lists subdirectories. The command ls -R / would therefore list all files.
-d shows information about a symbolic link or directory, rather than about the link's target or listing the contents
of a directory.
-t sort the list of files by modification time.
-h print sizes in human readable format. (e.g., 1K, 234M, 2G, etc.)
In some environments, providing the option --color (for GNU ls) or -G (FreeBSD ls) causes ls to highlight
different types of files with different colors, instead of with characters as -F would. To determine what color to use
for a file, GNU ls checks the Unix file type, the file permissions, and the file extension, while FreeBSD ls
checks only the Unix file type and file permissions. On the other hand, the FreeBSD implementation uses the
termcap database while the GNU program uses its own database which does not necessarily match the termcap data
on a given system.
When the option to use color to indicate file types is selected, the output might look like:
brw-r--r-- 1 unixguy staff 64, 64 Jan 27 05:52 block
crw-r--r-- 1 unixguy staff 64, 255 Jan 26 13:57 character
-rw-r--r-- 1 unixguy staff 290 Jan 26 14:08 compressed.gz
-rw-r--r-- 1 unixguy staff 331836 Jan 26 14:06 data.ppm
drwxrwxr-x 2 unixguy staff 48 Jan 26 11:28 directory
-rwxrwxr-x 1 unixguy staff 29 Jan 26 14:03 executable
prw-r--r-- 1 unixguy staff 0 Jan 26 11:50 fifo
srw-rw-rw- 1 unixguy staff 0 Jan 26 12:00 socket
lrwxrwxrwx 1 unixguy staff 3 Jan 26 11:44 link -> dir
-rw-rw---- 1 unixguy staff 217 Jan 26 14:08 regularfile
ls has a large number of other options (see: man ls). It is a frequently used tool that provides an interface to the
file system via the command line.
On some systems (e.g. PCLinuxOS), ls has an alias of just l. Many systemsWikipedia:Avoid weasel words also
alias ls -l to ll or ls -la to la (e.g. PC-BSD, zsh preset).
[citation needed]
Sample usage
The following example demonstrates the output of the ls command given two different arguments (pwd is a
command that shows the present working directory, or in other words, the folder you are currently in):
$ pwd
/home/fred
$ ls -l
drwxr--r-- 1 fred editors 4096 drafts
-rw-r--r-- 1 fred editors 30405 edition-32
-r-xr-xr-x 1 fred fred 8460 edit
$ ls -F
drafts/
Ls
38
edition-32
edit*
In this example, the user fred has a directory named drafts, a regular file called edition-32, and an
executable named edit in his home directory. ls uses Unix file permission notation to indicate which users or
groups are allowed to access each file or directory.
drwxr--r-- 1 fred editors 4096 Mar 1 2007 drafts
This means that the letters behind the file descriptor (d), which indicates a folder or 'directory', list three characters to
indicate permissions for the owner of 'drafts' (rwx), then the group to which the file belongs (r--), and the rights of
others (r--).
'drafts' is a directory (d), the owner of which has the right to read (r) write (w) and execute (x): rwx, group members
have (r--), meaning read only, and others have (r--), meaning read only access. See Unix file permission notation for
a more detailed description.
Notes
External links
ls (http:/ / wiki. linuxquestions. org/ wiki/ Ls) at the LinuxQuestions.org wiki
ls (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ ls. html) specified by the Single Unix
Specification
GNU ls source code (as part of coreutils) (http:/ / ftp. gnu. org/ pub/ gnu/ coreutils/ )
ls(1) (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ ls-invocation. html) manual pages
from GNU coreutils.
Lsattr
39
Lsattr
lsattr is a command-line program for listing the attributes on a Linux second extended file system (ext2).
[1]
It is
also a command to display attributes of devices on an AIX operating system.
Options
The form of the lsattr command (gnu 1.41.3):
lsattr [ -RVadv ] [ files... ]
-R Recursively list attributes of directories and their contents.
-V Display the program version.
-a List all files in directories, including files that start with '.'
-d List directories like other files, rather than listing their contents.
-v List the files version/generation number.
Attributes
Some attributes include:
don't update atime (A)
synchronous updates (S)
synchronous directory updates (D)
append only (a)
compressed (c)
no dump (d)
immutable (i)
data journaling (j)
secure deletion (s)
top of directory hierarchy (T)
no tail-merging (t)
undeletable (u)
use hashed b-trees for directory lookups (I)
Details of the attributes can be found in the chattr man page
[2]
References
[1] lsattr man (http:/ / linux.about. com/ library/ cmd/ blcmdl1_lsattr. htm)
[2] chattr man (http:/ / linux. about. com/ od/ commands/ l/ blcmdl1_chattr. htm)
Lsof
40
Lsof
lsof
Developer(s) Victor A. Abell
Latest stable 4.87 / 2January2013
License
BSD license-compatible
[1]
Website
people.freebsd.org/~abe/
[2]
lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files
and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the
retired Associate Director of the Purdue University Computing Center. It works in and supports several Unix flavors.
Examples
Open files in the system include disk files, named pipes, network sockets and devices opened by all processes. One
use for this command is when a disk cannot be unmounted because (unspecified) files are in use. The listing of open
files can be consulted (suitably filtered if necessary) to identify the process that is using the files.
# lsof /var
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
syslogd 350 root 5w VREG 222,5 0 440818
/var/adm/messages
syslogd 350 root 6w VREG 222,5 339098 6248
/var/log/syslog
cron 353 root cwd VDIR 222,5 512 254550 /var --
atjobs
To view the port associated with a daemon:
# lsof -i -n -P | grep sendmail
sendmail 31649 root 4u IPv4 521738 TCP *:25 (LISTEN)
From the above one can see that "sendmail" is listening on its standard port of "25".
-i Lists IP sockets.
-n Do not resolve hostnames (no DNS).
-P Do not resolve port names (list port number instead of its name).
One can also list Unix Sockets by using lsof -U.
Lsof
41
Lsof output
The lsof output describes:
the identification number of the process (PID) that has opened the file;
the process group identification number (PGID) of the process (optional);
the process identification number of the parent process (PPID) (optional);
the command the process is executing;
the owner of the process;
for all files in use by the process, including the executing text file and the shared libraries it is using:
the file descriptor number of the file, if applicable;
the file's access mode;
the file's lock status;
the file's device numbers;
the file's inode number;
the file's size or offset;
the name of the file system containing the file;
any available components of the file's path name;
the names of the file's stream components;
the file's local and remote network addresses;
the TLI network (typically UDP) state of the file;
the TCP state, read queue length, and write queue length of the file;
the file's TCP window read and write lengths (Solaris only); and
other file or dialect-specific values.
References
[1] lsof FAQ, 1.9 Is there an lsof license? (ftp:/ / lsof.itap. purdue. edu/ pub/ tools/ unix/ lsof/ FAQ)
[2] http:/ / people. freebsd. org/ ~abe/
External links
Official website (http:/ / people. freebsd. org/ ~abe/ )
lsof(8) (http:/ / linux. die. net/ man/ 8/ lsof)Linux Administration and Privileged Commands Manual
Using lsof (http:/ / danielmiessler. com/ study/ lsof)
lsof manpage on www.netadmintools.com (http:/ / www. netadmintools. com/ html/ lsof. man. html)
Troubleshooting Runnings Systems with lsof (http:/ / www. digitalprognosis. com/ linuxtips/
troubleshooting-running-systems-with-lsof/ )
Lsof FAQ (http:/ / gd. tuwien. ac. at/ utils/ admin-tools/ lsof/ FAQ)
Sam Nelson's PCP (http:/ / www. unix. ms/ pcp/ ) script, an alternative to "lsof -i" for Solaris.
Glsof (http:/ / glsof. sourceforge. net/ ) is two separate utilities (Queries and Filemonitor) based on lsof.
Mkdir
42
Mkdir
The mkdir (make directory) command in the Unix, DOS, OS/2, and Microsoft Windows operating systems and in
the PHP scripting language is used to make a new directory. In DOS, OS/2 and Windows, the command is often
abbreviated to md.
Usage
Normal usage is as straightforward as follows:
mkdir name_of_directory
where name_of_directory is the name of the directory one wants to create. When typed as above (i.e. normal
usage), the new directory would be created within the current directory. On Unix and Windows (with Command
extensions enabled, the default ), multiple directories can be specified, and mkdir will try to create all of them.
Options
On Unix-like operating systems, mkdir takes options. Three of the most common options are:
-p: will also create all directories leading up to the given directory that do not exist already. If the given directory
already exists, ignore the error.
-v: display each directory that mkdir creates. Most often used with -p.
-m: specify the octal permissions of directories created by mkdir.
-p is most often used when using mkdir to build up complex directory hierarchies, in case a necessary directory is
missing or already there. -m is commonly used to lock down temporary directories used by shell scripts.
Examples
An example of -p in action is:
mkdir -p /tmp/a/b/c
If /tmp/a exists but /tmp/a/b does not, mkdir will create /tmp/a/b before creating /tmp/a/b/c.
And an even more powerful command, creating a full tree at once (this however is a Shell extension, nothing mkdir
does itself):
mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags}
If one is using variables with mkdir in a bash script, POSIX `special' built-in command 'eval' would serve its
purpose.
DOMAIN_NAME=includes,docs
eval "mkdir -p tmpdir/{trunk/sources/{${DOMAIN_NAME}},branches,tags}"
This will create:
tmpdir
________|______
| | |
branches tags trunk
|
Mkdir
43
sources
____|_____
| |
includes docs
History
In early versions of Unix (4.1BSD and early versions of System V), this command had to be setuid root as the kernel
did not have an mkdir syscall. Instead, it made the directory with mknod and linked in the . and .. directory
entries manually.
References
External links
Microsoft TechNet Mkdir article (http:/ / technet. microsoft. com/ en-us/ library/ bb490930. aspx)
mkdir (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ mkdir. html):make
directoriesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
mount
Before a user can access a file on a Unix-like machine, the file system that contains it needs to be mounted with the
mount command. Frequently mount is used for SD card, USB storage, DVD and other removable storage devices.
The mount command instructs the operating system that a file system is ready to use, and associates it with a
particular point in the overall file system hierarchy (its mount point) and sets options relating to its access. Mounting
makes file systems, files, directories, devices and special files available for use and available to the user. Its
counterpart umount instructs the operating system that the file system should be disassociated from its mount point,
making it no longer accessible and may be removed from the computer. It is important to umount a device before
removing it since changes to files may have only partially been written and are completed as part of the umount.
The mount and umount commands require root user privilege to effect changes. Alternately, specific privileges to
perform the corresponding action may have been previously granted by the root user. A file system can be defined as
user mountable in the /etc/fstab file by the root user.
Use
Display partitions on an device:
$ mount
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)
10.4.0.4:/srv/export/setup_server on /nfs/setup_server type nfs
(ro,addr=10.4.0.4)
The second partition of a hard disk is mounted:
mount
44
$ mount /dev/hda2 /media/PHOTOS
and unmounted (by referring to the physical disk partition) :
$ umount /dev/hda2
or (by referring to the mount point)
$ umount /media/PHOTOS
To remount a partition with specific options:
$ mount -o remount,rw /dev/hda2
Derivatives and wrappers
pmount is a wrapper around the standard mount program which permits normal users to mount removable devices
without a matching /etc/fstab entry. This provides a robust basis for automounting frameworks like GNOME's
Utopia project and keeps the usage of root to a minimum.
This package also contains a wrapper pmount-hal, which reads information such as device labels and mount options
from HAL and passes it to pmount.
The gnome-mount package contains programs for mounting, unmounting and ejecting storage devices. The goal
for gnome-mount is for GNOME software such as gnome-volume-manager and GNOME-VFS to use this instead of
invoking mount/umount/eject/pmount or direct HAL invoking methods. GNOME previously used pmount. Note,
gnome-mount is not intended for direct use by users.
All the gnome-mount programs utilize HAL methods and as such run unprivileged. The rationale for gnome-mount
is to have a centralized place (in GConf) where settings such as mount options and mount locations are
maintained.
[1]
As with all unix-like commands, the options are specific to the version of mount and are precisely detailed in its man
page.
In addition to the system call mount, the function mount_root() mounts the first, or root filesystem. In this context
mount is called by the system call setup.
References
[1] gnome-mount-0.6 (http:/ / www. linuxfromscratch.org/ blfs/ view/ svn/ gnome/ gnome-mount. html)
External links
mount(8) (http:/ / linux. die. net/ man/ 8/ mount)Linux Administration and Privileged Commands Manual
pmount(1) (http:/ / linux. die. net/ man/ 1/ pmount)Linux User Commands Manual
gnome-mount(1) (http:/ / linux. die. net/ man/ 1/ gnome-mount)Linux User Commands Manual
Mv
45
Mv
mv (short for move) is a Unix command that moves one or more files or directories from one place to another. Since
it can "move" files from one filename to another, it is also used to rename files. Using mv requires the user to have
write permission for the directories the file will move between. This is because mv changes the file's location by
editing the file list of each directory. When using mv command new file's timestamp is not updated.
Conflicting existing file
When a filename is moved to an existing filename (in the same directory), the existing file is deleted. If the existing
file is not writable but is in a directory that is writable, the mv command asks for confirmation (if run from a
terminal) before proceeding, unless the -f (force) option is used
move versus copy and remove
Usually moving files within the same file system is not the same as copying and then removing the original. First a
new link is added to the new directory then the original link is deleted. The data of file is not accessed. This is much
faster than physical copy and remove the file-content. The file still has the same inode.
When moving files to a different file system, all files are copied and then all files are removed. If the copy fails (as in
not enough space) none of the original files are removed and all of the copied files remain (and the volume remains
full!). If the files are on one volume, an out of space condition cannot occur.
You cannot copy a file if you do not have read permissions, but you can move it if you have write permission to its
old and new directories.
You can rename a directory you do not have write permission to, but you cannot move it to a different parent
directory because the directory entry ".." cannot be changed. If you lack write or execute permission to a non-empty
directory, you cannot delete this directory (since you cannot delete its contents).
Options
Most versions Single Unix Specification#1980s: Motivation of mv support:
-h help by displaying additional options supported. Use man mv for details for the version on the system you
are using.
-i interactively process, write a prompt to standard error before moving a file that would overwrite an existing
file. If the response from the standard input begins with the character`y' or `Y', the move is attempted. (overrides
previous -f or -n options.)
-n no overwriting of existing files. (overrides previous -f or -i options.)
-f force overwriting the destination (overrides previous -i or -n options).
-v verbose, shows filenames/directory names after they are moved.
Additional options (Use man mv for details):
-u update only when the original is newer than the destination or when the destination doesn't exist.
-b backup of existing destination using default ~ suffix.
Mv
46
Examples
mv myfile mynewfilename # renames 'myfile' to 'mynewfilename'.
mv myfile ~/myfile # moves 'myfile' from the current
directory to user's home directory.
mv myfile subdir/myfile # moves 'myfile' to 'subdir/myfile'
relative to the current directory.
mv myfile subdir # same as the previous command, filename
is implied to be the same.
mv myfile subdir/myfile2 # moves 'myfile' to 'subdir' named
'myfile2'.
mv be.03 /mnt/bkup/bes # copies 'be.03' to the mounted volume
'bkup' the 'bes' directory,
# then 'be.03' is removed.
mv afile another /home/yourdir/yourfile mydir
# moves multiple files to directory
'mydir'.
mv -v Jun* bkup/06 # displays each filename as it is moved to
the subdirectory 'bkup/06'.
mv /var/log/*z ~/logs # takes longer than expected if '/var' is
on a different file system,
# as it frequently is, since files will be
copied & deleted.

mv --help # shows a concise help about the syntax of
the command.
mv !(bkup) bkup # mv all files and dirs to the dir in the
same level
# move "all the files and
directories"(except bkup) to the "bkup" directory,
# (assuming , if "all the files and
directories" and "bkup" directory are in the same directory )
mv !(bkup1|bkup2) bkup2 # move "all the files and
directories"(except bkup1, bkup2) to the "bkup2" directory.
man mv # displays complete manual for mv.

Mv
47
References
mv
[1]
:move filesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
mv(1)
[2]
:move (rename) filesLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ mv. html
[2] http:/ / linux.die. net/ man/ 1/ mv
pax
pax is an archiving utility created by POSIX and defined by the POSIX.1-2001
[1]
standard. Rather than sort out the
incompatible options that have crept up between tar and cpio, along with their implementations across various
versions of UNIX, the IEEE designed a new archive utility. The name "pax" is an acronym for portable archive
exchange. Furthermore, "pax" means "peace" in Latin, so its name implies that it shall create peace between the
tar and cpio format supporters. The command invocation and command structure is somewhat a unification of
both tar and cpio.
Features
Modes
pax has four general modes which are invoked by a combination of the -r ("read") option and -w ("write") option.
This table summarizes the modal behaviour:
Option Mode Description
(none) "list" shows contents of archive, does not modify or extract anything.
-r "read" reads and extracts contents of an archive
-w "write" creates archives or appends files to an archive
-rw "copy" reads and copies files and directory tree to a specified directory
Examples:
List contents of an archive:
pax < archive.tar
Extract contents of an archive into the current directory:
pax -r < archive.tar
Create an archive of the current directory:
When used in the cpio style, the find command can be used to get a list of files to be archived:
find . -depth -print | pax -wd > archive.tar
Copy current directory tree to another location:
The target directory must exist beforehand!
find . -depth -print | pax -rwd target_dir
pax
48
Command invocation
pax can be either used in a similar manner as cpio or tar. The cpio syntax takes a list of files from standard
input (stdin) when archiving or an already existing archive, when in listing contents or extracting files:
find . -depth -print | pax -wd > archive.tar
and
pax -r < archive.tar
respectively.
It is possible to invoke these commands in a tar-like syntax as well:
pax -wf archive.tar .
and
pax -rf archive.tar
And for clarity and completeness:
Listing files from an archive:
pax -f archive.tar
and "copy" mode:
pax -rw . archive_dir
The -f option specifies which archive to use, instead of writing to stdio or reading from stdin. Also note the -d
option when using pax together with find, this keeps pax from traversing directory trees.
Compression
Most implementations of pax use the -z (gzip) and -j (bzip2) switches for compression, this feature however, is
not specified by POSIX. It is important to note that pax cannot append to compressed archives.
Example for extracting a gziped archive:
pax -rzf archive.tar.gz
Due to the possibility to use pax in a cpio-like fashion, it is possible to use whatever compression program, as an
example xz is used here:
pax -w . | xz > archive.tar.xz
and listing an xz-compressed archive:
xzcat archive.tar.xz | pax
pax
49
Format support
As of September 2009, the version of pax included with most Linux distributions (a derivative of an old MirBSD
pax
[2]
) supports the following formats, selectable via the -x option:
cpio - The extended cpio interchange format specified in the IEEE Std 1003.2 ("POSIX.2") standard.
bcpio - The old binary cpio format.
sv4cpio - The System V release 4 cpio.
sv4crc - The System V release 4 cpio with file crc checksums.
tar - The old BSD tar format as found in BSD4.3.
ustar (default) - The tar interchange format specified in the IEEE Std 1003.2 ("POSIX.2") standard.
Notably the pax format itself is not supported by this version of pax.
[3]
Other implementations, such as Heirloom pax
support further formats,
[4]
including the pax file format itself.
Multiple volumes
pax supports archiving on multiple volumes. When the end of a volume is reached, the following message appears:
pax -wf /dev/fd0 .
ATTENTION! pax archive volume change required.
/dev/fd0 ready for archive volume: 2
Load the NEXT STORAGE MEDIA (if required) and make sure it is WRITE ENABLED.
Type "y" to continue, "." to quit pax, or "s" to switch to new device.
If you cannot change storage media, type "s"
Is the device ready and online? >
When restoring an archive from multiple media, pax asks for the next media in the same fashion, when the end of the
media is reached before the end of the archive.
Standardization, reception and popularity
Despite being standardized in 2001 by IEEE, as of 2010, pax enjoys relatively little popularity and penetration rate.
pax is required to be present in all conformant systems by Linux Standard Base since version 3.0 (released on July 6,
2005),
[5]
but so far few Linux distributions ship and install it by default. However, most distributions include pax as
a separately installable package.
pax has also been present in Windows NT, where it is limited to file archives (tapes not supported). It was later
moved to the Interix subsystem. It does not support archiving or restoring Win32 ACLs.
[6]
Packages handled by the Installer (OS X) often carry the bulk of their contents in an Archive.pax.gz file that may be
read using the pax utility.
pax
50
Notes
[1] The Open Group Base Specifications Issue 6 (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ pax. html) - POSIX.1-2001
(IEEE Std 1003.1) Copyright 2001-2004 The IEEE and The Open Group (http:/ / www. opengroup. org/ )
[2] Launchpad page for pax (https:/ / launchpad. net/ paxmirabilis)
[3] Launchpad - pax lacks of support for "pax" format, fails LSB (https:/ / bugs. launchpad. net/ paxmirabilis/ + bug/ 456405)
[4] Heirloom pax man page (http:/ / heirloom.sourceforge. net/ man/ pax. 1. html)
[5] Release notes for LSB 3.0 (http:/ / www. linuxfoundation. org/ en/ ReleaseNotes3#Commands) note that pax was added: LSB 3.0. Commands
and Utilities (http:/ / refspecs.linux-foundation.org/ LSB_3. 0. 0/ LSB-Core-generic/ LSB-Core-generic/ command. html#CMDUTIL)
requires pax, but LSB 2.1.0. Commands and Utilities (http:/ / refspecs. linux-foundation. org/ LSB_2. 1. 0/ LSB-Core-generic/
LSB-Core-generic/ command.html#CMDUTIL) does not require it
[6] http:/ / support. microsoft.com/ kb/ 246322
External links
Archiving with Pax (http:/ / onlamp. com/ pub/ a/ bsd/ 2002/ 08/ 22/ FreeBSD_Basics. html) Article in FreeBSD
basics on ONLamp.com (http:/ / onlamp. com/ ), by Dru Lavigne (http:/ / onlamp. com/ pub/ au/ 73) (2002-08-22)
Pwd
In Unix-like and some other operating systems, the pwd command (print working directory) is used to output the
path of the current working directory.
The command is a shell builtin in certain Unix shells such as sh, and bash. It can be implemented easily with the
POSIX C functions getcwd() and/or getwd().
The equivalent on DOS (COMMAND.COM) and Microsoft Windows (cmd.exe) is the "cd" command with no
arguments. Windows PowerShell provides the equivalent "Get-Location" cmdlet with the standard aliases "gl"
and "pwd". The OpenVMS equivalent is "show default".
Example
If the following is input into a terminal:
$ pwd
/home/foobar
and the computer prints out /home/foobar, that means that the directory the user is currently in is
/home/foobar. In the following example, the user is located in the directory /usr/local/bin, uses the
command pwd, uses the command cd .. to move back to the parent directory and then uses pwd again:
$ pwd
/usr/local/bin
$ cd ..
$ pwd
/usr/local
Pwd
51
References
pwd
[1]
:return working directory nameCommands & Utilities Reference, The Single UNIX Specification,
Issue 7 from The Open Group
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ pwd. html
rm
rm (short for remove) is a basic UNIX command used to remove objects such as files, directories, device nodes,
symbolic links, and so on from the filesystem. To be more precise, rm removes references to objects from the
filesystem, where those objects might have had multiple references (for example, a file with two different names),
and the objects themselves are discarded only when all references have been removed and no programs still have
open handles to the objects.
This allows for scenarios where a program can open a file, immediately remove it from the filesystem, and then use
it for temporary space, knowing that the file's space will be reclaimed after the program exits, even if it exits by
crashing.
rm generally does not destroy file data, since its purpose is really merely to unlink references, and the filesystem
space freed may still contain leftover data from the removed file. This can be a security concern in some cases, and
hardened versions sometimes provide for wiping out the data as the last link is being cut, and programs such as shred
are available which specifically provide data wiping capability.
Example
To remove a file named "foo" from a directory one could type:
% rm foo
Normally, no output is produced by rm, since it typically only generates messages in the event of an error. The -v
option can be used to get rm to detail successful removal actions.
Users concerned about removing files unexpectedly - particularly when using wildcards - sometimes use the -i
option to cause rm to verify each removal in advance, although this method has its own problems.Wikipedia:Please
clarify
% rm -i foo
remove foo? y
rm
52
Context
rm is generally only seen on UNIX-derived operating systems, which typically do not provide for recovery of
deleted files through a mechanism like the recycle bin,
[1]
hence the tendency for users to enclose rm in some kind of
wrapper to limit accidental file deletion.
There are undelete utilities that will attempt to reconstruct the index and can bring the file back if the parts were not
reused.
Options
Common options that rm accepts include:
-r, which removes directories, removing the contents recursively beforehand (so as not to leave files without a
directory to reside in) ("recursive")
-i, which asks for every deletion to be confirmed ("interactive")
-f, which ignores non-existent files and overrides any confirmation prompts ("force"), although it will not remove
files from a directory if the directory is write protected.
rm can be overlain by a C shell alias or Bourne shell function of "rm -i" so as to avoid accidental deletion of files. If
a user still wishes to delete a large number of files without confirmation, they can manually cancel out the -i
argument by adding the -f option (as the option specified later on the expanded command line "rm -i -f" takes
precedence). Unfortunately this approach generates dangerous habits towards the use of wildcarding, leading to its
own version of accidental removals.
rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Unix
disasters. The rm -rf variant of the command, if run by a superuser on the root directory, would cause the
contents of nearly every writable mounted filesystem on the computer to be deleted, up to the point the system itself
crashes from missing some crucial file, directory, or the like.
rm is often used in conjunction with xargs to supply a list of files to delete:
xargs rm < filelist
Or, to remove all PNG images in all directories below the current one:
find . -name '*.png' -print0 | xargs -0 rm
Permissions
Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute
permission, in order to enter the directory in the first place). (Note that, confusingly for beginners, permissions on
the file itself are irrelevant. However, GNU rm asks for confirmation if a write-protected file is to be deleted, unless
the -f option is used.)
To delete a directory (with rm -r), one must delete all of its contents recursively. This requires that one must have
read and write and execute permission to that directory (if it's not empty) and all non-empty subdirectories
recursively (if there are any). The read permissions are needed to list the contents of the directory in order to delete
them. This sometimes leads to an odd situation where a non-empty directory cannot be deleted because one doesn't
have write permission to it and so cannot delete its contents; but if the same directory were empty, one would be able
to delete it.
If a file resides in a directory with the sticky bit set, then deleting the file requires one to be the owner of the file.
rm
53
Protection of the filesystem root
Sun Microsystems introduced "rm -rf /" protection in Solaris 10, first released in 2005. Upon executing the
command, the system now reports that the removal of / is not allowed.
[2]
Shortly after, the same functionality was
introduced into FreeBSD version of rm utility. GNU rm refuses to execute rm -rf / if the
--preserve-root option is given, which has been the default since version 6.4 of GNU Core Utilities was
released in 2006.
User-proofing
Systems administrators, designers, and even users often attempt to defend themselves against accidentally deleting
files by creating an alias or function along the lines of:
alias rm="rm -i"
rm () { /bin/rm -i "$@" ; }
This results in rm asking the user to confirm on a file-by-file basis whether it should be deleted, by pressing the Y
or N key. Unfortunately, this tends to train users to be careless about the wildcards they hand into their rm
commands, as well as encouraging a tendency to alternately pound y and the return key to affirm removes - until
just past the one file they needed to keep
[citation needed]
. Users have even been seen going as far as "yes | rm
files", which automatically inserts "yes" for each file.
[citation needed]
.
A compromise that allows users to confirm just once, encourages proper wildcarding, and makes verification of the
list easier can be achieved with something like:
if [ -n "$PS1" ] ; then
rm ()
{
ls -FCsd "$@"
echo 'remove[ny]? ' | tr -d '\012' ; read
if [ "_$REPLY" = "_y" ]; then
/bin/rm -rf "$@"
else
echo '(cancelled)'
fi
}
fi
It's important to note that this function should not be made into a shell script, which would run a risk of it being
found ahead of the system rm in the search path, nor should it be allowed in non-interactive shells where it could
break batch jobs. Enclosing the definition in the if [ -n "$PS1" ] ; then .... ; fi construct protects
against the latter.
There exist third-party wrappers that prevent accidental deletion of important files, like "safe-rm".
[3]
rm
54
History
On some old versions of Unix, the rm command would delete directories if they were empty.
[4]
This behaviour can
still be obtained in modern versions of rm, such as the GNU coreutils version, with the -d flag. On modern UNIX
and Linux platforms, this functionality has been replaced by the rmdir command.
References
[1] http:/ / www. faqs.org/ faqs/ unix-faq/ faq/ part3/ section-6. html
[2] Meddling in the Affairs of Wizards (http:/ / blogs. oracle. com/ jbeck/ date/ 20041001#rm_rf_protection)
[3] https:/ / launchpad.net/ safe-rm
[4] Unix 8th ed. rm man page (http:/ / man.cat-v. org/ unix_8th/ 1/ rm)
External links
rm (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ rm. html):remove directory
entriesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Rmdir
rmdir (or rd) is a command which will remove an empty directory on a Unix, DOS, OS/2 or Microsoft Windows
operating system. In Unix, Linux, and OS X, it is case sensitive, whereas DOS, OS/2 and Windows (95, 98, ME),
you can type the characters in any combination of upper case and lower case letters, and rd/rmdir will recognize and
remove that directory. Normal usage is straightforward where one types:
rmdir name_of_directory
where name_of_directory corresponds with the name of the directory one wishes to delete. There are options to this
command such as -p in Unix which removes parent directories if they are also empty.
For example:
rmdir -p foo/bar/baz
will first remove baz/, then bar/ and finally foo/ thus removing the entire directory tree specified in the command
argument.
rmdir will not remove a directory if it is not empty in UNIX. The correct
[citation needed]
way to remove a directory and
all its contents recursively is with the rm command. For example:
rm -r foo/bar/baz
rm -rf foo/bar/baz
The DOS equivalent of this command is deltree, or in Microsoft Windows.
rd /s directory_name
Rmdir
55
NT functionality
Windows based on the NT kernel (XP, Vista, 7, 8, Server 2003/2008) are case insensitive, just like their earlier
predecessors, unless two files of the same name and different case exist. Then case sensitivity applies when selecting
which file to use, or if the case does not match either file, one may be chosen by Windows.
Having two files named the same with different case sensitivity is allowed either when Windows Services for Unix
is installed or when the registry settings are set to allow it.
An example of the security risk is:
Using rd/rmdir and two directories with the same name and different case sensitivities exist, one of which contains
valid data and/or programs, and the other contains incriminating materials and/or malware. If rd/rmdir gets executed
without regard to case sensitivity and Windows chooses the legitimate folder to delete, the only folder left is the
undesired one. Windows then uses this folder instead of the previously legitimate one to execute programs, and one
may be led to believe it contains legitimate data.
References
rmdir
[1]
The program's manpage
rmdir
[2]
Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
External links
Microsoft TechNet Rmdir article
[3]
References
[1] http:/ / www. linuxmanpages.com/ man1/ rmdir. 1. php
[2] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ rmdir. html
[3] http:/ / technet. microsoft. com/ en-us/ library/ cc754993.aspx
size
56
size
size is a command line utility originally written for use with the Unix-like operating systems. It processes one or
more ELF files and its output are the dimensions (in bytes) of the text, data and uninitialized sections, and their total.
Common use:
$ size <option> <filename> ...
Here follows some examples on Solaris (/usr/ccs/bin/size); options and syntax may vary on different Operating
Systems:
$ size /usr/ccs/bin/size
9066 + 888 + 356 = 10310
With -f option name and size of each section are printed out, plus their total:
$ size -f /usr/ccs/bin/size
17(.interp) + 636(.hash) + 1440(.dynsym) + 743(.dynstr) +
64(.SUNW_version) + 48(.rela.ex_shared) + 24(.rela.bss) +
336(.rela.plt) + 4760(.text) +
80(.init) + 80(.fini) + 4(.exception_ranges) + 28(.rodata) +
590(.rodata1) + 12(.got) + 388(.plt) + 192(.dynamic) + 40(.ex_shared) +
112(.data) +
140(.data1) + 352(.bss) = 10086
With -F option size and permission flag of each sections are printed out, plus their total:
$ size -F /usr/ccs/bin/size
9066(r-x) + 1244(rwx) = 10470
References
"size - Linux Command"
[1]
. Retrieved November 17, 2010.
References
[1] http:/ / linux.about. com/ library/ cmd/ blcmdl1_size. htm
split
57
split
split is a Unix utility most commonly used to split a file into two or more smaller files.
Usage
The command-syntax is:
split [OPTION] [INPUT [PREFIX]]
The default behavior of split is to generate output files of a fixed size, default 1000 lines. The files are named by
appending aa, ab, ac, etc. to output filename. If output filename is not given, the default filename of x is used, for
example, xaa, xab, etc. When a hyphen (-) is used instead of input filename, data is derived from standard input.
To split filename to parts each 50 MB named partaa, partab, partac,....
split -b50m filename part
To join the files back together again use the cat command
cat xaa xab xac > filename
or
cat xa[a-c] > filename
or even
cat xa? > filename
Additional program options permit a maximum character count (instead of a line count), a maximum line length,
how many incrementing characters in generated filenames, and whether to use letters or digits.
Manual
split(1)
[1]
:split a file into piecesLinux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ split
tee
58
tee
The usage of tee: The output of ls -l is redirected to tee which copies them to the file
file.txt and to the pager less. The name tee comes from this scheme - it looks like the
capital letter T
In computing, tee is a command in
command-line interpreters (shells)
using standard streams which reads
standard input and writes it to both
standard output and one or more files,
effectively duplicating its input. It is
primarily used in conjunction with
pipes and filters. The command is
named after the T-splitter used in
plumbing.
Description and syntax
tee is normally used to split the output
of a program so that it can be both
displayed and saved in a file. The
command can be used to capture
intermediate output before the data is altered by another command or program. The tee command reads standard
input, then writes its content to standard output. It simultaneously copies the result into the specified file(s) or
variables. The syntax differs depending on the command's implementation:
Unix-like
tee [ -a ] [ -i ] [ File ... ]
Arguments:
File One or more files that will receive the "tee-d" output.
Flags:
-a Appends the output to the end of File instead of writing over it.
-i Ignores interrupts.
The command returns the following exit values (exit status):
0 The standard input was successfully copied to all output files.
>0 An error occurred.
Using process substitution lets more than one process read the standard output of the originating process. Read this
example from GNU Coreutils, tee invocation
[1]
.
Note: If a write to any successfully opened File operand is not successful, writes to other successfully opened File
operands and standard output will continue, but the exit value will be >0.
tee
59
4DOS and 4NT
TEE [/A] file...
Arguments:
file One or more files that will receive the "tee'd" output.
Flags:
/A Append the pipeline content to the output file(s) rather than overwriting them.
Note: When tee is used with a pipe, the output of the previous command is written to a temporary file. When that
command finishes, tee reads the temporary file, displays the output, and writes it to the file(s) given as command-line
argument.
Windows PowerShell
tee [-FilePath] <String> [-InputObject <PSObject>]
tee -Variable <String> [-InputObject <PSObject>]
Arguments:
-InputObject <PSObject> Specifies the object input to the cmdlet. The parameter accepts variables that
contain the objects and commands or expression that return the objects.
-FilePath <String> Specifies the file where the cmdlet stores the object. The parameter accepts wildcard
characters that resolve to a single file.
-Variable <String> A reference to the input objects will be assigned to the specified variable.
Note: tee is implemented as a ReadOnly command alias. The internal cmdlet name is
Microsoft.PowerShell.Utility\Tee-Object.
Examples
Unix-like
To view and save the output from a command (lint) at the same time:
lint program.c | tee program.lint
This displays the standard output of the command lint program.c at the computer, and at the same time saves
a copy of it in the file program.lint. If a file named program.lint already exists, it is deleted and replaced.
To view and append the output from a command to an existing file:
lint program.c | tee -a program.lint
This displays the standard output of the lint program.c command at the computer and at the same time
appends a copy of it to the end of the program.lint file. If the program.lint file does not exist, it is
created.
To allow escalation of permissions:
echo "Body of file..." | sudo tee root_owned_file > /dev/null
This example shows tee being used to bypass an inherent limitation in the sudo command. sudo is unable to pipe the
standard output to a file. By dumping its stdout stream into /dev/null, we also suppress the mirrored output in the
tee
60
console.
4DOS and 4NT
This example searches the file wikipedia.txt for any lines containing the string "4DOS", makes a copy of the
matching lines in 4DOS.txt, sorts the lines, and writes them to the output file 4DOSsorted.txt:
C:\>find "4DOS" wikipedia.txt | tee 4DOS.txt | sort > 4DOSsorted.txt
Windows PowerShell
To view and save the output from a command at the same time:
ipconfig | tee OutputFile.txt
This displays the standard output of the command ipconfig at the console window, and simultaneously saves a
copy of it in the file OutputFile.txt.
To display and save all running processes, filtered so that only programs starting with svc and owning more than
1000 handles are outputted:
Get-Process | where-Object { $_.Name -like "svc*" } | Tee-Object ABC.txt | Where-Object { $_.Handles -gt 1000 }
This example shows that the piped input for tee can be filtered and that tee is used to display that output, which is
filtered again so that only processes owning more than 1000 handles are displayed, and writes the unfiltered output
to the file ABC.txt.
References
tee
[2]
:duplicate standard inputCommands & Utilities Reference, The Single UNIX Specification, Issue 7
from The Open Group
GNU tee manual
[1]
[1] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ tee-invocation. html
[2] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ tee. html
External links
An introduction on Linux I/O Redirection "Linux I/O Redirection" (http:/ / wadhavankar. org/ tn/ linux/ user/
standardIo. php) with tee
touch
61
touch
touch is a standard Unix program used to change a file's access and modification timestamps. It is also used to create
a new empty file.
History
A touch utility appeared in Version 7 AT&T UNIX. The version of touch bundled in GNU coreutils was written
by Paul Rubin, Arnold Robbins, Jim Kingdon, and David MacKenzie.
Specification
The Single Unix Specification (SUS) specifies that touch should change the access times, modification times, or
both, for a file. The file is identified by a pathname supplied as a single argument. It also specifies that if the file
identified does not exist, the file is created and the access and modification times are set as specified. If no new
timestamps are specified, touch uses the current time.
Usage
The SUS mandates the following options:
-a, change the access time only
-c, if the file does not exist, do not create it and do not report this condition
-d date_time, use the date_time specified to update the access and modification times
-m, change the modification time only
-r file, use the access and modification times of file
-t time, use the time specified (in the format below) to update the access and modification times
The time is specified in the format [[cc]yy]MMDDhhmm[.ss] where MM specifies the two-digit numeric month, DD
specifies the two-digit numeric day, hh specifies the two-digit numeric hour, mm specifies the two-digit numeric
minutes. Optionally ss specifies the two-digit seconds, cc specifies the first two digits of the year, and yy specifies
the last two digits of the year.
Note that if invoked without these options, the standard specifies that the current date and time are used to change
the access and modification times. This behaviour simulates an update to a file without having to change it, which
may be desirable in certain situations (see the example below).
Other Unix and Unix-like operating systems may add extra options. For example, GNU touch adds a -d option,
which enables time input in formats other than that specified.
Note that the dates of creation of symbolic links are not changed .
touch
62
Examples
The simplest use case for touch is this:
$ touch myfile.txt
Touch doesn't modify the contents of myfile.txt; it just updates the timestamp of the file to the computer's current
date and time, whatever that happens to be. Or, if myfile.txt does not exist it is created, with zero length.
Here's an example that shows why we might want to do this. We wish to re-make a software project we are writing.
We have changed the makefile and need to run make again. However, if we run make immediately we find that
$ make
make: nothing to be done for `all'
Since the source code file is already updated, we will need to use touch to simulate a file update, so make will run
and recompile the software.
$ touch project.c
$ make
Then make will rebuild the project.
The creation date of links are unchanged. For example, on the following system, the date is the 20th Feb 2012, but a
link was created on 25th Jan 2012. Despite touching the link, the date of this remains at 22nd Jan 2012 - it not
changed to the 20th Feb 2012.
$ date
Wed Feb 20 09:45:50 GMT 2012
$ ls -l libcidn.so
lrwxrwxrwx 1 foobar foobar 22 Jan 25 01:41 libcidn.so ->
../../lib/libcidn.so.1
$ touch libcidn.so
$ ls -l libcidn.so
lrwxrwxrwx 1 foobar foobar 22 Jan 25 01:41 libcidn.so ->
../../lib/libcidn.so.1
Although commands like cp, grep, chmod etc. have a recursive switch (-r or -R or both) to apply the
command recursively to the subdirectories, touch doesn't have this functionality yet (as of February, 2013). It can
be accomplished by the following:
$ find . -exec touch {} +
or to recursively set the date to be 5th July 2023, and the time 0201, the following will work
find . -exec touch 0705020123 {} +
touch
63
Other operating systems
Programs that perform similar operations as the Unix touch utility are available for other operating systems,
including Microsoft Windows and Mac OS.
Windows
touch dot exe
[1]
- free and open source, for Windows.
File Date Touch
[2]
- freeware for Windows
Synesis Software File Touch Shell Extension
[3]
- freeware for Windows
The ntouch/dtouch page
[4]
External links
touch specification from the Single Unix Specification
[5]
examples showing how to use touch
[6]
Manual pages
touch
[7]
manual page from GNU coreutils
touch
[8]
manual page from OpenBSD
References
[1] http:/ / www. binarez. com/ touch_dot_exe/
[2] http:/ / date. bghot. com
[3] http:/ / shellext.com/ #metouch
[4] http:/ / www. flos-freeware. ch/ archive. html
[5] http:/ / pubs. opengroup. org/ onlinepubs/ 9699919799/ utilities/ touch. html
[6] http:/ / web. archive. org/ web/ 20091227161436/ http:/ / www. bellevuelinux. org/ touch. html
[7] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ touch-invocation. html
[8] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=touch
type
64
type
type is a Unix command that describes how its arguments would be interpreted if used as command names.
Function
Where applicable, type will display the command name's path. Possible command types are:
shell built-in
function
alias
hashed command
keyword
The command returns a non-zero exit status if command names cannot be found.
Examples
$ type test
test is a shell builtin
$ type cp
cp is /bin/cp
$ type unknown
-bash: type: unknown: not found
$ type type
type is a shell builtin
$ type -a gzip
gzip is /opt/local/bin/gzip
gzip is /usr/bin/gzip
Umask
65
Umask
In computing, umask is a command that determines the settings of a mask that controls which file permissions are
set for files and directories when they are created. It also refers to a function that sets the mask, and to the mask
itself, which is formally known as the file mode creation mask.
In UNIX, each file and directory has sets of attributes which control who is permitted access (aka modes). When a
file or directory is created the permissions to be set are specified. The mask restricts which permissions are allowed.
If the mask bit is set to "1", the corresponding permission will be disabled. For a bit set to "0", the corresponding
permission will be determined by the program and the system. In other words, the mask acts as a last-stage filter that
strips away permissions as a file or directory is created where the bit that is set to a "1". Since the permissions are
categorized by owner, group and other "the mask" helps with defaulting access. The modes can be changed using
chmod.
Each program (technically called a process) has its own mask, which is applied whenever that process creates a new
file. Each process is able to change the settings of its own mask using a function call. When the process is a shell, the
mask is set with the umask command. When a shell, or any other process, launches a new process, the child process
inherits the mask from its parent process. The mask does not work retroactively, that is, changes made to the mask
only affect new files created after the changes are made. Generally, the mask only affects file permissions during the
creation of new files and has no effect when file permissions are changed in existing files, however, in some specific
cases it can help determine permissions when file permissions are changed in existing files using the chmod
command.
The mask is always stored as a group of bits. It may be displayed in binary, octal, or symbolic notation. Usually, it is
represented in octal notation (e.g., 0754) or symbolic notation (e.g., u=wrx,g=rx,o=r) (see symbolic notation below
for details). The umask command uses the same octal and symbolic notation as the chmod command.
The umask command is used with Unix-like operating systems and the umask function is defined in the POSIX.1
specification.
History
The mask, the umask command, and the umask function were not part of the original implementation of UNIX. The
operating system evolved in a relatively small computer center environment where security was not an issue.
Unix eventually grew to serve hundreds of users from different organizations. At first, developers made creation
modes for key files more restrictive, especially for cases of actual security breaches, but this was not a generally (or
universally) workable solution.
The mask and the umask command were introduced around 1978 between the sixth edition and the eighth edition of
the operating system, so it could allow sites, groups, and individuals to choose their own defaults. The mask has
since been implemented in most, if not all, of the contemporary implementations of UNIX-like (POSIX) operating
systems. Typically for operating systems that don't support umask there is a toolkit that is available that has the
command.
Umask
66
Shell command
In a shell, the mask is set by using the umask command. The syntax of the command is:
umask [-S ] [maskdefinition]
(the items within the [brackets] are optional)
Displaying the current mask
If the umask command is invoked without any arguments, it will display the current mask. The output will be in
either octal or symbolic notation depending on the operating system used, however, invoking umask with the -S
argument (i.e., umask -S) will force it to display the current mask in symbolic notation. For example:
$ umask
0022
$ umask -S
u=rwx,g=rx,o=rx
Setting the mask using octal notation
If the umask command is invoked with an octal argument, it will directly set the bits of the mask to that argument:
$ umask # display current value
0022
$ umask 0077 #set to prevent files from being created with any
access by group members or others
$ umask #display confirms new setting
0077
$ umask -S # display symbolically
u=rwx,g=,o=
If fewer than 4 digits are entered, leading zeros are assumed. An error will result if the argument is not a valid octal
number (or symbolic argument see below) or if it has more than 4 digits.
[1]
Octal codes used in the command
Octal digit in
umask command
Prevents (if requested)
7 read, write and execute
6 read and write
5 read and execute
4 read only
3 write and execute
2 write only
1 execute only
0 no permissions
Umask
67
Setting the mask using symbolic notation
If the umask command is invoked with an argument using symbolic notation, it will add to, substract from, or
directly set the bits of the mask as directed by the [maskdefinition] argument of the umask command. The symbolic
notation is composed of permission-symbols, user-class-letters, and operators.
The syntax of the [maskdefinition] in the umask command looks like this:
umask [user-class-letters] operator permission-symbols[,]...
There are no spaces allowed between the arguments. The only space is between the umask command itself and the
arguments.
The permission-symbols indicate which file permission settings are to be allowed or prohibited by the mask when
files are subsequently created. There are three basic file permission modes which correspond to the basic
permissions. They are r (read), w (write), and x (execute). The more esoteric symbols are X (special execute), s
(setuid/guid), t (sticky bit). (See File permissions for more details.)
Symbol Name Description
r read read a file or list a directory's contents
w write write to (or delete) a file or directory
x execute execute a file or recurse a directory tree
X special
execute
which is not a permission in itself but rather can be used instead of x. It allows the application of execute permissions to
directories regardless of their current permissions and allows the application of execute permissions to a file which already
has at least 1 execute permission bit already set (either user, group or other). It is only really useful when used with '+' d
s setuid/gid See File permissions for details.
t sticky See File permissions for details.
The permissions of a file are applied to three different classes of users: the user (the file's owner), the group, and
others. (See File permissions for details.) Those user classes are represented by one or more of the following letters:
Letter Class Description
u user the owner of the file
g group users who are members of the file's group
o others users who are not the owner of the file or members of the group
a all all three of the above, it is the same as ugo. (This is the default if no class is specified in the umask command.)
The umask command uses an operator to specify how the permission modes of the mask should be adjusted. The
following operators are accepted:
Operator How the mask works after the command in issued
+ During file creation, the mask will allow the specified file permissions to be enabled for the specified user classes; (permissions that are
not specified are unchanged in the mask)
- During file creation, the mask will prohibit the specified file permissions from being enabled for the specified user classes; (permissions
that are not specified are unchanged in the mask)
= During file creation, the mask will allow the specified file permissions to be enabled for the specified user classes; permissions not
specified will be prohibited by the mask during file creation
For example:
umask u+w
Umask
68
This would set the mask so that it would, when files are subsequently created, allow write permission to be enabled
for the user (file owner). The rest of the bits in the mask would be unchanged.
Multiple changes can be specified by separating multiple sets of symbolic notation with commas. (Spaces are not
allowed within the arguments.) For example:
umask u-x,g=r,o+w
This would set the mask so that it would, when subsequent files are created:
1. prohibit the execute permission from being set for the file's owner (user), while leaving the rest of the owner bits
in the mask unchanged;
2. allow the read permission to be enabled for the group, while prohibiting write and execute permission for the
group;
3. allow the write permission to be enabled for others, while leaving the rest of the other bits in the mask
unchanged.
Command line examples
Here are more examples of using the umask command.
umaskcommandissued How the mask works after the command is issued
umask a+r allows read permission to be enabled for all user classes; the rest of the mask bits are unchanged
umask a-x prohibits enabling execute permission for all user classes; the rest of the mask bits are unchanged
umask a+rw allows read or write permission to be enabled for all user classes; the rest of the mask bits are unchanged
umask +rwx allows read, write or execute permission to be enabled for all user classes; (Note: On some UNIX platforms, this
will restore the mask to a default.)
umask u=rw,go= allow read and write permission to be enabled for the owner, while prohibiting execute permission from being
enabled for the owner; prohibit enabling any permissions for the group and others
umask u+w,go-w allow write permission to be enabled for the owner; prohibit write permission from being enabled for the group and
others;
umask -S display the current umask in symbolic notation
umask 777 disallow read, write, and execute permission for all
umask 000 allow read, write, and execute permission for all (security risk)
umask 113 allow read or write permission to be enabled for the owner and the group, but not execute permission; allow read
permission to be enabled for others, but not write or execute permission
umask 0755 equivalent to u-rwx (4+2+1),go=w (4+1 & 4+1). (The 0 specifies that special modes may be enabled if
allowed by the OS.)
Function call
The mask may be set using a function call. The GNU functions are declared in sys/stat.h. The function is:
mode_t umask (mode_t mask)
The umask function will set the mask of the current process to mask, and return the previous value of the mask.
Here is an example from GNU.org which shows how to read the mask without changing it permanently:
mode_t
read_umask (void) {
mode_t mask = umask (0);
Umask
69
umask (mask);
return mask;
}
However, on GNU/Hurd systems it is better to use the getumask function if reading the mask value is the only
requirement, because it is reentrant.
mode_t getumask (void)
Returns the current value of the mask for the current process. (Note: The getumask function is a GNU extension and
is only available on GNU/Hurd systems.
Mask effect
The mask is applied whenever a file is created. If the mask has a bit set to "1", that means the corresponding file
permission will always be disabled when files are subsequently created. A bit set to "0" in the mask means that the
corresponding permission will be determined by the requesting process and the OS when files are subsequently
created. In other words, the mask acts as a last-stage filter that strips away permissions as a file is created; each bit
that is set to a "1" strips away that corresponding permission for the file.
Truth table
Here is the truth table for the masking logic. Each bit in the requesting process' file permission mode is operated on
by the mask using this logic to yield the permission mode that is applied to the file as it is created. (p is a bit in the
requested file permission mode of a process that is creating a file; q is a bit in the mask; r is the resulting bit in the
created file's permission mode)
p q r
T T F
T F T
F T F
F F F
How the mask is applied
Programmatically, the mask is applied by the OS by first negating (complementing) the mask, and then performing a
logical AND with the requested file mode. In the [probably] first UNIX manual to describe its function, the manual
says,
"the actual mode... of the newly-created file is the logical and of the given mode and the complement of the
argument. Only the low-order 9 bits of the mask (the protection bits) participate. In other words, the mask
shows [indicates] the bits to be turned off when files are created."
UNIX Eighth Edition Manual, Bell Labs UNIX (manual), AT&T Laboratories
Umask
70
How umask (in octal) translates to full (r,w,x) permissions.
Mask
digit
(octal)
Mask
digit
(binary)
Mask digit
negated (binary)
Logical AND
with
"rwx" request
[2]
0 000 111 rwx
1 001 110 rw-
2 010 101 r-x
3 011 100 r--
4 100 011 -wx
5 101 010 -w-
6 110 001 --x
7 111 000 ---
Logic
The mask is applied using boolean logic known as material nonimplication or abjunction. It is represented in logic
notation as:
C: (P&(~Q))
This says that the file's permission mode (C) is a result of a logical AND operation between the negation of the mask
(Q), and the process' requested permission mode setting (P).
Exceptions
Note: Many operating systems do not allow a file to be created with execute permissions. In these environments,
newly created files will always have execute permission disabled for all users.
The mask is generally only applied to functions that create a new file, however, there are exceptions. For example,
when using UNIX and GNU versions of chmod to set the permissions of a file, and symbolic notation is used, and no
user is specified, then the mask is applied to the requested permissions before they are applied to the file. For
example:
$ umask 0000
$ chmod +rwx filename
$ ls -l filename
-rwxrwxrwx filename
$ umask 0022
$ chmod +rwx filename
$ ls -l filename
-rwxr-xr-x filename
Umask
71
Processes
Each process has its own mask, which is applied whenever the process creates a new file. When a shell, or any other
process, spawns a new process, the child process inherits the mask from its parent process. When the process is a
shell, the mask is changed by the umask command. As with other processes, any process launched from the shell
inherits that shell's mask.
Mount option
In the Linux kernel, the fat, hfs, hpfs, ntfs, and udf file system drivers support a umask mount option,
which controls how the disk information is mapped to permissions. This is not the same as the per-process umask
described above, although the permissions are calculated in a similar way. Some of these file system drivers also
support separate umasks for files and directories, using mount options such as fmask.
References
[1] Note: Some programming languages require a prefix symbol in front of octal notation such as the digit 0, or the letters o or q. The umask
command does not use this type of prefix notation -- only the octal digits are used.
[2] Note: Operating systems usually will also strip off execute permissions on newly created files.
72
Processes
at
In Unix-like computer operating systems, the at command is used to schedule commands to be executed once, at a
particular time in the future.
More precisely, it reads a series of commands from standard input and collects them into one "at-job" which is
carried out at a later date. The at-job inherits the current environment, so that it is executed in the same working
directory and with the same environment variables set as when it was scheduled.
It differs from cron, which is used for recurring executions (e.g. once an hour, every Tuesday, January 1 every
year). As with cron, many Unix systems allow the administrator to restrict access to the at command.
at can be made to mail a user when done carrying out a scheduled job of theirs, can use more than one job queue,
and can read a list of jobs to carry out from a file instead of standard input. A sample command to compile a C
program at 11:45 a. m. on January 31st would be:
$ echo "cc -o foo foo.c" | at 1145 jan 31
or
$ at 1145 jan 31
at> cc -o foo foo.c
at> ^D #(press Control-D while at the beginning of a line)
The atq program lists the currently queued jobs, while atrm removes jobs from the queue:
$ atq
1234 2011-08-12 11:45 cc -o foo foo.c user
$ atrm 1234
$ atq
$
In some Unix-like computer operating systems it uses a daemon, atd, which waits in the background periodically
checking the list of jobs to do and executing those at their scheduled time on behalf of at.
The batch command can be used instead of at to only run scheduled jobs if the system's load average is below a
certain value.
Windows NT/2000/XP/7 also has an at command (similar to cron), but it is deprecated in favor of Task
Scheduler.
at
73
External links
at
[1]
:execute commands at a later timeCommands & Utilities Reference, The Single UNIX Specification,
Issue 7 from The Open Group
at(1)
[2]
:queue, examine or delete jobs for later executionLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ at. html
[2] http:/ / linux.die. net/ man/ 1/ at
bg
bg is a job control command in Unix and Unix-like operating systems that resumes execution of a suspended process
without bringing it to the foreground;
[1]
the resumed process continues to execute in the background without
receiving user input from the terminal. bg is required to be included in an operating system in order for it to be
POSIX compliant.
[2]
References
[1] bg man page (http:/ / pwet.fr/ man/ linux/ commandes/ posix/ bg)
[2] POSIX (BS2000/OSD) - Commands User Guide (http:/ / web. archive. org/ web/ 20060318201600/ http:/ / manuals. fujitsu-siemens. com/
servers/ bs2_man/ man_us/ posix/ v6_0/ posix_k.pdf)
Chroot
A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running
process and its children. A program that is run in such a modified environment cannot name (and therefore normally
not access) files outside the designated directory tree. The term "chroot" may refer to the chroot(2) system call
or the chroot(8) wrapper program. The modified environment is called a "chroot jail".
History
The chroot system call was introduced during development of Version 7 Unix in 1979, and added to BSD by Bill Joy
on 18 March 1982 17 months before 4.2BSD was released in order to test its installation and build system.
[citation needed]
Uses
A chroot environment can be used to create and host a separate virtualized copy of the software system. This can be
useful for:
Testing and development
A test environment can be set up in the chroot for software that would otherwise be too risky to deploy on a
production system.
Dependency control
Software can be developed, built and tested in a chroot populated only with its expected dependencies. This
can prevent some kinds of linkage skew that can result from developers building projects with different sets of
program libraries installed.
Chroot
74
Compatibility
Legacy software or software using a different ABI must sometimes be run in a chroot because their supporting
libraries or data files may otherwise clash in name or linkage with those of the host system.
Recovery
Should a system be rendered unbootable, a chroot can be used to move back into the damaged environment
after bootstrapping from an alternate root file system (such as from installation media, or a Live CD).
Privilege separation
Programs are allowed to carry open file descriptors (for files, pipelines and network connections) into the
chroot, which can simplify jail design by making it unnecessary to leave working files inside the chroot
directory. This also simplifies the common arrangement of running the potentially vulnerable parts of a
privileged program in a sandbox, in order to pre-emptively contain a security breach. Note that chroot is not
necessarily enough to contain a process with root privileges.
Limitations
The chroot mechanism is not intended to defend against intentional tampering by privileged (root) users. On most
systems, chroot contexts do not stack properly and chrooted programs with sufficient privileges may perform a
second chroot
[1]
to break out. To mitigate the risk of this security weakness, chrooted programs should relinquish
root privileges as soon as practical after chrooting, or other mechanisms such as FreeBSD Jails - should be used
instead. Note that some systems, such as FreeBSD, take precautions to prevent the second chroot attack.
[2]
On systems that support device nodes on ordinary filesystems, a chrooted root user can still create device nodes and
mount the file systems on them; thus, the chroot mechanism is not intended by itself to be used to block low-level
access to system devices by privileged users. It is not intended to restrict the use of resources like I/O, bandwidth,
disk space or CPU time. Most Unixes are not completely file system-oriented and leave potentially disruptive
functionality like networking and process control available through the system call interface to a chrooted program.
At startup, programs expect to find scratch space, configuration files, device nodes and shared libraries at certain
preset locations. For a chrooted program to successfully start, the chroot directory must be populated with a
minimum set of these files. This can make chroot difficult to use as a general sandboxing mechanism.
Only the root user can perform a chroot. This is intended to prevent users from putting a setuid program inside a
specially crafted chroot jail (for example, with a fake /etc/passwd and /etc/shadow file) that would fool it
into a privilege escalation.
Some Unixes offer extensions of the chroot mechanism to address at least some of these limitations (see
Implementations of operating system-level virtualization technology).
Graphical applications on chroot
It is possible to run graphical applications on a chrooted environment, using methods such as:
[3][4]
xhost (or copy the secret from .Xauthority)
Nested X servers like Xnest or the more modern Xephyr (or start a real X server from inside the jail)
Accessing the chroot via SSH using the X11 forwarding (ssh -X) feature
xchroot
[5]
an extended version of chroot for users and Xorg/X11 forwarding (socat/mount)
An X11 VNC server and connecting a VNC client outside the environment.
Chroot
75
Notable applications
The Postfix mail transfer agent operates as a pipeline of individually chrooted helper programs.
Like 4.2BSD before it, the Debian and Ubuntu internal package-building farms use chroots extensively to catch
unintentional build dependencies between packages. SUSE uses a similar method with its build program. Fedora,
Red Hat, and various RPM-based distributions build all RPMs using a chroot tool such as mock
[6]
.
Many FTP servers for POSIX systems use the chroot mechanism to sandbox untrusted FTP clients. This may be
done by forking a process to handle an incoming connection, then chrooting the child (to avoid having to populate
the chroot with libraries required for program startup).
If privilege separation is enabled, the OpenSSH daemon will chroot an unprivileged helper process into an empty
directory to handle pre-authentication network traffic for each client. The daemon can also sandbox SFTP and shell
sessions in a chroot (from version 4.9p1 onwards).
References
[1] http:/ / www. bpfh.net/ simes/ computing/ chroot-break.html
[2] http:/ / man.freebsd. org/ chroot/ 2
[3] http:/ / wiki. mandriva.com/ en/ Development/ Howto/ Chroot#Launch_X_Applications_inside_the_chroot
[4] http:/ / www. gentoo-wiki.info/ HOWTO_startx_in_a_chroot
[5] http:/ / www. elstel.org/ xchroot/
[6] http:/ / fedoraproject. org/ wiki/ Projects/ Mock
External links
chroot(2) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=chroot& sektion=2):change root
directoryFreeBSD System Calls Manual
chroot(8) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=chroot& sektion=8):change root
directoryFreeBSD System Manager's Manual
chroot(2) (http:/ / www. kernel. org/ doc/ man-pages/ online/ pages/ man2/ chroot. 2. html):change root
directoryLinux Programmer's Manual System Calls
Cron
76
Cron
The software utility cron is a time-based job scheduler in Unix-like computer operating systems. People who set up
and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at
fixed times, dates, or intervals. It typically automates system maintenance or administrationthough its
general-purpose nature makes it useful for things like connecting to the Internet and downloading email at regular
intervals. The name cron comes from the Greek word for time, chronos.
Overview
Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on
a given schedule. The crontab files are stored where the lists of jobs and other instructions to the cron daemon are
kept. Users can have their own individual crontab files and often there is a system wide crontab file (usually in
/etc or a subdirectory of /etc) that only system administrators can edit.
Each line of a crontab file represents a job, and is composed of a CRON expression, followed by a shell command to
execute. Some cron implementations, such as in the popular 4th BSD edition written by Paul Vixie and included in
many Linux distributions, add a sixth field: an account username that runs the specified job (subject to user existence
and permissions). This is allowed only in the system crontabsnot in others, which are each assigned to a single
user to configure. The sixth field is alternatively sometimes used for year instead of an account usernamethe
nncron daemon for Windows does this.
While normally the job is executed when the time/date specification fields all match the current time and date, there
is one exception: if both "day of month" and "day of week" are restricted (not "*"), then either the "day of month"
field (3) or the "day of week" field (5) must match the current day.
Examples
The following specifies that the Apache error log clears at one minute past midnight (00:01) of every day of the
month, of every day of the week, assuming that the default shell for the cron user is Bourne shell compliant:
1 0 * * * printf > /var/log/apache/error_log
The following line makes the user program test.plostensibly a Perl scriptrun every two hours, at midnight,
2am, 4am, 6am, 8am, and so on:
0 */2 * * * /home/username/test.pl
Another example showing how to run a shell program called export_dump.sh at 0th minute of 20th hour, every day.
00 20 * * * /home/oracle/scripts/export_dump.sh
Cron
77
Predefined scheduling definitions
Several special predefined values can substitute in the cron expression. Note that in some uses of the cron format
there is also a seconds field at the beginning of the pattern (e.g. Quartz).
Entry Description Equivalent to
@yearly (or @annually) Run once a year at midnight in the morning of January 1 0 0 1 1 *
@monthly Run once a month at midnight in the morning of the first day of the month 0 0 1 * *
@weekly Run once a week at midnight in the morning of Sunday 0 0 * * 0
@daily Run once a day at midnight 0 0 * * *
@hourly Run once an hour at the beginning of the hour 0 * * * *
@reboot Run at startup @reboot
# * * * * * command to execute
#
#
#
# day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# month (1 - 12)
# day of month (1 - 31)
# hour (0 - 23)
# min (0 - 59)
@reboot configures a job to run once when the daemon is started. Since cron is typically never restarted, this
typically corresponds to the machine being booted. This behavior is enforced in some variations of cron, such as that
provided in Debian, so that simply restarting the daemon does not re-run @reboot jobs.
@reboot can be useful if there is a need to start up a server or daemon under a particular user, and the user does not
have access to configure init to start the program.
cron permissions
The following two files play an important role:
/etc/cron.allow - If this file exists, it must contain your username for you to use cron jobs.
/etc/cron.deny - If the cron.allow file does not exist but the /etc/cron.deny file does exist then, to use cron jobs,
you must not be listed in the /etc/cron.deny file.
Note that if neither of these files exist then, depending on site-dependent configuration parameters, either only the
super user can use cron jobs, or all users can use cron jobs.
Timezone handling
Most cron implementations simply interpret crontab entries in the system time zone setting that the cron daemon
runs under. This can be a source of dispute if a large multiuser machine has users in several time zones, especially if
the system default timezone includes the potentially confusing DST. Thus, a cron implementation may as a
special-case any "CRON_TZ=<timezone>" environment variable setting lines in user crontabs, interpreting
subsequent crontab entries relative to that timezone.
Cron
78
History
Early versions
The cron in Version 7 Unix, written by Brian Kernighan, was a system service (later called daemons) invoked from
/etc/inittab when the operating system entered multi-user mode. Its algorithm was straightforward:
1. Read /usr/etc/crontab
2. Determine if any commands must run at the current date and time, and if so, run them as the superuser, root.
3. 3. Sleep for one minute
4. 4. Repeat from step 1.
This version of cron was basic and robust but it also consumed resources whether it found any work to do or not. In
an experiment at Purdue University in the late 1970s to extend cron's service to all 100 users on a time-shared VAX,
it was found to place too much load on the system.
Multi-user capability
The next version of cron, with the release of Unix System V, was created to extend the capabilities of cron to all
users of a Unix system, not just the superuser. Though this may seem trivial today with most Unix and Unix-like
systems having powerful processors and small numbers of users, at the time it required a new approach on a one
MIPS system having roughly 100 user accounts.
In the August, 1977 issue of the Communications of the ACM, W. R. Franta and Kurt Maly published an article
entitled "An efficient data structure for the simulation event set" describing an event queue data structure for discrete
event-driven simulation systems that demonstrated "performance superior to that of commonly used simple linked
list algorithms," good behavior given non-uniform time distributions, and worst case complexity , "n"
being the number of events in the queue.
A graduate student, Robert Brown, reviewing this article, recognized the parallel between cron and discrete event
simulators, and created an implementation of the Franta-Maly event list manager (ELM) for experimentation.
Discrete event simulators run in virtual time, peeling events off the event queue as quickly as possible and advancing
their notion of "now" to the scheduled time of the next event. Running the event simulator in "real time" instead of
virtual time created a version of cron that spent most of its time sleeping, waiting for the scheduled time to execute
the task at the head of the event list.
The following school year brought new students into the graduate program, including Keith Williamson, who joined
the systems staff in the Computer Science department. As a "warm up task" Brown asked him to flesh out the
prototype cron into a production service, and this multi-user cron went into use at Purdue in late 1979. This version
of cron wholly replaced the /etc/cron that was in use on the computer science department's VAX 11/780
running 32/V.
The algorithm used by this cron is as follows:
1. On start-up, look for a file named .crontab in the home directories of all account holders.
2. 2. For each crontab file found, determine the next time in the future that each command must run.
3. 3. Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time
specifier.
4. 4. Enter main loop:
1. 1. Examine the task entry at the head of the queue, compute how far in the future it must run.
2. 2. Sleep for that period of time.
3. 3. On awakening and after verifying the correct time, execute the task at the head of the queue (in background)
with the privileges of the user who created it.
4. 4. Determine the next time in the future to run this command and place it back on the event list at that time value.
Cron
79
Additionally, the daemon responds to SIGHUP signals to rescan modified crontab files and schedules special "wake
up events" on the hour and half hour to look for modified crontab files. Much detail is omitted here concerning the
inaccuracies of computer time-of-day tracking, Unix alarm scheduling, explicit time-of-day changes, and process
management, all of which account for the majority of the lines of code in this cron. This cron also captured the
output of stdout and stderr and e-mailed any output to the crontab owner.
The resources consumed by this cron scale only with the amount of work it is given and do not inherently increase
over time with the exception of periodically checking for changes.
Williamson completed his studies and departed the University with a Masters of Science in Computer Science and
joined AT&T Bell Labs in Murray Hill, New Jersey, and took this cron with him. At Bell Labs, he and others
incorporated the Unix at command into cron, moved the crontab files out of users' home directories (which were
not host-specific) and into a common host-specific spool directory, and of necessity added the crontab command
to allow users to copy their crontabs to that spool directory.
This version of cron later appeared largely unchanged in Unix System V and in BSD and their derivatives, the
Solaris Operating System from Sun Microsystems, IRIX from Silicon Graphics, HP-UX from Hewlett-Packard, and
IBM AIX. Technically, the original license for these implementations should be with the Purdue Research
Foundation who funded the work, but this took place at a time when little concern was given to such matters.
Modern versions
With the advent of the GNU Project and Linux, new crons appeared. The most prevalent of these is the Vixie cron,
originally coded by Paul Vixie in 1987. Version 3 of Vixie cron was released in late 1993. Version 4.1 was renamed
to ISC Cron and was released in January 2004. Version 3, with some minor bugfixes, is used in most distributions
of Linux and BSDs.
In 2007, Red Hat forked vixie-cron 4.1 to the cronie project and included anacron 2.3 in 2009.
Other popular implementations include anacron, dcron, and fcron. However, anacron is not an independent cron
program. Another cron job must call it. dcron was made by DragonFly BSD founder Matt Dillon, and its
maintainership was taken over by Jim Pryor in 2010.
A webcron solution schedules recurring tasks to run on a regular basis wherever cron implementations are not
available in a web hosting environment.
CRON expression
A CRON expression is a string comprising five or six fields separated by white space that represents a set of times,
normally as a schedule to execute some routine.
Format
Cron
80
Field name Mandatory? Allowed values Allowed special characters Remarks
Minutes Yes 0-59 * / , - -
Hours Yes 0-23 * / , - -
Day of month Yes 1-31 * / , - ? L W -
Month Yes 1-12 or JAN-DEC * / , - -
Day of week Yes 0-6 or SUN-SAT * / , - ? L # -
Year No 19702099 * / , - This field is not supported in standard/default implementations.
In some uses of the CRON format there is also a seconds field at the beginning of the pattern. In that case, the CRON
expression is a string comprising 6 or 7 fields.
Special characters
Support for each special character depends on specific distributions and versions of cron
Asterisk ( * )
The asterisk indicates that the cron expression matches for all values of the field. E.g., using an asterisk in the
4th field (month) indicates every month.
Slash ( / )
Slashes describe increments of ranges. For example 3-59/15 in the 1st field (minutes) indicate the third minute
of the hour and every 15 minutes thereafter. The form "*/..." is equivalent to the form "first-last/...", that is, an
increment over the largest possible range of the field.
Percent ( % )
Percent-signs (%) in the command, unless escaped with backslash (\), are changed into newline characters, and
all data after the first % are sent to the command as standard input.
Comma ( , )
Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the 5th field (day of
week) means Mondays, Wednesdays and Fridays.
Hyphen ( - )
Hyphens define ranges. For example, 2000-2010 indicates every year between 2000 and 2010 AD, inclusive.
L
'L' stands for "last". When used in the day-of-week field, it allows you to specify constructs such as "the last
Friday" ("5L") of a given month. In the day-of-month field, it specifies the last day of the month.
Note: L is a non-standard character and exists only in some cron implementations (Quartz java scheduler)
W
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday
(Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the
day-of-month field, the meaning is: "the nearest weekday to the 15th of the month." So, if the 15th is a
Saturday, the trigger fires on Friday the 14th. If the 15th is a Sunday, the trigger fires on Monday the 16th. If
the 15th is a Tuesday, then it fires on Tuesday the 15th. However if you specify "1W" as the value for
day-of-month, and the 1st is a Saturday, the trigger fires on Monday the 3rd, as it does not 'jump' over the
boundary of a month's days. The 'W' character can be specified only when the day-of-month is a single day,
not a range or list of days.
Note: W is a non-standard character and exists only in some cron implementations (Quartz java scheduler)
Cron
81
Hash ( # )
'#' is allowed for the day-of-week field, and must be followed by a number between one and five. It allows you
to specify constructs such as "the second Friday" of a given month.
Question mark ( ? )
Note: Question mark is a non-standard character and exists only in some cron implementations. It is used
instead of '*' for leaving either day-of-month or day-of-week blank.
References
External links
crontab (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ crontab. html):schedule periodic
background workCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
GNU cron (http:/ / www. gnu. org/ software/ mcron/ ) (mcron)
ISC Cron 4.1 (ftp:/ / ftp. isc. org/ isc/ cron/ cron_4. 1. shar)
cronie (https:/ / fedorahosted.org/ cronie/ )
ACM Digital library Franta, Maly, "An efficient data structure for the simulation event set" (http:/ / portal. acm.
org/ citation. cfm?id=359763. 359801& coll=ACM& dl=ACM& CFID=63647367& CFTOKEN=55814330)
(requires ACM pubs subscription)
Crontab syntax tutorial (http:/ / linuxmoz. com/ crontab-syntax-tutorial/ ) - Crontab syntax explained
UNIX / Linux cron tutorial (http:/ / www. cyberciti. biz/ faq/
how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ ) - a quick tutorial for UNIX like operating systems with
sample shell scripts.
All about Cron on one page (http:/ / www. markus-gattol. name/ ws/ time. html#cron) - a page covering Cron,
starting with theory and ending with many practical examples about its usage.
Dillon's cron (http:/ / www. jimpryor. net/ linux/ dcron. html) (dcron)
Cron Expression translator (http:/ / crontranslator. appspot. com) - Small site that tries to convert a cron tab
expression to English
CronSandbox - Cron simulator, try out crontab timing values in a sandbox. (http:/ / www. dataphyx. com/
cronsandbox) - Put in the cron time/date values and get back a list of future run-times.
Crontab syntax generator (http:/ / www. easycron. com/ generator/ crontab) - Choose date/time, enter command,
output path and Email address (for receiving notification) to generate a Crontab syntax.
fg
82
fg
fg is a job control command in Unix and Unix-like operating systems that resumes execution of a suspended process
by bringing it to the foreground and thus redirecting its standard input and output streams to the user's terminal.
[1]
fg
is required to be included in an operating system in order for it to be POSIX compliant.
[2]
References
[1] fg man page (http:/ / www. computerhope.com/ unix/ ufg. htm)
[2] POSIX (BS2000/OSD) - Commands User Guide (http:/ / manuals. fujitsu-siemens. com/ servers/ bs2_man/ man_us/ posix/ v6_0/ posix_k.
pdf)
External links
fg (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ fg. html):run jobs in the
foregroundCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
kill
In computing, kill is a command that is used in several popular operating systems to send signals to running
processes in order to request the termination of the process.
Implementations
Unix and Unix-like
In Unix and Unix-like operating systems, kill is a command used to send a signal to a process. By default, the
message sent is the termination signal, which requests that the process exit. But kill is something of a misnomer; the
signal sent may have nothing to do with process killing. The kill command is a wrapper around the kill()
system call, which sends signals to processes or process groups on the system, referenced by their numeric process
IDs (PIDs) or process group IDs (PGIDs). kill is always provided as a standalone utility as defined by the POSIX
standard. However, most shells have built-in kill commands that may slightly differ from it.
There are many different signals that can be sent (see signal for a full list), although the signals in which users are
generally most interested are SIGTERM and SIGKILL. The default signal sent is SIGTERM. Programs that handle
this signal can do useful cleanup operations (such as saving configuration information to a file) before quitting.
However, many programs do not implement a special handler for this signal, and so a default signal handler is called
instead. Other times, even a process that has a special handler has gone awry in a way that prevents it from properly
handling the signal.
All signals except for SIGKILL and SIGSTOP can be "intercepted" by the process, meaning that a special function
can be called when the program receives those signals. The two exceptions SIGKILL and SIGSTOP are only seen by
the host system's kernel, providing reliable ways of controlling the execution of processes. SIGKILL kills the
process, and SIGSTOP pauses it until a SIGCONT is received.
Unix provides security mechanisms to prevent unauthorized users from killing other processes. Essentially, for a
process to send a signal to another, the owner of the signaling process must be the same as the owner of the receiving
process or be the superuser.
The available signals all have different names, and are mapped to certain numbers. It is important to note that the
specific mapping between numbers and signals can vary between Unix implementations. SIGTERM is often
kill
83
numbered 15 while SIGKILL is often numbered 9.
Examples
A process can be sent a SIGTERM signal in four ways (the process ID is '1234' in this case):
kill 1234
kill -s TERM 1234
kill -TERM 1234
kill -15 1234
The process can be sent a SIGKILL signal in three ways:
kill -s KILL 1234
kill -KILL 1234
kill -9 1234
Other useful signals include HUP, TRAP, INT, SEGV and ALRM. HUP sends the SIGHUP signal. Some daemons,
including Apache and Sendmail, re-read configuration files upon receiving SIGHUP, so the kill command may be
used for this too. A SIGINT signal can be generated very simply by pressing ^ Ctrl+C in most Unix shells. It is
also common for ^ Ctrl+Z to be mapped to SIGTSTP, and for ^ Ctrl+\ (backslash) to be mapped to SIGQUIT,
which can force a program to do a core dump.
Related programs
killall - on some variations of Unix, such as Solaris, this utility is automatically invoked when the system is going
through a shutdown. It behaves much like the kill command above, but instead of sending a signal to an
individual process, the signal is sent to all processes on the system. However, on others such as IRIX, Linux, and
FreeBSD, an argument is supplied specifying the name of the process (or processes) to kill. For instance, to kill a
process such as an instance of the XMMS music player invoked by xmms, the user would run the command
killall xmms. This would kill all processes named xmms, and is equivalent to kill `pidof xmms` on
systems like Solaris.
pkill - signals processes based on name and other attributes. It was introduced in Solaris 7 and has since been
reimplemented for Linux, NetBSD and OpenBSD. pkill makes killing processes based on their name much more
convenient: e.g. to kill a process named firefox without pkill (and without pgrep), one would have to type kill
`ps--no-headers-Cfirefox-opid` whereas with pkill, one can simply type pkill firefox.
xkill - if called without any parameters, the cursor changes, and the user can click on a window to force the X
server to close the connection with the client owning the window. This often causes the process to terminate when
it detects that its connection to the X server has been closed.
Microsoft Windows
Microsoft's command-line interpreter Windows PowerShell, kill, is a predefined command alias for the
Stop-Process cmdlet.
Microsoft Windows XP, Vista and 7 include the command taskkill
[1]
to terminate processes. The usual syntax
for this command is taskkill /im "IMAGENAME". An "unsupported" version of kill was included in
several releases of the Microsoft Windows Resource Kits available for Windows NT 3.x, NT 4.0, Windows 2000
and Microsoft Windows Server 2003, the most efficacious of these being Version 3.5 of Kill, Copyright (C) 1994
Microsoft Corp.
GNU versions of kill have been ported via Cygwin and run inside of the Unix environment subsystem that
Microsoft Windows Services for UNIX
[2]
provides (Microsoft acquired Windows Services for Unix wholesale via
their purchase of Softway Systems and their Interix product on September 17, 1999).
kill
84
Examples
Find all processes beginning with the letter "p" that were developed by Apple and use more than 10 MB of memory
and kill them:
PS C:\>ps p* | where { $_.Company -like "Apple*" -and $_.WorkingSet -gt 10MB } | kill -confirm
Confirm
Are you sure you want to perform this action?
Performing operation "Stop-Process" on Target "powershell (6832)".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A
PS C:\>
Here is a simpler example, which asks the process Explorer.exe to terminate:
PS C:\>taskkill /im explorer.exe
This example forces the process to terminate:
PS C:\>taskkill /f /im explorer.exe
You can also kill processes by their PID number, like as in:
PS C:\>taskkill /pid 3475
Microsoft Singularity
Singularity shell, the standard shell for Microsoft Research's microkernel operating system Singularity includes a
kill command to terminate background processes.
Examples
Stop the process with the name "SampleProcess":
Singularity>kill SampleProcess
Stop the process with the process identifier "42":
Singularity>kill 42
Plan 9 from Bell Labs
Under Plan 9 from Bell Labs, the kill program does not actually perform this termination, nor does it take process
IDs. Rather, it takes the actual names of processes and outputs the commands for rc, the shell used by Plan 9, to kill
the process.
A similar command provided is called slay, which does the same but for processes that refuse to be killed this way.
Examples
For example, to kill all instances of troff, one types:
kill troff | rc
kill
85
References
[1] Microsoft TechNet taskkill article (http:/ / technet. microsoft. com/ en-us/ library/ bb491009. aspx)
[2] Windows Services for UNIX (http:/ / technet.microsoft. com/ en-us/ interopmigration/ bb380242. aspx)
External links
Command: kill(1) (http:/ / linux. die. net/ man/ 1/ kill):terminate a processLinux User Commands Manual
System call: kill(2) (http:/ / linux. die. net/ man/ 2/ kill):send signal to a processLinux System Calls
Manual
Killall
killall is a command line utility available on Unix-like systems. There are two very different implementations.
The implementation supplied with genuine UNIX System V (including Solaris) and with the Linux sysvinit
[1]
tools (as killall5) is a particularly dangerous command that kills all processes that the user is able to kill,
effectively shutting down the system if run by root.
The implementation supplied with the FreeBSD (including Mac OS X) and Linux psmisc
[2]
tools is similar to the
pkill and skill commands, killing only the processes specified on the command line.
Both commands operate by sending a signal, like the kill program.
Example usage
Kill all processes (UNIX System V version)
killall
Kill the GNOME Display Manager
killall gdm
Kill the Dock (restarts) (Mac OS X)
killall Dock
List all signals (FreeBSD/Linux version)
killall -l
Send the USR1 signal to the dd process (FreeBSD/Linux version)
killall -s USR1 dd
Kill a process which is not responding (FreeBSD/Linux version)
killall -9 dd
Killall
86
The numeric argument specifies a signal to send to the process. In this case, the command sends signal 9 to the
process, which is SIGKILL, as opposed to the default SIGTERM.
External links
killall(1)
[3]
:kill processes by nameLinux User Commands Manual
killall(1)
[4]
FreeBSD General Commands Manual
killall(1)
[5]
Darwin and Mac OS X General Commands Manual
References
[1] ftp:/ / ftp. cistron.nl/ pub/ people/ miquels/ sysvinit/
[2] http:/ / psmisc. sourceforge. net/
[3] http:/ / linux.die. net/ man/ 1/ killall
[4] http:/ / www. freebsd. org/ cgi/ man. cgi?query=killall& sektion=1
[5] http:/ / developer. apple. com/ documentation/ Darwin/ Reference/ ManPages/ man1/ killall. 1. html
nice
nice is a program found on Unix and Unix-like operating systems such as Linux. It directly maps to a kernel call of
the same name. nice is used to invoke a utility or shell script with a particular priority, thus giving the process
more or less CPU time than other processes. A niceness of 20 is the highest priority and 19 or 20 is the lowest
priority. The default niceness for processes is inherited from its parent process, usually 0.
Use and effect
nice becomes useful when several processes are demanding more resources than the CPU can provide. In this state,
a higher priority process will get a larger chunk of the CPU time than a lower priority process. Only the superuser
(root) may set the niceness to a smaller (higher priority) value. On Linux it is possible to change
/etc/security/limits.conf to allow other users or groups to set low nice values.
[1]
If a user wanted to compress a large file, but not slow down other processes, they might run the following:
$ nice -n 19 tar cvzf archive.tgz largefile
The related renice program can be used to change the priority of a process that is already running.
The exact mathematical effect of setting a particular niceness value for a process depends on the details of how the
scheduler is designed on that implementation of Unix. A particular operating system's scheduler will also have
various heuristics built into it, e.g. to favor processes that are mostly I/O-bound over processes that are CPU-bound.
As a simple example, when two otherwise identical CPU-bound processes are running simultaneously on a
single-CPU Linux system, each one's share of the CPU time will be proportional to 20p, where p is the process'
priority. Thus a process run with nice +15 will receive 25% of the CPU time allocated to a normal-priority
process: (2015)/(200) = 0.25.
[citation needed]
On the BSD 4.x scheduler, on the other hand, the ratio in the same
example is about ten to one.
[citation needed]
Linux also has an ionice program, which affects scheduling of I/O rather than CPU time.
nice
87
Etymology
The name "nice" comes from the fact that the program's purpose is to modify a process niceness value. The true
priority, used to decide how much CPU time to concede to each process, is calculated by the kernel process
scheduler from a combination of the different processes niceness values and other data, such as the amount of I/O
done by each process.
The name "niceness" originates from the idea that a process with a higher niceness value is "nicer" to other processes
in the system:
This is why the nice number is usually called niceness: a job with a high niceness is very kind to the users of
your system (i.e., it runs at low priority), while a job with little niceness hogs the CPU. The term "niceness" is
awkward, like the priority system itself. Unfortunately, it's the only term that is both accurate (nice numbers
are used to compute the priorities but are not the priorities themselves) and avoids horrible circumlocutions
("increasing the priority means lowering the priority...").
[2]
References
[1] limits.conf man page (http:/ / manpages.debian.net/ cgi-bin/ man. cgi?query=limits. conf)
[2] Jerry Peek, Shelley Powers, Tim O'Reilly and Mike Loukides (2007). Unix Power Tools. O'Reilly, p. 507.
External links
nice (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ nice. html):invoke a utility with an
altered nice valueCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
Pgrep
pgrep is a command-line utility initially written for use with the Solaris 7 operating system. It has since been
reimplemented for Linux and the BSDs (Dragonfly BSD, FreeBSD, NetBSD, and OpenBSD). It searches for all the
named processes that can be specified as extended regular expression patterns, andby defaultreturns their
process ID. Alternatives include pidof (finds process ID given a program name) and ps.
Example usage
The default behaviour of pgrep (returning the process identifier of the named tasks) simplifies an otherwise
complex task and is invoked with:
$ pgrep 'bash'
Which is roughly equivalent to:
$ ps ax | awk '/[p]rocessname/ {print $1}'
(With a redundant `grep`:)
$ ps ax | grep 'processname' | grep 'grep' -v | awk '{print $1}'
Additional functionality of pgrep is listing the process name as well as the PID (-l Lists the process name as
well as the process ID) of all processes belonging to the group alice (-G Only match processes whose real group
ID is listed. Either the numerical or symbolical value may be used):
$ pgrep -l -G alice
Pgrep
88
showing all processes that do not belong to the user root (-u euid Only match processes whose effective user
ID is listed. Either the numerical or symbolical value may be used) by inverting the matching (-v Negates the
matching):
$ pgrep -v -u root
and only matching the most recently started process (-n Select only the newest (most recently started) of the
matching processes):
$ pgrep -n # The most recent process started
$ pgrep -n -u alice emacs # The most recent `emacs` process started by
user `alice`
References
pgrep(1)
[1]
:look up processes based on name and other attributesLinux User Commands Manual
External links
A Comparison of Unix pgrep Implementations
[2]
References
[1] http:/ / linux.die. net/ man/ 1/ pgrep
[2] http:/ / rsquared. sdf. org/ pgrep/
Pidof
pidof is a Linux utility that returns the process identifier (PID) of a running process or processes. On other
operating systems, pgrep and ps are often used instead.
pidof is implemented in the same program as killall5 (see readlink $(command -v pidof)), the
Linux name for the System V killall program used by the runlevel scripts. pidof is usually a symbolic link to
killall5, and the name the program is called under is what determines its behavior.
Some examples that return the process identifiers of several processes using pidof:
$ pidof ntpd
3580 3579
$ pidof emacs
22256
$ pidof file
10269
$ pidof pidof
23571
Pidof
89
External links
pidof(8)
[1]
:find the process ID of a running programLinux Administration and Privileged Commands
Manual
killall5(8)
[2]
:send a signal to all processesLinux Administration and Privileged Commands Manual
References
[1] http:/ / linux.die. net/ man/ 8/ pidof
[2] http:/ / linux.die. net/ man/ 8/ killall5
Pkill
pkill (see pgrep) is a command-line utility initially written for use with the Solaris 7 operating system. It has
since been reimplemented for Linux and some BSDs.
As with the kill and killall commands, pkill is used to send signals to processes. The pkill command
allows the use of extended regular expression patterns and other matching criteria.
Example usage
Kill the most recently created acroread process:
pkill -n acroread
Send a USR1 signal to acroread process:
pkill -USR1 acroread
ps
90
ps
In most Unix-like operating systems, the ps program (short for "process status") displays the currently-running
processes. A related Unix utility named top provides a real-time view of the running processes.
In Windows PowerShell, ps is a predefined command alias for the Get-Process cmdlet which essentially
serves the same purpose.
Examples
For example:
# ps
PID TTY TIME CMD
7431 pts/0 00:00:00 su
7434 pts/0 00:00:00 bash
18585 pts/0 00:00:00 ps
Users can also utilize the ps command in conjunction with the grep (see the pgrep and pkill commands)
command to find information about one process, such as its process id:
$ # Trying to find the PID of `firefox-bin` which is 2701
$ ps -A | grep firefox-bin
2701 ? 22:16:04 firefox-bin
and the easier and non-racy version with pgrep:
$ pgrep -l firefox-bin
2701 firefox-bin
To see every process running as root in user format:
# ps -U root -u
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 1 0.0 0.0 9436 128 - ILs Sun00AM 0:00.12
/sbin/init --
Break Down
Column Header Contents
%CPU How much of the CPU the process is using
%MEM How much memory the process is using
ADDR Memory address of the process
C or CP CPU usage and scheduling information
COMMAND* Name of the process, including arguments, if any
NI nice value
F Flags
PID Process ID number
PPID ID number of the processs parent process
PRI Priority of the process
RSS Real memory usage
S or STAT Process status code
ps
91
START or STIME Time when the process started
SZ Virtual memory usage
TIME Total CPU usage
TT or TTY Terminal associated with the process
UID or USER Username of the processs owner
WCHAN Memory address of the event the process is waiting for
* = Often abbreviated
Options
ps has many options. On operating systems that support the SUS and POSIX standards, ps commonly runs with the
options -ef, where "-e" selects every process and "-f" chooses the "full" output format. Another common option on
these systems is -l, which specifies the "long" output format.
Most systems derived from BSD fail to accept the SUS and POSIX standard options because of historical conflicts
(for example, the "e" or "-e" option will cause the display of environment variables). On such systems, ps commonly
runs with the non-standard options aux, where "a" lists all processes on a terminal, including those of other users,
"x" lists all processes without controlling terminals and "u" adds a column for the controlling user for each process.
Note that, for maximum compatibility when using this syntax, there is no "-" in front of the "aux". Also you can add
'ww' after aux, like "ps auxww" for complete information about the process including all parameters.
External links
ps
[1]
Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Show all running processes in Linux using ps command
[2]
ps(1)
[3]
:report a snapshot of the current processesLinux User Commands Manual
In Unix, what do the output fields of the ps command mean?
[4]
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ ps. html
[2] http:/ / www. cyberciti.biz/ faq/ show-all-running-processes-in-linux/
[3] http:/ / linux.die. net/ man/ 1/ ps
[4] http:/ / kb.iu.edu/ data/ afnv. html
Pstree
92
Pstree
pstree output in FreeBSD
pstree is a Unix command that shows the running processes as a tree.
It is used as a more visual alternative to the ps command. The root of
the tree is either init or the process with the given pid.
External links
pstree
[1]
at Freecode
The pstree Command
[2]
by The Linux Information Project (LINFO)
Gnome Process Tree
[3]
pstree(1)
[4]
Linux User Commands Manual
References
[1] http:/ / freecode. com/ projects/ pstree/
[2] http:/ / www. linfo.org/ pstree.html
[3] http:/ / gnopstree. sourceforge. net/
[4] http:/ / linux.die. net/ man/ 1/ pstree
time
time is a command in the Unix operating systems. It is used to determine the duration of execution of a particular
command.
Usage
To use the command, simply precede any command by the word time, such as:
time ls
When the command completes, time will report how long it took to execute the ls command in terms of user
CPU time, system CPU time, and real time. The output format varies between different versions of the command,
and some give additional statistics, as in this example:
$ time host wikipedia.org
wikipedia.org has address 207.142.131.235
0.000u 0.000s 0:00.17 0.0% 0+0k 0+0io 0pf+0w
$
time(1) can exist as a standalone program (such as GNU time) or as a shell builtin (e.g. in tcsh or in zsh).
User Time vs System Time
The term 'user CPU time' can be a bit misleading at first. To be clear, the total CPU time is the combination of the
amount of time the CPU(s) spent performing some action for a program and the amount of time the CPU(s) spent
performing system calls for the kernel on the program's behalf. When a program loops through an array, it is
accumulating user CPU time. Conversely, when a program executes a system call such as exec or fork, it is
accumulating system CPU time.
time
93
Real Time vs CPU Time
The term "real time" in this context refers to elapsed "wall clock" time, like using a stop watch. The total CPU time
(user time + sys time) may be more or less than that value. Because a program may spend some time waiting and not
executing at all (whether in user mode or system mode) the real time may be greater than the total CPU time.
Because a program may fork children whose CPU times (both user and sys) are added to the values reported by the
time command, the total CPU time may be greater than the real time.
Method of operation
According to the source code of the GNU implementation of time, most information shown by time is derived
from the wait3 system call. On systems that do not have a wait3 call that returns status information, the
times system call is used instead.
References
time
[1]
:time a simple commandCommands & Utilities Reference, The Single UNIX Specification, Issue 7
from The Open Group
time(1)
[2]
:time a simple command or give resource usageLinux Programmer's Manual User Commands
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ time. html
[2] http:/ / www. kernel. org/ doc/ man-pages/ online/ pages/ man1/ time. 1. html
top
94
top
top
Latest stable 3.2.8
Written in C
Operating system Unix-like
Type Process Viewer / System monitor
License GNU General Public License
Website
www.unixtop.org
[1]
procps.sourceforge.net
[2]
top is a task manager program found in many Unix-like operating systems. It produces an ordered list of running
processes selected by user-specified criteria, and updates it periodically. Default ordering by CPU usage, and only
the top CPU consumers shown (hence the name). top shows how much processing power and memory are being
used, as well as other information about the running processes. Some versions of top allow extensive
customization of the display, such as choice of columns or sorting method.
top is useful for system administrators, as it shows which users and processes are consuming the most system
resources at any given time.
On Solaris, the roughly equivalent program is prstat. MS-DOS has tasklist and graphical Microsoft operating
systems have the Windows Task Manager. IBM AIX has an updating running processes list as part of the topas
and topas_nmon commands.
The load average numbers in Linux refers to the sum of the number of processes waiting in the run-queue plus the
number currently executing. The number is absolute, not relative. And thus it can be unbounded; unlike utilization.
The instant variations of the number of processes are damped with a exponential decay formula which is calculated
using fixed point math.
The ps program is similar to top, but instead produces a snapshot of processes taken at the time of invocation.
top
95
External links
FreeBSD freebsd.org: top(1)
[3]
BSD top home page
[1]
and man page
[4]
Linux top home page (procps)
[5]
and man page
[6]
Alternate top programs for Linux include atop
[7]
(uses process accounting) and Htop
References
[1] http:/ / www. unixtop. org/
[2] http:/ / procps. sourceforge. net/
[3] http:/ / www. freebsd. org/ cgi/ man. cgi?query=top& apropos=0& sektion=0& manpath=FreeBSD+ 9. 1-RELEASE& arch=default&
format=html
[4] http:/ / www. unixtop. org/ top1.html
[5] http:/ / procps. sf.net/
[6] http:/ / www. linuxmanpages.com/ man1/ top. 1. php
[7] http:/ / www. atcomputing. nl/ Tools/ atop
96
User environment
clear
Clear being used on GNU/Linux under uxterm
clear is a standard Unix computer operating system command which
is used to clear the screen.
Depending on the system, clear uses the terminfo or termcap
database, as well as looking into the environment for the terminal type
in order to deduce how to clear the screen. The Unix command
clear takes no arguments and is roughly analogous to the MS-DOS
command cls.
External links
The manual (man) page for clear
[1]
References
[1] http:/ / invisible-island. net/ ncurses/ man/ clear. 1. html
Env
env is a shell command for Unix and Unix-like operating systems. It is used to either print a list of environment
variables or run another utility in an altered environment without having to modify the currently existing
environment. Using env, variables may be added or removed, and existing variables may be changed by assigning
new values to them.
In practice, env has another common use. It is often used by shell scripts to launch the correct interpreter. In this
usage, the environment is typically not changed.
Examples
To clear the environment (creating a new environment without any existing environment variables) for a new shell:
env -i /bin/sh
To launch the X Window application xcalc and have it appear on a different display:
env DISPLAY=foo.bar:1.0 xcalc
Here is the code of a very simple Python script:
#!/usr/bin/env python2
print "Hello World."
In this example, /usr/bin/env is the full path of the env command. The environment is not altered.
Env
97
Note that it is possible to specify the interpreter without using env, by giving the full path of the python
interpreter. A problem with that approach is that on different computer systems, the exact path may be different. By
instead using env as in the example, the interpreter is searched for and located at the time the script is run. This
makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches
for a match in every directory on the executable search path. It also suffers from the same problem in that the path to
the env binary may also be different on a per-machine basis.
External links
env
[1]
:set the environment for command invocationCommands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
env
[2]
-- manual page from GNU coreutils.
env(1)
[3]
:run a program in a modified environmentOpenBSD General Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ env. html
[2] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ env-invocation. html
[3] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=env& section=1
exit
exit is a command used in many operating system command line shells and scripting languages. The command
causes the shell or program to terminate. If performed within an interactive command shell, the user is logged out of
their current session, and/or user's current console or terminal connection is disconnected. Typically an optional exit
code can be specified, which is a simple integer value that is then returned to the parent process. Scripting languages
providing this command include sh, ksh, Perl, AWK, PHP, TCL, and others.
References
exit
[1]
:cause the shell to exitCommands & Utilities Reference, The Single UNIX Specification, Issue 7
from The Open Group
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ exit. html
finger
98
finger
Internet
protocol suite
Application layer
BGP
DHCP * DHCPv6
DNS
FTP
HTTP
IMAP
IRC
LDAP
MGCP
NNTP
NTP
POP
RPC
RTP
RTSP
RIP
SIP
SMTP
SNMP
SOCKS
SSH
Telnet
TLS/SSL
XMPP
more...
Transport layer
TCP
UDP
DCCP
SCTP
RSVP
more...
Internet layer
IP
IPv4
IPv6
ICMP
ICMPv6
ECN
IGMP
IPsec
more...
Link layer
finger
99
ARP/InARP
NDP
OSPF
Tunnels
L2TP
PTPP
Media access control
Ethernet
DSL
ISDN
FDDI
DOCSIS
more...
v
t
e
[1]
In computer networking, the Name/Finger protocol and the Finger user information protocol are simple network
protocols for the exchange of human-oriented status and user information.
Name/Finger protocol
The Name/Finger protocol, written by David Zimmerman, is based on Request for comments document RFC 742
(December 1977) as an interface to the nameWikipedia:Please clarify and finger programs that provide status
reports on a particular computer system or a particular person at network sites. The finger program was written in
1971 by Les Earnest who created the program to solve the need of users who wanted information on other users of
the network. Information on who is logged-in was useful to check the availability of a person to meet. This was
probably the earliest form of presence information for remote network users.
Prior to the finger program, the only way to get this information was with a who program that showed IDs and
terminal line numbers (the server's internal number of the communication line, over which the user's terminal is
connected) for logged-in users. Earnest named his program after the idea that people would run their fingers down
the who list to find what they were looking for.
Finger user information protocol
The finger daemon runs on TCP port 79. The client will (in the case of remote hosts) open a connection to port 79.
An RUIP (Remote User Information Program) is started on the remote end of the connection to process the request.
The local host sends the RUIP one line query based upon the Finger query specification, and waits for the RUIP to
respond. The RUIP receives and processes the query, returns an answer, then initiates the close of the connection.
The local host receives the answer and the close signal, then proceeds closing its end of the connection.
The Finger user information protocol is based on RFC 1288 (The Finger User Information Protocol, December
1991). Typically the server side of the protocol is implemented by a program fingerd (for finger daemon), while
the client side is implemented by the name and finger programs which are supposed to return a friendly,
human-oriented status report on either the system at the moment or a particular person in depth. There is no required
format, and the protocol consists mostly of specifying a single command line.
The program would supply information such as whether a user is currently logged-on, e-mail address, full name etc.
As well as standard user information, finger displays the contents of the .project and .plan files in the user's
home directory. Often this file (maintained by the user) contains either useful information about the user's current
activities, similar to micro-blogging, or alternatively all manner of humor.
finger
100
Security concerns
Supplying such detailed information as e-mail addresses and full names was considered acceptable and convenient in
the early days of networking, but later was considered questionable for privacy and security reasons. Finger
information has been frequently used by hackers as a way to initiate a social engineering attack on a company's
computer security system. By using a finger client to get a list of a company's employee names, email addresses,
phone numbers, and so on, a cracker can telephone or email someone at a company requesting information while
posing as another employee. The finger daemon has also had several exploitable security holes which crackers have
used to break into systems. The Morris worm, in 1988, exploited an overflow vulnerability in fingerd (among
others) to spread. The finger protocol is also incompatible with Network Address Translation (NAT) from the private
network address ranges (e.g. 192.168.0.0/16) that are used by the majority of home and office workstations that
connect to the Internet through routers or firewalls.
For these reasons, while finger was widely used during the early days of Internet, by the late 1990s the vast majority
of sites on the Internet no longer offered the service.
Application support
It is implemented on Unix, Unix-like systems, and current versions of Windows (finger.exe command). Other
software has finger support:
ELinks
Minuet
References
[1] http:/ / en. wikipedia. org/ w/ index. php?title=Template:IPstack& action=edit
External links
RFC 742 (December 1977)
RFC 1288 (December 1991)
Mail from Les Earnest explaining the origin of finger (http:/ / www. djmnet. org/ lore/ finger-origin. txt)
Linux finger command (http:/ / manpages. debian. net/ cgi-bin/ man. cgi?query=finger)
History of the Finger protocol by Rajiv Shah (http:/ / www. rajivshah. com/ Case_Studies/ Finger/ Finger. htm)
Microsoft TechNet Finger article (http:/ / technet. microsoft. com/ en-us/ library/ bb490908. aspx)
history
101
history
The various Unix shells maintain a record of the commands issued by the user during the current session. The
history command manipulates this history list. In its simplest form, it prints the history list. Options allow for the
recall and editing of particular commands and for setting parameters such as the number of past commands to retain
in the list.
In early versions of Unix the history command was a separate program. However, most shells have long included the
history command as a shell built-in, so the separate program is no longer in common use. Since most current history
commands are shell built-ins, details depend on the choice of shell.
tcsh
history [-hTr] [n]
history -S|-L|-M [filename] (+)
history -c (+)
The first form prints the history event list. If n is given only the n most recent events are printed or saved. With -h,
the history list is printed without leading numbers. If -T is specified, timestamps are printed also in comment form.
(This can be used to produce files suitable for loading with 'history -L' or 'source -h'.) With -r, the order of printing is
most recent first rather than oldest first.
With -S, the second form saves the history list to filename. If the first word of the savehist shell variable is set to a
number, at most that many lines are saved. If the second word of savehist is set to `merge', the history list is merged
with the existing history file instead of replacing it (if there is one) and sorted by time stamp. (+) Merging is intended
for an environment like the X Window System with several shells in simultaneous use. Currently it succeeds only
when the shells quit nicely one after another.
With -L, the shell appends filename, which is presumably a history list saved by the -S option or the savehist
mechanism, to the history list. -M is like -L, but the contents of filename are merged into the history list and sorted
by timestamp. In either case, histfile is used if filename is not given and ~/.history is used if histfile is unset. `history
-L' is exactly like 'source -h' except that it does not require a filename.
Note that login shells do the equivalent of `history -L' on startup and, if savehist is set, `history -S' before exiting.
Because only ~/.tcshrc is normally sourced before ~/.history, histfile should be set in ~/.tcshrc rather than ~/.login.
If histlit is set, the first and second forms print and save the literal (unexpanded) form of the history list.
The last form clears the history list.
References
id
102
id
In computer software, id is a program in Unix-like operating systems that prints the user or group identifier of the
account by which the program is executed; an example of the command id as executed by user alice:
alice@darkstar:~$ id
uid=1016(alice) gid=100(users) groups=100(users)
The root account has a UID of 0:
root@darkstar:~# id
uid=0(root) gid=0(root) groups=0(root)
The whoami utility has been obsoleted by the id utility and displays a user's ID as a name:
alice@darkstar:~$ whoami
alice
alice@darkstar:~$ id -un # Where `-u` refers to `--user` and `-n`
refers to `--name`
alice
References
id
[1]
:return user identityCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from
The Open Group
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ id. html
Logname
103
Logname
In computer software, logname (stands for Login Name) is a program in Unix and Unix-like operating systems that
prints the name of the user executing the command. It corresponds to the LOGNAME variable in the system-state
environment. The logname system call and command appeared for the first time in UNIX System III.
Usage: logname
Print the name of the current user.
References
logname
[1]
:return the user's login nameCommands & Utilities Reference, The Single UNIX Specification,
Issue 7 from The Open Group
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ logname. html
Mesg
mesg is a Unix command that sets or reports the permission other users have to write to your terminal using the
talk and write commands. It is invoked as:
mesg [y|n]
The 'y' and 'n' options respectively allow and disallow write access to your terminal. When invoked with no option,
the current permission is printed.
Input redirection may be used to control the permission of another TTY. For example:
% mesg
is y
% tty
/dev/tty1
% mesg < /dev/tty2
is y
% mesg n < /dev/tty2
% mesg < /dev/tty2
is n
% mesg
is y
Mesg
104
References
mesg(1)
[1]
Linux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ mesg
passwd
passwd is a tool on most Unix and Unix-like operating systems used to change a user's password. The password
entered by the user is run through a key derivation function to create a hashed version of the new password, which is
saved. Only the hashed version is stored; the entered password is not saved for security reasons.
When the user logs on, the password entered by the user during the log on process is run through the same key
derivation function and the resulting hashed version is compared with the saved version. If the hashes are identical,
the entered password are considered to be identical, and so the user is authenticated. In theory, it is possible to occur
that two different passwords produce the same hash. However, cryptographic hash functions are designed in such
way that finding any password that produces the given hash is very difficult and practically unfeasible, so if the
produced hash matches the stored one, the user can be authenticated.
The passwd command may be used to change passwords for local accounts, and on most systems, can also be used to
change passwords managed in a distributed authentication mechanism such as NIS, Kerberos, or LDAP.
Password file
The /etc/passwd file is a text-based database of information about users that may log in to the system or other
operating system user identities that own running processes.
In many operating systems this file is just one of many possible back-ends for the more general passwd name
service.
The file's name originates from one of its initial functions as it contained the data used to verify passwords of user
accounts. However, on modern Unix systems the security-sensitive password information is instead often stored in a
different file using shadow passwords, or other database implementations.
The /etc/passwd file typically has file system permissions that allow it to be readable by all users of the system
(world-readable), although it may only be modified by the superuser or by using a few special purpose privileged
commands.
The /etc/passwd file is a text file with one record per line, each describing a user account. Each record consists
of seven fields separated by colons. The ordering of the records within the file is generally unimportant.
An example record may be:
jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh
The fields, in order from left to right, are:
[1]
1. The first field is the user name, i.e. the string a user would type in when logging into the operating system: the
logname. Each record in the file must have a unique user name field.
2. The second field stores information used to validate a user's password; however in most modern uses this field is
usually set to "x" (or some other indicator) with the actual password information being stored in a separate
shadow password file. Setting this field to an asterisk ("*") is a common way to disable direct logins to an account
while still preserving its name. Another possible value is "*NP*" which indicates to use an NIS server to obtain
passwd
105
the password.
[2]
3. The third field is the user identifier, the number that the operating system uses for internal purposes. It does not
have to be unique.
4. The fourth field is the group identifier. This number identifies the primary group of the user; all files that are
created by this user may initially be accessible to this group.
5. The fifth field, called the Gecos field, is commentary that describes the person or account. Typically, this is a set
of comma-separated values including the user's full name and contact details.
6. The sixth field is the path to the user's home directory.
7. The seventh field is the program that is started every time the user logs into the system. For an interactive user,
this is usually one of the system's command line interpreters (shells).
Shadow file
/etc/shadow is used to increase the security level of passwords by restricting all but highly privileged users'
access to hashed password data. Typically, that data is kept in files owned by and accessible only by the super user.
Systems administrators can reduce the likelihood of brute force attacks by making the list of hashed passwords
unreadable by unprivileged users. The obvious way to do this is to make the passwd database itself readable only
by the root user. However, this would restrict access to other data in the file such as username-to-userid mappings,
which would break many existing utilities and provisions. One solution is a "shadow" password file to hold the
password hashes separate from the other data in the world-readable passwd file. For local files, this is usually
/etc/shadow on Linux and Unix systems, or /etc/master.passwd on BSD systems; each is readable only
by root. (Root access to the data is considered acceptable since on systems with the traditional "all-powerful root"
security model, the root user would be able to obtain the information in other ways in any case). Virtually all recent
Unix-like operating systems use shadowed passwords.
The shadow password file does not entirely solve the problem of attacker access to hashed passwords, as some
network authentication schemes operate by transmitting the hashed password over the network (sometimes in
cleartext, e.g., Telnet
[3]
), making it vulnerable to interception. Copies of system data, such as system backups written
to tape or optical media, can also become a means for illicitly obtaining hashed passwords. In addition, the functions
used by legitimate password-checking programs need to be written in such a way that malicious programs cannot
make large numbers of authentication checks at high rates of speed.
On a system without shadowed passwords (typically older Unix systems dating from before 1990 or so), the passwd
file holds the following user information for each user account:
Username
Salt combined with the current hash of the user's password (usually produced from a cryptographic hash function)
Password expiration information
User ID (UID)
Default group ID (GID)
Full name
Home directory path
Login shell
The passwd file is readable by all users so that name service switch can work (e.g., to ensure that user names are
shown when the user lists the contents of a folder), but only the root user can write to it. This means that an attacker
with unprivileged access to the system can obtain the hashed form of every user's password. Those values can be
used to mount a brute force attack offline, testing possible passwords against the hashed passwords relatively quickly
without alerting system security arrangements designed to detect an abnormal number of failed login attempts.
With a shadowed password scheme in use, the /etc/passwd file typically shows a character such as '*', or 'x' in
the password field for each user instead of the hashed password, and /etc/shadow usually contains the following
passwd
106
user information:
User login name
salt and hashed password OR a status exception value e.g.:
"$id$salt$hashed", the printable form of a password hash as produced by crypt (C), where "$id" is the
algorithm used. (On GNU/Linux, "$1$" stands for MD5, "$2a$" is Blowfish, "$2y$" is Blowfish (correct
handling of 8-bit chars), "$5$" is SHA-256 and "$6$" is SHA-512, crypt(3) manpage
[4]
, other Unix may
have different values, like NetBSD
[5]
. Key stretching is used to increase password cracking difficulty, using
by default 1000 rounds of modified MD5,
[6]
64 rounds of Blowfish, 5000 rounds of SHA-256 or SHA-512.
[7]
The number of rounds may be varied for Blowfish
[5]
, or for SHA-256 and SHA-512 by using e.g.
"$6$rounds=50000$".)
Empty string - No password, the account has no password. (Reported by passwd on Solaris with "NP")
[8]
"!" - the account is password Locked, user will be unable to log-in via password authentication but other
methods (e.g. ssh key) may be still allowed)
[9]
"*LK*" or "*" - the account is Locked, user will be unable to log-in via password authentication but other
methods (e.g. ssh key) may be still allowed)
"!!" - the password has never been set (RedHat)
[10]
Days since epoch of last password change
Days until change allowed
Days before change required
Days warning for expiration
Days before account inactive
Days since Epoch when account expires
Reserved
The format of the shadow file is simple, and basically identical to that of the password file, to wit, one line per user,
ordered fields on each line, and fields separated by colons. Many systems require the order of user lines in the
shadow file be identical to the order of the corresponding users in the password file.
History
Password shadowing first appeared in UNIX systems with the development of System V Release 3.2 in 1988 and
BSD4.3 Reno in 1990. But, vendors who had performed ports from earlier UNIX releases did not always include the
new password shadowing features in their releases, leaving users of those systems exposed to password file attacks.
System administrators may also arrange for the storage of passwords in distributed databases such as NIS and
LDAP, rather than in files on each connected system. In the case of NIS, the shadow password mechanism is often
still used on the NIS servers; in other distributed mechanisms the problem of access to the various user
authentication components is handled by the security mechanisms of the underlying data repository.
In 1987 the author of the original Shadow Password Suite, Julie Haugh, experienced a computer break-in and wrote
the initial release of the Shadow Suite containing the login, passwd and su commands. The original release,
written for the SCO Xenix operating system, quickly got ported to other platforms. The Shadow Suite was ported to
Linux in 1992 one year after the original announcement of the Linux project, and was included in many early
distributions, and continues to be included in many current Linux distributions.
In the past, it was necessary to have different commands to change passwords in different authentication schemes.
For example, the command to change a NIS password was yppasswd. This required users to be aware of the different
methods to change passwords for different systems, and also resulted in wasteful duplication of code in the various
programs that performed the same functions with different back ends. In most implementations, there is now a single
passwd command, and the control of where the password is actually changed is handled transparently to the user via
pluggable authentication modules (PAMs). For example, the type of hash used is dictated by the configuration of the
passwd
107
pam_unix.so module. By default, the MD5 hash has been used, while current modules are also capable of
stronger hashes such as blowfish, SHA256 and SHA512.
References
[1] Understanding /etc/passwd File Format (http:/ / www. cyberciti. biz/ faq/ understanding-etcpasswd-file-format/ )
[2] http:/ / man7. org/ linux/ man-pages/ man5/ passwd.5.html
[3] RFC 2877: 5250 Telnet Enhancements
[4] http:/ / man7. org/ linux/ man-pages/ man3/ crypt.3.html
[5] http:/ / netbsd.gw.com/ cgi-bin/ man-cgi?crypt+ 3+ NetBSD-current
[6] Password hashing with MD5-crypt in relation to MD5 (http:/ / www. vidarholen. net/ contents/ blog/ ?p=32)
[7] Implementation of SHA512-crypt vs MD5-crypt (http:/ / www. vidarholen. net/ contents/ blog/ ?p=33)
[8] http:/ / www. cs. bgu.ac. il/ ~arik/ usail/ man/ solaris/ passwd. 1. html
[9] shadow(5) man page (http:/ / linux. die.net/ man/ 5/ shadow)
[10] https:/ / access. redhat. com/ site/ documentation/ en-US/ Red_Hat_Enterprise_Linux/ 3/ html/ Introduction_to_System_Administration/
s1-acctsgrps-rhlspec. html
External links
Manual page from Unix First Edition describing /etc/passwd (http:/ / man. cat-v. org/ unix-1st/ 5/ passwd)
passwd(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=passwd& sektion=1):update a user's
authentication token(s)FreeBSD General Commands Manual
authconfig (http:/ / linux. die. net/ man/ 8/ authconfig), a command-line tool for controlling the use of shadow
passwords
Example shadow file (http:/ / configuration. logfish. net/ index. php/ etc/ shadow) showing the general layout of
the file
su
The su command, also referred to as substitute user, super user, or switch user, allows a computer operator to
change the current user account associated with the running virtual console.
By default, and without any other command line argument, this will elevate the current user to the superuser of the
local system.
Usage
When run from the command line, su asks for the target user's password, and if authenticated, grants the operator
access to that account and the files and directories that account is permitted to access.
john@localhost:~$ su
Password:
root@localhost:/home/john# exit
logout
john@localhost:~$
Additionally, one can switch to another user who is not the superuser; e.g. su jane.
john@localhost:~$ su jane
Password:
jane@localhost:/home/john$ exit
logout
su
108
john@localhost:~$
It should generally be used with a hyphen by administrators (su -, which is identical to su - root), which can
be used to start a login shell. This way users can assume the user environment of the target user:
john@localhost:~$ su - jane
Password:
jane@localhost:~$
A related command called sudo executes a command as another user but observes a set of constraints about which
users can execute which commands as which other users (generally in a configuration file named /etc/sudoers,
best editable by the command visudo). Unlike su, sudo authenticates users against their own password rather
than that of the target user (to allow the delegation of specific commands to specific users on specific hosts without
sharing passwords among them and while mitigating the risk of any unattended terminals).
Some Unix-like systems have a wheel group of users, and only allow these users to su to root. This may or may not
mitigate these security concerns, since an intruder might first simply break into one of those accounts. GNU su,
however, does not support a wheel group for philosophical reasons. Richard Stallman argues that because a wheel
group would prevent users from utilizing root passwords leaked to them, the group would allow existing admins to
ride roughshod over ordinary users.
References
External links
su (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ su-invocation. html) manual pages from
GNU coreutils.
su(1) (http:/ / linux. die. net/ man/ 1/ su)Linux User Commands Manual
The su command (http:/ / www. linfo. org/ su. html) by The Linux Information Project (LINFO)
Definition of su (http:/ / dictionary. die. net/ su) dictionary.die.net
Sudo
109
Sudo
Sudo
sudo in a terminal
Developer(s) Todd C. Miller
Latest stable 1.8.8 / September29, 2013
Written in C
Operating system Unix-like
Type Privilege authorization
License ISC-style
Website
www.sudo.ws
[1]
sudo (/sudu/ or /sudo/) is a program for Unix-like computer operating systems that allows users to run
programs with the security privileges of another user (normally the superuser, or root). Its name is a concatenation of
"su" (substitute user) and "do", or take action.
Unlike the su command, users typically supply their own password to sudo rather than the root password. After
authentication, and if the /usr/local/etc/sudoers (sometimes found at /etc/sudoers) configuration file
permits the user access, then the system will invoke the requested command. The sudoers configuration file enables a
huge amount of configurability, including but not limited to: enabling root commands only from the invoking
terminal; not requiring a password for certain commands; requiring a password per user or group; requiring re-entry
of a password every time or never requiring a password at all for a particular command line. It can also be configured
to permit passing arguments or multiple commands, and even supports commands with regular expressions.
History
The program was originally written by Robert Coggeshall and Cliff Spencer "around 1980" at the Department of
Computer Science at SUNY/Buffalo. The current version is under active development and is maintained by
OpenBSD developer Todd C. Miller and distributed under a BSD-style license.
In November 2009 Thomas Claburn, in response to fears that Microsoft had patented the sudo command, stated
that such suspicions are overblown. The claims were narrowly framed to a particular GUI, rather than to the sudo
concept.
Sudo
110
Design
Unlike the su command, users typically supply their own password to sudo. After authentication, and if the
configuration file permits the user access, then the system will invoke the requested command. By default the user's
password can be retained through a grace period (15 minutes per pseudo terminal), allowing the user to execute
several successive commands as the requested user without having to provide a password again.
sudo is able to log each command run. Where a user attempts to invoke sudo without being listed in the sudoers file
an error is presented to the user indicating that the attempt has been recorded in the system log.
[citation needed]
Configuration
The /etc/sudoers file allows listed users access to execute a subset of commands while having the privileges of
the root user.
sudo may be configured to require the root password, or no password at all.
Impact
In some cases sudo has completely supplanted the superuser login for administrative tasks, most notably in Linux
distributions as well as Apple's Mac OS X.
RBAC
In association with SELinux, sudo can be used to transition between roles in role-based access control (RBAC).
Tools and similar programs
visudo is a command-line utility that allows editing of the /etc/sudoers file in a safe fashion. It opens
/etc/sudoers, using the vi editor's interface by default (although this can be changed by setting the shell's
EDITOR environment variable to a different text editor), prevents multiple simultaneous edits with locks, performs
sanity checks and checks for parse errors.
The runas command provides similar functionality in Microsoft Windows, but it cannot pass current directories,
environment variables or long command lines to the child. And while it supports running the child as another user, it
does not support simple elevation. A true su and sudo for Windows that can pass all of that state information and
start the child either elevated or as another user (or both) is included with Hamilton C shell.
There exist several frontends to sudo for use in a GUI environment, notably kdesudo, and gksudo, and user
interfaces not directly built on sudo but providing similar temporary privilege elevation for administrative
purposes, such as User Account Control in Microsoft Windows and Mac OS X Authorization Services.
References
[1] http:/ / www. sudo. ws
External links
Official website (http:/ / www. sudo. ws/ )
uptime
111
uptime
Uptime is a measure of the time a machine, typically a computer, has been working and available. Uptime is the
opposite of downtime.
Htop adds an exclamation mark when uptime is
bigger than 100 days
It is often used as a measure of computer operating system reliability
or stability, in that this time represents the time a computer can be left
unattended without crashing, or needing to be rebooted for
administrative or maintenance purposes.
[citation needed]
Conversely, long
uptime may indicate negligence, because some critical updates can
require reboots on some platforms.
[1]
Records
In 2005, Novell reported a server with a 6-year uptime.
[2][3]
Although that might sound unusual, that is actually
common when servers are maintained under an industrial context and host critical applications such as banking
systems.
Netcraft maintains the uptime records for many thousands of web hosting computers.
A server running Novell NetWare has been reported to have been shut down after 16 years of uptime due to a failing
hard disk.
[4][5]
Determining system uptime
Microsoft Windows
Using systeminfo
Users of Windows XP Professional, Windows Server 2003 and Windows Vista systems can type systeminfo at
the Command Prompt to display all system information, including the System Up Time.
[6]
C:\> systeminfo | findstr "Time:"
System Up Time: 0 Days, 8 Hours, 7 Minutes, 19 Seconds
Note: Windows Vista Business 64-bit and Windows 7 do not return a "System Up Time" but "System Boot Time"
instead. Also note that the exact text and date format is dependent of the language and locale Windows is running.
Note:Windows 7's "System Boot Time" is not a reliable indicator of boot time. It does not take into account the time
spent in sleep or hibernation mode. Hence, the boot time drifts forward every time the computer is left in sleep or
hibernate mode.
uptime
112
Using net statistics server/workstation
C:\> net statistics workstation | findstr "since"
Server Statistics for \\COMPUTERNAME
Statistics since 8/31/2009 8:52:29 PM
The line that start with "Statistics since ..." provides the time that the server was up from. The command "net stats
srv" is shorthand for "net statistics server."
[7]
The exact text and date format is dependent of the language and locale
Windows is running.
Using Uptime.exe
Microsoft has also provided a downloadable Uptime.exe utility
[8]
:
C:\> Uptime
SYSTEMNAME has been up for: 2 day(s), 4 hour(s), 24 minute(s), 47
second(s)
Note:On Windows 7's the Uptime.exe utility is not a reliable indicator of total uptime either. It gives the same wrong
information than boot time and that Task Manager Uptime. It does not take into account the time spent in sleep or
hibernation mode. The only real indicator may be the one given through "net statistics workstation" under
"Statistics".
Using WMI
Uptime can also be determined via Windows Management Instrumentation from the command-line with WMIC:
C:\> wmic os get lastbootuptime
LastBootUpTime
20110508161751.822066+060
The timestamp is in the format yyyymmddhhmmss.nnn, so this is a computer that last booted up on 8 May 2011 at
16:17:51.822. WMI can also be used to find the boot time of remote computers as well (Windows permissions
allowing), for example with WMIC:
C:\> wmic /node:"my-server" os get lastbootuptime
LastBootUpTime
20101219141712.462006+060
The text "LastBootUpTime" and the timestamp format are always the same regardless of the language and locale,
Windows is running.
WMI can also be used via a programming language such as VBScript or Powershell
[9][10]
uptime
113
Using Windows Task Manager
Windows 7 Task Manager Performance tab
screenshot.
Users of Windows Vista, Windows 7 and Windows 8 can see uptime in
Windows Task Manager under the tab Performance. The uptime
format is DD:HH:MM:SS, that is Days:Hours:Minutes:Seconds that
the system has been up.
Linux
Using uptime
Users of Linux systems can use the uptime utility ( uptime(1)
[11]
Linux User Commands Manual) to get the uptime, together with
the current time, the number of users and load averages for the past 1,
5 and 15 minute intervals:
$ uptime
18:17:07 up 68 days, 3:57, 6 users, load average: 0.16, 0.07, 0.06
Using /proc/uptime
Shows how long the system has been on since it was last restarted:
$ cat /proc/uptime
350735.47 234388.90
The first number is the total number of seconds the system has been up. The second number is how much of that
time the machine has spent idle, in seconds.
[12]
On multi core systems (and some linux versions) the second number
is the sum of the idle time accumulated by each CPU.
[13]
BSD
Using uptime
Like Linux, BSD-based operating systems such as FreeBSD and Mac OS X also have the uptime command (See
uptime(1)
[14]
FreeBSD General Commands Manual).
$ uptime
3:01AM up 69 days, 7:53, 0 users, load averages: 0.08, 0.07, 0.05
Using sysctl
There is also a method of using sysctl to call the system's last boot time:
[15]
$ sysctl kern.boottime
kern.boottime: { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46
2010
uptime
114
OpenVMS
Users of OpenVMS systems can type show system at the command prompt.
[16]
$ show system/noprocess
OpenVMS V7.3-2 on node JACK 29-JAN-2008 16:32:04.67 Uptime 894
22:28:52
This shows the uptime as days then hours:minutes:seconds.
External Uptime Measuring
There are a many external services which can be used to monitor the uptime and downtime as well as availability of
a service or a host. Some examples:
AlertBot
[17]
CloudTrawl
[18]
DownNotifier
[19]
HostTracker
[20]
Internetseer
[21]
HubScript from MonitorHub
[22]
Ping admin
[23]
Pingdom
StatusCake
[24]
The TUGS' Uptime Project
[25]
Thought Provoking
[26]
Uptime Robot
[27]
UpTimePal
[28]
WatchMouse
[29]
Webmon
[30]
References
[1] How to install Windows Updates with only one reboot (http:/ / support. microsoft. com/ kb/ 296861)
[2] Marathon servers: Novell shows off servers with longest uptime (http:/ / www. networkworld. com/ newsletters/ netware/ 2005/ 1128nw2.
html)
[3] Uptime Workhorses: Still Crazy after all these Years (http:/ / www. novell. com/ coolsolutions/ trench/ 241. html)
[4] Ars Technica: Epic uptime achievement unlocked. Can you beat 16 years? (http:/ / arstechnica. com/ information-technology/ 2013/ 03/
epic-uptime-achievement-can-you-beat-16-years/ )
[5] Ars Technica: So long to a valiant companion (http:/ / arstechnica. com/ civis/ viewtopic. php?f=23& t=1199529)
[6] Tracking down uptime in Windows XP (http:/ / archive. is/ 20120708043004/ http:/ / articles. techrepublic. com. com/
5100-10878_11-5826014.html)
[7] How to find Windows uptime? (http:/ / support. microsoft. com/ kb/ 555737)
[8] http:/ / support. microsoft.com/ kb/ 232243
[9] How Can I Tell if a Server has Rebooted? (http:/ / blogs. technet. com/ heyscriptingguy/ archive/ 2004/ 09/ 07/
how-can-i-tell-if-a-server-has-rebooted.aspx)
[10] How Can I Determine the Uptime for a Server? (http:/ / blogs. technet. com/ heyscriptingguy/ archive/ 2005/ 08/ 02/
how-can-i-determine-the-uptime-for-a-server.aspx)
[11] http:/ / linux. die. net/ man/ 1/ uptime
[12] Reference Guide For Red Hat Enterprise Linux 4.5 - 5.2.30. /proc/uptime (http:/ / www. redhat. com/ docs/ manuals/ enterprise/
RHEL-4-Manual/ en-US/ Reference_Guide/ s2-proc-uptime. html)
[13] See comments to the patch (http:/ / lkml.org/ lkml/ 2009/ 5/ 11/ 35)
[14] http:/ / www.freebsd. org/ cgi/ man. cgi?query=uptime& sektion=1
uptime
115
[15] sysctl(8) Mac OS X Manual Page (http:/ / developer. apple. com/ mac/ library/ documentation/ Darwin/ Reference/ ManPages/ man8/ sysctl.
8. html)
[16] PARSEC Group - Undocumented OpenVMS Features (http:/ / www. parsec. com/ openvms/ undocumented. php?page=9)
[17] http:/ / www.alertbot. com
[18] http:/ / www.cloudtrawl. com
[19] http:/ / www.downnotifier. com
[20] http:/ / host-tracker. com
[21] http:/ / www.internetseer. com
[22] http:/ / www.monitorhub. com
[23] http:/ / ping-admin.ru/
[24] http:/ / www.statuscake. com
[25] http:/ / www.uptimeprj. com/
[26] http:/ / www.thoughtprov. com/ website-monitoring
[27] 10 Free Services to Monitor Your Sites Uptime (http:/ / mashable. com/ 2010/ 04/ 09/ free-uptime-monitoring/ )
[28] http:/ / www.uptimepal.com/ ru/
[29] Wikimediafoundation.org (http:/ / wikimediafoundation. org/ wiki/ Press_releases/
February_2011_Wikimedia_selects_Watchmouse_for_monitoring_services)
[30] http:/ / www.webmon.com
talk
talk is a Unix text chat program, originally allowing messaging only between the users logged on to one multi-user
computerbut later extended to allow chat to users on other systems.
Although largely superseded by IRC and other modern systems, it is still included with most Unix-like systems
today, including Linux,
[1]
BSD systems
[2]
and Apple's OSX.
[3]
History
Similar facilities existed on earlier system such as Multics, CTSS, and NLS.
[4]
Early versions of
talkWikipedia:Manual of Style/Dates and numbers#Chronological items did not separate text from each user. Thus,
if each user were to type simultaneously, characters from each user were intermingled. Since slow teleprinter
keyboards were used at the time (11 characters per second maximum), users often could not wait for each other to
finish. It was common etiquette for a long typing user to stop when intermingling occurred to see the listener's
interrupting response. This is much the same as interrupting a long monologue when speaking in person. More
modern versions use curses to break the terminal into multiple zones for each user, thus avoiding intermingling text.
In 1983, a new version of talk was introduced as a Unix command with BSD v4.2, and would also accommodate
electronic conversations between users on different machines. Follow-ons to talk included ntalk and Britt Yenne's
ytalk. ytalk was the first of these three to allow conversations between more than two users, and was written in part
to allow communication between users on computers with different endianness. All of these programs split the
interface into different sections for each participant. The interfaces did not convey the order in which statements
typed by different participants would be reassembled into a log of the conversation. Also, all three programs are
real-time text, where they transmit each character as it was typed. This leads to a more immediate feel to the
discussion than recent instant messaging clients or IRC. Users more familiar with other forms of instant text
communication would sometimes find themselves in embarrassing situations by typing something and deciding to
withdraw the statement, unaware that other participants of the conversation had seen every keystroke happen in real
time.
talk
116
Security
A popular program called "flash", which sent malformed information via the talk protocol, was frequently used by
pranksters to corrupt the terminal output of the unlucky target in the early 1990s.
[citation needed]
It did this by
including terminal commands in the field normally designated for providing the name of the person making the
request. When the victim would receive the talk request, the name of the person sending the request would be
displayed on their screen. This would cause the terminal commands to execute, rendering the person's display
unreadable until they reset it. Later versions of talk blocked flash attempts and alerted the user that one had taken
place. Later it became clear that, by sending different terminal commands, it is even possible to have the user
execute commands. As it has proven impossible to fix all programs that output untrusted data to the terminal,
modern terminal emulators have been rewritten to block this attack, though some may still be vulnerable.
[5][6]
Screenprint
Command-line Unix "talk", using a split screen user interface, was popular in the 1980s and early 1990s.
talk
117
Notes
[1] man talk (http:/ / manpages.ubuntu.com/ manpages/ precise/ en/ man1/ talk. 1posix. html), ubuntu.com
[2] man talk (http:/ / www. freebsd.org/ cgi/ man.cgi?query=talk& sektion=1), freebsd.org
[3] man talk (http:/ / developer. apple. com/ library/ mac/ #documentation/ Darwin/ Reference/ ManPages/ man1/ talk. 1. html#/ / apple_ref/ doc/
man/ 1/ talk), apple.com
[4] http:/ / osdir. com/ ml/ culture. internet. history/ 2002-12/ msg00026. html Origin of 'talk' command
[5] "Fix gnome-terminal vulnerability" (http:/ / rhn. redhat. com/ errata/ RHSA-2003-053. html), redhat.com
[6] Example vulnerability in the Gnome terminal emulator (http:/ / www. securityfocus. com/ bid/ 6948/ info), securityfocus.com
Tput
In computing, tput is a standard Unix operating system command which makes use of terminal capabilities.
Depending on the system, tput uses the terminfo or termcap database, as well as looking into the environment for the
terminal type.
History
Tput was provided in UNIX System V in the early 1980s. A clone of the AT&T tput was submitted to volume 7 of
the mod.sources newsgroup (later comp.sources.unix) in September 1986. In contrast to the System V program, the
clone used termcap rather than terminfo. It accepted command-line parameters for the cm (cursor addressing)
capability, and recognized terminfo capability names.
System V Release 3 provided an improved version which combined the different initialization capabilities as a new
option init, and the reset capabilities as reset, thereby simplifying use of tput for initializing or reinitializing the
terminal. System V Release 3.2 added several printer-specific capabilities to the terminfo database, such as swidm
(enter_doublewide_mode) which tput could use. It also added capabilities for color.
System V Release 4 defined additional terminfo capabilities including standardized ANSI color capabilities setaf
and setab, which could be used by tput.
BSD platforms provided a different implementation of tput in 4.3BSD-Reno (June 1990). It used termcap,
recognizing only termcap capability names, and did not accept command-line parameters for cursor-addressing.
FreeBSD used this in 1994, improving it by accepting one or two numeric command-line parameters.
Ross Ridge's mytinfo package in 1992 provided a tput which accepted either termcap or terminfo capability names.
Like the Reno implementation, it did not pass command-line arguments to parameterized capabilities. ncurses
incorporated the mytinfo code in June 1995. The initial version added a -S option, and interpreted command-line
parameters as described in the System V Release 4 documentation.
Portability
The Open Group defines one option (-T, to specify the terminal type) and three keywords (init, clear and
reset). Most implementations accept the name of a terminal capability together with any parameters that may be
needed for that. However, some implementations expect a termcap name, while others expect a terminfo name.
All System V Release 4 implementations, as well as those which are designed to be compatible, also recognize a -S
option (to tell tput to read data from the standard input), and an additional keyword longname. They also accept
command-line parameters, usually distinguishing numeric from string parameters by the form of the parameter,
checking for all-numeric characters. That makes it impossible for example to set a function-key label to a string of
digits. Using a different approach, ncurses determines the expected type of the parameters with a table of the
terminfo capabilities which use string parameters, eliminating the ambiguity.
Tput
118
Usage
Action Parameters
Set background color tput setab color
Set foreground color tput setaf color
Set bold mode tput bold
Set half-bright mode tput dim
Set underline mode tput smul
Exit underline mode tput rmul
Reverse mode tput rev
Set standout mode tput smso
Exit standout mode tput rmso
Reset all attributes tput sgr0
Color Code
Black 0
Red 1
Green 2
Yellow 3
Blue 4
Magenta 5
Cyan 6
White 7
For an example, to make the terminal font color red, execute
tput setaf 1
References
Further reading
Tansley, D. S. W. (2000). "Creating screen output". Linux and UNIX shell programming. Safari Tech Books
Online. Addison-Wesley. ISBN978-0-201-67472-9.
External links
The Open Group Base Specifications Issue 6 tput (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/
tput. html)
Manual pages
tput(1) manual page for ncurses (http:/ / invisible-island. net/ ncurses/ man/ tput. 1. html)
AIX (http:/ / pic. dhe. ibm. com/ infocenter/ aix/ v7r1/ index. jsp?topic=/ com. ibm. aix. cmds/ doc/ aixcmds5/
tput. htm)
Tput
119
BSDI (http:/ / www. tenacitymedia. com/ cgi-bin/ bsdi-man?proto=1. 1& query=tput& msection=1& apropos=0)
SCO (http:/ / uw714doc. sco. com/ en/ man/ html. 1/ tput. 1. html)
HPUX (http:/ / docs. hp. com/ en/ B3921-90010/ tput. 1. html)
SGI (http:/ / techpubs. sgi. com/ library/ tpl/ cgi-bin/ getdoc. cgi?coll=0650& db=man& fname=/ usr/ share/
catman/ u_man/ cat1/ tput. z)
Sun (http:/ / docs. oracle. com/ cd/ E23824_01/ html/ 821-1461/ tput-1. html)
Tru64 (http:/ / h30097. www3. hp. com/ docs/ base_doc/ DOCUMENTATION/ V51_HTML/ MAN/ MAN1/
0386____. HTM)
Tutorials
Colours and Cursor Movement With tput in Bash Prompt HOWTO (http:/ / tldp. org/ HOWTO/
Bash-Prompt-HOWTO/ x405. html)
Discover tput on IBM DeveloperWorks (http:/ / www. ibm. com/ developerworks/ aix/ library/ au-learningtput/
?S_TACT=105AGY06& )
Uname
uname (short for unix name) is a software program in Unix and Unix-like computer operating systems that prints the
name, version and other details about the current machine and the operating system running on it. The uname
system call and command appeared for the first time in PWB/UNIX. Both are specified by POSIX.
[1][2]
Some Unix variants, such as AT&T UNIX System V Release 3.0, include the related setname program, used to
change the values that uname reports.
The GNU version of uname is included in the "sh-utils" or "coreutils" packages. uname itself is not available as a
standalone program.
Examples
On a system running Darwin, the output from running uname with the -a command line argument might look like
the text below:
Darwin Roadrunner.local 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26
11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386
The following table contains examples from various versions of uname on various platforms.
[3]
Within the bash
shell, the environment variable OSTYPE contains a value similar (but not identical) to the value of uname -o.
Distribution System (or kernel) (-s) Operating
System (or
distribution)
(-o)
Machine (-m) Processor
(-p)
Hardware platform
(-i or -M)
OS (kernel) version (-v) OS (kernel) release (-r)
Android 4.2.1
on Nexus 4
Linux GNU/Linux armv7l
Unknown Unknown
#1 SMP PREEMPT Thu Nov 8 15:42:02 PST 2012 3.4.0-perf-ge039dcb
Android 2.3 on
Meteorit
netbook
Linux GNU/Linux armv6l
Unknown Unknown
any, coreutils
7.1
Linux GNU/Linux sparc64 sparc64 UltraSPARC T1
(Niagara)
(all) (all)
any, coreutils
7.18.4
Linux GNU/Linux ppc64 ppc64 PPC 970FX (XServe
G5)
(all) (all)
Uname
120
CentOS 6.5,
Pentium
SU4100
Linux GNU/Linux i686 i686 i386 #1 SMP Fri Nov 22 00:26:36 UTC 2013 2.6.32-431.el6.i686
Cygwin
(Windows XP),
Pentium 4
CYGWIN_NT-5.1 Cygwin i686
Unknown Unknown
2006-01-20 13:28 1.5.19(0.150/4/2)
Cygwin 1.7
(Windows 7
32-bit), Core i7
CYGWIN_NT-6.1 Cygwin i686
Unknown Unknown
2012-07-20 22:55 1.7.16(0.262/5/3)
Cygwin 1.7
(Windows 7
64-bit), Core i7
CYGWIN_NT-6.1-WOW64 Cygwin i686
Unknown Unknown
2012-05-09 10:25 1.7.15(0.260/5/3)
Cygwin 1.7 64
bit (Windows 7
64-bit)
CYGWIN_NT-6.1 Cygwin x86_64
Unknown Unknown
2014-02-09 21:06 1.7.28(0.271/5/3)
Debian 6.0.5 on
Raspberry Pi B
Linux GNU/Linux armv6l
Unknown Unknown
#90 Wed Apr 18 18:23:05 BST 2012 3.1.9+
Debian on WD
MyBookLive
Linux GNU/Linux ppc
Unknown Unknown
Debian
GNU/Hurd
GNU GNU i686-AT386 unknown unknown (-i) / illegal
option (-M)
GNU-Mach 1.3.99-486/Hurd-0.3 0.3
Debian
GNU/kFreeBSD
6.0, AMD
GNU/kFreeBSD GNU/kFreeBSD x86_64 amd64 AMD Sempron(tm)
Processor 3000+
#0 Thu Nov 26 04:22:59 CET 2009 8.0-1-amd64
DragonFlyBSD DragonFly i368 i368 GENERIC
DragonFlyBSD
2.7, AMD64
DragonFly illegal option x86_64 x86_64 [filename of kernel
conf file]
DragonFly v2.7.3.122.g0ba92-DEVELOPMENT #0: Tue
June 8 16:50:35 CEST 2010
2.7-DEVELOPMENT root@Chance.:
/usr/obj/usr/src/sys/X86_64_GENERIC
Fedora 19 Linux GNU/Linux i686 i686 i386 #1 SMP Fri Mar 7 17:22:54 UTC 2014 3.13.6-100.fc19.i686
FreeBSD 6.1,
Intel
FreeBSD illegal option i386 i386 [kernel name from
kernel conf file. i.e.:
GENERIC]
FreeBSD 6.1-RELEASE-p15 #1: Sun Apr 15 18:04:51
EDT 2007
6.1-RELEASE-p15
FreeBSD 9.0,
Intel
FreeBSD FreeBSD amd64 amd64 [kernel name from
kernel conf file. i.e.:
GENERIC]
FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC
2012
root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
9.0-RELEASE
Gentoo,
UltraSparc IIe
Linux GNU/Linux sparc64 sun4u TI UltraSparc IIe
(Hummingbird)
#1 SMP Wed Nov 10 02:04:26 CET 2010 2.6.34-gentoo-r12
Haiku R1/Alpha
1, QEMU
Haiku Haiku BePC
Unknown Unknown
r33109 Sep 12 2009 17:45:45 1
HP-UX HP-UX illegal option 9000/712 illegal
option
[Unique machine ID
number or node name
if cannot be
determined.]
HP-UX 11i v3 HP-UX illegal option ia64 illegal
option
[Unique machine ID
number or node name
if cannot be
determined.]
U B.11.31
IBM AIX 5.3 AIX AIX 00C57D4D4C00 powerpc IBM,8205-E6B 5 3
IRIX IRIX illegal option IP22 mips illegal option
Uname
121
IRIX 6.5.30,
Origin 2000
IRIX64 illegal option IP30 IP35 mips illegal option 07202013 6.5
Linux Mint 10
"Julia" 64-bit
Linux GNU/Linux x86_64
Unknown Unknown
#33-Ubuntu SMP Sun Sep 19 20:32:27 UTC 2010 2.6.35-22-generic
Linux on Xeon
Phi
Linux GNU/Linux k1om k1om k1om #2 SMP Fri Jun 21 13:43:31 EDT 2013 2.6.38.8-g2593b11
Mac OS X
Panther 10.3,
PowerBook G4
(2004)
Darwin illegal option Power
Macintosh
powerpc illegal option Darwin Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST
2004; root:xnu/xnu-517.11.1.obj~1/RELEASE_PPC
7.8.0
Mac OS X
Snow Leopard
10.6,
MacBook3,1
(Late 2007)
Darwin illegal option i386 i386 illegal option Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT
2009; root:xnu-1456.1.25~1/RELEASE_I386
10.0.0
Mac OS X Lion
10.7.3 build
11D50,
MacbookPro7,1
(Late 2010)
Darwin illegal option x86_64 i386 illegal option Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST
2012; root:xnu-1699.24.23~1/RELEASE_X86_64
11.3.0
Mac OS X
Mountain Lion
10.8.3 build
12D78,
MacbookPro10,1
(Mid 2012)
Darwin illegal option x86_64 i386 illegal option Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST
2013; root:xnu-2050.22.13~1/RELEASE_X86_64
12.3.0
Mac OS X
Mavericks 10.9
build 13A598,
MacbookPro15,1
(Mid 2010)
Darwin illegal option x86_64 i386 illegal option Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT
2013; root:xnu-2422.1.72~6/RELEASE_X86_64
13.0.0
MINIX 3.1.7,
x86
Minix illegal option i686 i386 illegal option 1.7 3
MSYS
(Windows
Vista)
MINGW32_NT-6.0 Msys i686
Unknown Unknown
2009-07-11 17:46 1.0.11(0.46/3/2)
NetBSD Linux i386 i386 Unknown
OpenBSD 5.4 OpenBSD illegal option amd64 amd64 illegal option GENERIC.MP#1 5.4
openSUSE 10.3,
Core2-duo
64-bit
Linux GNU/Linux x86_64 x86_64 x86_64 #1 SMP 2007/09/21 22:29:00 UTC 2.6.22.5-31-default
QNX QNX x86pc x86
Solaris 8 SunOS illegal option sun4u sparc SUNW,UltraAX-i2 Generic_117350-50 5.8
Solaris 9, Sun
Fire 280R
SunOS illegal option sun4u sparc SUNW,Sun-Fire-280R Generic_112233-08 5.9
Solaris 10, Sun
Fire V490
SunOS illegal option sun4u sparc SUNW,Sun-Fire-V490 Generic_142900-13 5.10
Solaris 11.1,
Sun Fire X4540
SunOS Solaris i86pc i386 i86pc 11.1 5.11
Tru64 OSF1 alpha alpha
Uname
122
Ubuntu 11.04 Linux GNU/Linux x86_64 x86_64 x86_64 #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 2.6.38-10-generic
Ubuntu 12.0.4
on Pandaboard
ES
Linux GNU/Linux armv7l armv7l armv7l #33-Ubuntu SMP PREEMPT Sat Jan 26 00:46:04 UTC
2013
3.2.0-1425-omap4
Ultrix ULTRIX VAX
Unity Linux Linux GNU/Linux i686 Intel(R)
Core...
Unknown
(SCO)
UnixWare 7.1.4
UnixWare illegal option i386 x86at -i hardware
serial/license number,
.e.g. 1AB000123 or
NUL000000; -M is
illegal option
7.1.4 5
UWIN (64 bit
Windows 7),
Intel Core i5
UWIN-W7 UWIN i686-64 x64 64/64 2012-06-26 5.0/6.1
Footnotes
[1] uname (http:/ / pubs. opengroup. org/ onlinepubs/ 9699919799/ utilities/ uname. html). The Open Group Base Specifications Issue 7/IEEE Std
1003.1, 2013 Edition. Specifies the command.
[2] uname (http:/ / pubs. opengroup. org/ onlinepubs/ 9699919799/ functions/ uname. html). The Open Group Base Specifications Issue 7/IEEE
Std 1003.1, 2013 Edition. Specifies the function/system call.
[3] [3] These are merely meant to broadly represent common systems; actual output may vary depending on hardware type, OS version, and which
software patches have been installed.
External links
uname(1) (http:/ / linux. die. net/ man/ 1/ uname)Linux User Commands Manual
w
123
w
The command w on many Unix-like operating systems provides a quick summary of every user logged into a
computer, what that user is currently doing, and what load all the activity is imposing on the computer itself. The
command is a one-command combination of several other Unix programs: who, uptime, and ps -a.
Example
Sample output (this may vary between systms):
$ w
11:12am up 608 day(s), 19:56, 6 users, load average: 0.36, 0.36, 0.37
User tty login@ idle what
smithj pts/5 8:52am w
jonesm pts/23 20Apr06 28 -bash
harry pts/18 9:01am 9 pine
peterb pts/19 21Apr06 emacs -nw html/index.html
janetmcq pts/8 10:12am 3days -csh
singh pts/12 16Apr06 5:29 /usr/bin/perl -w perl/test/program.pl
References
External links
w(1) (http:/ / linux. die. net/ man/ 1/ w)Linux User Commands Manual
wall
124
wall
wall (an abbreviation of write to all) is a Unix command-line utility that displays the contents of a file or standard
input to all logged-in users. It is typically used by root to send out shutting down message to all users just before
poweroff.
Invocation
wall reads the message from standard input by default when the filename is omitted, that can be done by piping it
with the echo command:
alice@sleipnir:~$ # `tty` to show the current terminal name
alice@sleipnir:~$ tty
/dev/pts/7
alice@sleipnir:~$ echo Remember to brush your teeth! | wall
The message may also be typed in much the same way cat is used; invoking wall by typing wall and pressing
Enter followed by a message, pressing Enter and ^ Ctrl+D:
alice@sleipnir:~$ wall
Remember to brush your teeth!
^D
Using a here-string:
alice@sleipnir:~$ wall <<< 'Remember to brush your teeth!'
Reading from a file is also supported:
alice@sleipnir:~$ cat .important_announcement
Remember to brush your teeth!
alice@sleipnir:~$ wall .important_announcement # same as `wall !$`
All the commands above should display the following output on terminals that users allow write access to (see
mesg(1)):
Broadcast Message from alice@sleipnir
(/dev/pts/7) at 16:15 ...
Remember to brush your teeth!
References
wall(1)
[1]
:send message to everybody's terminalLinux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ wall
who
125
who
The standard Unix command who displays a list of users who are currently logged into the computer.
The who command is related to the command w, which provides the same information but also displays additional
data and statistics.
Specification
The Single Unix Specification (SUS) specifies that who should list information about accessible users. The XSI
extension also specifies that the data of the username, terminal, login time, process ID, and time since last activity
occurred on the terminal, furthermore, an alternate system database used for user information can be specified as an
optional argument to who.
The command can be invoked with the arguments am i or am I (so it is invoked as who am i or who am I),
showing information about the current terminal only (see the command tty and the -m option below, of which
this invocation is equivalent).
Usage
The SUS without extensions only specifies the following -m, -T, and -u options, all other options are specified in
the XSI extension.
-a, process the system database used for user information with the -b, -d, -l, -p, -r, -t, -T and -u.
-b, show time when system was last rebooted
-d, show zombie processes and details
-H, show column headers
-l, show terminals where a user can log in
-m, show information about the current terminal only
-p, show active processes
-q, quick format, show only names and the number of all users logged on, disables all other options;
equivalent to users command line utility
-r, show runlevel of the init process.
-s, (default) show only name, terminal, and time details
-t, show when system clock was last changed
-T, show details of each terminal in a standard format (see note in Examples section)
-u, show idle time; XSI shows users logged in and displays information whether the terminal has been used
recently or not
Other Unix and Unix-like operating systems may add extra options. GNU who includes a -i option behaving
similarly to -u and a -w option displaying whether the user listed accepts messages (the SUS displays this when
-T is specified), yet GNU who and BSD who both omit a number of the above options (such as -a, -b, -d, and
others); GNU who instead uses -l to perform DNS lookups on hostnames listed.
who
126
Output
The SUS without extensions specifies that the output format is to be "implementation-defined". The XSI extension
specifies a format, but notes that it is not fully specified; delimiters and field lengths are not precisely specified.
Thus, the format of the output differs considerably among Unix implementations.
External links
who
[1]
specification from the Single Unix Specification
who
[2]
manual page from GNU coreutils
who
[3]
manual page from OpenBSD
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ who. html
[2] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ who-invocation. html
[3] http:/ / www. openbsd. org/ cgi-bin/ man.cgi?query=who
Whoami
In computing, whoami is a command found on most Unix-like operating systems, Windows Vista, Windows 7,
Windows 8, Windows Server 2003, and Windows Server 2008. It is a concatenation of the words "Who am I?" and
prints the effective username of the current user when invoked. It has the same effect as the Unix command id
-un.
On Unix-like operating systems, the output of the command is slightly different from $USER because whoami
outputs the username that the user is working under, whereas $USER outputs the username that was used to login.
For example, if the user logged in as John and su into root, whoami displays root and echo $USER displays
John. This is because the su command does not invoke a login shell by default.
The earliest versions were created in 2.9BSD as a convenience form for who am i, the Berkeley Unix who
command's way of printing just the logged in user's identity.
[1]
The GNU version was written by Richard Mlynarik
and is part of the GNU Core Utilities (coreutils).
The command is also available as part of the Windows 2000 Resource Kit
[2]
and Windows XP SP2 Support Tools.
[3]
This command was also available as a NetWare-Command residing in the public-directory of the fileserver. It also
outputs the current connections to which server the workstation is attached with which username.
References
[1] 2.9.1BSD Manual Page (http:/ / www. freebsd. org/ cgi/ man. cgi?query=whoami& apropos=0& sektion=0& manpath=2. 9. 1+ BSD&
arch=default& format=html)
[2] Windows 2000 Resource Kit Tool: Whoami.exe (http:/ / www. microsoft. com/ downloads/ details.
aspx?familyid=3E89879D-6C0B-4F92-96C4-1016C187D429& displaylang=en)
[3] Windows XP Service Pack 2 Support Tools (http:/ / www. microsoft. com/ downloads/ details.
aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38& displaylang=en)
External links
whoami(1) (http:/ / linux. die. net/ man/ 1/ whoami)Linux User Commands Manual
Microsoft TechNet Whoami article (http:/ / technet2. microsoft. com/ windowsserver/ en/ library/
fc7edb8c-0e13-4d95-bb29-ad7464dac7071033. mspx?mfr=true)
write
127
write
write can refer to several Unix commands. All known variations of write are used to write messages to another
user. The most popular variation sends a message directly to another user's TTY.
Usage
The syntax for the write command is:
$ write user [tty]
message
The write session is terminated by sending EOF, which can be done by pressing Ctrl+D. The tty argument is only
necessary when a user is logged into more than one terminal.
Example
A conversation initiated between two users on the same machine:
$ write root pts/7
test
Will show up to the user on that console as:
Message from root@punch on pts/8 at 11:19 ...
test
History
A version of the write command appeared in the First Edition of the Research Unix operating system. Another
variation of write writes a message to a user on a Windows network, using the SMB packet format
[citation needed]
.
Programmer's Workbench UNIX contained a program wall that wrote a message to all users in the same way.
The "Orville write" implementation of write dates from ca 1985.
Footnotes
128
Text processing
awk
AWK
Paradigm(s) scripting, procedural, data-driven
Designed by Alfred Aho, Peter Weinberger, and Brian Kernighan
Appeared in 1977
Stable release
IEEE Std 1003.1-2008
[1]
(POSIX) / 1985
Typing discipline none; can handle strings, integers and floating point numbers; regular expressions
Major implementations awk, GNU Awk, mawk, nawk, MKS AWK, Thompson AWK (compiler), Awka (compiler)
Dialects old awk oawk 1977, new awk nawk 1985, GNU Awk gawk
Influenced by C, SNOBOL4, Bourne shell
Influenced Tcl, AMPL, Perl, Korn Shell (ksh93, dtksh, tksh), Lua
OS Cross-platform
Website
cm.bell-labs.com/cm/cs/awkbook
[2]
AWK is an interpreted programming language designed for text processing and typically used as a data extraction
and reporting tool. It is a standard feature of most Unix-like operating systems. AWK was very popular in the late
1970s and 1980s, but from the 1990s has not retained its level of awareness in light of newer languages like
Perl,
[3]
WP:NOTRS on which AWK had a strong influence.
AWK was created at Bell Labs in the 1970s,
[4]
and its name is derived from the family names of its authors Alfred
Aho, Peter Weinberger, and Brian Kernighan. The acronym is pronounced the same as the name of the bird, auk
(which acts as an emblem of the language such as on The AWK Programming Language
[5]
book cover - the book is
often referred to by the abbreviation TAPL). When written in all lowercase letters, as awk, it refers to the Unix or
Plan 9 program that runs scripts written in the AWK programming language.
The AWK language is a data-driven scripting language consisting of a set of actions to be taken against streams of
textual data either run directly on files or used as part of a pipeline for purposes of extracting or transforming
text, such as producing formatted reports. The language extensively uses the string datatype, associative arrays (that
is, arrays indexed by key strings), and regular expressions. While AWK has a limited intended application domain,
and was especially designed to support one-liner programs, the language is Turing-complete, and even the early Bell
Labs users of AWK often wrote well-structured large AWK programs.
awk
129
History
As one of the early tools to appear in Version 7 Unix, it gained popularity as a way to add computational features to
a Unix pipeline and besides the Bourne shell is the only scripting language available in a standard Unix environment.
It is one of the mandatory utilities of the Single UNIX Specification;
[6]
required by the Linux Standard Base
specification
[7]
and implementations of AWK exist for almost all other operating systems.
[citation needed]
AWK was preceded by sed (1974) they are both designed for text processing, share the line-oriented, data-driven
paradigm, and are particularly suited to writing one-liner programs, due to the implicit main loop and current line
variables. Sed is significantly simpler, while AWK can be seen as extending the same approach. AWK was an
important inspiration for Perl, which is in turn a more complex and multi-paradigm programming language, but
allows the same data-driven programming as in AWK. The power and terseness of early AWK programs notably
the powerful regular expression handling and concision due to implicit variables, which facilitate one-liners
together with the limitations of AWK at the time, were important inspirations for Larry Wall when developing Perl.
AWK was initially developed in 1977, then significantly revised and expanded in 198588, resulting in nawk (New
AWK) and the free GNU AWK (gawk) implementation see versions and implementations, below. The revision of
AWK coincided with the development of Perl (1987), and in the 1990s Perl became very popular, largely replacing
AWK in the niche of Unix text-processing languages. AWK remains in some use, and is also of continuing interest
as an archetypal example of the data-driven programming paradigm.
Structure of AWK programs
"AWK is a language for processing text files. A file is treated as a sequence of records, and by default
each line is a record. Each line is broken up into a sequence of fields, so we can think of the first word in
a line as the first field, the second word as the second field, and so on. An AWK program is of a
sequence of pattern-action statements. AWK reads the input a line at a time. A line is scanned for each
pattern in the program, and for each pattern that matches, the associated action is executed." - Alfred V.
Aho
[8]
An AWK program is a series of pattern action pairs, written as:
''condition'' { ''action'' }
where condition is typically an expression and action is a series of commands. The input is split into records, where
by default records are separated by newline characters so that the input is split into lines. The program tests each
record against each of the conditions in turn, and executes the action for each expression that is true. Either the
condition or the action may be omitted. The condition defaults to matching every record. The default action is to
print the record. This is the same pattern-action structure as sed.
In addition to a simple AWK expression, such as foo == 1 or /^foo/, the condition can be BEGIN or END
causing the action to be executed before or after all records have been read, or pattern1, pattern2 which matches the
range of records starting with a record that matches pattern1 up to and including the record that matches pattern2
before again trying to match against pattern1 on future lines.
In addition to normal arithmetic and logical operators, AWK expressions include the tilde operator, ~, which
matches a regular expression against a string. As handy syntactic sugar, /regexp/ without using the tilde operator
matches against the current record; this syntax derives from sed, which in turn inherited it from the ed editor, where
/ is used for searching. This syntax of using slashes as delimiters for regular expressions was subsequently adopted
by Perl and ECMAScript, and is now quite common. The tilde operator was also adopted by Perl, but has not seen as
wide use.
awk
130
AWK commands
AWK commands are the statements that are substituted for action in the examples above. AWK commands can
include function calls, variable assignments, calculations, or any combination thereof. AWK contains built-in
support for many functions; many more are provided by the various flavors of AWK. Also, some flavors support the
inclusion of dynamically linked libraries, which can also provide more functions.
For brevity, the enclosing curly braces ( { } ) will be omitted from these examples.
The print command
The print command is used to output text. The output text is always terminated with a predefined string called the
output record separator (ORS) whose default value is a newline. The simplest form of this command is:
print
This displays the contents of the current record. In AWK, records are broken down into fields, and these can
be displayed separately:
print $1
Displays the first field of the current record
print $1, $3
Displays the first and third fields of the current record, separated by a predefined string called the output field
separator (OFS) whose default value is a single space character
Although these fields ($X) may bear resemblance to variables (the $ symbol indicates variables in Perl), they actually
refer to the fields of the current record. A special case, $0, refers to the entire record. In fact, the commands
"print" and "print $0" are identical in functionality.
The print command can also display the results of calculations and/or function calls:
print 3+2
print foobar(3)
print foobar(variable)
print sin(3-2)
Output may be sent to a file:
print "expression" > "file name"
or through a pipe:
print "expression" | "command"
Built-in variables
Awk's built-in variables include the field variables: $1, $2, $3, and so on ($0 represents the entire record). They hold
the text or values in the individual text-fields in a record.
Other variables include:
NR: Keeps a current count of the number of input records.
NF: Keeps a count of the number of fields in an input record. The last field in the input record can be designated
by $NF.
FILENAME: Contains the name of the current input-file.
FS: Contains the "field separator" character used to divide fields on the input record. The default, "white space",
includes any space and tab characters. FS can be reassigned to another character to change the field separator.
awk
131
RS: Stores the current "record separator" character. Since, by default, an input line is the input record, the default
record separator character is a "newline".
OFS: Stores the "output field separator", which separates the fields when Awk prints them. The default is a
"space" character.
ORS: Stores the "output record separator", which separates the output records when Awk prints them. The default
is a "newline" character.
OFMT: Stores the format for numeric output. The default format is "%.6g".
Variables and syntax
Variable names can use any of the characters [A-Za-z0-9_], with the exception of language keywords. The operators
+ - * / represent addition, subtraction, multiplication, and division, respectively. For string concatenation, simply
place two variables (or string constants) next to each other. It is optional to use a space in between if string constants
are involved, but two variable names placed adjacent to each other require a space in between. Double quotes delimit
string constants. Statements need not end with semicolons. Finally, comments can be added to programs by using #
as the first character on a line.
User-defined functions
In a format similar to C, function definitions consist of the keyword function, the function name, argument names
and the function body. Here is an example of a function.
function add_three (number) {
return number + 3
}
This statement can be invoked as follows:
print add_three(36) # Outputs '''39'''
Functions can have variables that are in the local scope. The names of these are added to the end of the argument list,
though values for these should be omitted when calling the function. It is convention to add some whitespace in the
argument list before the local variables, to indicate where the parameters end and the local variables begin.
Sample applications
Hello World
Here is the customary "Hello world" program written in AWK:
BEGIN { print "Hello, world!" }
Note that an explicit exit statement is not needed here; since the only pattern is BEGIN, no command-line
arguments are processed.
Print lines longer than 80 characters
Print all lines longer than 80 characters. Note that the default action is to print the current line.
length($0) > 80
awk
132
Print a count of words
Count words in the input, and print the number of lines, words, and characters (like wc)
{
w += NF
c += length + 1
}
END { print NR, w, c }
As there is no pattern for the first line of the program, every line of input matches by default so the increment actions
are executed for every line. Note that w += NF is shorthand for w = w + NF.
Sum last word
{ s += $NF }
END { print s + 0 }
s is incremented by the numeric value of $NF which is the last word on the line as defined by AWK's field separator,
by default white-space. NF is the number of fields in the current line, e.g. 4. Since $4 is the value of the fourth field,
$NF is the value of the last field in the line regardless of how many fields this line has, or whether it has more or
fewer fields than surrounding lines. $ is actually a unary operator with the highest operator precedence. (If the line
has no fields then NF is 0, $0 is the whole line, which in this case is empty apart from possible white-space, and so
has the numeric value 0
At the end of the input the END pattern matches so s is printed. However, since there may have been no lines of
input at all, in which case no value has ever been assigned to s, it will by default be an empty string. Adding zero to a
variable is an AWK idiom for coercing it from a string to a numeric value. (Concatenating an empty string is to
coerce from a number to a string, e.g. s "". Note, there's no operator to concatenate strings, they're just placed
adjacently.) With the coercion the program prints 0 on an empty input, without it an empty line is printed.
Match a range of input lines
$ yes Wikipedia | awk 'NR % 4 == 1, NR % 4 == 3 { printf "%6d %s\n", NR, $0 }' | sed 7q
1 Wikipedia
2 Wikipedia
3 Wikipedia
5 Wikipedia
6 Wikipedia
7 Wikipedia
9 Wikipedia
The yes command repeatedly prints its argument (by default the letter "y") on a line. In this case, we tell the
command to print the word "Wikipedia". The action statement prints each line numbered. The printf function
emulates the standard C printf, and works similarly to the print command described above. The pattern to match,
however, works as follows: NR is the number of records, typically lines of input, AWK has so far read, i.e. the
current line number, starting at 1 for the first line of input. % is the modulo operator. NR % 4 == 1 is true for the
first, fifth, ninth, etc., lines of input. Likewise, NR % 4 == 3 is true for the third, seventh, eleventh, etc., lines of
input. The range pattern is false until the first part matches, on line 1, and then remains true up to and including when
the second part matches, on line 3. It then stays false until the first part matches again on line 5. The sed command is
used to print the first 7 lines, to prevent yes running forever. It is equivalent to head -n7 if the head command
is available. Or just add ; if (++n == 7) exit after the print statement.
awk
133
The first part of a range pattern being constantly true, e.g. 1, can be used to start the range at the beginning of input.
Similarly, if the second part is constantly false, e.g. 0, the range continues until the end of input:
/^--cut here--$/, 0
prints lines of input from the first line matching the regular expression ^--cut here--$, that is, a line containing only
the phrase "--cut here--", to the end.
Calculate word frequencies
Word frequency uses associative arrays:
BEGIN {
FS="[^a-zA-Z]+"
}
{
for (i=1; i<=NF; i++)
words[tolower($i)]++
}
END {
for (i in words)
print i, words[i]
}
The BEGIN block sets the field separator to any sequence of non-alphabetic characters. Note that separators can be
regular expressions. After that, we get to a bare action, which performs the action on every input line. In this case,
for every field on the line, we add one to the number of times that word, first converted to lowercase, appears.
Finally, in the END block, we print the words with their frequencies. The line
for (i in words)
creates a loop that goes through the array words, setting i to each subscript of the array. This is different from most
languages, where such a loop goes through each value in the array. The loop thus prints out each word followed by
its frequency count. tolower was an addition to the One True awk (see below) made after the book was
published.
Match pattern from command line
This program can be represented in several ways. The first one uses the Bourne shell to make a shell script that does
everything. It is the shortest of these methods:
pattern=$1
shift
awk '/'$pattern'/ { print FILENAME ":" $0 }' "$@"
The $pattern in the awk command is not protected by quotes. A pattern by itself in the usual way checks to see
if the whole line ($0) matches. FILENAME contains the current filename. awk has no explicit concatenation
operator; two adjacent strings concatenate them. $0 expands to the original unchanged input line.
There are alternate ways of writing this. This shell script accesses the environment directly from within awk:
pattern=$1
shift
awk '$0 ~ ENVIRON["pattern"] { print FILENAME ":" $0 }' "$@"
awk
134
This is a shell script that uses ENVIRON, an array introduced in a newer version of the One True awk after the book
was published. The subscript of ENVIRON is the name of an environment variable; its result is the variable's value.
This is like the getenv function in various standard libraries and POSIX. The shell script makes an environment
variable pattern containing the first argument, then drops that argument and has awk look for the pattern in each
file.
~ checks to see if its left operand matches its right operand; !~ is its inverse. Note that a regular expression is just a
string and can be stored in variables.
The next way uses command-line variable assignment, in which an argument to awk can be seen as an assignment to
a variable:
pattern=$1
shift
awk '$0 ~ pattern { print FILENAME ":" $0 }' "pattern=$pattern" "$@"
Or You can use the -v var=value command line option (e.g. awk -v pattern="$pattern" ...).
Finally, this is written in pure awk, without help from a shell or without the need to know too much about the
implementation of the awk script (as the variable assignment on command line one does), but is a bit lengthy:
BEGIN {
pattern = ARGV[1]
for (i = 1; i < ARGC; i++) # remove first argument
ARGV[i] = ARGV[i + 1]
ARGC--
if (ARGC == 1) { # the pattern was the only thing, so force read from standard input (used by book)
ARGC = 2
ARGV[1] = "-"
}
}
$0 ~ pattern { print FILENAME ":" $0 }
The BEGIN is necessary not only to extract the first argument, but also to prevent it from being interpreted as a
filename after the BEGIN block ends. ARGC, the number of arguments, is always guaranteed to be 1, as
ARGV[0] is the name of the command that executed the script, most often the string "awk". Also note that
ARGV[ARGC] is the empty string, "". # initiates a comment that expands to the end of the line.
Note the if block. awk only checks to see if it should read from standard input before it runs the command. This
means that
awk 'prog'
only works because the fact that there are no filenames is only checked before prog is run! If you explicitly set
ARGC to 1 so that there are no arguments, awk will simply quit because it feels there are no more input files.
Therefore, you need to explicitly say to read from standard input with the special filename -.
awk
135
Self-contained AWK scripts
On Unix-like operating systems self-contained AWK scripts can be constructed using the "shebang" syntax.
For example, a script called hello.awk that prints the string Hello, world! may be built by creating a file named
hello.awk containing the following lines:
#!/usr/bin/awk -f
BEGIN { print "Hello, world!" }
The -f tells awk that the argument that follows is the file to read the AWK program from, and the same flag is used
in sed. Both these programs default to executing a program given as a command line argument, rather than a separate
file since they are often used for one-liners though most other interpreted languages default to reading a program
from a file.
Versions and implementations
AWK was originally written in 1977, and distributed with Version 7 Unix.
In 1985 its authors started expanding the language, most significantly by adding user-defined functions. The
language is described in the book The AWK Programming Language, published 1988, and its implementation was
made available in releases of UNIX System V. To avoid confusion with the incompatible older version, this version
was sometimes called "new awk" or nawk. This implementation was released under a free software license in 1996,
and is still maintained by Brian Kernighan. (see external links below)
Old versions of Unix, such as UNIX/32V, included awkcc, which converted AWK to C. Kernighan wrote a
program to turn awk into C++; its state is not known.
[9]
BWK awk or nawk refers to the version by Brian Kernighan. It has been dubbed the "One True AWK" because
of the use of the term in association with the book that originally described the language and the fact that
Kernighan was one of the original authors of AWK.
[10]
FreeBSD refers to this version as one-true-awk.
[11]
This
version also has features not in the book, such as tolower and ENVIRON that are explained above; see the
FIXES file in the source archive for details. This version is used by e.g. FreeBSD, NetBSD, OpenBSD and OS X.
gawk (GNU awk) is another free software implementation and the only implementation that makes serious
progress implementing internationalization and localization and TCP/IP networking. It was written before the
original implementation became freely available. It includes its own debugger, and its profiler enables the user to
make measured performance enhancements to a script, and it also enables the user to extend functionality via
shared libraries. Linux distributions are mostly GNU software, and so they include gawk. FreeBSD before version
5.0 also included gawk version 3.0 but subsequent versions of FreeBSD use BWK awk to avoid the more
restrictive GNU General Public License (GPL) license as well as for its technical characteristics.
[12][13]
mawk is a very fast AWK implementation by Mike Brennan based on a byte code interpreter.
libmawk is a fork of mawk, allowing applications to embed multiple parallel instances of awk interpreters.
awka (which front end is written atop the mawk program) is another translator of AWK scripts into C code. When
compiled, statically including the author's libawka.a, the resulting executables are considerably sped up and,
according to the author's tests, compare very well with other versions of AWK, Perl, or Tcl. Small scripts will
turn into programs of 160-170 kB.
tawk (Thompson AWK) is an AWK compiler for Solaris, DOS, OS/2, and Windows, previously sold by
Thompson Automation Software (which has ceased its activities).
Jawk is a project to implement AWK in Java, hosted on SourceForge.
[14]
Extensions to the language are added to
provide access to Java features within AWK scripts (i.e., Java threads, sockets, Collections, etc.).
awk
136
jawk (Josh's Awk) is a modern implementation of AWK in the Perl programming language, hosted on CPAN.
[15]
It supports ranges, indexing columns by negative numbers, a Perl mode, and more.
xgawk is a fork of gawk
[16]
that extends gawk with dynamically loadable libraries. The XMLgawk extension was
integrated into the official GNU Awk release 4.1.0.
QSEAWK is an embedded AWK interpreter implementation included in the QSE library that provides
embedding application programming interface (API) for C and C++.
[17]
BusyBox includes a sparsely documented AWK implementation that appears to be complete, written by Dmitry
Zakharov. This is a very small implementation suitable for embedded systems.
Books
Aho, Alfred V.; Kernighan, Brian W.; Weinberger, Peter J. (1988-01-01). The AWK Programming Language
[18]
.
New York, NY: Addison-Wesley. ISBN0-201-07981-X. Retrieved 2009-04-16. The book's webpage includes
downloads of the current implementation of Awk and links to others.
Robbins, Arnold (2001-05-15). Effective awk Programming
[19]
(3rd ed.). Sebastopol, CA: O'Reilly Media.
ISBN0-596-00070-7. Retrieved 2009-04-16.
Dougherty, Dale; Robbins, Arnold (1997-03-01). sed & awk
[20]
(2nd ed.). Sebastopol, CA: O'Reilly Media.
ISBN1-56592-225-5. Retrieved 2009-04-16.
Robbins, Arnold (2000). Effective Awk Programming: A User's Guide for Gnu Awk
[21]
(1.0.3 ed.). Bloomington,
IN: iUniverse. ISBN0-595-10034-1. Archived
[22]
from the original on 12 April 2009. Retrieved 2009-04-16.
Arnold Robbins maintained the GNU Awk implementation of AWK for more than 10 years. The free GNU Awk
manual was also published by O'Reilly in May 2001. Free download of this manual is possible through the
following book references.
References
[1] http:/ / pubs. opengroup. org/ onlinepubs/ 9699919799/ utilities/ awk. html
[2] http:/ / cm.bell-labs. com/ cm/ cs/ awkbook
[3] http:/ / www. software. ac.uk/ blog/ 2013-10-25-heroes-software-engineering-brian-kernighan-man-who-put-k
[4] Awk -- A Pattern Scanning and Processing Language (Second Edition) (1978) (http:/ / citeseerx. ist. psu. edu/ viewdoc/ summary?doi=10. 1.
1. 31. 1299)
[5] http:/ / plan9. bell-labs. com/ cm/ cs/ awkbook/
[6] The Single UNIX Specification, Version 3, Utilities Interface Table (http:/ / www. unix. org/ version3/ apis/ cu. html)
[7] Linux Standard Base Core Specification 4.0, Chapter 15. Commands and Utilities (http:/ / refspecs. freestandards. org/ LSB_4. 0. 0/
LSB-Core-generic/ LSB-Core-generic/ command. html#AEN32008)
[8] http:/ / www. computerworld. com. au/ index.php/ id;1726534212;pp;2 The A-Z of Programming Languages: AWK
[9] An AWK to C++ Translator (http:/ / cm. bell-labs. com/ cm/ cs/ who/ bwk/ awkc+ + . ps)
[10] The AWK Programming Language, ISBN 0-201-07981-X. (http:/ / cm. bell-labs. com/ cm/ cs/ awkbook/ )
[11] FreeBSD's work log for importing BWK awk into FreeBSD's core (http:/ / www. freebsd. org/ cgi/ cvsweb. cgi/ src/ contrib/ one-true-awk/
FREEBSD-upgrade?rev=1. 9& content-type=text/ x-cvsweb-markup), dated 2005-05-16, downloaded 2006-09-20
[12] FreeBSD's view of GPL Advantages and Disadvantages (http:/ / www. freebsd. org/ doc/ en_US. ISO8859-1/ articles/ bsdl-gpl/ )
[13] FreeBSD 5.0 release notes (http:/ / www.freebsd. org/ releases/ 5. 0R/ relnotes-i386. html#USERLAND) with notice of BWK awk in the
base distribution
[14] Jawk at SourceForge (http:/ / sourceforge.net/ projects/ jawk/ )
[15] jawk at CPAN (https:/ / metacpan. org/ module/ jawk)
[16] xgawk Home Page (http:/ / gawkextlib. sourceforge.net/ )
[17] QSEAWK at Google Code (http:/ / qse.googlecode. com/ )
[18] http:/ / cm. bell-labs.com/ cm/ cs/ awkbook/
[19] http:/ / www.oreilly. com/ catalog/ awkprog3/
[20] http:/ / www.oreilly. com/ catalog/ sed2/
[21] http:/ / www.gnu. org/ software/ gawk/ manual/
[22] http:/ / web.archive. org/ web/ 20090412190359/ http:/ / www. gnu. org/ software/ gawk/ manual/
awk
137
Further reading
Hamilton, Naomi (2008-05-27). "The A-Z of Programming Languages: AWK" (http:/ / www. computerworld.
com. au/ article/ 216844). Computerworld. Retrieved 2009-04-16. Interview with Alfred V. Aho on AWK
Robbins, Daniel (2000-12-01). "Awk by example, Part 1: An intro to the great language with the strange name"
(http:/ / www. ibm. com/ developerworks/ linux/ library/ l-awk1. html). Common threads. IBM DeveloperWorks.
Retrieved 2009-04-16.
Robbins, Daniel (2001-01-01). "Awk by example, Part 2: Records, loops, and arrays" (http:/ / www. ibm. com/
developerworks/ linux/ library/ l-awk2. html). Common threads. IBM DeveloperWorks. Retrieved 2009-04-16.
Robbins, Daniel (2001-04-01). "Awk by example, Part 3: String functions and ... checkbooks?" (http:/ / www.
ibm. com/ developerworks/ linux/ library/ l-awk3. html). Common threads. IBM DeveloperWorks. Archived
(http:/ / web. archive. org/ web/ 20090519074032/ http:/ / www. ibm. com/ developerworks/ linux/ library/
l-awk3. html) from the original on 19 May 2009. Retrieved 2009-04-16.
AWK Become an expert in 60 minutes (http:/ / www. think-lamp. com/ 2008/ 10/
awk-a-boon-for-cli-enthusiasts/ )
awk (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ awk. html):pattern scanning and
processing languageCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The
Open Group
gawk(1) (http:/ / linux. die. net/ man/ 1/ gawk)Linux User Commands Manual
Gawkinet (http:/ / www. gnu. org/ software/ gawk/ manual/ gawkinet/ ): TCP/IP Internetworking with Gawk
External links
The Amazing Awk Assembler (http:/ / doc. cat-v. org/ henry_spencer/ amazing_awk_assembler/ ) by Henry
Spencer.
Awk Community Portal (http:/ / awk. info/ )
Awk on flossmanuals.net (http:/ / en. flossmanuals. net/ command-line/ ch044_awk)
AWK (http:/ / www. dmoz. org/ Computers/ Programming/ Languages/ Awk) on the Open Directory Project
Git repository of the direct lineage of the original AWK source code (https:/ / github. com/ danfuzz/
one-true-awk)
banner
138
banner
The Unix banner program outputs a large ASCII art version of the text that is supplied to it as its program
arguments. One use of the command is to create highly visible separator pages for print jobs.
Operation
Each argument is truncated at 10 characters and printed on a "line" of its own. To print multiple words on a single
line, they must therefore be passed as a single argument, which is done from the shell by escaping or quoting the
words as appropriate.
A related and more flexible program is FIGlet, which can display text in different fonts and orientations.
Implementation
The way that the program is implemented internally is antiquated. The character fonts used are hardwired into the
program code itself, as statically initialized data structures. Two data structures are used. The first is a data table
comprising a sequence of printing instructions that encode the bitmap for each character (in an encoding specific to
the banner program). The second is an index into that table that indicates, for each character code, where the
printing instructions for that character begin and end.
Both data structures were hand-written. Spinellis observes that it is "difficult to come up with a more error-prone and
unmaintainable data format". He observes a stark contrast between the source code of the banner program and
automatically generated source code for encoding computer fonts into program data (using the 6-by-10 font data in
the source code of the mac68k port of NetBSD for comparison). The automatically generated data are commented,
documenting with ASCII art how the bit patterns were derived. The automatically generated data were generated
from a bitmap file, itself generated using a bitmap creation/editing program with a graphical user interface. And the
automatically generated data are organized in a straightforward and obvious manner a fixed-length sequence of
unencoded bytes for each glyph.
Spinellis further observes that in modern computer systems it is seldom sensible to embed such data into the program
executable image itself, the performance gains of doing so being negligible. Doing so makes it difficult to adapt the
program to different locales, or to maintain the program. The more preferred approach in modern systems is to store
such data in a separate data file, distinct from the program executable image file, or in a resource fork of the
program, that the program reads at run-time.
Versions
A partial list of versions:
By AT&T, in UNIX System V.
[1][2][3]
By Cedar Solutions
[4]
. Runs on modern Linux systems as of 2008. Prints horizontally only with a fixed size.
By Mark Horton at the University of California Berkeley, distributed as part of the bsdmainutils
[5]
package,
under the name printerbanner. Runs of modern Linux, GNU Hurd and Mac OS X systems as of 2008. Prints
vertically with variable size font.
banner
139
Example output
From the terminal-oriented banner program:
$ banner 'Hello!'
# # ###
# # ###### # # #### ###
# # # # # # # ###
####### ##### # # # # #
# # # # # # #
# # # # # # # ###
# # ###### ###### ###### #### ###
One letter from the printer-oriented banner program as usually found in BSD and derivatives:
$ banner -w80 "a"
#####
#########
############### ###
################ ######
################## ########
##### ##### #########
#### #### ## ###
### #### ##
### ### ##
### ### ###
#### ### ####
#############################
##############################
##############################
############################
###########################
###
#
#
Display a continuous clock for 1000 seconds:
$ repeat 1000 sh -c '( clear ; date +" %H.%M.%S" | xargs banner ;
sleep 1)'
# ##### # ##### ####### #######
## # # ## # # # #
# # # # # # # #
# ###### # ##### ###### ######
# # # ### # # ### # #
# # # ### # # ### # # # #
##### ##### ### ##### ####### ### ##### #####
banner
140
References
[1] http:/ / www. zen77087.zen. co. uk/ nug/ alleg/ sysv-aix-dynix. shtml
[2] http:/ / www. zen77087.zen. co. uk/ nug/ doc/ IBM-157-28-E. pdf
[3] http:/ / packages. debian. org/ stable/ sysvbanner
[4] http:/ / cedar-solutions.com/ software/ utilities.html
[5] http:/ / packages. debian. org/ stable/ bsdmainutils
Further reading
Amir Afzal (2008). "The banner command". UNIX Unbounded. Prentice Hall. pp.462463.
ISBN0-13-119449-6.
Basename
basename is a standard UNIX computer program. When basename is given a pathname, it will delete any prefix
up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification
and is primarily used in shell scripts.
Usage
The Single UNIX Specification specification for basename is.
basename string [suffix]
string
A pathname
suffix
If specified, basename will also delete the suffix.
Example
$ basename /home/jsmith/base.wiki
base.wiki
$ basename /home/jsmith/base.wiki .wiki
base
Performance
Since basename accepts only one operand, its usage within the inner loop of shell scripts can be detrimental to
performance. Consider
while read file; do
basename "$file" ;
done < some-input
The above excerpt would cause a separate process invocation for each line of input. For this reason, shell substitution
is typically used instead
echo "${file##*/}";
Basename
141
External links
basename
[1]
:return non-directory portion of a pathnameCommands & Utilities Reference, The Single
UNIX Specification, Issue 7 from The Open Group
basename(1)
[2]
:strip directory and suffix from filenamesLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ basename. html
[2] http:/ / linux.die. net/ man/ 1/ basename
Comm
The comm command in the Unix family of computer operating systems is a utility that is used to compare two files
for common and distinct lines. comm is specified in the POSIX standard. It has been widely available on Unix-like
operating systems since the mid to late 1980s.
Usage
comm reads two files as input, regarded as lines of text. comm outputs one file, which contains three columns. The
first two columns contain lines unique to the first and second file, respectively. The last column contains lines
common to both. This functionally is similar to diff.
Columns are typically distinguished with the <tab> character. If the input files contain lines beginning with the
separator character, the output columns can become ambiguous.
For efficiency, standard implementations of comm expect both input files to be sequenced in the same line collation
order, sorted lexically. The sort (Unix) command can be used for this purpose.
The comm algorithm makes use of the collating sequence of the current locale. If the lines in the files are not both
collated in accordance with the current locale, the result is undefined.
Return code
Unlike diff, the return code from comm has no logical significance concerning the relationship of the two files. A
return code of 0 indicates success, a return code >0 indicates an error occurred during processing.
Example
File foo
apple
banana
eggplant
File bar
apple
banana
banana
zucchini
$ comm foo bar
apple
Comm
142
banana
banana
eggplant
zucchini
This shows that both files have one banana, but only bar has a second banana.
In more detail, the output file has the appearance that follows. Note that the column is interpreted by the number of
leading tab characters. \t represents a tab character and \n represents a newline
(Escape_character#Programming_and_data_formats).
0 1 2 3 4 5 6 7 8 9
0 \t \t a p p l e \n
1 \t \t b a n a n a \n
2 \t b a n a n a \n
3 e g g p l a n t \n
4 \t z u c c h i n i \n
Comparison to diff
In general terms, diff is a more powerful utility than comm. The simpler comm is best suited for use in scripts.
The primary distinction between comm and diff is that comm discards information about the order of the lines
prior to sorting.
A minor difference between comm and diff is that comm will not try to indicate that a line has "changed"
between the two files; lines are either shown in the "from file #1", "from file #2", or "in both" columns. This can be
useful if one wishes two lines to be considered different even if they only have subtle differences.
Other options
comm has command-line options to suppress any of the three columns. This is useful for scripting.
There is also an option to read one file (but not both) from standard input.
Limits
Up to a full line must be buffered from each input file during line comparison, before the next output line is written.
Some implementations read lines with the function readlinebuffer() which does not impose any line length
limits if system memory suffices.
Other implementations read lines with the function fgets(). This function requires a fixed buffer. For these
implementations, the buffer is often sized according to the POSIX macro LINE_MAX.
Comm
143
References
comm
[1]
:select or reject lines common to two filesCommands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
comm(1)
[2]
:compare two sorted files line by lineLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ comm. html
[2] http:/ / linux.die. net/ man/ 1/ comm
Csplit
The csplit command in Unix is a utility that is used to split a file into two or more smaller files determined by
context lines.
Usage
The command-syntax is:
csplit [OPTION]... FILE PATTERN...
The patterns may be line numbers or regular expressions. The program outputs pieces of the file separated by the
patterns into files xx00, xx01, etc., and outputs the size of each piece, in bytes, to standard output.
The optional parameters modify the behaviour of the program in various ways. For example, the default prefix string
(xx) and number of digits (2) in the output filenames can be changed.
As with most Unix utilities, a return code of 0 indicates success, while nonzero values indicate failure.
Comparison to split
The split command also splits a file into pieces, except that all the pieces are of a fixed size (measured in lines or
bytes).
References
csplit
[1]
:split files based on contextCommands & Utilities Reference, The Single UNIX Specification,
Issue 7 from The Open Group
csplit(1)
[2]
:split a file into sections determined by context linesLinux User Commands Manual
Ellen Siever, Aaron Weber, Stephen Figgins, Robert Love, Arnold Robbins, et al. Linux in a Nutshell, 5th
Edition. O'Reilly Media: July 2005. ISBN 978-0-596-00930-4.
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ csplit. html
[2] http:/ / linux.die. net/ man/ 1/ csplit
cut
144
cut
In computing, cut is a Unix command line utility which is used to extract sections from each line of input usually
from a file. It is currently part of the GNU coreutils package and the BSD Base System. It first appeared in AT&T
System III UNIX in 1982.
[1]
Extraction of line segments can typically be done by bytes (-b), characters (-c), or fields (-f) separated by a
delimiter (-d the tab character by default). A range must be provided in each case which consists of one of N,
N-M, N- (N to the end of the line), or -M (beginning of the line to M), where N and M are counted from 1 (there is
no zeroth value). Since version 6, an error is thrown if you include a zeroth value. Prior to this the value was ignored
and assumed to be 1.
Examples
Assuming a file named "file" containing the lines:
foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
the quick brown fox jumps over the lazy dog
To output the fourth through tenth characters of each line:
$ cut -c 4-10 file
This gives the output:
:bar:ba
:two:th
ha:beta
quick
To output the fifth field through the end of the line of each line using the colon character as the field delimiter:
$ cut -d ":" -f 5- file
This gives the output:
quux
five:six:seven
epsilon:zeta:eta:teta:iota:kappa:lambda:mu
the quick brown fox jumps over the lazy dog
(note that because the colon character is not found in the last line the entire line is shown)
Option -d specified a single character delimiter (in the example above it is a colon) which serves as field separator.
Option -f which specifies range of fields included in the output (here fields range from five till the end). Option
-d presupposes usage of option -f.
To output the third field of each line using space as the field delimiter:
$ cut -d " " -f 3 file
This gives the output:
cut
145
foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
brown
(Note that because the space character is not found in the first three lines these entire lines are shown.)
To separate two words having any delimiter:

line=process.processid
$ cut -d "." -f1 $line
$ cut -d "." -f2 $line
This gives the output:
process
processid
Syntax
cut [-b] [-c] [-f list] [-n] [-d delim] [-s] [file]
Flags which may be used include
-b
Bytes; a list following -b specifies a range of bytes which will be returned, e.g. cut -b1-66 would return the
first 66 bytes of a line. NB If used in conjunction with -n, no multi-byte characters will be split. NNB. -b will
only work on input lines of less than 1023 bytes
-c
Characters; a list following -c specifies a range of characters which will be returned, e.g. cut -c1-66 would
return the first 66 characters of a line
-f
Specifies a field list, separated by a delimiter
list
A comma separated or blank separated list of integer denoted fields, incrementally ordered. The - indicator
may be supplied as shorthand to allow inclusion of ranges of fields e.g. 4-6 for ranges 46 or 5- as shorthand
for field 5 to the end, etc.
-n
Used in combination with -b suppresses splits of multi-byte characters
-d
Delimiter; the character immediately following the -d option is the field delimiter for use in conjunction with
the -f option; the default delimiter is tab. Space and other characters with special meanings within the context
of the shell in use must be enquoted or escaped as necessary.
-s
Bypasses lines which contain no field delimiters when -f is specified, unless otherwise indicated.
file
The file (and accompanying path if necessary) to process as input. If no file is specified then standard input
will be used.
cut
146
References
[1] http:/ / www. unix. com/ man-page/ FreeBSD/ 1/ CUT/
External links
Softpanorama cut page (http:/ / www. softpanorama. org/ Tools/ cut. shtml).
cut(1) (http:/ / linux. die. net/ man/ 1/ cut):remove sections from each line of filesLinux User Commands
Manual
Dirname
dirname is a standard UNIX computer program. When dirname is given a pathname, it will delete any suffix
beginning with the last slash ('/') character and return the result. dirname is described in the Single UNIX
Specification and is primarily used in shell scripts.
Usage
The Single UNIX Specification specification for dirname is.
dirname NAME
For example:
$ dirname /usr/home/carpetsmoker/dirname.wiki
/usr/home/carpetsmoker
Performance
Since dirname accepts only one operand, its usage within the inner loop of shell scripts can be detrimental to
performance. Consider
while read file; do
dirname "$file"
done < some-input
The above excerpt would cause a separate process invocation for each line of input. For this reason, shell substitution
is typically used instead
echo "${file%/*}";
Dirname
147
External links
dirname
[1]
:return the directory portion of a pathnameCommands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
dirname(1)
[2]
:strip nondirectory suffix from filenamesLinux User Commands Manual
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ dirname. html
[2] http:/ / linux.die. net/ man/ 1/ dirname
ed
ed is a line editor for the Unix operating system. It was one of the first end-user programs hosted on the system and
has been standard in Unix-based systems ever since.
[1][2]
The original version was written in PDP-11/20 assembler in 1971 by Ken Thompson.
History and influence
The editor was originally written in PDP-11/20 assembler in 1971 by Ken Thompson. Many features of ed came
from the qed from his alma mater University of California at Berkeley
[3]
Thompson was very familiar with qed, and
had reimplemented it on the CTSS and Multics systems. His versions of qed were the first to implement regular
expressions. Although regular expressions are part of ed, their implementation is considerably less general than that
in qed.
Aspects of ed went on to influence ex, which in turn spawned vi. The non-interactive Unix command grep was
inspired by a common special uses of qed and later ed, where the command g/re/p means globally search for the
regular expression re and print the lines containing it. The Unix stream editor, sed implemented many of the
scripting features of qed that were not supported by ed on Unix. In turn sed influenced the design of the
programming language AWK which inspired aspects of Perl.
Features
Features of ed include:
available on essentially all Unix systems (and mandatory on systems conforming to the Single Unix
Specification).
a modal editor supporting command mode, text mode and viewing mode
support for regular expressions
powerful automation can be achieved by feeding commands from standard input
Famous for its terseness, ed gives almost no visual feedback. For example, the message that ed will produce in case
of error, or when it wants to make sure the user wishes to quit without saving, is "?". It does not report the current
filename or line number, or even display the results of a change to the text, unless requested. This terseness was
appropriate in the early versions of Unix, when consoles were teletypes, modems were slow, and memory was
precious. As computer technology improved and these constraints were loosened, editors with more visual feedback
became the norm.
In current practice, ed is rarely used interactively, but does find use in some shell scripts. For interactive use, ed was
subsumed by the sam, vi and Emacs editors in the 1980s. ed can be found on virtually every version of Unix and
GNU/Linux available, and as such is useful for people who have to work with multiple versions of Unix. If
something goes wrong, ed is sometimes the only editor available. This is often the only time when it is used
ed
148
interactively.
The ed commands are often imitated in other line-based editors. For example, EDLIN in early MS-DOS versions and
32-bit versions of Windows NT has a somewhat similar syntax, and text editors in many MUDs (LPMud and
descendants, for example) use ed-like syntax. These editors, however, are typically more limited in function.
Example
Here is an example transcript of an ed session. For clarity, commands and text typed by the user are in normal face,
and output from ed is emphasized.
a
ed is the standard Unix text editor.
This is line number two.
.
2i

.
%l
ed is the standard Unix text editor.$
$
This is line number two.$
3s/two/three/
,l
ed is the standard Unix text editor.$
$
This is line number three.$
w text
65
q
The end result is a simple text file containing the following text:
ed is the standard Unix text editor.

This is line number three.
Started with an empty file, the a command appends text (all ed commands are single letters). The command put ed in
insert mode, inserting the characters that follow and is terminated by a single dot on a line. The two lines that are
entered before the dot end up in the file buffer. The 2i command also goes into insert mode, and will insert the
entered text (a single empty line in our case) before line two. All commands may be prefixed by a line number to
operate on that line.
In the line %l, the lowercase L stands for the list command. The command is prefixed by a range, in this case %
which is a shortcut for 1,$. A range is two line numbers separated by a comma ($ means the last line). In return, ed
lists all lines, from first to last. These lines are ended with dollar signs, so that white space at the end of lines is
clearly visible.
Once the empty line is inserted in line 2, the line which reads "This is line number two." is now actually the third
line. This error is corrected with 3s/two/three/, a substitution command. The 3 will apply it to the correct line,
following the command is the text to be replaced, and then the replacement. Listing all lines with ,l (a lone comma is
also a synonym for %) the line is shown now to be correct.
ed
149
w text writes the buffer to the file "text" making ed respond with 65, the number of characters written to the file. q
will end an ed session.
ed as a design archetype
The influence of ed on later Unix utilities has been noted. More generally, ed continues to serve as an interface
model for programs that must modify record sequences and for which scriptability is extremely important, even
when the records bear little resemblance to the text lines manipulated by ed itself.
Since 2010 one well-known example has been reposurgeon
[4]
, a scriptable editor/converter for version-control
repositories.
Footnotes
[1] http:/ / roguelife. org/ ~fujita/ COOKIES/ HISTORY/ V6/ ed. 1. html
[2] It is included in Linux, NetBSD, FreeBSD and its derivatives like Apple OS X and PC-BSD.
[3] D. M. Ritchie and K. L. Thompson, "QED Text Editor", MM-70-1373-3 (http:/ / cm. bell-labs. com/ cm/ cs/ who/ dmr/ qedman. pdf) (June
1970), reprinted as "QED Text Editor Reference Manual", MHCC-004, Murray Hill Computing, Bell Laboratories (October 1972).
[4] http:/ / www. catb.org/ ~esr/ reposurgeon/
External links
ed (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ ed. html):edit textCommands & Utilities
Reference, The Single UNIX Specification, Issue 7 from The Open Group
Manual page from Unix First Edition describing ed (http:/ / man. cat-v. org/ unix-1st/ 1/ ed).
GNU ed homepage (http:/ / www. gnu. org/ software/ ed/ ed. html)
ed(1) (http:/ / linux. die. net/ man/ 1/ ed):text editorLinux User Commands Manual
ed(1) (http:/ / man. cat-v. org/ plan_9/ 1/ ed) from the Plan 9 from Bell Labs manual, a direct descendant of the
original ed.
GNU ed for Win32 (http:/ / gnuwin32. sourceforge. net/ packages/ ed. htm)
Unix Editors I (http:/ / snap. nlc. dcccd. edu/ learn/ nlc/ ed. html)
Examples for ed in scripts (http:/ / wiki. bash-hackers. org/ howto/ edit-ed)
ed Humor ("Ed is the standard text editor") (http:/ / www. gnu. org/ fun/ jokes/ ed. msg. html)
A History of UNIX before Berkeley (http:/ / www. darwinsys. com/ history/ hist. html) section 3.1 describes the
history of ed.
ex
150
ex
ex, short for EXtended, is a line editor for Unix systems originally written by Bill Joy
[1]
in 1976, beginning with an
earlier program written by Charles Haley.
[2]
The original ex was an advanced version of the standard Unix editor ed, included in the Berkeley Software
Distribution. ex is similar to ed, with the exception that some switches and options are modified so that they are
more user-friendly.
ex was eventually given a screen oriented visual interface (adding to its command line oriented operation), thereby
becoming the vi text editor. In recent times, ex is implemented as a personality of the vi program; most variants of vi
still have an "ex mode", which is invoked using the command ex, or from within vi for one command by typing the :
(colon) character. Although there is overlap between ex and vi functionality, some things can only be done with ex
commands, so it remains useful when using vi.
The core ex commands which relate to search and replace are essential to vi. For instance, the ex command issued
from vi :%s/XXX/YYY/g replaces every instance of XXX with YYY. The % means every line in the file. The 'g'
stands for global and means replace every instance on every line (if it was not specified, then only the first instance
on each line would be replaced).
ex has a synonym e in HP-UX environments.
Switches
ex recognises the following switches:
- (obsolete) suppresses user-interactive feedback
-s (XPG4 only) suppresses user-interactive feedback
-l sets lisp editor option
-r recover specified files after a system crash
-R sets readonly
-t tag Edit the file containing the specified tag
-v invoke visual mode (vi)
-w set window size n
-x set encryption mode
-C encryption option
file specifies file to be edited
External links
ex
[3]
:text editorCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
Notes
[1] ex manual page (http:/ / ex-vi. sourceforge.net/ ex. html)
[2] William N. Joy, Ex reference manual (http:/ / roguelife. org/ ~fujita/ COOKIES/ HISTORY/ 1BSD/ exrefm. pdf), November, 1977
[3] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ ex. html
fmt
151
fmt
The fmt command in Unix is used to format natural language text for humans to read. It has been traditionally used
to reformat email messages after composition and prior to delivery. Its syntax is similar among various Unixes, but
not identical. fmt attempts to break, fill and join input lines to produce globally optimal, balanced output with the
lengths of each line approaching the target width as closely as possible, rather than wrapping the input lines exactly
as fold (from GNU Core Utilities) does.
In most implementations of fmt, the word wrap optimization procedure usually requires two criteria: the target
output line width, and the maximum acceptable line width (which should be larger than the previous one to give
room for optimization). It might be not always possible to give these two options simultaneously. For example, GNU
fmt can only accept the maximum width option, which is given by -w switch, or directly -digits as the first
command line option for compatibility. See the Solaris man page for fmt and FreeBSD manual entry for fmt for
detailed examples, and compare with the latest documentation of GNU fmt utility included by most Linux
distributions. See also the Plan 9 fmt man page.
Unlike par, fmt has no Unicode support, and does not support text justification.
Example
Given text like this as input:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur dignissim
venenatis pede. Quisque dui dui, ultricies ut, facilisis non, pulvinar non,
purus. Duis quis arcu a purus volutpat iaculis. Morbi id dui in diam ornare
dictum. Praesent consectetuer vehicula ipsum. Praesent tortor massa, congue et,
ornare in, posuere eget, pede.
Vivamus rhoncus. Quisque lacus. In hac habitasse platea dictumst. Nullam mauris
tellus, sollicitudin non, semper eget, sodales non, pede. Phasellus varius
ullamcorper libero. Fusce ipsum lorem, iaculis nec, vulputate vitae, suscipit
vel, tortor. Cras varius.
Nullam fringilla pellentesque orci. Nulla eu ante pulvinar velit rhoncus
lacinia. Morbi fringilla lacus quis arcu. Vestibulum sem quam, dapibus in,
fringilla ut, venenatis ut, neque.
After passing this through fmt -w 50, the width of each line is at most 50 characters and the text flows within this
constraint:
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur dignissim venenatis
pede. Quisque dui dui, ultricies ut, facilisis
non, pulvinar non, purus. Duis quis arcu a
purus volutpat iaculis. Morbi id dui in diam
ornare dictum. Praesent consectetuer vehicula
ipsum. Praesent tortor massa, congue et, ornare
in, posuere eget, pede.
Vivamus rhoncus. Quisque lacus. In hac
fmt
152
habitasse platea dictumst. Nullam mauris tellus,
sollicitudin non, semper eget, sodales non,
pede. Phasellus varius ullamcorper libero. Fusce
ipsum lorem, iaculis nec, vulputate vitae,
suscipit vel, tortor. Cras varius.
Nullam fringilla pellentesque orci. Nulla eu ante
pulvinar velit rhoncus lacinia. Morbi fringilla
lacus quis arcu. Vestibulum sem quam, dapibus in,
fringilla ut, venenatis ut, neque.
References
head
head is a program on Unix and Unix-like systems used to display the beginning of a text file or piped data. The
command syntax is:
head [options] <file_name>
By default, head will print the first 10 lines of its input to the standard output. The number of lines printed may be
changed with a command line option. The following example shows the first 20 lines of filename:
head -n 20 filename
This displays the first 5 lines of all files starting with foo:
head -n 5 foo*
Most versions allow omitting the n and just let you say -5. GNU head allows negative arguments for -n option,
meaning to print all but the last - argument value counted - lines of each input file.
Flags
-c <x number of bytes> Copy first x number of bytes.
Other
Many early versions of Unix did not have this command, and so documentation and books had sed do this job:
sed 5q foo
This says to print every line (implicit), and quit after the fifth.
External links
head
[1]
manual page from GNU coreutils.
FreeBSD documentation for head
[2]
head
153
References
[1] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ head-invocation. html
[2] http:/ / www. freebsd. org/ cgi/ man. cgi?query=head& apropos=0& sektion=0& manpath=FreeBSD+ 5. 3-RELEASE+ and+ Ports&
format=html
Iconv
iconv is a computer program and a standardized application programming interface (API) used to convert between
different character encodings.
History
The iconv API is the standard programming interface for converting character strings from one character encoding to
another in Unix-like operating systems.
Initially appearing on the HP-UX operating system, it was standardized within XPG4 and is part of the Single UNIX
Specification (SUS).
All recent Linux distributions contain a free implementation of iconv() as part of the GNU C Library which is
the C library for current Linux systems. To use it, the GNU glibc locales need to be installed, which are provided as
a separate package (usually named glibc-locale) normally installed by default.
Usage
stdin can be converted from ISO-8859-1 to current locale and output to stdout using:
iconv -f iso-8859-1
An input file infile can be converted from ISO-8859-1 to UTF-8 and output to output file outfile using:
iconv -f iso-8859-1 -t utf-8 <infile >outfile
Ports
Under Microsoft Windows, the iconv binary (and thus, likely also the API) is provided by the Cygwin and
GnuWin32 environments or native Win32 port win_iconv.exe.
iconv is also available for many programming languages. For example, one of the libraries supported by PHP
[1]
(also
under Windows using a DLL file), so it is possible to use iconv() from a PHP program easily.
References
[1] http:/ / www. php. net/ iconv
External links
iconv() OpenGroup Standards page (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ functions/ iconv.
html)
GNU libiconv (http:/ / www. gnu. org/ software/ libiconv/ )
win_iconv (http:/ / code. google. com/ p/ win-iconv/ downloads/ list)
join
154
join
join is a command in Unix-like operating systems that merges the lines of two sorted text files based on the
presence of a common field. It is similar to the join operator used in relational databases but operating on text files.
The join command takes as input two text files and a number of options. If no command-line argument is given,
this command looks for a pair of lines from the two files having the same first field (a sequence of characters that are
different from space), and outputs a line composed of the first field followed by the rest of the two lines.
The program arguments specify which character to be used in place of space to separate the fields of the line, which
field to use when looking for matching lines, and whether to output lines that do not match. The output can be stored
to another file rather than printing using redirection.
As an example, the two following files list the known fathers and the mothers of some people. Note that both files
have been sorted on the join field this is a requirement of the program.
george jim
kumar gunaware
albert martha
george sophie
The join of these two files (with no argument) would produce:
george jim sophie
Indeed, only "george" is common as a first word of both files.
External links
man page
[1]
join examples
[2]
References
[1] http:/ / www. die. net/ doc/ linux/ man/ man1/ join. 1. html
[2] http:/ / www. albany. edu/ ~ig4895/ join.htm
less
155
less
less
less output in an x-terminal
Developer(s) Mark Nudelman
Initial release 1985
Latest stable 458 / April24,2013
Operating system Cross-platform
Type system utility
License Simplified BSD License
GPL (GNU Version)
Website
www.greenwoodsoftware.com/less/
[1]
www.gnu.org/software/less/
[2]
less is a terminal pager program on Unix, Windows, and Unix-like systems used to view (but not change) the
contents of a text file one screen at a time. It is similar to more, but has the extended capability of allowing both
forward and backward navigation through the file. Unlike most Unix text editors/viewers, less does not need to
read the entire file before starting, resulting in faster load times with large files.
History
Mark Nudelman initially wrote less during 1983-85, in the need of a version of more able to do backward
scrolling of the displayed text. The name came from the joke of doing "backwards more." To help remember the
difference between less and more, a common joke is to say, "less > more," implying that less has greater
functionality than more. A similar saying is that "less is more, more or less". less is included in most Unix
and Unix-like systems.
Usage
less can be invoked with options to change its behaviour, for example, the number of lines to display on the screen.
A few options vary depending on the operating system. While less is displaying the file, various commands can
be used to navigate through the file. These commands are based on those used by both more and vi. It is also
possible to search for character patterns in the file.
By default, less displays the contents of the file to the standard output (one screen at a time). If the file name
argument is omitted, it displays the contents from standard input (usually the output of another command through a
pipe). If the output is redirected to anything other than a terminal, for example a pipe to another command, less
behaves like cat.
The command-syntax is:
less
156
less [options] [file_name]
Frequently used options
-g: Highlights just the current match of any searched string.
-I: Case-insensitive searches.
-M: Shows more detailed prompt, including file position.
-N: Shows line numbers (useful for source code viewing).
-S: Disables line wrap ("chop long lines"). Long lines can be seen by side scrolling.
-?: Shows help.
Frequently used commands
Key Command
Space bar Next Page
b Previous Page
v Edit Content
j or Enter Next Line
k Previous Line
g or < First Line
G or > Last Line
<n>G Line <n>
/<text> Forward Search for <text>. Text is interpreted as a regex.
?<text> Backward Search like /
n Next Search Match
N Previous Search Match
Escu Turn off Match Highlighting (see -g command line option)
-<c> Toggle option <c>, e.g., -i toggles option to match case in searches
m<c> Set Mark <c>
'<c> Go to Mark <c>
= or ^ Ctrl+G File information
h Help. This is presented with less, q to quit.
q Quit
Examples
less -M readme.txt # Read "readme.txt."
less +F /var/log/mail.log # Follow mode for log
file * | less # Easier file analysis.
less -I -p void *.c # Case insensitive search for
"void" in all .c files
less
157
Memory considerations
The --buffers=n and --auto-buffers options control how much memory less may use to buffer inputs. This is most
relevant when less is directly accessing a named file that is modified or deleted while less is still running, and when
less is receiving data from a pipe and the data can not be randomly accessed or regenerated. In these situations,
anything not buffered can not be redisplayed or searched by less. On the other hand, unlimited buffering means that
less will request as much memory as it is fed data, which could drive the system into using virtual memory and
swapping a lot of data between RAM and disks (dramatically slowing system performance for most applications on
the host), or even further into memory exhaustion where any application on the host requesting memory may have
that request denied, or may crash when attempting to access memory that the OS promised but can't find when the
application actually attempts to use it and a page-fault occurs. For this reason, some companies/organisations insist
that less be used only with fixed buffering - or not at all - on production machines.
[citation needed]
Variations
AquaLess
[3]
for Mac OS X
References
[1] http:/ / www. greenwoodsoftware.com/ less/
[2] http:/ / www. gnu. org/ software/ less/
[3] http:/ / aqualess. sourceforge.net/
External links
Official website (http:/ / www. greenwoodsoftware. com/ less/ )
Manual page (http:/ / www. freebsd. org/ cgi/ man. cgi?query=less& apropos=0& sektion=0&
manpath=FreeBSD+ 9. 0-RELEASE& arch=default& format=html)
more
158
more
more
Example output of the more command
Developer(s) Daniel Halbert
Operating system Cross-platform
Type system utility
License BSD License
In computing, more is a command to view (but not modify) the contents of a text file one screen at a time (terminal
pager). It is available on Unix and Unix-like systems, DOS, OS/2, and Microsoft Windows. Programs of this sort are
called pagers.
[1]
more is a very basic pager, originally allowing only forward navigation through a file, though
newer implementations do allow for limited backward movement.
History
The more command was originally written by Daniel Halbert, a graduate student at the University of California,
Berkeley, in 1978. It was first included in 3.0 BSD, and has since become a standard program in all Unix systems.
less, a similar command with the extended capability of allowing both forward and backward navigation through
the file was written by Mark Nudelman during 1983-85 and is now included in most Unix and Unix-like systems.
Usage
Unix
The command-syntax is:
more [options] [file_name]
If no file name is provided, more looks for input from standard input.
Once more has obtained input, it displays as much as can fit on the current screen and waits for user input to
advance, with the exception that a form feed (^L) will also cause more to wait at that line, regardless of the amount
of text on the screen. In the lower-left corner of the screen is displayed the text "--More--" and a percentage,
representing the percent of the file that more has paged through. (This percentage includes the text displayed on the
current screen.) When more reaches the end of a file (100%) it exits. The most common methods of navigating
through a file are Enter, which advances the output by one line, and Space, which advances the output by one
screen.
There are also other commands that can be used while navigating through the document; consult more's man page
for more details.
more
159
Options
Options are typically entered before the file name, but can also be entered in the environment variable $MORE.
Options entered in the actual command line will override those entered in the $MORE environment variable.
Available options may vary between Unix systems, but a typical set of options is as follows:
-num: This option specifies an integer which is the screen size (in lines).
-d: more will prompt the user with the message "[Press space to continue, 'q' to quit.]" and will display "[Press
'h' for instructions.]" instead of ringing the bell when an illegal key is pressed.
-l: more usually treats ^L (form feed) as a special character, and will pause after any line that contains a form
feed. The -l option will prevent this behavior.
-f: Causes more to count logical, rather than screen lines (i.e., long lines are not folded).
-p: Do not scroll. Instead, clear the whole screen and then display the text.
-c: Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.
-s: Squeeze multiple blank lines into one.
-u: Backspaces and carriage returns to be treated as printable characters;
+/: This option specifies a string that will be searched for before each file is displayed. (Ex.: more
+/Preamble gpl.txt)
+num: Start at line number num.
Microsoft Windows
The command-syntax is:
[2]
command | more [/c] [/p] [/s] [/tn] [+n]
more /c] [/p] [/s] [/tn] [+n < [Drive:] [Path] FileName
more [/c] [/p] [/s] [/tn] [+n] [files]
Examples
To display the file named letter.txt on the screen, the user can type either of the following two commands:
more letter.txt
type letter.txt | more
The command displays the first screen of information from letter.txt, and then the following prompt appears:
-- More --
When the spacebar is pressed, the next screen of information will be displayed. It is also possible to clear the screen
and remove all extra blank lines before displaying the file:
more /c /s < letter.txt
type letter.txt | more /c /s
more
160
OS/2
The command-syntax is:
MORE < [drive:][path]filename
command | more
drive:\path\filename Specifies the location of the file to display one screen at a time.
command | Specifies the command whose output will be displayed.
Example
Return the content of the OS/2 system directory using the dir command and display it one screen at a time using
the more command:
[C:\]dir C:\OS2 | more
References
[1] foldoc.org/?pager (http:/ / foldoc. org/ ?pager)
[2] Microsoft TechNet More article (http:/ / technet. microsoft. com/ en-us/ library/ bb490933. aspx)
External links
"FOLDOC entry for pager" (http:/ / foldoc. org/ ?pager); see definition #2.
manpage of more (http:/ / www. linuxmanpages. com/ man1/ more. 1. php)
Early history of the more command (http:/ / danhalbert. org/ more. html)
paste
paste is a Unix command line utility which is used to join files horizontally (parallel merging) by outputting lines
consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output. It
is effectively the horizontal equivalent to the utility cat command which operates on the vertical plane of two or
more files.
Usage
The paste utility is invoked with the following syntax:
paste [options] [file1 ..]
paste
161
Description
Once invoked, paste will read all its file arguments. For each corresponding line, paste will append the
contents of each file at that line to its output along with a tab. When it has completed its operation for the last file,
paste will output a newline character and move on to the next line.
Options
The paste utility accepts the following options:
-d delimiters, which specifies a list of delimiters to be used instead of tabs for separating consecutive values on
a single line. Each delimiter is used in turn; when the list has been exhausted, paste begins again at the first
delimiter.
-s, which causes paste to append the data in serial rather than in parallel; that is, in a horizontal rather than
vertical fashion.
Examples
For the following examples, assume that names.txt is a plain-text file that contains the following information:
Mark Smith
Bobby Brown
Sue Miller
Jenny Igotit
and that numbers.txt is another plain-text file that contains the following information:
555-1234
555-9876
555-6743
867-5309
The following example shows the invocation of paste with names.txt and numbers.txt as well as the
resulting output:
$ paste names.txt numbers.txt
Mark Smith 555-1234
Bobby Brown 555-9876
Sue Miller 555-6743
Jenny Igotit 867-5309
When invoked with the -s option, the output of paste is adjusted such that the information is presented in a
horizontal fashion:
$ paste -s names.txt numbers.txt
Mark Smith Bobby Brown Sue Miller Jenny Igotit
555-1234 555-9876 555-6734 867-5309
Finally, the use of the -d option (delimiters) is illustrated in the following example:
$ paste -d ., names.txt numbers.txt
Mark Smith.555-1234
Bobby Brown,555-9876
Sue Miller.555-6743
paste
162
Jenny Igotit,867-5309
As an example usage of both, the paste command can be used to concatenate multiple consecutive lines into a
single row:
$ paste -s -d '\t\n' names.txt
Mark Smith Bobby Brown
Sue Miller Jenny Igotit
References
"PASTE(1) - FreeBSD General Commands Manual"
[1]
. Retrieved 2010-08-12.
References
[1] http:/ / www. freebsd. org/ cgi/ man. cgi?query=paste& section=1& format=html
Sed
163
Sed
Sed
Paradigm(s) scripting
Designed by Lee E. McMahon
Appeared in 1974
Influenced by ed
Influenced Chomski, Perl, AWK
Implementation language C
Website
GNU sed
[1]
sed (stream editor) is a Unix utility that parses and transforms text, using a simple, compact programming language.
sed was developed from 1973 to 1974 by Lee E. McMahon of Bell Labs, and is available today for most operating
systems. sed was based on the scripting features of the interactive editor ed ("editor", 1971) and the earlier qed
("quick editor", 196566). sed was one of the earliest tools to support regular expressions, and remains in use for text
processing, most notably with the substitution command. Other options for doing "stream editing" include AWK and
Perl.
History of sed
sed is one of the very early Unix commands built for command line processing of data files. It evolved as the natural
successor to the popular grep command. The original motivation was an analog of grep (g/re/p) for substitution,
hence "g/re/s". Foreseeing that further special-purpose programs for each command would also arise, such as g/re/d,
McMahon wrote a general-purpose line-oriented stream editor, which became sed. The syntax for sed, notably the
use of / for pattern matching, and s/// for substitution, originated with ed, the precursor to sed, which was in
common use at the time, and the regular expression syntax has influenced other languages, notably ECMAScript and
Perl. Later the more powerful language AWK developed, and these functioned as cousins, allowing powerful text
processing to be done by shell scripts. sed and AWK are often cited as progenitors and inspiration for Perl, and
influenced Perl's syntax and semantics, notably in the matching and substitution operators.
GNU sed added several new features, of which the best-known is in-place editing of files. Super-sed is an extended
version of sed that includes regular expressions compatible with Perl. Another variant of sed is minised, originally
reverse-engineered from 4.1BSD sed by Eric S. Raymond and currently maintained by Ren Rebe. minised was used
by the GNU Project until the GNU Project wrote a new version of sed based on the new GNU regular expression
library. The current minised contains some extensions to BSD sed but is not as feature-rich as GNU sed. Its
advantage is that it is very fast and uses little memory.
[citation needed]
It is used on embedded systems and is the
version of sed provided with Minix.
[citation needed]
Mode of operation
sed is a line-oriented text processing utility: it reads text, line by line, from an input stream or file, into an internal
buffer called the pattern space. Each line read starts a cycle. To the pattern space, sed applies one or more operations
which have been specified via a sed script. sed implements a programming language with about 25 commands that
specify the operations on the text. For each line, after running the script sed ordinarily outputs the pattern space (the
input line as modified by the script) and begins the cycle again with the next line. Other end-of-script behaviors are
available through sed options and script commands, e.g. d to delete the pattern space, q to quit, N to add the next
Sed
164
line to the pattern space immediately, and so on. Thus a sed script corresponds to the body of a loop that iterates
through the lines of a stream, where the loop itself and the loop variable (the current line number) are implicit and
maintained by sed.
The sed script can either be specified on the command line (-e option) or read from a separate file (-f option).
Commands in the sed script may take an optional address, in terms of line numbers or regular expressions. The
address determines when the command is run. For example, 2d would only run the d (delete) command on the
second input line (printing all lines but the second), while /^ /d would delete all lines beginning with a space. A
separate special buffer, the hold space, may be used by a few sed commands to hold and accumulate text between
cycles. sed's command language has only two variables (the "hold space" and the "pattern space") and GOTO-like
branching functionality; nevertheless, the language is Turing-complete, and esoteric sed scripts exist for games such
as sokoban, arkanoid, chesschess,
[2]
and tetris.
A main loop executes for each line of the input stream, evaluating the sed script on each line of the input. Lines of a
sed script are each a pattern-action pair, indicating what pattern to match and which action to perform, which can be
recast as a conditional statement. Because the main loop, working variables (pattern space and hold space), input and
output streams, and default actions (copy line to pattern space, print pattern space) are implicit, it is possible to write
terse one-liner programs. For example, the sed program given by:
10q
will print the first 10 lines of input, then stop.
Usage
Substitution command
The following example shows a typical, and the most common, use of sed, for substitution; this usage was indeed the
original motivation for sed:
sed 's/regexp/replacement/g' inputFileName > outputFileName
In some versions of sed, the expression must be preceded by a -e to indicate that an expression follows. The s stands
for substitute, while the g stands for global, which means that all matching occurrences in the line would be replaced.
The regular expression (i.e. pattern) to be searched is placed after the first delimiting symbol (slash here) and the
replacement follows the second symbol. Slash (/) is the conventional symbol, originating in the character for
"search" in ed, but any other could be used to make syntax more readable if it does not occur in the pattern or
replacement (see below); this is useful to avoid "leaning toothpick syndrome".
The substitution command, which originates in search-and-replace in ed, implements simple parsing and templating.
The regexp provides both pattern matching and saving text via sub-expressions, while the replacement can
be either literal text, or a format string containing the characters & for "entire match" or the special escape sequences
\1 through \9 for the nth saved sub-expression. For example, sed -r "s/(cat|dog)s?/\1s/g" replaces
all occurrences of "cat" or "dog" with "cats" or "dogs", without duplicating an existing "s": (cat|dog) is the 1st
(and only) saved sub-expression in the regexp, and \1 in the format string substitutes this into the output.
Sed
165
Other sed commands
Besides substitution, other forms of simple processing are possible, using some 25 sed commands. For example, the
following uses the d command to delete lines that are either blank or only contain spaces:
sed '/^ *$/d' inputFileName
This example uses some of the following regular expression metacharacters (sed supports the full range of regular
expressions):
The caret (^) matches the beginning of the line.
The dollar sign ($) matches the end of the line.
The asterisk (*) matches zero or more occurrences of the previous character.
Complex sed constructs are possible, allowing it to serve as a simple, but highly specialised, programming language.
Flow of control, for example, can be managed by the use of a label (a colon followed by a string) and the branch
instruction b. An instruction b followed by a valid label name will move processing to the block following that label.
sed used as a filter
Under Unix, sed is often used as a filter in a pipeline:
generate_data | sed 's/x/y/g'
That is, generate the data, and then make the small change of replacing x with y.
In command line use, the quotes around the expression are not required, and are only necessary if the shell would
otherwise not interpret the expression as a single word (token). For the expression s/x/y/g there is no ambiguity,
and the following is also allowed:
generate_data | sed s/x/y/g
However, quotes are usually included for clarity, and since they are often necessary, notably for whitespace (e.g.,
's/x x/y y/'). Most often single quotes are used, to avoid having the shell interpret $ as a shell variable. Double
quotes are used, such as "s/$1/$2/g", to allow the shell to substitute for a command line argument or other shell
variable.
File-based sed scripts
Several substitutions or other commands can be put together in a file called, for example, subst.sed and then be
applied using the -f option to read the commands (such as s/x/y/g) from the file:
sed -f subst.sed inputFileName > outputFileName
This also avoids problems with shell escaping or substitutions.
Alternatively, by adding a "shebang line" and making the script file executable, a sed script can be directly executed.
For example, a file subst.sed can be created with contents:
#!/bin/sed -f
s/x/y/g
The file can then be executed directly:
subst.sed inputFileName > outputFileName
Sed
166
In-place editing
The -i option, introduced in GNU sed, allows in-place editing of files (actually, a temporary output file is created in
the background, and then the original file is replaced by the temporary file). For example:
sed -i 's/abc/def/' file
Examples
Hello, world! example
# convert input text stream to "Hello, world!"
s/.*/Hello, world!/
q
This "Hello, world!" script is in a file (e.g., script.txt) and invoked with "sed -f script.txt infile", where "infile" is the
input text file. The script changes "infile" line #1 to "Hello, world!" and then quits, printing the result before sed
exits. Any input lines past line #1 are not read, and not printed. So the sole output is "Hello, world!".
The example emphasizes many key characteristics of sed:
Typical sed programs are rather short and simple.
sed is unique. No other "Hello, world!" example is even vaguely similar.
sed scripts can have comments (the line starting with the # symbol).
The s (substitute) command is the most important sed command.
sed allows simple programming, with commands such as q (quit).
sed uses regular expressions, such as .* (zero or more of any character).
Other simple examples
Below follow various sed scripts; these can be executed by passing as an argument to sed, or put in a separate file
and executed via -f or by making the script itself executable.
To replace any instance of a certain word in a file with "REDACTED", such as an IRC password, and save the
result:
sed -i s/yourpassword/REDACTED/ ./status.freenode.log
To delete any line containing the word "yourword" (the address is '/yourword/'):
/yourword/ d
To delete all instances of the word "yourword":
s/yourword//g
To delete two words from a file simultaneously:
s/firstword//g
s/secondword//g
To express the previous example on one line, such as when entering at the command line, one may join two
commands via the semicolon:
Sed
167
sed "s/firstword//g; s/secondword//g" infile
Multiline processing example
In the next example, sed, which usually only works on one line, removes newlines from sentences where the second
line starts with one space. Consider the following text:
This is my cat,
whose name is Betty.
This is my dog,
whose name is Frank.
This is my fish,
whose name is George.
This is my goat,
whose name is Adam.
The sed script below will turn the text above into the following text. Note that the script affects only the input lines
that start with a space:
This is my cat, whose name is Betty.
This is my dog, whose name is Frank.
This is my fish,
whose name is George.
This is my goat, whose name is Adam.
The script is:
N
s/\n / /
P
D
This is explained as:
(N) add the next line to the pattern space
(s) substitute
(/\n /) match a newline character and a " ": find a new line followed by a space
(/ /) replace with: one space
(P) print the top line of the pattern space
(D) delete the top line from the pattern space and run the script again
This can be expressed on a single line via semicolons:
sed 'N; s/\n / /; P; D'
Sed
168
Limitations and alternatives
While simple and limited, sed is sufficiently powerful for a large number of purposes. For more sophisticated
processing, more powerful languages such as awk or Perl are used instead. These are particularly used if
transforming a line in a way more complicated than a regex extracting and template replacement, though arbitrarily
complicated transforms are in principle possible by using the hold buffer.
Conversely, for simpler operations, specialized Unix utilities such as grep (print lines matching a pattern), head
(print the first part of a file), tail (print the last part of a file), and tr (translate or delete characters) are often
preferable. For the specific tasks they are designed to carry out, such specialized utilities are usually simpler, clearer,
and faster than a more general solution such as sed.
The ed/sed commands and syntax continue to be used in descendent programs, such as the text editors vi and vim.
An analog to ed/sed is sam/ssam, where sam is the Plan 9 editor, and ssam is a stream interface to it, yielding
functionality similar to sed.
References
[1] http:/ / www. gnu. org/ software/ sed/
[2] https:/ / github.com/ bolknote/ SedChess
Further reading
Bell Lab's Eight Edition (circa 1985) Unix sed(1) manual page (http:/ / man. cat-v. org/ unix_8th/ 1/ sed)
GNU sed(1) manual page (http:/ / www. unix. com/ man-page/ linux/ 1/ sed/ )
Dale Dougherty & Arnold Robbins (March 1997). sed & awk (http:/ / shop. oreilly. com/ product/
9781565922259. do) (2nd ed.). O'Reilly. ISBN1-56592-225-5.
Arnold Robbins (June 2002). sed and awk Pocket Reference (http:/ / shop. oreilly. com/ product/ 9780596003524.
do) (2nd ed.). O'Reilly. ISBN0-596-00352-8.
Peter Patsis (December 1998). UNIX AWK and SED Programmer's Interactive Workbook (UNIX Interactive
Workbook) (http:/ / www. amazon. com/ UNIX-AWK-Programmers-Interactive-Workbook/ dp/ 0130826758).
Prentice Hall. ISBN0-13-082675-8.
Daniel Goldman (February 2013). Definitive Guide to sed (http:/ / www. sed-book. com/ ). EHDP Press.
ISBN978-1-939824-00-4.
Sourceforge.net (http:/ / sed. sourceforge. net/ sedfaq. html), the sed FAQ
External links
Tutorials
Sed - An Introduction and Tutorial (http:/ / www. grymoire. com/ Unix/ Sed. html), by Bruce Barnett
SED -- A Non-interactive Text Editor (http:/ / sed. sourceforge. net/ grabbag/ tutorials/ sed_mcmahon. txt), by
Lee E. McMahon
"Sed by example" (http:/ / www. ibm. com/ developerworks/ linux/ library/ l-sed1. html), three part tutorial from
IBM
Sed
169
Examples
Major sources for sed scripts, files, usage (http:/ / sed. sourceforge. net)
Roger Chang's SED and Shell Scripts (http:/ / main. rtfiber. com. tw/ ~changyj/ sed/ )
Top 'sed' commands Usage examples (http:/ / www. shell-fu. org/ lister. php?tag=sed)
Barry Pederson's SED Examples (http:/ / users. cybercity. dk/ ~bse26236/ batutil/ help/ SED. HTM)
Other links
GNU sed homepage (http:/ / www. gnu. org/ software/ sed/ ) (includes GNU sed manual)
Sed Cheat Sheets (http:/ / devcheatsheet. com/ tag/ sed/ )
sed for Windows with working -i option (http:/ / www. pement. org/ sed/ )
sed-users Yahoo discussion group (http:/ / tech. groups. yahoo. com/ group/ sed-users/ )
sort
In Unix-like operating systems, sort is a standard command line program that prints the lines of its input or
concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or more sort keys
extracted from each line of input. By default, the entire input is taken as sort key. Blank space is the default field
separator.
The "-r" flag will reverse the sort order.
Examples
Sort a file in alphabetical order
$ cat phonebook
Smith, Brett 555-4321
Doe, John 555-1234
Doe, Jane 555-3214
Avery, Cory 555-4132
Fogarty, Suzie 555-2314
$ sort phonebook
Avery, Cory 555-4132
Doe, Jane 555-3214
Doe, John 555-1234
Fogarty, Suzie 555-2314
Smith, Brett 555-4321
Sort by number
The -n option makes the program sort according to numerical value:
$ du /bin/* | sort -n
4 /bin/domainname
24 /bin/ls
102 /bin/sh
304 /bin/csh
sort
170
Sort the current directory by file size
$ ls -k2 | sort -n
96 Nov1.txt
128 _arch_backup.lst
128 _arch_backup.lst.tmp
1708 NMON
Columns or fields
In old versions of sort, the +1 option made the program sort using the second column of data (+2 for the third,
etc.). This is deprecated, and instead the -k option can be used to do the same thing (note: "-k 2" for the second
column):
$ cat zipcode
Adam 12345
Bob 34567
Joe 56789
Sam 45678
Wendy 23456
$ sort -nk 2 zipcode
Adam 12345
Wendy 23456
Bob 34567
Sam 45678
Joe 56789
Sort on multiple fields
The -k m,n option lets you sort on a particular field (start at m, end at n):
$ cat quota
bob 1000
an 1000
chad 1000
don 1500
eric 5000
fred 2000
$ sort -k2n,2 -k1,1 quota
an 1000
bob 1000
chad 1000
don 1500
fred 2000
eric 5000
-k2 stands for column 2, the n stands for 'numeric ordering'
sort
171
Sorting a pipe delimited file
$ sort -t'|' -k2 zipcode
Adam|12345
Wendy|23456
Bob|34567
Sam|45678
Joe|56789
Sorting a tab delimited file
Sorting a file with tab separated values requires a tab character to be specified as the column delimiter. This
illustration uses the shell's dollar-quote notation to specify the tab as a C escape sequence.
$ sort -k2,2 -t $'\t' phonebook
Doe, John 555-1234
Fogarty, Suzie 555-2314
Doe, Jane 555-3214
Avery, Cory 555-4132
Smith, Brett 555-4321
Sort in reverse
The -r option just reverses the order of the sort:
$ sort -nrk 2 zipcode
Joe 56789
Sam 45678
Bob 34567
Wendy 23456
Adam 12345
Sort in random
The GNU implementation has a -R/--random-sort option based on hashing; this is not a full random shuffle
because it will sort non-unique lines together. A true random sort is provided by the Unix utility shuf.
Sorting algorithm
The implementation in GNU Core Utilities, used on Linux, employs the merge sort algorithm.
References
External links
Sort manpage (http:/ / www. linuxmanpages. com/ man1/ sort. 1. php) The program's manpage
Softpanorama Unix sort page (http:/ / softpanorama. org/ Tools/ sort. shtml)
spell
172
spell
Spell is the standard English language spell checker for Unix.
Spell was originally written by Stephen C. Johnson of Bell Labs in 1975. Douglas McIlroy later improved its
accuracy, performance, and memory use, and described his work and spell in general in his 1982 paper Development
of a Spelling list
[1]
.
Spell has a simple command-line interface: It goes over all the words in a given text file, and prints a sorted list of
unique misspelled words in that file. It does not provide any interface for looking for those words in the file, or
helping to correct the mistakes. In 1983, a different spell-checker, ispell (the interactive spell-checker) was ported to
Unix. ispell had a user interface for showing the spelling mistakes in context, and suggest how to correct them. Since
then, the original Spell tool has been mostly considered obsolete.
Another reason why Spell is considered obsolete is that it only supports the English language. Modern spell-checkers
for Unix and Linux systems, such as aspell, MySpell and hunspell all support a multitude of different languages and
character sets. The Single Unix Specification has officially declared Spell a "legacy application", stating that this was
done "because there is no known technology that can be used to make it recognise general language for
user-specified input without providing a complete dictionary along with the input file."
[2]
Nevertheless, the Single
Unix Specification does not standardize any other spell-checking utility to take Spell's place.
Because of Spell's problems and the superiority of its alternatives, a free software version of McIlroy's spell has
never been written. Instead, in 1996 Thomas Morgan of GNU wrote a simple wrapper to ispell (which was already
popular at the time) to replicate spell's original behaviour. Many Linux distributions include this GNU spell, or an
even simpler shell script; For example, the "spell" command in Fedora Linux simply runs aspell, as:
cat "$@" | aspell listmode=none | sort -u
External links
Original unix spell source code
[3]
References
[1] http:/ / cm.bell-labs. com/ cm/ cs/ who/ doug/ spell.ps.gz
[2] http:/ / pubs. opengroup. org/ onlinepubs/ 007908799/ xcu/ spell. html
[3] http:/ / code. google. com/ p/ unix-spell/
strings
173
strings
In computer software, strings is a program in Unix-like operating systems that finds and prints text strings
embedded in binary files such as executables. It can be used on object files and core dumps.
Strings are recognized by looking for sequences of at least 4 (by default) printable characters terminating in a NUL
character (that is, null-terminated strings). Some implementations provide options for determining what is
recognized as a printable character, which is useful for finding non-ASCII and wide character text.
Common usage includes piping it to grep and fold or redirecting the output to a file.
It is part of the GNU Binary Utilities (binutils), and has been ported to other operating systems including Microsoft
Windows.
[1]
Example
Using strings to print sequences of characters that are at least 8 characters long (this command prints the system's
BIOS information; should be run as root):
dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8 |
less
References
[1] [1] cygwin
External links
strings(1) (http:/ / linux. die. net/ man/ 1/ strings):print the strings of printable characters in filesLinux
User Commands Manual
tail
174
tail
tail is a program on Unix and Unix-like systems used to display the tail end of a text file or piped data.
Syntax
The command-syntax is:
tail [options] <file_name>
By default, tail will output the last 10 lines of its input to the standard output. With command line options the
amount of output and the units (lines, blocks or bytes) may be changed.
In the following example only the last line of the reports is output:
> tail -n1 report-13*
==> report-1301 <==
Total tons output for month of January '13 was 523
==> report-1302 <==
Total tons output for month of February '13 was 272
==> report-1303 <==
Total tons output for month of March '13 was 623
This example outputs the last 4 characters of the reports, silently suppressing the filenames. Notice that the count
includes the newline character at the end of each line and so the output does not include a leading space you might
expect.
> tail --silent -c4 report*
523
272
623
This example shows all lines of report from the second line onwards:
tail -n +2 report
Using an older syntax (still used in older version of Sun Solaris as the -n option is not supported), the last 20 lines
and the last 50 bytes of filename can be shown with the following command:
tail -20 filename
tail -50c filename
However this syntax is now obsolete and does not conform with the POSIX 1003.1-2001 standard. Even if still
supported in current versions, when used with other options (like -f, see below), these switches could not work at all.
As with all unix commands, use man pages on the running system for specific options and actions.
tail
175
File monitoring
tail has a special command line option -f (follow) that allows a file to be monitored. Instead of just displaying
the last few lines and exiting, tail displays the lines and then monitors the file. As new lines are added to the file
by another process, tail updates the display. This is particularly useful for monitoring log files. The following
command will display the last 10 lines of messages and append new lines to the display as new lines are added to
messages:
tail -f /var/adm/messages
In cases when the user is following a log file that rotates then it is advisable to use the -F option as it keeps following
the log even when it is recreated, renamed, or removed as part of log rotation.
tail -F /var/adm/messages
To interrupt tail while it is monitoring, break-in with Ctrl+C. This command can be run "in the background" with
&, see job control.
If you have a command's result to monitor, you can use the watch command.
Variants
CCZE
[1]
is tail-like while displaying its output in color
pctail
[2]
Like CCZE: Python Colorized TAIL, a colorized tail made in python which tails and colorizes syslog
output.
Inotail
[3]
: the regular tail polls every second to see if new data can be displayed. Inotail uses the Linux kernel's
inotify-interface so that it only checks for new data when there really is some.
MultiTail not only displays logfiles in colors, it can also merge, filter, scrollback and split a terminal window in
subwindows. It is more or less a combination of tail, sed, watch, CCZE/pctail, grep, diff, Beeper
[4]
and others.
External links
GNU Project documentation for tail
[5]
FreeBSD documentation for tail
[6]
References
[1] http:/ / freshmeat. net/ projects/ ccze/
[2] http:/ / sourceforge. net/ projects/ pctail/
[3] http:/ / distanz.ch/ inotail/
[4] http:/ / cosoleto. free. fr/ beeper/
[5] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ tail-invocation. html
[6] http:/ / www. freebsd. org/ cgi/ man. cgi?query=tail& apropos=0& sektion=0& manpath=FreeBSD+ 5. 3-RELEASE+ and+ Ports&
format=html
tr
176
tr
tr is a command in Unix-like operating systems. It is an abbreviation of translate or transliterate, indicating its
operation of replacing or removing specific characters in its input data set.
The utility reads a byte stream from its standard input and writes the result to the standard output. As arguments, it
takes two sets of characters, and replaces occurrences of the characters in the first set with the corresponding
elements from the second set. For example,
tr 'abcd' 'jkmn'
maps all characters a to j, b to k, c to m, and d to n.
The character set may be abbreviated by using character ranges. The previous example could be written:
tr 'a-d' 'jkmn'
In POSIX-compliant versions of tr, the set represented by a character range depends on the locale's collating order,
so it is safer to avoid character ranges in scripts that might be executed in a locale different from that in which they
were written. Ranges can often be replaced with POSIX character sets such as [:alpha:].
The s flag causes tr to compress sequences of identical adjacent characters in its output to a single token. For
example,
tr -s '\n'
replaces sequences of one or more newline characters with a single newline.
The d flag causes tr to delete all tokens of the specified set of characters from its input. In this case, only a single
character set argument is used. The following command removes carriage return characters.
tr -d '\r'
The c flag complements the first set of characters. The invocation
tr -cd '[:alnum:]'
therefore removes all non-alphanumeric characters.
Most versions of tr, including GNU tr and classic Unix tr, operate on single-byte characters and are not Unicode
compliant. An exception is the Heirloom Toolchest implementation, which provides basic Unicode support.
Ruby and Perl also have an internal tr operator, which operates analogously. Tcl's string map command is more
general in that it maps strings to strings while tr maps characters to characters.
tr
177
External links
tr(1)
[1]
- Unix 8th Edition manual page.
[2] The program's manpage
usage examples at examplenow.com
[3]
References
[1] http:/ / man.cat-v. org/ unix_8th/ 1/ tr
[2] http:/ / www. linuxmanpages.com/ man1/ tr.1.php
[3] http:/ / www. examplenow.com/ tr
Uniq
uniq is a Unix utility which, when fed a text file, outputs the file with adjacent identical lines collapsed to one. It is a
kind of filter program. Typically it is used after sort. It can also output only the duplicate lines (with the -d option),
or add the number of occurrences of each line (with the -c option).
An example: To see the list of lines in a file, sorted by the number of times each occurs:
sort file | uniq -c | sort -n
Using uniq like this is common when building pipelines in shell scripts.
Switches
-u Print only those lines which are not repeated (unique) in the input.
-d Print only those lines which are repeated in the input.
-c Generate an output report in default style except that each line is preceded by a count of the number of times it
occurred. If this option is specified, the -u and -d options are ignored if either or both are also present.
-i Ignore case differences when comparing lines
-f Ignore a number of fields in a line
-s Skips a number of characters in a line
-w Specifies the number of characters to compare in lines, after any characters and fields have been skipped
--help Displays a help message
--version Displays version number on stdout and exits.
External links
uniq's
[1]
Linux manpage
SourceForge UnxUtils Port of several GNU utilities to Windows
[2]
References
[1] http:/ / www. linuxmanpages.com/ man1/ uniq.1.php
[2] http:/ / sourceforge. net/ projects/ unxutils/
Vi
178
Vi
vi
vi editing a Hello World program in C. Tildes signify lines not present in the file.
Developer(s) Bill Joy
Initial release 1976, 3738 years ago
Written in C
Operating system Unix-like
Type Text editor
License BSD License
vi /via/ is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the
behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by
(and thus standardized by) the Single Unix Specification and POSIX.
The original code for vi was written by Bill Joy in 1976, as the visual mode for a line editor called ex that Joy had
written with Chuck Haley.
[1]
Bill Joy's ex 1.1 was released as part of the first BSD Unix release in March, 1978. It
was not until version 2.0 of ex, released as part of Second Berkeley Software Distribution in May, 1979 that the
editor was installed under the name vi (which took users straight into ex's visual mode), and the name by which it is
known today. Some current implementations of vi can trace their source code ancestry to Bill Joy; others are
completely new, largely compatible reimplementations.
The name vi is derived from the shortest unambiguous abbreviation for the command visual in ex; the command
in question switches the line editor ex to visual mode. The name vi is pronounced /via/ (as in the discrete English
letters v and i), or /va/.
In addition to various nonfree software implementations of vi distributed with proprietary implementations of Unix,
several free and open source software implementations of vi exist. A 2009 survey of Linux Journal readers found
that vi was the most widely used text editor among respondents, beating gedit, the second most widely used editor by
nearly a factor of two (36% to 19%).
Vi
179
History
Creation
Bill Joy, the original creator of the vi editor
vi was derived from a sequence of UNIX command line editors,
starting with ed, which was a line editor designed to work well on
teletypes, rather than display terminals. Within AT&T Corporation,
where ed originated, people seemed to be happy with an editor as basic
and unfriendly as ed, George Coulouris recalls:
[...] for many years, they had no suitable terminals. They
carried on with TTYs and other printing terminals for a
long time, and when they did buy screens for everyone,
they got Tektronix 4014s. These were large storage tube
displays. You can't run a screen editor on a storage-tube
display as the picture can't be updated. Thus it had to fall
to someone else to pioneer screen editing for Unix, and
that was us initially, and we continued to do so for many
years.
Coulouris considered the cryptic commands of ed to be only suitable
for "immortals", and thus in February, 1976, he enhanced ed (using Ken Thompson's ed source as a starting point) to
make em (the "editor for mortals"
[2]
) while acting as a lecturer at Queen Mary College.
[]
The em editor was designed
for display terminals and was a single-line-at-a-time visual editor. It was one of the first programs on Unix to make
heavy use of "raw terminal input mode", in which the running program, rather than the terminal device driver,
handled all keystrokes. When Coulouris visited UC Berkeley in the summer of 1976, he brought a DECtape
containing em, and showed the editor to various people. Some people considered this new kind of editor to be a
potential resource hog, but others, including Bill Joy were impressed.
Inspired by em, and by their own tweaks to ed, Bill Joy and Chuck Haley, both graduate students at UC Berkeley,
took code from em to make en, and then "extended" en to create ex version 0.1. After Haley's departure, Bruce
Englar encouraged Joy to redesign the editor,
[3]
which he did June through October 1977 adding a full-screen visual
mode to ex.
[4]
Many of the ideas in ex's visual mode (a.k.a. vi) were taken from other software that existed at the time. According
to Bill Joy, inspiration for vi's visual mode came from the Bravo editor, which was a bimodal editor. In an interview
about vi's origins, Joy said:
A lot of the ideas for the screen editing mode were stolen from a Bravo manual I surreptitiously looked
at and copied. Dot is really the double-escape from Bravo, the redo command. Most of the stuff was
stolen. There were some things stolen from edwe got a manual page for the Toronto version of ed,
which I think Rob Pike had something to do with. We took some of the regular expression extensions
out of that.
Vi
180
ADM3A keyboard layout
Joy used a Lear Siegler ADM3A
terminal. On this terminal, the Escape
key was at the location now occupied
by the Tab key on the widely used
IBM PC keyboard (on the left side of
the alphabetic part of the keyboard,
one row above the middle row). This
made it a convenient choice for
switching vi modes. Also, the keys
h,j,k,l served double duty as cursor movement keys and were inscribed with arrows, which is why vi uses them in
that way. The ADM3A had no other cursor keys. Joy explained that the terse, single character commands and the
ability to type ahead of the display were a result of the slow 300 baud modem he used when developing the software
and that he wanted to be productive when the screen was painting slower than he could think.
Distribution
Joy was responsible for creating the first BSD Unix release in March, 1978, and included ex 1.1 (dated 1 February
1978)
[5]
in the distribution, thereby exposing his editor to an audience beyond UC Berkeley.
[6]
From that release of
BSD Unix onwards, the only editors that came with the Unix system were ed and ex. In a 1984 interview, Joy
attributed much of the success of vi to the fact that it was bundled for free, whereas other editors, such as Emacs,
could cost hundreds of dollars.
Eventually it was observed that most ex users were spending all their time in visual mode,
[citation needed]
and thus in
ex 2.0 (released as part of Second Berkeley Software Distribution in May, 1979), Joy created vi as a hard link to
ex,
[7]
such that when invoked as vi, ex would automatically start up in its visual mode. Thus, vi is not the evolution
of ex, vi is ex.
Joy described ex 2.0 (vi) as a very large program, barely able to fit in the memory of a PDP-11/70,
[8]
thus although
vi may be regarded as a small, lightweight, program today, it was not seen that way early in its history. By version
3.1, shipped with 3BSD in December 1979, the full version of vi was no longer able to fit in the memory of a
PDP-11.
[8]
Joy continued to be lead developer for vi until version 2.7 in June, 1979, and made occasional contributions to vi's
development until at least version 3.5 in August, 1980.
[]
In discussing the origins of vi and why he discontinued
development, Joy said:
I wish we hadn't used all the keys on the keyboard. I think one of the interesting things is that vi is really a
mode-based editor. I think as mode-based editors go, it's pretty good. One of the good things about EMACS,
though, is its programmability and the modelessness. Those are two ideas which never occurred to me. I also
wasn't very good at optimizing code when I wrote vi. I think the redisplay module of the editor is almost
intractable. It does a really good job for what it does, but when you're writing programs as you're learning...
That's why I stopped working on it.
What actually happened was that I was in the process of adding multiwindows to vi when we installed our
VAX, which would have been in December of '78. We didn't have any backups and the tape drive broke. I
continued to work even without being able to do backups. And then the source code got scrunched and I didn't
have a complete listing. I had almost rewritten all of the display code for windows, and that was when I gave
up. After that, I went back to the previous version and just documented the code, finished the manual and
closed it off. If that scrunch had not happened, vi would have multiple windows, and I might have put in some
programmabilitybut I don't know.
Vi
181
The fundamental problem with vi is that it doesn't have a mouse and therefore you've got all these commands.
In some sense, its backwards from the kind of thing you'd get from a mouse-oriented thing. I think multiple
levels of undo would be wonderful, too. But fundamentally, vi is still ed inside. You can't really fool it.
It's like one of those pinatasthings that have candy inside but has layer after layer of paper mache on top. It
doesn't really have a unified concept. I think if I were going to go backI wouldn't go back, but start over
again.
In 1979, Mark Horton took on responsibility for vi. Horton added support for arrow and function keys, macros, and
improved performance by replacing termcap with terminfo.
[9]
Ports and clones
The vi editor in OpenBSD (nvi) on startup,
editing a temporary empty file
The vi editor in OpenBSD, editing a small "Hello,
world!" type Ruby program
Up to version 3.7 of vi, created in October, 1981, UC Berkeley was the
development home for vi, but with Bill Joy's departure in early 1982,
to join Sun Microsystems, and AT&T's UNIX System V (January,
1983) adopting vi, changes to the vi codebase happened more slowly
and in a more dispersed and mutually incompatible ways. At UC
Berkeley, changes were made but the version number was never
updated beyond 3.7. Commercial Unix vendors, such as Sun, HP,
DEC, and IBM each received copies of the vi source, and their
operating systems, Solaris, HP-UX, Tru64 UNIX, and AIX, today
continue to maintain versions of vi directly descended from the 3.7
release, but with added features, such as adjustable key mappings,
encryption, and wide character support.
While commercial vendors could work with Bill Joy's codebase (and
continue to use it today), many people could not. Because Joy had
begun with Ken Thompson's ed editor, ex and vi were derivative works
and could not be distributed except to people who had an AT&T
source license. People looking for a free Unix-style editor would have
to look elsewhere. By 1985, a version of Emacs (MicroEMACS) was
available for a variety of platforms, but it was not until June, 1987 that
Stevie (ST editor for VI enthusiasts), a limited vi clone appeared. In
early January, 1990, Steve Kirkendall posted a new clone of vi, Elvis, to the Usenet newsgroup comp.os.minix,
aiming for a more complete and more faithful clone of vi than Stevie. It quickly attracted considerable interest in a
number of enthusiast communities.
[10][11]
Andrew Tanenbaum quickly asked the community to decide one of these
two editors to be the vi clone in Minix; Elvis was chosen, and remains the vi clone for Minix today.
In 1989 Lynne Jolitz and William Jolitz began porting BSD Unix to run on 386 class processors, but to create a free
distribution they needed to avoid any AT&T-contaminated code, including Joy's vi. To fill the void left by removing
vi, their 1992 386BSD distribution adopted Elvis as its vi replacement. 386BSD's descendants, FreeBSD and
NetBSD followed suit. But at UC Berkeley, Keith Bostic wanted a "bug for bug compatible" replacement for Joy's vi
for BSD 4.4 Lite. Using Kirkendall's Elvis (version 1.8) as a starting point, Bostic created nvi, releasing it in Spring
of 1994. When FreeBSD and NetBSD resynchronized the 4.4-Lite2 codebase, they too switched over to Bostic's nvi,
which they continue to use today.
Despite the existence of vi clones with enhanced featuresets, sometime before June, 2000,
[12]
Gunnar Ritter ported
Joy's vi codebase (taken from 2.11BSD, February, 1992) to modern Unix-based operating systems, such as Linux
and FreeBSD. Initially, his work was technically illegal to distribute without an AT&T source license, but, in
January, 2002, those licensing rules were relaxed,
[13]
allowing legal distribution as an open-source project. Ritter
Vi
182
continued to make small enhancements to the vi codebase similar to those done by commercial Unix vendors still
using Joy's codebase, including changes required by the POSIX.2 standard for vi. His work is available as
Traditional Vi
[14]
, and runs today on a variety of systems.
But although Joy's vi was now once again available for BSD Unix, it arrived after the various BSD flavors had
committed themselves to nvi, which provides a number of enhancements over traditional vi, and drops some of its
legacy features (such as open mode for editing one line at a time). It is in some sense, a strange inversion that BSD
Unix, where Joy's vi codebase began, no longer uses it, and the AT&T-derived Unixes, which in the early days
lacked Joy's editor, are the ones that now use and maintain modified versions of his code.
Impact
Over the years since its creation, vi became the de facto standard Unix editor and a nearly undisputed hacker
favorite
[citation needed]
outside of MIT until the rise of Emacs after about 1984. The Single UNIX Specification
specifies vi, so every conforming system must have it.
vi is still widely used by users of the Unix family of operating systems. About half the respondents in a 1991
USENET poll preferred vi. In 1999, Tim O'Reilly, founder of the eponymous computer book publishing company,
stated that his company sold more copies of its vi book than its emacs book.
Interface
vi is a modal editor: it operates in either insert mode (where typed text becomes part of the document) or normal
mode (where keystrokes are interpreted as commands that control the edit session). For example, typing i while in
normal mode switches the editor to insert mode, but typing i again at this point places an "i" character in the
document. From insert mode, pressing the escape key switches the editor back to normal mode. A perceived
advantage of vi's separation of text entry and command modes is that both text editing and command operations can
be performed without requiring the removal of the user's hands from the home row. As non-modal editors usually
have to reserve all keys with letters and symbols for the printing of characters, any special commands for actions
other than adding text to the buffer must be assigned to keys which do not produce characters, such as function keys,
or combinations of modifier keys such as ^ Ctrl, and Alt with regular keys. Vi has the property that most
ordinary keys are connected to some kind of command for positioning, altering text, searching and so forth, either
singly or in key combinations. Many commands can be touch typed without the use of Shift,^ Ctrl or Alt.
Other types of editors generally require the user to move their hands from the home row when touch typing:
To use a mouse to select text, commands, or menu items in a GUI editor.
To the arrow keys or editing functions (Home / End or Function Keys).
To invoke commands using modifier keys in conjunction with the standard typewriter keys.
For instance, replacing a word is cwreplacement text Escape which is a combination of two independent
commands (change and word-motion) together with a transition into and out of insert mode. Text between the cursor
position and the end of the word is overwritten by the replacement text. The operation can be repeated at some other
location by typing ., the effect being that the word starting that location will be replaced with the same replacement
text.
Vi
183
Contemporary derivatives and clones
The startup screen of vi clone vim
Traditional Vi
[15]
is a port of the original vi to modern Unix systems
by Gunnar Ritter. Minor enhancements include 8-bit input, support
for multi-byte character encodings like UTF-8, and features
demanded by POSIX.2. It contains few additions beyond these, so it
is of interest for those who look for a small but well-defined vi
implementation close to that of most commercial Unix systems. It
also has some features to cope with primitive terminals or slow
connections. It is available as part of the FreeBSD ports collection,
MacPorts, and an RPM is available for Linux from the OpenPKG
project. Ritter makes the following claims for Traditional Vi:
Compared to most of its many clones, the original vi is a rather small program (~120 KB code on i386)
just with its extremely powerful editing interface, but lacking fancy features like multiple undo, multiple
screens or syntax highlighting. In other words, it is a typical Unix program that does exactly what it
should and nothing more.
Vim "Vi IMproved" has yet more features than vi, including (scriptable) syntax highlighting, mouse support,
graphical versions, visual mode, many new editing commands and a large amount of extension in the area of ex
commands. Vim is included with almost every Linux distribution (and is also shipped with every copy of Apple
OS X). Vim also has a vi compatibility mode, in which Vim is more compatible with vi than it would be
otherwise, although some vi features, such as open mode, are missing in Vim, even in compatibility mode. This
mode is controlled by the :set compatible option. This mode is automatically turned on by Vim when it is
started in a situation which looks as if the software might be expected to be vi compatible. Vim then changes
some of its behaviors such that they are compatible with the vi standard. Vim features which do not conflict with
vi compatibility are always available, regardless of the setting.
Elvis is a free vi clone for Unix and other operating systems written by Steve Kirkendall. Elvis introduced a
number of features now present in other vi clones, including allowing the cursor keys to work in input mode. It
was the first to provide color syntax highlighting (and to generalize syntax highlighting to multiple filetypes).
Elvis 1.x was used as the starting point for nvi, but Elvis 2.0 added numerous features, including multiple buffers,
windows, display modes, and file access schemes. Elvis is the standard version of vi shipped on Slackware Linux,
Kate OS and MINIX. The most recent version of Elvis is 2.2, released in October 2003.
nvi is an implementation of the ex/vi text editor originally distributed as part of the final official Berkeley
Software Distribution (4.4 BSD-Lite). This is the version of vi that is shipped with all BSD-based open source
distributions. It adds command history and editing, filename completions, multiple edit buffers, multi-windowing
(including multiple windows on the same edit buffer). Beyond 1.79, from October, 1996, which is the
recommended stable version, there have been "development releases" of nvi, the most recent of which is 1.81.6,
from November, 2007.
vile was initially derived from an early version of Microemacs in an attempt to bring the Emacs
multi-window/multi-buffer editing paradigm to vi users.
BusyBox, a set of standard Linux utilities in a single executable, includes a tiny vi clone.
Vi
184
References
[1] Interview with Bill Joy, Unix Review, August 1984 (http:/ / web. cecs. pdx. edu/ ~kirkenda/ joy84. html)
[2] Source code for em; February, 1976 (http:/ / www.eecs. qmul. ac. uk/ ~gc/ history/ emsource/ )
[3] [3] (see Acknowlegments section at end of file)
[4] See dates in copyright headers, ex 1.1 source code (http:/ / minnie. tuhs. org/ cgi-bin/ utree. pl?file=1BSD/ ex-1. 1)
[5] version.c, ex 1.1 source code (http:/ / minnie.tuhs. org/ cgi-bin/ utree. pl?file=1BSD/ ex-1. 1/ Version. c)
[6] READ_ME from the first Berkeley Software Distribution (http:/ / minnie. tuhs. org/ cgi-bin/ utree. pl?file=1BSD/ READ_ME) ( formatted
version (http:/ / www. skytel. co. cr/ bsd/ research/ acrobat/ 780201. pdf))
[7] makefile, ex 2.0 source code (http:/ / minnie.tuhs.org/ cgi-bin/ utree. pl?file=2BSD/ src/ ex/ makefile)
[8] READ_ME (http:/ / minnie.tuhs.org/ cgi-bin/ utree.pl?file=2BSD/ src/ ex/ READ_ME), ex 2.0 source code
[9] [9] (see Acknowlegments section at end of file)
[10] [10] Usenet, various newsgroups (comp.editors, comp.sys.*, comp.os.*), 1990
[11] [11] (discusses January comp.os.minix posting, and design goals)
[12] Changes (http:/ / ex-vi. cvs.sourceforge. net/ viewvc/ ex-vi/ ex-vi/ Changes?view=markup) file, from Traditional Vi by Gunnar Ritter
[13] Caldera License for 32-bit 32V UNIX and 16 bit UNIX Versions 1, 2, 3, 4, 5, 6, 7 (http:/ / www. mckusick. com/ csrg/ calder-lic. pdf)
[14] http:/ / ex-vi. cvs. sourceforge. net/
[15] http:/ / ex-vi. cvs. sourceforge. net/
Further reading
Lamb, Linda; Arnold Robbins (1998). Learning the vi Editor (6th Edition) (http:/ / www. oreilly. com/ catalog/
vi6/ ). O'Reilly & Associates, Inc.
Robbins, Arnold; Linda Lamb, Elbert Hannah (2008). Learning the vi and Vim Editors, Seventh Edition (http:/ /
oreilly. com/ catalog/ 9780596529833/ ). O'Reilly & Associates, Inc.
External links
The original Vi version, adapted to more modern standards (http:/ / ex-vi. sourceforge. net/ )
An Introduction to Display Editing with Vi (http:/ / docs. freebsd. org/ 44doc/ usd/ 12. vi/ paper. html), by Mark
Horton and Bill Joy
vi lovers home page (http:/ / www. thomer. com/ vi/ vi. html)
explanation of modal editing with vi "Why, oh WHY, do those #?@! nutheads use vi?" (http:/ / www. viemu.
com/ a-why-vi-vim. html)
wc
185
wc
wc (short for word count) is a command in Unix-like operating systems.
The program reads either standard input or a list of files and generates one or more of the following statistics:
newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.
Sample execution of wc:
$ wc foo bar
40 149 947 foo
2294 16638 97724 bar
2334 16787 98671 total
The first column is the count of newlines, meaning that the text file foo has 40 newlines while bar has 2294
newlines- resulting in a total of 2334 newlines. The second column indicates the number of words in each text file
showing that there are 149 words in foo and 16638 words in bar- giving a total of 16787 words. The last column
indicates the number of characters in each text file, meaning that the file foo has 947 characters while bar has
97724 characters- 98671 characters all in all.
Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode
which includes multi-byte characters. The desired behaviour is selected with the -c or -m switch.
GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils.
Usage
wc -l <filename> print the line count (note that if the last line does not have \n, it will not be counted)
wc -c <filename> print the byte count
wc -m <filename> print the character count
wc -L <filename> print the length of longest line
wc -w <filename> print the word count
External links
wc(1)
[1]
Linux User Commands Manual from linux.die.net
wc(1) - Original Unix First Edition manual page for wc
[2]
.
wc
[3]
- The program's manpage
The wc Command
[4]
by The Linux Information Project (LINFO)
References
[1] http:/ / linux.die. net/ man/ 1/ wc
[2] http:/ / man.cat-v. org/ unix-1st/ 1/ wc
[3] http:/ / www. linuxmanpages.com/ man1/ wc.1.php
[4] http:/ / www. linfo.org/ wc.html
Xargs
186
Xargs
xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from
standard input. Commands like grep and awk can accept the standard input as a parameter, or argument by using
a pipe. However, others like cp and echo disregard the standard input stream and rely solely on the arguments
found after the command. Additionally, under the Linux kernel before version 2.6.23, arbitrarily long lists of
parameters could not be passed to a command,
[1]
so xargs breaks the list of arguments into sublists small enough
to be acceptable.
About
For example, commands like:
rm /path/*
or
rm `find /path -type f`
will fail with an error message of "Argument list too long" if there are too many files in /path.
However, the version below (functionally equivalent to rm `find /path -type f`) will not fail:
find /path -type f -print0 | xargs -0 rm
In the above example, the find utility feeds the input of xargs with a long list of file names. xargs then splits
this list into sublists and calls rm once for every sublist.
The previous example is more efficient than this functionally equivalent version which calls rm once for every
single file:
find /path -type f -exec rm '{}' \;
Note, however, that with modern versions of find, the following variant does the same thing as the xargs
version:
find /path -type f -exec rm '{}' +
xargs often covers the same functionality as the backquote (`) feature of many shells, but is more flexible and often
also safer, especially if there are blanks or special characters in the input. It is a good companion for commands that
output long lists of files like find, locate and grep, but only if you use -0, since xargs without -0 deals
badly with file names containing ', " and space. GNU Parallel is the perfect companion to find, locate and grep if
file names may contain ', " and space (newline still requires -0).
The separator problem
Many Unix utilities are line oriented. These may work with xargs as long as the lines do not contain ', " or
space. Some of the Unix utilities can use NUL as record separator (e.g. Perl (requires -0 and \0 instead of \n),
locate (requires using -0), find (requires using -print0), grep (requires -z or -Z), sort (requires
using -z)). Using -0 for xargs deals with the problem, but many Unix utilities cannot use NUL as separator (e.g.
head, tail, ls, echo, sed, tar -v, wc, which).
Xargs
187
But often people forget this and assume xargs is also line oriented, which is not the case (per default xargs
separates on newlines and blanks within lines, substrings with blanks must be single or double-quoted).
The separator problem is illustrated here:
touch important_file
touch 'not important_file'
find . -name not\* | tail -1 | xargs rm
mkdir -p '12" records'
find \! -name . -type d | tail -1 | xargs rmdir
Running the above will cause important_file to be removed but will remove neither the directory called 12"
records, nor the file called not important_file.
The proper fix is to use find -print0, but tail (and other tools) do not support NUL-terminated strings:
touch important_file
touch 'not important_file'
find . -name not\* -print0 | xargs -0 rm
mkdir -p '12" records'
find \! -name . -type d -print0 | xargs -0 rmdir
When using the syntax find -print0, entries are separated by a null character instead of an end-of-line. This is
equivalent to the more verbose command:
find . -name not\* | tr \\n \\0 | xargs -0 rm
or shorter, by switching xargs to line oriented mode with the -d (delimiter) option:
find . -name not\* | xargs -d '\n' rm
but in general using the -0 option should be preferred, since newlines in filenames are still a problem.
GNU Parallel is an alternative to xargs that is designed to have the same options, but be line oriented. Thus, using
GNU Parallel instead, the above would work as expected.
[2]
For Unix environments where xargs does not support the -0 option (e.g. Solaris, AIX), the following can not be
used as it does not deal with ' and " (GNU Parallel would work on Solaris, though):
find . -name not\* | sed 's/ /\\ /g' | xargs rm
For Solaris, do not use these examples to fix file perms as they do not deal correctly with names like 12" records
(GNU Parallel instead of xargs would work, though):
find . -type d -print | sed -e 's/^/"/' -e 's/$/"/' | xargs chmod 755
find . -type f -print | sed -e 's/^/"/' -e 's/$/"/' | xargs chmod 644
Xargs
188
References
[1] GNU Core Utilities FAQ (http:/ / www.gnu.org/ software/ coreutils/ faq/ coreutils-faq. html#Argument-list-too-long)
[2] Differences Between xargs and GNU Parallel (http:/ / www. gnu. org/ software/ parallel/ man.
html#differences_between_xargs_and_gnu_parallel). GNU.org (http:/ / www. gnu. org). Accessed February 2012.
External links
xargs (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ xargs. html):construct argument lists
and invoke utilityCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
Manual pages
xargs(1) (http:/ / www. gnu. org/ software/ findutils/ manual/ html_node/ find_html/ Invoking-xargs.
html)GNU Findutils reference
xargs(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=xargs& sektion=1):construct argument list(s) and
execute utilityFreeBSD General Commands Manual
xargs(1) (http:/ / netbsd. gw. com/ cgi-bin/ man-cgi?xargs+ 1+ NetBSD-current):construct argument list(s)
and execute utilityNetBSD General Commands Manual
xargs(1) (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=xargs& section=1):construct argument list(s)
and execute utilityOpenBSD General Commands Manual
xargs(1) (http:/ / docs. oracle. com/ cd/ E26505_01/ html/ 816-5165/ xargs-1. html):construct argument lists
and invoke utilitySolaris 10 User Commands Reference Manual
189
s
alias
In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and
Windows PowerShell, which enables a replacement of a word by another string. It is mainly used for abbreviating a
system command, or for adding default arguments to a regularly used command. Aliasing functionality in the
MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility.
An alias will last for the life of the shell session. Regularly used aliases can be set from the shell's configuration file
(~/.cshrc or the systemwide /etc/csh.cshrc for csh, or ~/.bashrc or the systemwide /etc/bashrc
or /etc/bash.bashrc for bash) so that they will be available upon the start of the corresponding shell session.
The alias commands may either be written in the config file directly or sourced from a separate file, typically named
.alias (or .alias-bash, .alias-csh, etc., if multiple shells may be used).
Creating aliases
Aliases can be created by supplying name/value pairs as arguments for the alias command. In Unix shells the syntax
is:
alias copy='cp'
The corresponding syntax in the C shell or tcsh shell is:
alias copy "cp"
This alias means that when the command copy is read in the shell, it will be replaced with cp and that command
will be executed instead.
In the 4DOS/4NT shell the following syntax is used to define cp as an alias for the 4DOS copy command:
alias cp copy
To create a new alias in Windows PowerShell, the new verb can be used with the alias cmdlet:
new-alias ci copy-item
This creates a new alias called ci that will be replaced with the copy-item cmdlet when executed.
History
In Unix, aliases were introduced in the C shell and thus survive in descendent shells such as tcsh and bash. C shell
aliases were strictly limited to one line in a shell language where all complex constructs required more, but still
useful for creating simple shortcut commands. Aliases were absent from the Bourne shell, which had the more
powerful facility of functions. The alias concept was imported into Bourne Again Shell (bash) and the Korn shell
(ksh). Shells such as these, that support both functions and aliases, recommend using functions where possible.
Cases where aliases are necessary include the use of chained aliases (bash and ksh).
alias
190
Viewing currently defined aliases
To view defined aliases the following commands can be used:
alias # Used without arguments; displays a list of all current aliases
alias -p # Analogous to the above; not available in 4DOS/4NT and PowerShell
alias myAlias # Displays the command for a defined alias
Overriding aliases
In Unix shells, if an alias exists for a command, it is possible to override the alias by surrounding the command with
quotes or prefixing it with a backslash. For example, consider the following alias definition:
alias ls='ls -la'
To override this alias and execute the ls command as it was originally defined, the following syntax can be used:
'ls'
or
\ls
In the 4DOS/4NT shell it is possible to override an alias by prefixing it with an asterisk. For example, consider the
following alias definition:
alias dir = *dir /2/p
The asterisk in the 2nd instance of dir causes the unaliased dir to be invoked, preventing recursive alias
expansion. Also the user can get the unaliased behaviour of dir at the command line by using the same syntax:
*dir
Changing aliases
In Windows PowerShell, the set verb can be used with the alias cmdlet to change an existing alias:
set-alias ci cls
The alias ci will now point to the cls command.
In the 4DOS/4NT shell, the eset command provides an interactive command line to edit an existing alias:
eset /a cp
The /a causes the alias cp to be edited, as opposed to an environment variable of the same name.
alias
191
Removing aliases
In Unix shells and 4DOS/4NT, aliases can be removed by executing the unalias command:
unalias copy # Removes the copy alias
unalias -a # The -a switch will remove all aliases; not
available in 4DOS/4NT
unalias * # 4DOS/4NT equivalent of `unalias -a` - wildcards are supported
In Windows PowerShell, the alias can be removed from the alias:\ drive using remove-item:
remove-item alias:ci # Removes the ci alias
Features
Chaining
An alias usually replaces just the first word. But some shells, such as bash and ksh allow a sequence or words to
be replaced; this particular feature is unavailable through the function mechanism.
The usual syntax is to define the first alias with a trailing space character. For instance, using the two aliases:
alias list='ls ' # note the trailing space to trigger chaining
alias long='-Flas' # options to ls for a long listing
allows:
list long myfile # becomes ls -Flas myfile when run
for a long listing, where "long" is also checked for being an alias.
Quoting quotes
To define an alias with single quotes, which itself needs to contain single quotes, you need to use several
concatenated quoted strings. For example, to define an alias which would do:
$ perl -pe 's/^(.*) foo/$1 bar/;'
You cannot do
$ alias foo2bar='perl -pe \'s/^(.*) foo/$1 bar/;\'' # WRONG: backslashes do not escape the next character inside single quotes
However, you can:
$ alias foo2bar='perl -pe '\''s/^(.*) foo/$1 bar/;'\''' # Put single quotes around your \' like '\''
But you can use single quotes quoted inside double quotes
$ alias foo2bar='perl -pe '"'"'s/^(.*) foo/$1 bar/;'"'"''
.
[1]
You may also consider using a function instead of an alias.
alias
192
Command arguments
In the C Shell, arguments can be embedded inside the command using the string \!*. For example, with this alias:
alias ls-more 'ls \!* | more'
ls-more /etc /usr expands to ls /etc /usr | more to list the contents of the directories /etc and /usr,
pausing after every screenful. Without \!*,
alias ls-more 'ls | more'
would instead expand to ls | more /etc /usr which incorrectly attempts to open the directories in more.
[2]
The Bash and Korn shells instead use shell functions see Alternatives below.
Typical aliases
Some commonly used, but deprecated, aliases in the Bash shell:
alias ls='ls --color=auto' # use colors
alias la='ls -Fa' # list all files
alias ll='ls -Fls' # long listing format
alias rm='rm -i' # prompt before overwrite (but dangerous, see rm for a better approach)
alias cp='cp -i' # prompt before overwrite (same general problem as the rm)
alias mv='mv -i' # prompt before overwrite (same general problem as the rm)
alias vi='vim' # use improved vi editor
Standard aliases of Windows PowerShell include:
new-alias cd set-location
new-alias ls get-childitem
new-alias dir get-childitem
new-alias echo write-output
new-alias ps get-process
new-alias kill stop-process
Alternatives
Aliases should usually be kept simple. Where it would not be simple, the recommendation is usually to use one of
the following:
Shell scripts, which essentially provide the full ability to create new system commands.
Symbolic links, either in /usr/local/bin if for all users, or in a user's $HOME/bin directory if for
personal use. This method is useful for providing an additional way of calling the command, and in some cases
may allow access to a buried command function for the small number of commands that use their invocation
name to select the mode of operation.
Shell functions, especially if the command being created needs to modify the internal runtime environment of the
shell itself (such as environment variables), needs to change the shell's current working directory, or must be
implemented in a way which guarantees they it appear in the command search path for anything but an interactive
shell (especially any "safer" version of rm, cp, mv and so forth).
alias
193
The most common form of aliases, which just add a few options to a command and then include the rest of the
command line, can be converted easily to shell functions following this pattern:
alias ll='ls -Flas' # long listing, alias
ll () { ls -Flas "$@" ; } # long listing, function
To make ls itself a function (note that "command ls" is Bash-specific, and that older Bourne shells would have
used "/bin/ls" instead):
ls () { command ls --color=auto "$@" ; }
References
[1] See this explanation (http:/ / stackoverflow.com/ questions/ 1250079/ bash-escaping-single-quotes-inside-of-single-quoted-strings#1250279)
[2] Examples of passing arguments given to a command alias (http:/ / unixhelp. ed. ac. uk/ shell/ alias_csh2. 1. html)
External links
alias (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ alias. html):define or display
aliasesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Bash man page for alias (http:/ / www. ss64. com/ bash/ alias. html)
The alias Command (http:/ / linfo. org/ alias. html) by The Linux Information Project (LINFO)
echo
In computing, echo is a command in DOS, OS/2, Microsoft Windows, Singularity, Unix and Unix-like operating
systems that places a string on the computer terminal. It is a built-in command typically used in shell scripts and
batch files to output status text to the screen or a file.
Many shells, including Bash
[1]
and zsh,
[2]
implement echo as a builtin command.
Usage example
> echo Hello world
Hello world
Using ANSI escape code SGR sequences, compatible terminals can print out colored text:
FGRED=`echo "\033[31m"`
FGCYAN=`echo "\033[36m"`
BGRED=`echo "\033[41m"`
FGBLUE=`echo "\033[35m"`
BGGREEN=`echo "\033[42m"`
NORMAL=`echo "\033[m"`
and after :
echo "${FGBLUE} Text in blue ${NORMAL}"
echo "Text normal"
echo "${BGRED} Background in red"
echo "${BGGREEN} Background in Green and back to Normal ${NORMAL}"
echo
194
Some variants of Unix, such as Linux, support the options -n and -e, and do not process escape sequences unless
the -e option is supplied. For example, FGRED=`echo -e "\033[31m"` might be used under Linux.
Unfortunately, such options are non standard
[3]
due to historical incompatibilities between BSD and System V; the
printf command can be used in situations where this is a problem. It is therefore recommended that printf be
used to ensure that escape sequences are processed. The equivalent code using printf is simply
FGRED=`printf "\033[31m"`.
Implementation example
The echo command can be implemented in the C programming language with only a few lines of code:
#include <stdlib.h>
#include <stdio.h>
/* echo command-line arguments; 1st version */
int main(int argc, char *argv[])
{
int i;
for (i = 1; i < argc-1; i++)
{
(void) printf("%s%s", argv[i], " ");
}
(void) printf("%s%s", argv[argc-1], "\n");
return EXIT_SUCCESS;
}
Scripting Languages can also emulate echo quite simply:
$ perl -e 'print join " ", @ARGV; print "\n"' This is a test.
This is a test.
$ python -c "import sys; print ' '.join(sys.argv[1:])" This is a test.
This is a test.
References
[1] https:/ / www. gnu. org/ software/ bash/ manual/ html_node/ Bash-Builtins. html
[2] http:/ / zsh. sourceforge. net/ Doc/ Release/ Shell-Builtin-Commands. html
[3] IEEE Std 1003.1, 2004, documentation for echo (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ echo. html)
External links
echo (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ echo. html):write arguments to standard
outputCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Microsoft TechNet Echo article (http:/ / technet. microsoft. com/ en-us/ library/ bb490897. aspx)
Expr
195
Expr
expr is a command line Unix utility which evaluates an expression and outputs the corresponding value. It first
appeared in Unix v7 as a standalone program, and was later incorporated into the shell as a built-in command.
Syntax: expr (expression)
expr evaluates integer or string expressions, including pattern matching regular expressions. Most of the challenge
posed in writing expressions is preventing the invoking command line shell from acting on characters intended for
expr to process.
The operators available
for integers: addition, subtraction, multiplication, division and modulus
for strings: find regular expression, find a set of characters in a string; in some versions: find substring, length of
string
for either: comparison (equal, not equal, less than, etc.)
The following is an example involving boolean expressions:
expr length "abcdef" "<" 5 "|" 15 - 4 ">" 8
This example outputs "1". This is because length "abcdef" is 6, which is not less than 5 (so the left side of the |
returns zero). But 15 minus 4 is 11 and is greater than 8, so the right side is true, which makes the or true, so 1 is the
result. The program exit status is zero for this example.
For pure arithmetic, it is often more convenient to use bc. For example:
echo "3*4+14/2" | bc
since it accepts the expression as a single argument.
For portable shell programming use of the length and substr commands is not recommended.
External links
expr
[1]
:evaluate arguments as an expressionCommands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
The program's manpage
[2]
expr invocation in GNU coreutils manual
[3]
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ expr. html
[2] http:/ / www. linuxmanpages.com/ man1/ expr.1.php
[3] http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ expr-invocation. html#expr-invocation
Printf
196
Printf
An example of the printf function.
Printf format string (of which
"printf" stands for "print formatted")
refers to a control parameter used by a
class of functions in the
string-processing libraries of various
programming languages. The format
string is written in a simple template
language, and specifies a method for rendering an arbitrary number of varied data type parameters into a string. This
string is then by default printed on the standard output stream, but variants exist that perform other tasks with the
result, such as returning it as the value of the function. Characters in the format string are usually copied literally into
the function's output, as is usual for templates, with the other parameters being rendered into the resulting text in
place of certain placeholders points marked by format specifiers, which are typically introduced by a % character,
though syntax varies. The format string itself is very often a string literal, which allows static analysis of the function
call. However, it can also be the value of a variable, which allows for dynamic formatting but also a security
vulnerability known as an uncontrolled format string exploit.
The term "printf" is due to the C language, which popularized this type of function, but these functions predate C,
and other names are used, notably "format". Printf format strings, which provide formatted output (templating), are
complementary to scanf format strings, which provide formatted input (parsing). In both cases these provide simple
functionality and fixed format compared to more sophisticated and flexible template engines or parsers, but are
sufficient for many purposes.
Timeline
Many programming languages implement a printf function to output a formatted string. It originated from the C
programming language, where it has a prototype similar to the following:
int printf(const char *format, ...);
The string constant format provides a description of the output, with placeholders marked by "%" escape
characters, to specify both the relative location and the type of output that the function should produce. The return
value yields the number of printed characters.
FORTRAN 66
Fortran's variadic PRINT statement referenced a non-executable FORMAT statement.
PRINT 601, 123456, 1000.0, 3.1415, 250
601 FORMAT (8H RED NUM,I7,4H EXP,E8.1,5H REAL,F5.2,4H VAL,I4)
will print the following (on a new line, because of the leading blank character):
RED NUM 123456 EXP 1.0E 03 REAL 3.14 VAL 250
Printf
197
COBOL
COBOL provided formatting via hierarchical data structure specification:
01 out-rec.
02 out-name picture x(20).
02 out-amount picture $9,999.99.
...
move me to out-name.
move amount to out-amount.
write out-rec.
1960s: BCPL, ALGOL 68, Multics PL/I
C's variadic printf has its origins in BCPL's writef function.
ALGOL 68 Draft and Final report had the functions inf and outf, subsequently these were revised out of the
original language and replaced with the now more familiar readf/getf and printf/putf.
printf(($"Color "g", number1 "6d,", number2 "4zd,", hex "16r2d,", float "-d.2d,", unsigned value"-3d"."l$,
"red", 123456, 89, BIN 255, 3.14, 250));
Multics has a standard function called ioa_ with a wide variety of control codes. It was based on a
machine-language facility from Multics's BOS (Bootstrap Operating System).
call ioa_ ("Hello, ^a", "World!");
1970s: C, Lisp
printf("Color %s, number1 %d, number2 %05d, hex %#x, float %5.2f,
unsigned value %u.\n",
"red", 123456, 89, 255, 3.14159, 250);

will print the following line (including new-line character, \n):
Color red, number1 123456, number2 00089, hex 0xff, float 3.14, unsigned value 250.
The printf function returns the number of characters printed, or a negative value if an output error occurs.
Common Lisp has the extremely powerful format function.
(format t "~{~a~^, ~}!" '(hello world))
;; "HELLO, WORLD!"

prints "Hello, World!" on the standard output stream. If the first argument is nil, format returns the string to
its caller. The first argument can also be any output stream. format was introduced into ZetaLisp at MIT in 1978,
based on the Multics ioa_, and was later adopted into the Common Lisp standard. Scheme incorporated Common
Lisp-style format in SRFi-28 and SRFi-54.
Printf
198
1980s: Perl, Shell
Perl also has a printf function. Common Lisp has a format function which acts according to the same principles
as printf, but uses different characters for output conversion. The GLib library contains g_print, an
implementation of printf.
Some Unix systems have a printf program for use in shell scripts; many derive this from the GNU Core Utilities
suite. This can be used instead of echo in situations where the latter is not portable. For example:
echo -n -e "$FOO\t$BAR"
may be rewritten portably as:
printf "%s\t%s" "$FOO" "$BAR"
1990s: PHP, Python
1995: PHP also has the printf function, with the same specifications and usage as that in C/C++. MATLAB does
not have printf, but does have its two extensions sprintf and fprintf which use the same formatting
strings. sprintf returns a formatted string instead of producing a visual output.
1991: Python's % operator hearkens to printf's syntax when interpolating the contents of a tuple. This operator
can, for example, be used with the print function:
print("%s\t%s" % (foo,bar))
Version 2.6 of Python added the more versatile str.format() method:
print("If you multiply five and six you get {0}.".format(5*6))
It's easy to create a C language-like printf() function in either Python 2.x or 3.x:
import sys
def printf(format, *args):
sys.stdout.write(format % args)
printf("%d x %d is %d\n", 6, 7, 6*7)
2000s: Java
2004: Java supported printf from version 1.5 onwards as a member of the PrintStream class, giving it the
functionality of both the printf and fprintf functions. At the same time sprintf-like functionality was added to
the String class by adding the format(String, Object... args) method.
// Write "Hello, World!" to standard output (like printf)
System.out.printf("%s, %s", "Hello", "World!");
// create a String object with the value "Hello, World!" (like sprintf)
String myString = String.format("%s, %s", "Hello", "World!");
Unlike most other implementations, Java's implementation of printf throws an exception on encountering a
malformed format string.
Printf
199
Format placeholders
Formatting takes place via placeholders within the format string. For example, if a program wanted to print out a
person's age, it could present the output by prefixing it with "Your age is ". To denote that we want the integer for
the age to be shown immediately after that message, we may use the format string:
"Your age is %d."
The syntax for a format placeholder is
%[parameter][flags][width][.precision][length]type
Parameter can be omitted or can be:
Character Description
n$ n is the number of the parameter to display using this format specifier, allowing the parameters provided to be output multiple times,
using varying format specifiers or in different orders. If any single placeholder specifies a parameter, all the rest of the placeholders
MUST also specify a parameter. This is a POSIX extension and not in C99. Example: printf("%2$d %2$#x; %1$d
%1$#x",16,17) produces "17 0x11; 16 0x10"
Flags can be zero or more (in any order) of:
Character Description
+ always denote the sign '+' or '-' of a number (the default is to omit the sign for positive numbers). Only applicable to numeric types.
space prefixes non-negative signed numbers with a space
- left-align the output of this placeholder (the default is to right-align the output).
# Alternate form. For 'g' and 'G', trailing zeros are not removed. For 'f', 'F', 'e', 'E', 'g', 'G', the output always contains a decimal point. For
'o', 'x', and 'X', a 0, 0x, and 0X, respectively, is prepended to non-zero numbers.
0 use 0 instead of spaces to pad a field when the width option is specified. For example, printf("%2d", 3) results in "3", while
printf("%02d", 3) results in "03".
Width specifies a minimum number of characters to output, and is typically used to pad fixed-width fields in
tabulated output, where the fields would otherwise be smaller, although it does not cause truncation of oversized
fields. A leading zero in the width value is interpreted as the zero-padding flag mentioned above, and a negative
value is treated as the positive value in conjunction with the left-alignment "-" flag also mentioned above.
Precision usually specifies a maximum limit on the output, depending on the particular formatting type. For floating
point numeric types, it specifies the number of digits to the right of the decimal point that the output should be
rounded. For the string type, it limits the number of characters that should be output, after which the string is
truncated.
Length can be omitted or be any of:
Character Description
hh For integer types, causes printf to expect an int-sized integer argument which was promoted from a char.
h For integer types, causes printf to expect an int-sized integer argument which was promoted from a short.
l For integer types, causes printf to expect a long-sized integer argument. For floating point types, causes printf to expect a
double argument.
ll For integer types, causes printf to expect a long long-sized integer argument.
L For floating point types, causes printf to expect a long double argument.
z For integer types, causes printf to expect a size_t-sized integer argument.
j For integer types, causes printf to expect a intmax_t-sized integer argument.
t For integer types, causes printf to expect a ptrdiff_t-sized integer argument.
Printf
200
Additionally, several platform-specific length options came to exist prior to widespread use of the ISO C99
extensions:
Characters Description
I For signed integer types, causes printf to expect ptrdiff_t-sized integer argument; for unsigned integer types, causes
printf to expect size_t-sized integer argument. Commonly found in Win32/Win64 platforms.
I32 For integer types, causes printf to expect a 32-bit (double word) integer argument. Commonly found in Win32/Win64 platforms.
I64 For integer types, causes printf to expect a 64-bit (quad word) integer argument. Commonly found in Win32/Win64 platforms.
q For integer types, causes printf to expect a 64-bit (quad word) integer argument. Commonly found in BSD platforms.
ISO C99 includes the inttypes.h header file that includes a number of macros for use in platform-independent
printf coding. Example macros include:
Macro Description
PRId32 Typically equivalent to I32d (Win32/Win64) or d
PRId64 Typically equivalent to I64d (Win32/Win64), lld (32-bit platforms) or ld (64-bit platforms)
PRIi32 Typically equivalent to I32i (Win32/Win64) or i
PRIi64 Typically equivalent to I64i (Win32/Win64), lli (32-bit platforms) or li (64-bit platforms)
PRIu32 Typically equivalent to I32u (Win32/Win64) or u
PRIu64 Typically equivalent to I64u (Win32/Win64), llu (32-bit platforms) or lu (64-bit platforms)
PRIx32 Typically equivalent to I32x (Win32/Win64) or x
PRIx64 Typically equivalent to I64x (Win32/Win64), llx (32-bit platforms) or lx (64-bit platforms)
Type
Type can be any of:
Character Description
d, i int as a signed decimal number. '%d' and '%i' are synonymous for output, but are different when used with scanf() for input
(where using %i will interpret a number as hexadecimal if it's preceded by 0x, and octal if it's preceded by 0.)
u Print decimal unsigned int.
f, F double in normal (fixed-point) notation. 'f' and 'F' only differs in how the strings for an infinite number or NaN are printed ('inf',
'infinity' and 'nan' for 'f', 'INF', 'INFINITY' and 'NAN' for 'F').
e, E double value in standard form ([-]d.ddd e[+/-]ddd). An E conversion uses the letter E (rather than e) to introduce the exponent.
The exponent always contains at least two digits; if the value is zero, the exponent is 00. In Windows, the exponent contains three
digits by default, e.g. 1.5e002, but this can be altered by Microsoft-specific _set_output_format function.
g, G double in either normal or exponential notation, whichever is more appropriate for its magnitude. 'g' uses lower-case letters, 'G' uses
upper-case letters. This type differs slightly from fixed-point notation in that insignificant zeroes to the right of the decimal point are
not included. Also, the decimal point is not included on whole numbers.
x, X unsigned int as a hexadecimal number. 'x' uses lower-case letters and 'X' uses upper-case.
o unsigned int in octal.
s null-terminated string.
c char (character).
p void * (pointer to void) in an implementation-defined format.
Printf
201
a, A
double in hexadecimal notation, starting with "0x" or "0X". 'a' uses lower-case letters, 'A' uses upper-case letters.
[1]
(C++11
iostreams have a hexfloat that works the same).
n Print nothing, but write number of characters successfully written so far into an integer pointer parameter.
% a literal '%' character (this type doesn't accept any flags, width, precision or length).
The width and precision formatting parameters may be omitted, or they can be a fixed number embedded in the
format string, or passed as another function argument when indicated by an asterisk "*" in the format string. For
example printf("%*d", 5, 10) will result in "10" being printed, with a total width of 5 characters, and
printf("%.*s", 3, "abcdef") will result in "abc" being printed.
If the syntax of a conversion specification is invalid, behavior is undefined, and can cause program termination. If
there are too few function arguments provided to supply values for all the conversion specifications in the template
string, or if the arguments are not of the correct types, the results are also undefined. Excess arguments are ignored.
In a number of cases, the undefined behavior has led to "Format string attack" security vulnerabilities.
Some compilers, like the GNU Compiler Collection, will statically check the format strings of printf-like functions
and warn about problems (when using the flags -Wall or -Wformat). GCC will also warn about user-defined
printf-style functions if the non-standard "format" __attribute__ is applied to the function.
Risks of using field width versus explicit delimiters in tabular output
Using only field widths to provide for tabulation, as with a format like "%8d%8d%8d" for three integers in three
8-character columns, will not guarantee that field separation will be retained if large numbers occur in the data. Loss
of field separation can easily lead to corrupt output. In systems which encourage the use of programs as building
blocks in scripts, such corrupt data can often be forwarded into and corrupt further processing, regardless of whether
the original programmer expected the output would only be read by human eyes. Such problems can be eliminated
by including explicit delimiters, even spaces, in all tabular output formats. Simply changing the dangerous example
from before to " %7d %7d %7d" addresses this, formatting identically until numbers become larger, but then
explicitly preventing them from becoming merged on output due to the explicitly included spaces. Similar strategies
apply to string data.
Custom format placeholders
There are a few implementations of printf-like functions that allow extensions to the escape-character-based
mini-language, thus allowing the programmer to have a specific formatting function for non-builtin types. One of the
most well-known is the (now deprecated) glibc's register_printf_function()
[2]
. However, it is rarely
used due to the fact that it conflicts with static format string checking. Another is Vstr custom formatters
[3]
, which
allows adding multi-character format names, and can work with static format checkers.
Some applications (like the Apache HTTP Server) include their own printf-like function, and embed extensions
into it. However these all tend to have the same problems that register_printf_function() has.
The Linux kernel printk function supports a number of ways to display kernel structures using the generic %p
specification, by appending additional format characters. For example, %pI4 prints an IPV4 address in
dotted-decimal form. This allows static format string checking (of the %p portion) at the expense of full
compatibility with normal printf.
Most non-C languages that have a printf-like function work around the lack of this feature by just using the "%s"
format and converting the object to a string representation. C++ offers a notable exception, in that it has a printf
function inherited from its C history, but also has a completely different mechanism that is preferred.
Printf
202
Programming languages with printf
AMPL
awk (via sprintf)
Bourne shell (sh) and derivatives such as Korn shell (ksh), Bourne again shell (bash), or Z shell (zsh)
C
C++ (also provides overloaded shift operators and manipulators as an alternative for formatted output - see
iostream and iomanip)
Objective-C
Clojure
Common Lisp
D
F#
GNU MathProg
GNU Octave
G (LabVIEW)
Go
Haskell
Java (since version 1.5)
Clojure
Scala
Lua (string.format)
Maple
Mathematica
MATLAB
Mythryl
OCaml
(OCaml Batteries Included provides an additional user-extensible printf)
PARI/GP
PHP
Perl
Python (using the % operator)
R
Ruby
Rust
Tcl (via format command)
Transact-SQL (via xp_sprintf
[4]
)
Vala (via print() and FileStream.printf())
Printf
203
Notes
[1] "printf" (http:/ / www. cplusplus.com/ reference/ cstdio/ printf/ ) ("%a" added in C99)
[2] http:/ / www. gnu. org/ software/ libc/ manual/ html_node/ Customizing-Printf. html
[3] http:/ / www. and. org/ vstr/ #cust-fmt
[4] http:/ / technet. microsoft. com/ en-us/ library/ ms175014. aspx
External links
C++ reference for std::fprintf (http:/ / en. cppreference. com/ w/ cpp/ io/ c/ fprintf)
gcc printf format specifications quick reference (http:/ / www. pixelbeat. org/ programming/ gcc/ format_specs.
html)
printf (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ functions/ printf. html):print formatted
outputSystem Interfaces Reference, The Single UNIX Specification, Issue 7 from The Open Group
The Formatter specification (http:/ / java. sun. com/ j2se/ 1. 5. 0/ docs/ api/ java/ util/ Formatter. html#syntax)
in Java 1.5
GNU Bash printf(1) builtin (http:/ / wiki. bash-hackers. org/ commands/ builtin/ printf)
sleep
sleep is a Unix command line program that suspends program execution for a specified period of time. The sleep
instruction suspends the calling process for at least the specified number of seconds (the default), minutes, hours or
days.
Usage
sleep '''number'''[suffix].....
or:
sleep option
Where number is a required floating point number, and suffix is an optional suffix to indicate the time period.
Suffix
s (seconds)
m (minutes)
h (hours)
d (days)
Options
--help display this help and exit
--version output version information and exit
sleep
204
Examples
sleep 5s
Causes the current terminal session to wait 5 seconds. The default unit is seconds.
sleep 5h
Causes the current terminal session to wait 5 hours
sleep 3h ; mplayer foo.mp3
Wait 3 hours then play foo.mp3
Note that sleep 5h30m and sleep 5h 30m are illegal since sleep takes only one value and unit as argument.
However, sleep 5.5h is allowed. Consecutive executions of sleep can also be used.
sleep 5h; sleep 30m
Sleep 5 hours, then sleep another 30 minutes.
The GNU Project's implementation of sleep (part of coreutils) allows the user to pass multiple arguments, therefore
sleep 5h 30m (a space separating hours and minutes is needed) will work on any system which uses GNU sleep,
including GNU/Linux.
Possible uses for sleep include scheduling tasks and delaying execution to allow a process to start, or waiting until
a shared network connection most likely has few users to wget a large file.
External links
sleep(1)
[1]
:delay for a specified amount of timeLinux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ sleep
test
205
test
test is a command-line utility found in Unix-like operating systems that evaluates conditional expressions.
Syntax
test expression
or
[ expression ]
Description
The test command evaluates the expression parameter. In some shells (such as FreeBSD sh(1)), it is actually a shell
builtin, even though external version still exists. In the second form of the command, the [ ] (brackets) must be
surrounded by blank spaces, this is because /bin/[ is a program and POSIX compatible shells require a space between
the program name and its arguments. One must test explicitly for file names in the C shell. File-name substitution
(globbing) causes the shell script to exit.
Functions
The following functions are used to construct this parameter:
-e FileName - FileName exists.
Note: All remaining functions return true if the object (file or string) exists, and the condition specified is true.
-b Filename - Returns a True exit value if the specified FileName exists
and is a block special file.
-c FileName - FileName is a character special file.
-d FileName - FileName is a directory.
-f FileName - FileName is a regular file.
-g FileName - FileName's Set Group ID bit is set.
-h FileName - FileName is a symbolic link.
-k FileName - FileName's sticky bit is set.
-L FileName - FileName is a symbolic link.
-p FileName - FileName is a named pipe (FIFO).
-r FileName - FileName is readable by the current process.
-s FileName - FileName has a size greater than 0.
-t FileDescriptor - FileDescriptor is open and associated with a terminal.
-u FileName - FileName's Set User ID bit is set.
-w FileName - FileName's write flag is on. However, the FileName will
not be writable on a read-only file system even if test indicates true.
-x FileName - FileName's execute flag is on.
If the specified file exists and is a directory, the True exit value indicates
that the current process has permission to change (chdir) into the directory.
test
206
file1 -nt file2 - file1 is newer than file2.
file1 -ot file2 - file1 is older than file2.
file1 -ef file2 - file1 is another name for file2. (symbolic link or hard link)
String functions
Note that in Perl, these sections are reversed: eq is a string operator and == is a numerical operator, and so on for the
others.
-n String1 - the length of the String1 variable is nonzero.
-z String1 - the length of the String1 variable is 0 (zero).
String1 = String2 - String1 and String2 variables are identical.
String1 != String2 - String1 and String2 variables are not identical.
String1 - String1 variable is not a null string.
Number functions
Integer1 -eq Integer2 - Integer1 and Integer2 variables are algebraically
equal. Any of the following comparisons can be used in place of -eq.
-ne (not equal)
-gt (greater than)
-ge (greater or equal)
-lt (less than)
-le (less or equal)
Operators
These functions can be combined with the following operators:
! - Unary negation operator
-a - Binary AND operator
-o - Binary OR operator (the -a operator has higher precedence
than the -o operator)
\(Expression\) - Parentheses for grouping must be escaped with a backslash (\).
The -a and -o operators, along with parentheses for grouping, are XSI extensions
[1]
and are therefore not portable. In
portable shell scripts, the same effect may be achieved by connecting multiple invocations of test together with the
&& and || operators and parentheses.
Exit Status
This command returns the following exit values:
0 - The Expression parameter is true.
1 - The Expression parameter is false or missing.
>1 - An error occurred.
Examples
1. To test whether a file is nonexistent or empty, type:
if test ! -s "$1"
then
test
207
echo $1 does not exist or is empty.
fi
If the file specified by the first positional parameter to the shell procedure, $1, does not exist or is of size 0, the test
command displays the message. If $1 exists and has a size greater than 0, the test command displays nothing.
Note: There must be a space between the -s function and the file name.
The quotation marks around $1 ensure that the test works properly even if the value of $1 is a null string. If the
quotation marks are omitted and $1 is the empty string, the test command displays the error message:
test: argument expected.
2. To do a complex comparison, type:
if [ $# -lt 2 -o ! -e "$1" ]
then
exit
fi
If the shell procedure is given fewer than two positional parameters or the file specified by $1 does not exist, then the
shell procedure exits. The special shell variable $# represents the number of positional parameters entered on the
command line that starts this shell procedure.
References
[1] IEEE Std 1003.1, 2004, documentation for test (http:/ / www. opengroup. org/ onlinepubs/ 009695399/ utilities/ test. html)
true and false
In Unix-like operating systems, true and false are commands whose only function is to always return with a
predetermined exit status. Programmers and scripts often use the exit status of a command to assess success (exit
status zero) or failure (non-zero) of the command. The true and false commands represent the logical values of
command success, because true returns 0, and false returns 1.
Usage
The commands are usually employed in conditional statements and loops of shell scripts. For example, the following
shell script repeats the echo hello loop until interrupted:
while true
do
echo hello
done
The commands can be used to ignore the success or failure of a sequence of other commands, as in the example:
make && false
Setting a user's login shell to false, in /etc/passwd, effectively denies them access to an interactive shell, but their
account may still be valid for other services, such as FTP. (Although /sbin/nologin, if available, may be more
fitting for this purpose, as it prints a notification before terminating the session.)
true and false
208
The programs take no "actual" parameters; in most Linux versions, the standard parameter --help displays a
usage summary and --version displays the program version.
Null command
The true command is sometimes substituted with the very similar null command, written as a single colon (:). The
null command is built into the shell, and may therefore be more efficient if true is an external program (true is
usually a shell built in function). We can rewrite the upper example using : instead of true:
while :
do
echo hello
done
The null command may take parameters, which are ignored. It is also used as a no-op dummy command for
side-effects such as assigning default values to shell variables through the ${parameter:=word} parameter
expansion form. For example, from bashbug, the bug-reporting script for Bash:
: ${TMPDIR:=/tmp}
: ${EDITOR=$DEFEDITOR}
: ${USER=${LOGNAME-`whoami`}}
References
External links
true (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ true. html):return true
valueCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
false (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ false. html):return false
valueCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Manual pages
true(1) (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ true-invocation. html): Do nothing,
successfully GNU Coreutils reference
false(1) (http:/ / www. gnu. org/ software/ coreutils/ manual/ html_node/ false-invocation. html): Do nothing,
unsuccessfully GNU Coreutils reference
true(1) (http:/ / man. freebsd. org/ true): Return true value FreeBSD manual page
false(1) (http:/ / man. freebsd. org/ false): Return false value FreeBSD manual page
Unset
209
Unset
unset is a builtin Unix shell command implemented by both the Bourne shell family of shells (sh, ksh, bash, etc.)
and the C shell family of shells (csh, tcsh, etc.). It unsets a shell variable, removing it from memory and the shell's
exported environment. It is implemented as a shell builtin, because it directly manipulates the internals of the shell.
Read-only shell variables cannot be unset. If one tries to unset a read-only variable, the unset command will print an
error message and return a non-zero exit code. For more information on read-only variables, see readonly.
External links
broken link: * unset
[1]
:unset values and attributes of variables and functionsCommands & Utilities Reference,
The Single UNIX Specification, Issue 7 from The Open Group
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ unset. html
wait
In computing, wait is a command which pauses until execution of a background process has ended.
Usage
wait [n]
where n is the pid or job ID of a currently executing background process (job). If n is not given, the command waits
until all jobs known to the invoking shell have terminated.
wait normally returns the exit status of the last job which terminated. It may also return 127 in the event that n
specifies a non-existent job or zero if there were no jobs to wait for.
Because wait needs to be aware of the job table of the current shell execution environment, it is usually
implemented as a shell builtin.
Example
This command can be useful where part of a script can execute in parallel to implement a barrier where an upcoming
section depends on the successful completion of the preceding sections.
The following example will fetch the src/ directory from a machine named iona using rsync and simultaneously
update the libraries on which this program depends, before building the combination.
#!/usr/bin/env bash
# Parallel update script which makes use of the wait command
# Update local copy
rsync iona:src/ . &
# Upgrade required libraries, or exit indicating failure if make failed
for some reason
make -C lib || exit 1
wait
210
# Wait for rsync to terminate (may have already happened) and finish
the job, unless rsync failed
wait && make
Wait for specified job control id number:
$ ls -R / > /dev/null 2>&1 & # start any long running background process
[2] 1986
$ wait %2 # waits for background job number 2 to terminate, then returns
External links
GNU bash reference manual
[1]
References
[1] http:/ / www. gnu. org/ software/ bash/ manual/ bashref. html
yes
yes is a Unix command, which outputs an affirmative response, or a user-defined string of text continuously until
killed.
Description
By itself, the yes command outputs 'y' or whatever is specified as an argument, followed by a newline repeatedly
until stopped by the user or otherwise killed; when piped into a command, it will continue until the pipe breaks (i.e.,
the program completes its execution).
It can also be used to test how well a system handles high loads, as using yes results in 100% processor usage, for
systems with a single processor (for a multiprocessor system, a process must be run for each processor).
Uses
yes can be used to send an affirmative (or negative; e.g. yes n) response to any command that would otherwise
request one, thereby causing the command to run non-interactively.
This usage may be obsolete today, as most commands that would request response from the user have either a 'force'
option (e.g., rm -f) or an 'assume-yes' option (e.g., apt-get -y).
As an example, the following:
rm -f *.txt
is functionally equivalent to
yes | rm *.txt
The yes command in conjunction with the head command can be used to generate large volume files for means of
testing. For example, executing
yes 1234567 | head -1000 > file
results in a file consisting of 1000 lines each consisting of eight characters (1, 2, 3, 4, 5, 6, 7 and newline).
yes
211
In 2006, the yes command received publicity for being a means to test whether or not a user's MacBook is affected
by the Intermittent Shutdown Syndrome. By running the yes command twice via Terminal under Mac OS X, users
were able to max out their computer's CPU, and thus see if the failure was heat related.
References
Further reading
Montfort, Nick (January 2012). The Trivial Program yes (http:/ / trope-tank. mit. edu/ TROPE-12-01. pdf)
(Technical report). Cambridge, Massachusetts: Trope Tank. 12-01. Retrieved 2013-04-26.
External links
Manpage for yes (http:/ / www. linuxmanpages. com/ man1/ yes. 1. php) (GNU version)
212
dig
dig (domain information groper) is a network administration command-line tool for querying Domain Name System
(DNS) name servers.
Dig is useful for network troubleshooting and for educational purposes. Dig can operate in interactive command line
mode or in batch mode by reading requests from an operating system file. When a specific name server is not
specified in the command invocation, it will use the operating systems default resolver, usually configured via the
resolv.conf file. Without any arguments it queries the DNS root zone.
Dig supports Internationalized Domain Name (IDN) queries.
Dig is part of the BIND domain name server software suite. Dig replaces older tools such as nslookup and the host
program.
Example usage
In this example, dig is used to query for any type of record information in the domain example.com:
Command line:
dig any example.com
Output:
; <<>> DiG 9.6.1 <<>> any example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4016
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN ANY
;; ANSWER SECTION:
example.com. 172719 IN NS a.iana-servers.net.
example.com. 172719 IN NS b.iana-servers.net.
example.com. 172719 IN A 208.77.188.166
example.com. 172719 IN SOA dns1.icann.org. hostmaster.icann.org. 2007051703 7200 3600 1209600 86400
;; Query time: 1 msec
;; SERVER: ::1#53(::1)
;; WHEN: Wed Aug 12 11:40:43 2009
;; MSG SIZE rcvd: 154
Queries may be directed to designated DNS servers for specific records; in this example, MX records:
Command:
dig
213
dig MX wikimedia.org @ns0.wikimedia.org
Output:
; <<>> DiG 9.6.1 <<>> MX wikimedia.org @ns0.wikimedia.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61144
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;wikimedia.org. IN MX
;; ANSWER SECTION:
wikimedia.org. 3600 IN MX 10 mchenry.wikimedia.org.
wikimedia.org. 3600 IN MX 50 lists.wikimedia.org.
;; ADDITIONAL SECTION:
mchenry.wikimedia.org. 3600 IN A 208.80.152.186
lists.wikimedia.org. 3600 IN A 91.198.174.5
;; Query time: 73 msec
;; SERVER: 208.80.152.130#53(208.80.152.130)
;; WHEN: Wed Aug 12 11:51:03 2009
;; MSG SIZE rcvd: 109
References
Paul Albitz and Cricket Liu. DNS and BIND, 5th Edition. Nutshell Series. O'Reilly and Associates, Inc., 2006.
External links
dig manual page as distributed with BIND 9.9
[1]
dig(1)
[2]
Linux User Commands Manual
How to use dig to query DNS name servers
[3]
References
[1] ftp:/ / ftp. isc.org/ isc/ bind9/ cur/ 9. 9/ doc/ arm/ man. dig.html
[2] http:/ / linux.die. net/ man/ 1/ dig
[3] http:/ / www. madboa. com/ geek/ dig/
Inetd
214
Inetd
inetd (internet service daemon) is a super-server daemon on many Unix systems that provides Internet services. For
each configured service, it listens for requests from connecting clients. Requests are served by spawning a process
which runs the appropriate executable, but simple services such as echo are served by inetd itself. External
executables, which are run on request, can be single- or multi-threaded. First appearing in 4.3BSD [1], it is generally
located at /usr/sbin/inetd.
Function
Often called a super-server, inetd listens on designated ports used by Internet services such as FTP, POP3, and telnet.
When a TCP packet or UDP packet arrives with a particular destination port number, inetd launches the appropriate
server program to handle the connection. For services that are not expected to run with high loads, this method uses
memory more efficiently, since the specific servers run only when needed. Furthermore, no network code is required
in the service-specific programs, as inetd hooks the sockets directly to stdin, stdout and stderr of the spawned
process. For protocols that have frequent traffic, such as HTTP and POP3, a dedicated server that intercepts the
traffic directly may be preferable.
Setup
The list of services that will be serviced is given in a configuration file, usually /etc/inetd.conf. A GUI for
managing the configuration file is an optional accessory. The daemon may need a signal in order to re-read its
configuration. For an example, telnet can be configured as follows (line taken from a machine running AIX version
5.1):
telnet stream tcp6 nowait root /usr/sbin/telnetd telnetd -a
The first word, telnet, is the official name of the service. It is resolved using the system database to map port
numbers and protocols to service names. In this case, /etc/services should contain:
telnet 23/tcp
The second and third words describe the type of socket and underlying protocol respectively. The
/etc/protocols database is consulted.
The fourth word is the wait/nowait switch. A single-threaded server expects inetd to wait until it finishes reading all
the data. Otherwise inetd lets the server run and spawns new, concurrent processes for new requests.
The fifth word is the user name, from the /etc/passwd/ database, that the service program should run as.
Finally, the path and the arguments of an external program are given. As usual, the first argument is the program
name. In the example, inetd is told to launch the program /usr/sbin/telnetd with the command line
arguments telnetd -a. inetd automatically hooks the socket to stdin, stdout, and stderr of the server program.
Generally TCP sockets are handled by spawning a separate server to handle each connection concurrently. UDP
sockets are generally handled by a single server instance that handles all packets on that port.
Some simple services, such as echo, are handled directly by inetd, without spawning an external server.
Inetd
215
Creating an inetd service
This is a simple inetd service, written in C. It expects a command line argument containing a filename for a log file,
and then it logs all strings sent through the socket to the log file.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
const char *fn = argv[1];
FILE *fp = fopen(fn, "a+");
if(fp == NULL)
exit(EXIT_FAILURE);
char str[4096];
//inetd passes its information to us in stdin.
while(fgets(str, sizeof(str), stdin)) {
fputs(str, fp);
fflush(fp);
}
fclose(fp);
return 0;
}
The example uses stdio functions and it responds to network traffic coming in on stdin. In this case, we want all
messages logged to a single file, so we only want one instance of the service running to service all requests. This
means UDP is the correct protocol to use. First, an unused port number must be selected. In this sample, 9999 will be
used. The /etc/services entry will look like this:
errorLogger 9999/udp
And the entry in /etc/inetd.conf will look like this:
errorLogger dgram udp wait root /usr/local/bin/errlogd errlogd /tmp/logfile.txt
This tells inetd to run the /usr/local/bin/errlogd program, with the commandline: errlogd
/tmp/logfile.txt (refer to the inetd.conf man page for information on the other arguments). The first
argument contains the filename to be used for the log file: /tmp/logfile.txt. inetd will run the service when
needed, and attach port 9999 to the input and output streams, and all strings sent to that port will be logged to the
file. By specifying wait, it tells inetd to only use one instance of the server to handle all requests.
Note: the functionality of the above example is usually implemented by using syslog and a process like syslogd.
syslogd would normally be started in parallel with inetd, not as an inetd service.
Inetd
216
inetd replacements
In recent years, because of the security limitations in the original design of inetd, it has been replaced by xinetd,
rlinetd, ucspi-tcp, and others in many systems. Distributions of Linux especially have many options and Mac OS X
(beginning with Mac OS X v10.2) uses xinetd. As of version Mac OS X v10.4, Apple has merged the functionality
of inetd into launchd.
The services provided by inetd can be omitted entirely. This is becoming more common where machines are
dedicated to a single function. For example, an HTTP server could be configured to just run httpd and have no other
ports open. A dedicated firewall could have no services started.
systemd supports inetd services, and expands socket activation beyond IP messaging (AF INET+6) to include AF
UNIX, AF NETLINK and more.
[2][3]
Security concerns
While the inetd concept as a service dispatcher is not inherently insecure, the long list of services that inetd
traditionally provided gave computer security experts pause. The possibility of a service having an exploitable flaw,
or the service just being abused, had to be considered. Unnecessary services were disabled and "off by default"
became the mantra. It is not uncommon to find an /etc/inetd.conf with almost all the services commented
out in a modern Unix distribution.
References
[1] http:/ / www. freebsd. org/ cgi/ man. cgi?query=inetd
[2] http:/ / 0pointer.de/ blog/ projects/ socket-activation.html
[3] http:/ / 0pointer.de/ blog/ projects/ systemd.html
External links
inetd(8) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=inetd& sektion=8):internet
'super-server'FreeBSD System Manager's Manual
host
217
host
host is a simple utility for performing Domain Name System lookups. It was developed by the Internet Systems
Consortium (ISC), and is released under the ISC license, a permissive free software license.
The similar dig utility interrogates DNS servers directly for troubleshooting and system administration purposes.
External links
host(1)
[1]
Linux User Commands Manual
References
[1] http:/ / linux.die. net/ man/ 1/ host
Ifconfig
ifconfig (short for interface configuration) is a system administration utility in Unix-like operating systems to
configure, control, and query TCP/IP network interface parameters from a command line interface (CLI) or in
system configuration scripts. Ifconfig originally appeared in 4.2BSD as part of the BSD TCP/IP suite.
Usage
Common uses for ifconfig include setting an interface's IP address and netmask, and disabling or enabling a given
interface.
[1]
At boot time, many UNIX-like operating systems initialize their network interfaces with shell-scripts
that call ifconfig. As an interactive tool, system administrators routinely use the utility to display and analyze
network interface parameters. The following example output samples display the state of a single active interface
each on a Linux-based host (interface eth0) and the ural0 interface on an OpenBSD installation.
eth0 Link encap:Ethernet HWaddr 00:0F:20:CF:8B:42
inet addr:217.149.127.10 Bcast:217.149.127.63 Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2472694671 errors:1 dropped:0 overruns:0 frame:0
TX packets:44641779 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1761467179 (1679.7 Mb) TX bytes:2870928587 (2737.9 Mb)
Interrupt:28
ural0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:0d:0b:ed:84:fb
media: IEEE802.11 DS2 mode 11b hostap (autoselect mode 11b hostap)
status: active
ieee80211: nwid ARK chan 11 bssid 00:0d:0b:ed:84:fb 100dBm
inet 172.30.50.1 netmask 0xffffff00 broadcast 172.30.50.255
inet6 fe80::20d:bff:feed:84fb%ural0 prefixlen 64 scopeid 0xa
The txqueuelen is measured in number of Ethernet frames and is the size of the buffer that is being managed by
the network scheduler.
Ifconfig
218
Changing Hardware MAC
ifconfig is commonly used to arbitrarily change the MAC address of a computer. This is down by first bring the
network conection down with the ipconfig command and then issues a MAC change command. Example:
ifconfig wlan0 down
ifconfig hw ether 00:11:22:33:44:55
ifconfig wlan0 up
Current status
The free Berkeley Software Distribution UNIX operating systems (e.g., NetBSD, OpenBSD, and FreeBSD) continue
active development of ifconfig and extension of its functionality to cover the configuration of wireless networking
interfaces, VLAN trunking, controlling hardware features such as TSO or hardware checksumming or setting up
bridge and tunnel interfaces. Solaris has historically used ifconfig for all network interface configuration, but as of
Solaris 10 introduced dladm to perform data-link (OSI model layer 2) configuration, reducing ifconfig's purview to
IP configuration.
In older Linux distributions, ifconfig, and the route command operated together to connect a computer to a network,
and to define routes between networks. ifconfig for Linux is part of the net-tools package which, while still
maintained,
[2]
released its latest version 1.60 on 2001-April-15.
Modern Linux distributions are in the process of deprecating ifconfig and route, replacing them with iproute2,
[citation
needed]
which has been available since 1999-April-17 for Linux 2.2.4.
[3]
Wikipedia:Verifiability iproute2 includes
support for all common functions of ifconfig(8), route(8), arp(8) and netstat(1), and beyond that, multicast
configuration support, tunnel and virtual link management, traffic control, and (lowlevel) IPsec configuration among
others.
Related tools
Versions of Microsoft Windows from Windows 95 to Windows Me used winipcfg to give a graphical display of
current IP information. ipconfig, a command similar to ifconfig, comes with Microsoft operating-systems based on
the Windows NT kernel. ipconfig also controls the Windows DHCP client.
In Mac OS X, the ifconfig command functions as a wrapper to the IPConfiguration agent, and can control the BootP
and DHCP clients from the command-line. Use of ifconfig to modify network settings in Mac OS X is discouraged,
because ifconfig operates below the level of the system frameworks which help manage network configuration. To
change network settings in Mac OS X from the command line, use /usr/sbin/ipconfig or /usr/sbin/networksetup.
iwconfig, a component of Wireless tools for Linux, which took its name from ifconfig, manages wireless network
interfaces outside the original scope of Linux's ifconfig. iwconfig sets such specialized settings as a wireless
network's SSID and WEP keys, and functions in tandem with iwlist. Linux also features iwspy, to read the signal,
noise and quality of a wireless connection.
Other related tools for configuring Ethernet adapters are: ethtool, mii-tool, and mii-diag for Linux and show-link for
Solaris.
Ifconfig
219
References
[1] Linux Network Administrators Guide Section 5.7. Interface Configuration for IP (http:/ / www. faqs. org/ docs/ linux_network/ x-087-2-iface.
interface. html)
[2] Upstream URL http:/ / net-tools. sourceforge. net/
[3] [3] Based upon the availability of tarballs in iproute2's project space. (The GIT history does not reach as far back.) Furthermore, iproute2 release
versions follow the kernel version.
External links
ifconfig(8) (http:/ / net-tools. sourceforge. net/ man/ ifconfig. 8. html), official manpage for Linux net-tools
ifconfig
ifconfig(8) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=ifconfig), manpage for the FreeBSD ifconfig
ifconfig(8) (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=ifconfig), manpage for the OpenBSD ifconfig
ifconfig(8) (http:/ / download. oracle. com/ docs/ cd/ E19253-01/ 816-5166/ ifconfig-1m/ index. html),
manpage for the Solaris ifconfig
networksetup(8) (http:/ / developer. apple. com/ documentation/ Darwin/ Reference/ ManPages/ man8/
networksetup. 8. html), manpage for the Mac OS X networksetup
ifconfig (http:/ / www. leastprivilege. com/ UPDATEDIfconfigForWindows21. aspx) for Windows
ipconfig (http:/ / technet. microsoft. com/ en-us/ library/ dd197434(WS. 10). aspx) for Windows on a
technet.microsoft.com (http:/ / technet. microsoft. com)
ip (http:/ / linux. die. net/ man/ 8/ ip), manpage for the Linux command ip
Debian net-tools (http:/ / packages. qa. debian. org/ n/ net-tools. html) page, which includes sources of the Linux
version of ifconfig
net-tools future (http:/ / lists. debian. org/ debian-devel/ 2009/ 03/ msg00780. html) thread, from current
maintainers
ifconfig examples (http:/ / www. examplenow. com/ ifconfig)
Netstat
220
Netstat
In computing, netstat (network statistics) is a command-line tool that displays network connections (both
incoming and outgoing), routing tables, and a number of network interface (network interface controller or
software-defined network interface) and network protocol statistics. It is available on Unix-like operating systems
including OS X, Linux, Solaris, and BSD, and is available on Windows NT-based operating systems including
Windows XP, Windows Vista, Windows 7 and Windows 8.
It is used for finding problems in the network and to determine the amount of traffic on the network as a performance
measurement.
[1]
Parameters
Parameters used with this command must be prefixed with a hyphen (-) rather than a slash (/). If a parameter is
supported only on some platform or platforms, the platform or platforms is listed in parentheses after the parameter.
-a Displays all active connections and the TCP and UDP ports on which the computer is listening.
-b (Windows) Displays the binary (executable) program's name involved in creating each connection or listening port. (Windows XP, 2003
Server and newer Windows operating systems; not Microsoft Windows 2000 or older).
-b (OS X,
NetBSD)
Causes -i to report the total number of bytes of traffic.
-e Displays ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s.
-f (Windows) Displays fully qualified domain names <FQDN> for foreign addresses (only available on Windows Vista and newer operating
systems).
-f Address Family
(FreeBSD)
Limits display to a particular socket address family, unix, inet, inet6
-g Displays multicast group membership information for both IPv4 and IPv6 (may only be available on newer operating systems)
-i Displays network interfaces and their statistics (not available under Windows)
-m Displays the memory statistics for the networking code (STREAMS statistics on Solaris).
-n Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to
determine names.
-o (Windows)
Displays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on
the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a, -n, and -p. This parameter is
available on Microsoft Windows XP, 2003 Server (and Windows 2000 if a hotfix is applied).
[2]
-p protocol
(Windows and
BSD)
Shows connections for the protocol specified by protocol. In this case, protocol can be tcp, udp, tcpv6, or udpv6. If this
parameter is used with -s to display statistics by protocol, protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6.
-p (Linux) Show which processes are using which sockets (similar to -b under Windows) (you must be root to do this)
-P protocol
(Solaris)
Shows connections for the protocol specified by protocol. In this case, protocol can be ip, ipv6, icmp, icmpv6, igmp, udp, tcp,
or rawip.
-r Displays the contents of the IP routing table. (This is equivalent to the route print command under Windows.)
-s Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol
for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p
parameter can be used to specify a set of protocols.
-t (Linux) Display only TCP connections.
-W (FreeBSD) Display wide output - doesn't truncate hostnames or IPv6 addresses
Netstat
221
-v (Windows) When used in conjunction with -b it will display the sequence of components involved in creating the connection or listening
port for all executables.
Interval Redisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted,
netstat prints the selected information only once.
-h (unix)
/? (windows)
Displays help at the command prompt.
Statistics provided
Netstat provides statistics for the following:
Proto - The name of the protocol (TCP or UDP).
Local Address - The IP address of the local computer and the port number being used. The name of the local
computer that corresponds to the IP address and the name of the port is shown unless the -n parameter is
specified. An asterisk (*) is shown for the host if the server is listening on all interfaces. If the port is not yet
established, the port number is shown as an asterisk.
Foreign Address - The IP address and port number of the remote computer to which the socket is connected. The
names that corresponds to the IP address and the port are shown unless the -n parameter is specified. If the port is
not yet established, the port number is shown as an asterisk (*).
State - Indicates the state of a TCP connection. The possible states are as follows: CLOSE_WAIT, CLOSED,
ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, LAST_ACK, LISTEN, SYN_RECEIVED, SYN_SEND, and
TIME_WAIT. For more information about the states of a TCP connection, see RFC 793.
Examples
To display the statistics for only the TCP or UDP protocols, type one of the following commands:
netstat -sp tcp
netstat -sp udp
On Microsoft Windows:
To display active TCP connections and the process IDs every 5 seconds, type the following command (works
on XP and 2003 only, or Windows 2000 with hotfix):
netstat -o 5
To display active TCP connections and the process IDs using numerical form, type the following command
(works on XP and 2003 only, or Windows 2000 with hotfix):
netstat -no
To display all ports open by a process with id pid:
netstat -aop | grep "pid"
Netstat
222
Caveats
Some versions of netstat lack explicit field delimiters in their printf-generated output, leading to numeric fields
running together and thus corrupting the output data.
Platform specific remarks
Under Linux, raw data can often be obtained from the /proc/net/dev to work around the printf output corruption
arising in netstat's network interface statistics summary, netstat -i, until such time as the problem is
corrected.
[citation needed]
On the Windows platform, netstat information can be retrieved by calling the GetTcpTable and GetUdpTable
functions in the IP Helper API, or IPHLPAPI.DLL. Information returned includes local and remote IP addresses,
local and remote ports, and (for GetTcpTable) TCP status codes. In addition to the command-line netstat.exe tool
that ships with Windows, GUI-based netstat programs are available.
On the Windows platform, this command is available only if the Internet Protocol (TCP/IP) protocol is installed as
a component in the properties of a network adapter in Network Connections.
On the Windows platform running Remote Desktop Services (formerly Terminal Services) it will only show
connections for the current user, not for the whole computer.
On OS X, the /Applications/Utilities folder contains a network GUI utility called Network Utility, the Netstat tab of
which runs the netstat command and displays its output in the tab.
References
[1] http:/ / publib. boulder. ibm.com/ infocenter/ systems/ index. jsp?topic=/ com. ibm. aix. prftungd/ doc/ prftungd/ netstat. htm
[2] http:/ / support. microsoft.com/ kb/ 907980
External links
Net-Tool (http:/ / sourceforge. net/ projects/ net-tools/ ) project page on Sourceforge
Ports & Services Database (http:/ / www. iana. org/ assignments/ port-numbers)
Microsoft TechNet Netstat article (http:/ / technet. microsoft. com/ en-us/ library/ bb490947. aspx)
documentation for the netstat.exe command-line program.
The netstat Command (Linux) (http:/ / www. faqs. org/ docs/ linux_network/ x-087-2-iface. netstat. html) a
guide to using the netstat command in Linux.
Security Now #49 - The NETSTAT Command (http:/ / www. grc. com/ SecurityNow. htm#49) podcast guide to
netstat from Security Now!.
From linux-ip.net (http:/ / linux-ip. net/ html/ tools-netstat. html) More complete description of some aspects of
the output.
Nslookup
223
Nslookup
nslookup is a network administration command-line tool available for many computer operating systems for
querying the Domain Name System (DNS) to obtain domain name or IP address mapping or for any other specific
DNS record.
As of BIND 9.9.0a3, nslookup has apparently been resurrected ("nslookup is no longer to be treated as deprecated").
(The Internet Systems Consortium had previously deprecated nslookup in favor of host and dig for some time.)
Background
The name "nslookup" means "name server lookup". nslookup does not use the operating system's local Domain
Name System resolver library to perform its queries, and thus may behave differently to dig (which does).
Additionally, vendor-provided versions can confuse matters by using or including output of other sources of name
information (such as host files, Network Information Service). Some behaviors of nslookup may be modified by the
contents of resolv.conf.
Usage
nslookup operates in interactive or non-interactive mode. When used interactively by invoking it without arguments
or when the first argument is - (minus sign) and the second argument is a host name or Internet address of a name
server, the user issues parameter configurations or requests when presented with the nslookup prompt (>). When no
arguments are given, then the command queries the default server. The - (minus sign) invokes subcommands which
are specified on the command line and should precede nslookup commands. In non-interactive mode, i.e. when the
first argument is a name or Internet address of the host being searched, parameters and the query are specified as
command line arguments in the invocation of the program. The non interactive mode searches the information for a
specified host using the default name server.
References
External links
Microsoft Windows
nslookup (http:/ / technet. microsoft. com/ en-us/ library/ bb490721. aspx) Microsoft TechNet library
Using NSlookup.exe (http:/ / support. microsoft. com/ kb/ 200525/ ), Microsoft Knowledge Base
Unix-like OSs
nslookup(1) (http:/ / linux. die. net/ man/ 1/ nslookup)Linux User Commands Manual
Other
DNS Web Tools (http:/ / www. dmoz. org/ Computers/ Internet/ Protocols/ DNS/ Web_Tools) on the Open
Directory Project (includes web-version of nslookup)
Ping
224
Ping
Ping may refer to:
Technology
Ping (networking utility), a computer network tool used to test whether a particular host is reachable across an IP
network
Echo Request message in Internet Control Message Protocol (ICMP)
Ping, a pulse of sound in active sonar
iTunes Ping, a social network for music that was once built into Apple iTunes
Ping (blogging), used for blogs, RSS, and related web services
PING (software), used for disk cloning or backup
People
Ping (given name)
Jean Ping (born 1942), Gabonese diplomat and Chairperson of the Commission of the African Union
Nimrod Ping (19472006), politician in Brighton, England
Frank Steven Ping Bodie (18871961), Major League Baseball player
Panfilo Morena "Ping" Lacson (born 1948), Filipino politician and current member of the Philippine Senate
Fictional characters
Ping, a domesticated Chinese duck in the illustrated book The Story about Ping, first published in 1933
Ping, a minor character in Seinfeld, an NBC sitcom
Ping, a character in the webcomic Megatokyo
Ping, the disguised identity of Hua Mulan in the animated film Mulan
Ping the Elastic Man, a comic strip character introduced in The Beano in 1938
"The machine that goes Ping!", a fictitious obstetric medical device featured in the film Monty Python's Meaning
of Life
Mr. Ping, a character in the film Kung Fu Panda
Professor Ping, a character in the film Barbarella
Other
Pinging, the noise indicative of improper combustion (detonation rather than deflagration) in internal combustion
engines
Ping, (Traditional Chinese Character: ), a Taiwanese measure of area
Ping, an ability in the trading card game Magic: The Gathering
Ping project, a European Molecular Biology network (EMBnet) mean to evaluate network efficiency
Ping River, a river in Thailand
Ping (golf), a brand of golf club
"Ping" (short story), by Samuel Beckett
Ping (video gaming), the network latency seen between a game player's computer and the game server (or another
player)
Rdate
225
Rdate
On Unix-like operating systems, rdate is a tool for querying the current time from a network server and, optionally,
setting the system time. Rdate uses the Time Protocol. The Time Protocol is generally considered obsolete and has
been replaced by the Network Time Protocol (NTP).
When used to set the local system time, rdate operates by changing system time immediately to the time and date
returned by the server. Abrupt changes of clock settings have been found to cause problems for software relying on
timing. This led to the development of the Network Time Protocol, which gradually changes the system time and
does not skip ticks.
Due to the problems described above, rdate is generally used only on systems where NTP is not available, or in
specialized circumstances where it is required that system time be set correctly as soon as possible during initial
setup, before services which may be vulnerable to abrupt time-changes have started.
References
rdate(1) manual page
[1]
RFC 868 - Describing the Time Protocol used by rdate
[2]
Open-rdate, a project implementing the rdate command
[3]
References
[1] http:/ / linux.die. net/ man/ 1/ rdate
[2] http:/ / www. apps. ietf. org/ rfc/ rfc868.html
[3] http:/ / sourceforge. net/ projects/ openrdate/
Rlogin
Internet
protocol suite
Application layer
BGP
DHCP * DHCPv6
DNS
FTP
HTTP
IMAP
IRC
LDAP
MGCP
NNTP
NTP
POP
RPC
RTP
RTSP
RIP
SIP
Rlogin
226
SMTP
SNMP
SOCKS
SSH
Telnet
TLS/SSL
XMPP
more...
Transport layer
TCP
UDP
DCCP
SCTP
RSVP
more...
Internet layer
IP
IPv4
IPv6
ICMP
ICMPv6
ECN
IGMP
IPsec
more...
Link layer
ARP/InARP
NDP
OSPF
Tunnels
L2TP
PTPP
Media access control
Ethernet
DSL
ISDN
FDDI
DOCSIS
more...
v
t
e
[1]
rlogin is a software utility for Unix-like computer operating systems that allows users to log in on another host via a
network, communicating via TCP port 513.
It was first distributed as part of the 4.2BSD release.
The rlogin homepage is at http:/ / rlogin. sourceforge. net.
rlogin is also the name of the application layer protocol used by the software, part of the TCP/IP protocol suite.
Authenticated users can act as if they were physically present at the computer. RFC 1282, in which it was defined,
Rlogin
227
states that: "The rlogin facility provides a remote-echoed, locally flow-controlled virtual terminal with proper
flushing of output." rlogin communicates with a daemon, rlogind, on the remote host. rlogin is similar to the Telnet
command, but has the disadvantage of not being as customizable and being able to connect only to Unix hosts.
Use
rlogin is most commonly deployed on corporate or academic networks, where user account information is shared
between all the Unix machines on the network (often using NIS). These deployments essentially trust ALL other
machines (and the network infrastructure itself) and the rlogin protocol relies on this trust. rlogind allows logins
without password (where rlogind trusts a remote rlogin client) if the remote host appears in the /etc/hosts.equiv file,
or if the user in question has a .rhosts file in their home directory (which is frequently shared using NFS).
Security
rlogin has several serious security problems:
All information, including passwords, is transmitted unencrypted (making it vulnerable to interception).
The .rlogin (or .rhosts) file is easy to misuse (potentially allowing anyone to log in without a password) - for this
reason many corporate system administrators prohibit .rlogin files and actively search their networks for
offenders.
The protocol partly relies on the remote party's rlogin client providing information honestly (including source port
and source host name). A corrupt client is thus able to forge this and gain access, as the rlogin protocol has no
means of authenticating other machines' identities, or ensuring that the rlogin client on a trusted machine is the
real rlogin client.
The common practice of mounting users' home directories via NFS exposes rlogin to attack by means of fake
.rhosts files - this means that any of NFS's security faults automatically plague rlogin.
Due to these serious problems rlogin was rarely used across untrusted networks (like the public internet) and even in
closed deployments it has fallen into relative disuse (with many Unix and Linux distributions no longer including it
by default). Many networks which formerly relied on rlogin and telnet have replaced it with SSH and its
rlogin-equivalent slogin.
Replacements
The original Berkeley package which provides rlogin also features rcp (remote-copy, allowing files to be copied over
the network) and rsh (remote-shell, allowing commands to be run on a remote machine without the user logging into
it). These share the hosts.equiv and .rhosts access-control scheme (although they connect to a different daemon,
rshd), and as such suffer from the same security problems. The ssh suite contains suitable replacements for both: scp
replaces rcp, and ssh itself replaces both rlogin and rsh.
Rlogin
228
References
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008
and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
External links
rlogin(1): The Untold Story (PDF)
[1]
RFC 1282 - BSD Rlogin
rlogin - remote login
[2]
- rloginman page.
rlogin(1)
[3]
:remote loginDarwin and Mac OS X General Commands Manual
rlogin(1)
[4]
:remote loginSolaris 10 User Commands Reference Manual
References
[1] http:/ / www. cert. org/ archive/ pdf/ 98tr017.pdf
[2] http:/ / unixhelp.ed. ac.uk/ CGI/ man-cgi?rlogin
[3] http:/ / developer. apple. com/ documentation/ Darwin/ Reference/ ManPages/ man1/ rlogin. 1. html
[4] http:/ / docs.oracle. com/ cd/ E26505_01/ html/ 816-5165/ rlogin-1. html
Netcat
229
Netcat
netcat
Developer(s) *Hobbit*
Latest stable 1.10 / 20March 1996
Operating system UNIX
Type Network utility
License Permissive free software
Website
nc110.sourceforge.net
[1]
Netcat is a computer networking service for reading from and writing to network connections using TCP or UDP.
Netcat is designed to be a dependable back-end that can be used directly or easily driven by other programs and
scripts. At the same time, it is a feature-rich network debugging and investigation tool, since it can produce almost
any kind of correlation its user could need and has a number of built-in capabilities.
Netcat is often referred to as a "Swiss-army knife for TCP/IP". Its list of features includes port scanning, transferring
files, and port listening, and it can be used as a backdoor.
Features
Some of netcat's major features are:
Outbound or inbound connections, TCP or UDP, to or from any ports
Full DNS forward/reverse checking, with appropriate warnings
Ability to use any local source port
Ability to use any locally-configured network source address
Built-in port-scanning capabilities, with randomization
Built-in loose source-routing capability
Can read command line arguments from standard input
Slow-send mode, one line every N seconds
Hex dump of transmitted and received data
Optional ability to let another program service establish connections
Optional telnet-options responder
Featured tunneling mode which permits user-defined tunneling, e.g., UDP or TCP, with the possibility of
specifying all network parameters (source port/interface, listening port/interface, and the remote host allowed to
connect to the tunnel).
Netcat
230
Examples
Opening a raw connection to port 25 (like SMTP)
nc mail.server.net 25
Setting up a one-shot webserver on port 8080 to present the content of a file
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l 8080
The file can then be accessed via a webbrowser under http://servername:8080/. Netcat only serves the file once to the
first client that connects and then exits, it also provides the content length for browsers that expect it. (This should
work fine in a LAN, but probably may fail with any kind of firewall between.).
Checking if UDP ports (-u) 80-90 are open on 192.168.0.1 using zero mode I/O (-z)
nc -vzu 192.168.0.1 80-90
Note that UDP tests will always show as "open". The -uz argument is useless.
Test if UDP port is open: simple UDP server and client
This test is useful, if you have shell access to the server that should be tested, but you do not know whether there is a
firewall blocking a specific UDP port on the server.
On the listening host, i.e. on the server whose port needs to be checked, do the following:
nc -ul 7000
On the sending host, do the following note that servname is the hostname of the listening host:
nc -u servname 7000
If text typed on the sending host (type something and hit enter) is displayed also on the listening host, then the UDP
port 7000 is open. If it is not open, you will get an error such as "Connection refused".
There is a caveat. On some machines, IPv6 may be the default IP version to use by netcat. Thus, the host specified
by the hostname is contacted using IPv6, and the user might not know about this. Ports may appear closed in the test,
even though they would be open when using IPv4. This can be difficult to notice and may cause the false impression
that the port is blocked, while it is actually open. You can force the use of IPv4 by using adding -4 to the options of
the nc commands.
Pipe via UDP (-u) with a wait time (-w) of 1 second to 'loggerhost' on port 514
echo '<0>message' | nc -w 1 -u loggerhost 514
Port scanning
An uncommon use of netcat is port scanning. Netcat is not considered the best tool for this job, but it can be
sufficient (a more advanced tool is nmap)
nc -v -n -z -w 1 192.168.1.2 1-1000
The "-n" parameter here prevents DNS lookup, "-z" makes nc not receive any data from the server, and "-w 1"
makes the connection timeout after 1 second of inactivity.
Netcat
231
Proxying
Another useful behaviour is using netcat as a proxy. Both ports and hosts can be redirected. Look at this
example:
nc -l 12345 | nc www.google.com 80
Port 12345 represents the request
This starts a nc server on port 12345 and all the connections get redirected to google.com:80. If a web browser
makes a request to nc, the request will be sent to google but the response will not be sent to the web browser. That is
because pipes are unidirectional. This can be worked around with a named pipe to redirect the input and output.
mkfifo backpipe
nc -l 12345 0<backpipe | nc www.google.com 80 1>backpipe
The "-c" option may also be used with the 'ncat' implementation:
ncat -l 12345 -c 'nc www.google.com 80'
Using a named pipe is a more reliable method because using "-c" option provides only a one-shot proxy.
Another useful feature is to proxy SSL connections. This way, the traffic can not be viewed in wire sniffing
applications such as wireshark. This can be accomplished on UNIXes by utilizing mkfifo, netcat, and
openssl.
mkfifo tmp
mkfifo tmp2
nc -l 8080 -k > tmp < tmp2 &
while [ 1 ]
do
openssl s_client -connect www.google.com:443 -quiet < tmp > tmp2
done
Making any process a server
netcat can be used to make any process a network server. It can listen on a port and pipe the input it receives to
that process. The -e option spawns the executable with its input and output redirected via network socket.
For example, it is possible to expose a bourne shell process to remote computers. To do so, on a computer A with IP
192.168.1.2, run this command:
nc -l -p 1234 -e /bin/sh
Then, from any other computer on the same network, one could run this nc command:
nc 192.168.1.2 1234
ls -las
And the output one would see might be like this:
total 4288
4 drwxr-xr-x 15 imsovain users 4096 2009-02-17 07:47 .
4 drwxr-xr-x 4 imsovain users 4096 2009-01-18 21:22 ..
8 -rw------- 1 imsovain users 8192 2009-02-16 19:30 .bash_history
Netcat
232
4 -rw-r--r-- 1 imsovain users 220 2009-01-18 21:04 .bash_logout
...
In this way, the -e option can be used to create a rudimentary backdoor. Some administrators perceive this as a
risk, and thus do not allow netcat on a computer.
Port Forwarding or Port Mapping
On Linux, NetCat can be used for port forwarding. Below are nine different ways to do port forwarding in NetCat
(-c switch not supported though - these work with the 'ncat' incarnation of netcat):
nc -l -p port1 -c ' nc -l -p port2'
nc -l -p port1 -c ' nc host2 port2'
nc -l -p port1 -c ' nc -u -l -p port2'
nc -l -p port1 -c ' nc -u host2 port2'
nc host1 port1 -c ' nc host2 port2'
nc host1 port1 -c ' nc -u -l -p port2'
nc host1 port1 -c ' nc -u host2 port2'
nc -u -l -p port1 -c ' nc -u -l -p port2'
nc -u -l -p port1 -c ' nc -u host2 port2'
Example, see Proxying Netcat#Proxying
Variants
The original version of netcat was a Unix program. The last version (1.10) was released in March 1996.
There are several implementations on POSIX systems, including rewrites from scratch like GNU netcat or OpenBSD
netcat, the latter of which supports IPv6. The OpenBSD version has been ported to the FreeBSD base and
Windows/Cygwin as well. Mac OS X users can use MacPorts to install a netcat variant. There is also a Microsoft
Windows version of netcat available. Known ports for embedded systems includes versions for the Windows CE
(named "Netcat 4 wince") or for the iPhone.
BusyBox includes by default a lightweight version of netcat.
Solaris 11 includes netcat implementation based on OpenBSD netcat.
Socat is a more complex variant of netcat. It is larger and more flexible and has more options that must be
configured for a given task.
Cryptcat is a version of netcat with integrated transport encryption capabilities.
In the middle of 2005, Nmap announced another netcat incarnation called Ncat. It features new possibilities such as
"Connection Brokering", TCP/UDP Redirection, SOCKS4 client and server support, ability to "Chain" Ncat
processes, HTTP CONNECT proxying (and proxy chaining), SSL connect/listen support and IP address/connection
filtering. Like Nmap, Ncat is cross-platform.
On some systems, modified versions or similar netcat utilities go by the command name(s) nc, ncat, pnetcat,
socat, sock, socket, sbd.
Netcat
233
References
[1] http:/ / nc110. sourceforge.net/
External links
Official website (http:/ / nc110. sourceforge. net/ )
OpenBSD nc(1) man page (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=nc) via OpenBSD
GNU netcat (http:/ / netcat. sourceforge. net/ )
Socat (http:/ / www. dest-unreach. org/ socat/ )
Adam Palmer (2008-09-16). "NetCat tutorial for Linux & Windows, HOWTO, nc" (http:/ / www. adamsinfo.
com/ netcat-tutorial-for-linux-windows-howto-nc/ ). Retrieved 2013-08-11.
George Notaras (2006-11-06). "Netcat a couple of useful examples" (http:/ / www. g-loaded. eu/ 2006/ 11/ 06/
netcat-a-couple-of-useful-examples/ ). Retrieved 2013-08-11.
Jon Crato (2009-04-10). "Netcat for Windows" (http:/ / joncraton. org/ blog/ netcat-for-windows). Retrieved
2013-08-11.
Thaoh Myrdania (2011-09-13). "Netcat Mirror" (http:/ / www. thaoh. net/ Tools/ Netcat/ ). Retrieved 2013-08-11.
"Netcat sous Windows - version non dtecte et projet CodeBlocks" (http:/ / 8pen. net/ ?p=382) (in French).
2011-06-08. Retrieved 2013-08-11. (Netcat for Windows with GAPING_SECURITY_HOLE and TELNET
enabled)
NetCat 1.14 for Windows GitHub Repository (https:/ / github. com/ diegocr/ netcat/ )
ssh
234
ssh
OpenSSH
"Don't tell anyone that I'm free"
Developer(s) The OpenBSD Project
Latest stable 6.6 / March16, 2014
Development status Active
Operating system Cross-platform
Type Remote access
License Simplified BSD License
Website
www.openssh.com
[1]
OpenSSH (OpenBSD Secure Shell) is a set of computer programs providing encrypted communication sessions
over a computer network using the SSH protocol. It was created as an open source alternative to the proprietary
Secure Shell software suite offered by SSH Communications Security.
OpenSSH is developed as part of the security conscious OpenBSD project, which is led by Theo de Raadt. The
project's development is funded via donations.
History
OpenSSH was created by the OpenBSD team as an alternative to the original SSH software by Tatu Ylnen, which
is now proprietary software. Although source code is available for the original SSH, various restrictions are imposed
on its use and distribution. The OpenSSH developers claim that their application is more secure than the original,
due to their policy of producing clean and audited code and because it is released under the BSD license, the open
source license to which the word open in the name refers.
OpenSSH first appeared in OpenBSD 2.6 and the first portable release was made in October 1999.
Release History:
OpenSSH 6.6: March 16, 2014
OpenSSH 6.5: January 30, 2014
OpenSSH 6.4: November 8, 2013
OpenSSH 6.3: September 13, 2013
OpenSSH 6.2: March 22, 2013
Add a GCM-mode for the AES cipher, similar to RFC 5647
OpenSSH 6.1: August 29, 2012
OpenSSH 6.0: April 22, 2012
OpenSSH 5.9: September 6, 2011
Introduce sandboxing of the pre-auth privilege separated child
OpenSSH 5.8: February 4, 2011
OpenSSH 5.7: January 24, 2011
Added support for elliptic curve cryptography for key exchange as well as host/user keys, per RFC RFC 5656
OpenSSH 5.6: August 23, 2010
OpenSSH 5.5: April 16, 2010
OpenSSH 5.4: March 8, 2010
ssh
235
Disabled SSH protocol 1 default support. Clients and servers must now explicitly enable it.
Added PKCS11 authentication support for ssh(1) (-I pkcs11)
Added Certificate based authentication
Added "Netcat mode" for ssh(1) (-W host:port). Similar to "-L tunnel", but forwards instead stdin and stdout.
This allows, for example, using ssh(1) itself as a ssh(1) ProxyCommand to route connections via intermediate
servers, without the need for nc(1) on the server machine.
Added the ability to revoke public keys in sshd(8) and ssh(1). While it was already possible to remove the keys
from authorised lists, revoked keys will now trigger a warning if used.
OpenSSH 5.3: October 1, 2009
OpenSSH 5.2: February 23, 2009
OpenSSH 5.1: July 21, 2008
OpenSSH 5.0: April 3, 2008
OpenSSH 4.9: March 30, 2008
Added chroot support for sshd(8)
Create an internal SFTP server for easier use of the chroot functionality
OpenSSH 4.7: September 4, 2007
OpenSSH 4.6: March 9, 2007
OpenSSH 4.5: November 7, 2006
OpenSSH 4.4: September 27, 2006
OpenSSH 4.3: February 1, 2006
Added OSI layer 2/3 tun-based VPN (-w option on ssh(1))
OpenSSH 4.2: September 1, 2005
OpenSSH 4.1: May 26, 2005
OpenSSH 4.0: March 9, 2005
OpenSSH 3.9: August 17, 2004
OpenSSH 3.8: February 24, 2004
OpenSSH 3.7.1: September 16, 2003
OpenSSH 3.7: September 16, 2003
OpenSSH 3.6.1: April 1, 2003
OpenSSH 3.6: March 31, 2003
OpenSSH 3.5: October 14, 2002
OpenSSH 3.4: June 26, 2002
Development and structure
OpenSSH remotely controlling a server through
Unix shell
OpenSSH is developed as part of the OpenBSD operating system.
Rather than including changes for other operating systems directly into
OpenSSH, a separate portability infrastructure is maintained by the
OpenSSH Portability Team and "portable releases" are made
periodically. This infrastructure is substantial, partly because OpenSSH
is required to perform authentication, a capability that has many
varying implementations. This model is also used for other OpenBSD
projects such as OpenNTPD.
The OpenSSH suite includes the following tools:
ssh, a replacement for rlogin, rsh and telnet to allow shell access to
a remote machine.
ssh
236
scp, a replacement for rcp.
sftp, a replacement for ftp to copy files between computers.
sshd, the SSH server daemon.
ssh-keygen a tool to inspect and generate the RSA, DSA and Elliptic Curve keys that are used for user and host
authentication.
ssh-agent and ssh-add, utilities to ease authentication by holding keys ready and avoid the need to enter
passphrases every time they are used.
ssh-keyscan, which scans a list of hosts and collects their public keys.
The OpenSSH server can authenticate users using the standard methods supported by the ssh protocol: with a
password; public-key authentication, using per-user keys; host-based authentication, which is a secure version of
rlogin's host trust relationships using public keys; keyboard-interactive, a generic challenge-response mechanism that
is often used for simple password authentication but which can also make use of stronger authenticators such as
tokens; and Kerberos/GSSAPI. The server makes use of authentication methods native to the host operating system;
this can include using the BSD authentication system (bsd auth) or PAM to enable additional authentication through
methods such as one-time passwords. However, this occasionally has side-effects: when using PAM with OpenSSH
it must be run as root, as root privileges are typically required to operate PAM. OpenSSH versions after 3.7
(September 16, 2003) allow PAM to be disabled at run-time, so regular users can run sshd instances.
On OpenBSD OpenSSH supports OTP and utilises systrace for sandboxing but like most OpenBSD native services,
OpenSSH also utilises a dedicated sshd user by default to drop privileges and perform privilege separation in
accordance to OpenBSDs least privilege policy that has been applied throughout the operating system such as for
their X server (see Xenocara).
Features
OpenSSH includes the ability to forward remote TCP ports over a secure tunnel. This is used to multiplex additional
TCP connections over a single ssh connection, concealing connections and encrypting protocols which are otherwise
unsecured, and for circumventing firewalls. An X Window System tunnel may be created automatically when using
OpenSSH to connect to a remote host, and other protocols, such as HTTP and VNC, may be forwarded easily.
In addition, some third-party software includes support for tunnelling over SSH. These include DistCC, CVS, rsync,
and Fetchmail. On some operating systems, remote file systems can be mounted over SSH using tools such as sshfs
(using FUSE).
An ad hoc SOCKS proxy server may be created using OpenSSH. This allows more flexible proxying than is possible
with ordinary port forwarding.
Beginning with version 4.3, OpenSSH implements an OSI layer 2/3 tun-based VPN. This is the most flexible of
OpenSSH's tunnelling capabilities, allowing applications to transparently access remote network resources without
modifications to make use of SOCKS.
Trademark
In February 2001, Tatu Ylnen, Chairman and CTO of SSH Communications Security informed the OpenSSH
development mailing list, that after speaking with key OpenSSH developers Markus Friedl, Theo de Raadt, and Niels
Provos, the company would be asserting its ownership of the "SSH" and "Secure Shell" trademarks. Ylnen
commented that the trademark "is a significant asset ... SSH Communications Security has made a substantial
investment in time and money in its SSH mark" and sought to change references to the protocol to "SecSH" or
"secsh", in order to maintain control of the "SSH" name. He proposed that OpenSSH change its name in order to
avoid a lawsuit, a suggestion that developers resisted. OpenSSH developer Damien Miller replied that "SSH has
been a generic term to describe the protocol well before your [Ylnen's] attempt to trademark it" and urged Ylnen
ssh
237
to reconsider, commenting: "I think that the antipathy generated by pursuing a free software project will cost your
company a lot more than a trademark."
At the time, "SSH," "Secure Shell" and "ssh" had appeared in documents proposing the protocol as an open standard
and it was hypothesised that by doing so, without marking these within the proposal as registered trademarks,
Ylnen was relinquishing all exclusive rights to the name as a means of describing the protocol. Improper use of a
trademark, or allowing others to use a trademark incorrectly, results in the trademark becoming a generic term, like
Kleenex or Aspirin, which opens the mark to use by others. After study of the USPTO trademark database, many
online pundits opined that the term "ssh" was not trademarked, merely the logo using the lower case letters "ssh." In
addition, the six years between the company's creation and the time when it began to defend its trademark, and that
only OpenSSH was receiving threats of legal repercussions, weighed against the trademark's validity.
Both developers of OpenSSH and Ylnen himself were members of the IETF working group developing the new
standard; after several meetings this group denied Ylnen's request to rename the protocol, citing concerns that it
would set a bad precedent for other trademark claims against the IETF. The participants argued that both "Secure
Shell" and "SSH" were generic terms and could not be trademarks.
Microsoft Windows support
Although there is no native Windows port of OpenSSH, there are several ways to access OpenSSH servers from
Windows computers:
The Cygwin system that includes a port of OpenSSH
The PuTTY SSH client
The SmarTTY SSH client
[2]
References
[1] http:/ / www. openssh.com/
[2] http:/ / smartty. sysprogs. com/
Further reading
The 101 Uses of OpenSSH: Part 1 (http:/ / www. linuxjournal. com/ article/ 4412)
The 101 Uses of OpenSSH: Part 2 (http:/ / www. linuxjournal. com/ article/ 4413)
OpenBSD OpenSSH man page (http:/ / www. openbsd. org/ cgi-bin/ man. cgi?query=ssh)
ssh(1) (http:/ / linux. die. net/ man/ 1/ ssh)Linux User Commands Manual
sshd(8) (http:/ / linux. die. net/ man/ 8/ sshd)Linux Administration and Privileged Commands Manual
External links
Official website (http:/ / www. openssh. com/ )
OpenSSH (http:/ / freecode. com/ projects/ openssh/ ) at Freecode
Traceroute
238
Traceroute
In computing, traceroute is a computer network diagnostic tool for displaying the route (path) and measuring
transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the
round-trip times of the packets received from each successive host (remote node) in the route (path); the sum of the
mean times in each hop indicates the total time spent to establish the connection. Traceroute proceeds unless all
(three) sent packets are lost more than twice, then the connection is lost and the route cannot be evaluated. Ping, on
the other hand, only computes the final round-trip times from the destination point.
traceroute outputs the list of traversed routers in simple text format, together with timing
information
The traceroute command is
available on a number of modern
operating systems. On Apple Mac OS,
it is available by opening 'Network
Utilities' then selecting 'Traceroute'
tab, as well as by typing the
"traceroute" command in the terminal.
On other Unix systems, such as
FreeBSD or Linux, it is available as a
traceroute(8)
[1]
command in a terminal. On Microsoft Windows, it is named tracert. Windows NT-based
operating systems also provide PathPing, with similar functionality. For Internet Protocol Version 6 (IPv6) the tool
sometimes has the name traceroute6 or tracert6.
Traceroute on Snow Leopard Mac
Implementation
Traceroute, by default, sends a sequence of User Datagram Protocol
(UDP) packets addressed to a destination host; ICMP Echo Request or
TCP SYN packets can also be used. The time-to-live (TTL) value, also
known as hop limit, is used in determining the intermediate routers
being traversed towards the destination. Routers decrement packets'
TTL value by 1 when routing and discard packets whose TTL value
has reached zero, returning the ICMP error message ICMP Time
Exceeded. Common default values for TTL are 128 (Windows OS) and
64 (Unix-based OS).
Traceroute works by sending packets with gradually increasing TTL value, starting with TTL value of 1. The first
router receives the packet, decrements the TTL value and drops the packet because it then has TTL value zero. The
router sends an ICMP Time Exceeded message back to the source. The next set of packets are given a TTL value of
2, so the first router forwards the packets, but the second router drops them and replies with ICMP Time Exceeded.
Proceeding in this way, traceroute uses the returned ICMP Time Exceeded messages to build a list of routers that
packets traverse, until the destination is reached and returns an ICMP Echo Reply message.
The timestamp values returned for each router along the path are the delay (latency) values, typically measured in
milliseconds for each packet.
Hop 192.168.1.2 Depth 1
Probe status: unsuccessful
Parent: ()
Return code: Label-switched at stack-depth 1
Sender timestamp: 2008-04-17 09:35:27 EDT 400.88 msec
Traceroute
239
Receiver timestamp: 2008-04-17 09:35:27 EDT 427.87 msec
Response time: 26.92 msec
MTU: Unknown
Multipath type: IP
Address Range 1: 127.0.0.64 ~ 127.0.0.127
Label Stack:
Label 1 Value 299792 Protocol RSVP-TE
The sender expects a reply within a specified number of seconds. If a packet is not acknowledged within the
expected interval, an asterisk is displayed. The Internet Protocol does not require packets to take the same route
towards a particular destination, thus hosts listed might be hosts that other packets have traversed. If the host at hop
#N does not reply, the hop is skipped in the output.
On Unix-like operating systems, the traceroute utility uses User Datagram Protocol (UDP) datagrams by default,
with destination port numbers ranging from 33434 to 33534. The traceroute utility usually has an option to instead
use ICMP Echo Request (type 8) packets, like the Windows tracert utility does, or to use TCP SYN packets. If a
network has a firewall and operates both Windows and Unix-like systems, more than one protocol must be enabled
inbound through the firewall for traceroute to work and receive replies.
Some traceroute implementations use TCP packets, such as tcptraceroute or layer four traceroute. PathPing is a
utility introduced with Windows NT that combines ping and traceroute functionality. MTR is an enhanced version of
ICMP traceroute available for Unix-like and Windows systems. The various implementations of traceroute all rely
on ICMP Time Exceeded (type 11) packets being sent to the source.
The implementations of traceroute shipped with Linux, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, and
MacOSX include an option to use ICMP Echo packets (-I), or any arbitrary protocol (-P) such as UDP, TCP or
ICMP.
Cisco's implementation of traceroute also uses a sequence of UDP datagrams, each with incrementing TTL values, to
an invalid port number at the remote host; by default, UDP port 33434 is used. Extended version of this command
(known as the extended traceroute command) can change the destination port number used by the UDP probe
messages.
Usage
Most implementations include at least options to specify the number of queries to send per hop, time to wait for a
response, the hop limit and port to use. Invoking traceroute with no specified options displays the list of
available options, while man traceroute presents more details, including the displayed error flags. Simple
example on Linux:
$ traceroute -w 3 -q 1 -m 16 example.com
In the example above, selected options are to wait for three seconds (instead of five), send out only one query to each
hop (instead of three), limit the maximum number of hops to 16 before giving up (instead of 30), with
example.com as the final host.
This can help identify incorrect routing table definitions or firewalls that may be blocking ICMP traffic, or high port
UDP in Unix ping, to a site. Note that a firewall may permit ICMP packets but not permit packets of other protocols.
Traceroute is also used by penetration testers to gather information about network infrastructure and IP ranges
around a given host.
It can also be used when downloading data, and if there are multiple mirrors available for the same piece of data, one
can trace each mirror to get a good idea of which mirror would be the fastest to use.
Traceroute
240
Origins
The traceroute manual page states that the original traceroute program was written by Van Jacobson in 1987 from a
suggestion by Steve Deering, with particularly cogent suggestions or fixes from C. Philip Wood, Tim Seaver and
Ken Adelman. Also, the inventor of the ping program, Mike Muuss, states on his website that traceroute was written
using kernel ICMP support that he had earlier coded to enable raw ICMP sockets when he first wrote the ping
program.
[2]
References
[1] http:/ / man.cx/ ?page=traceroute(8)
[2] The Story of the PING Program (http:/ / ftp.arl.army.mil/ ~mike/ ping. html)
External links
traceroute(8) (http:/ / man. cx/ ?page=traceroute(8)) Linux man page
Tracert (http:/ / technet. microsoft. com/ en-us/ library/ bb491018. aspx) Windows XP Command-line reference
RFC 1393: Traceroute using an IP Option Internet RFC
RFC 792: Internet Control Message Protocol (ICMP)
How traceroute works InetDaemon (http:/ / www. inetdaemon. com/ tutorials/ troubleshooting/ tools/
traceroute/ definition. shtml)
Implementations:
Traceroute for Linux (http:/ / traceroute. sourceforge. net/ )
Paris traceroute (http:/ / www. paris-traceroute. net/ )
Graphical TraceRoute for Windows (http:/ / www. loriotpro. com/ Products/ On-line_Documentation_V5/
LoriotProDoc_EN/ J10-Loriotpro_tools/ J10-U21_Trace_Route_EN. htm)
Online traceroute services:
Dazzlepod (https:/ / dazzlepod. com/ ip/ ): Multi-source visual traceroute on Google Map
traceroute.org (http:/ / www. traceroute. org): monthly updated list of online traceroutes
IPv4 traceroute sites (http:/ / www. bgp4. net/ tr), listed by ASN. (An IPv6 Traceroute page (http:/ / www. bgp4.
net/ wiki/ doku. php?id=tools:ipv6_traceroute) is also available.) (BGP4.net)
Misk.com Traceroute (https:/ / www. misk. com/ tools/ #traceroute), Supports IPv6
Online Traceroute with GeoIP mapping (http:/ / whatismyip. cc/ online-traceroute/ )
IPv6 Tools (http:/ / lg. consulintel. euro6ix. org/ index. php) (Euro6IX)
TRACEROUTE6.NET (http:/ / www. traceroute6. net/ ): Located in Japan, Asia. Online IPv6 and IPv4 Ping and
Traceroute tools
Traceroute from multiple locations (http:/ / www. host-tracker. com/ InstantCheck/ Create): Locations in
Netherlands, Hong Kong, USA, Croatia, UK, Ukraine, Malaysia, Russia, India, Turkey.
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and
incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
241
Searching
Find
In Unix-like and some other operating systems, find is a command-line utility that searches through one or more
directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action
on each matched file. The possible search criteria include a pattern to match against the file name or a time range to
match against the modification time or access time of the file. By default, find returns a list of all files below the
current working directory.
The related locate programs use a database of indexed files obtained through find (updated at regular
intervals, typically by cron job) to provide a faster method of searching the entire filesystem for files by name.
Find syntax
find [-H] [-L] [-P] path... [expression]
The three options control how the find command should treat symbolic links. The default behaviour is never to
follow symbolic links. This can be explicitly specified using the -P flag. The -L flag will cause the find command
to follow symbolic links. The -H flag will only follow symbolic links while processing the command line arguments.
These flags are not available with some older versions of find.
At least one path must precede the expression. find is capable of interpreting wildcards internally and commands
must be constructed carefully in order to control shell globbing.
Expression elements are whitespace-separated and evaluated from left to right. They can contain logical elements
such as AND (and or a) and OR (or or o) as well as more complex predicates.
The GNU find has a large number of additional features not specified by POSIX.
POSIX protection from infinite output
Real-world filesystems often contain looped structures created through the use of hard or soft links. The POSIX
standard requires that
The find utility shall detect infinite loops; that is, entering a previously visited directory that is an ancestor
of the last file encountered. When it detects an infinite loop, find shall write a diagnostic message to
standard error and shall either recover its position in the hierarchy or terminate.
Operators
Operators can be used to enhance the expressions of the find command. Operators are listed in order of decreasing
precedence:
( expr ) Force precedence.
! expr True if expr is false.
-not expr Same as ! expr.
expr1 expr2 And (implied); expr2 is not evaluated if expr1 is false.
expr1 -a expr2 Same as expr1 expr2.
expr1 -and expr2 Same as expr1 expr2.
expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true.
Find
242
expr1 -or expr2 Same as expr1 -o expr2.
expr1 , expr2 List; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the value of the
list is the value of expr2.
find . -name 'fileA_*' -or -name 'fileB_*'
This command searches files whose name has a prefix of "fileA_" or "fileB_" in the current directory.
find . -name 'foo.cpp' -not -path '.svn'
This command searches for files with the name "foo.cpp" in all subdirectories of the current directory (current
directory itself included) other than ".svn".
Type filter explanation
-type option used to specify search for only file, link or directory. Various type filters are supported by find, they are
activated using the
find -type c
configuration switch where c may be any of:
b block (buffered) special
c character (unbuffered special)
d directory
p named pipe (FIFO)
f regular file
l symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is
broken. If you want to search for symbolic links when -L is in effect, use -xtype.
s socket
D door (Solaris)
(Bold listed configuration switches are most commonly used)
Examples
From current directory
find . -name 'my*'
This searches in the current directory (represented by the dot character) and below it, for files and directories with
names starting with my. The quotes avoid the shell expansion without them the shell would replace my* with the
list of files whose names begin with my in the current directory. In newer versions of the program, the directory may
be omitted, and it will imply the current directory.
Find
243
Files only
find . -name 'my*' -type f
This limits the results of the above search to only regular files, therefore excluding directories, special files, pipes,
symbolic links, etc. my* is enclosed in single quotes (apostrophes) as otherwise the shell would replace it with the
list of files in the current directory starting with my......
Commands
The previous examples created listings of results because, by default, find executes the '-print' action. (Note that
early versions of the find command had no default action at all; therefore the resulting list of files would be
discarded, to the bewilderment of users.)
find . -name 'my*' -type f -ls
This prints extended file information.
Search all directories
find / -name myfile -type f -print
This searches every file on the computer for a file with the name myfile and prints it to the screen. It is generally not
a good idea to look for data files this way. This can take a considerable amount of time, so it is best to specify the
directory more precisely. Some operating systems may mount dynamic filesystems that are not congenial to find.
More complex filenames including characters special to the shell may need to be enclosed in single quotes.
Search all but one directory subtree
find / -path excluded_path -prune -o -type f -name myfile -print
This searches every folder on the computer except the subtree excluded_path (full path including the leading /), for a
file with the name myfile. It will not detect directories, devices, links, doors, or other "special" filetypes.
Specify a directory
find /home/weedly -name 'myfile' -type f -print
This searches for files named myfile in the /home/weedly directory, the home directory for userid weedly. You should
always specify the directory to the deepest level you can remember. The quotes are optional in this example because
"myfile" contains no characters special to the shell.
Search several directories
find local /tmp -name mydir -type d -print
This searches for directories named mydir in the local subdirectory of the current working directory and the /tmp
directory.
Ignore errors
If you're doing this as a user other than root, you might want to ignore permission denied (and any other) errors.
Since errors are printed to stderr, they can be suppressed by redirecting the output to /dev/null. The following
example shows how to do this in the bash shell:
find / -name 'myfile' -type f -print 2>/dev/null
Find
244
If you are a csh or tcsh user, you cannot redirect stderr without redirecting stdout as well. You can use sh to run the
find command to get around this:
sh -c find / -name 'myfile' -type f -print 2>/dev/null
An alternate method when using csh or tcsh is to pipe the output from stdout and stderr into a grep command. This
example shows how to suppress lines that contain permission denied errors.
find . -name 'myfile' |& grep -v 'Permission denied'
Find any one of differently named files
find . \( -name '*jsp' -o -name '*java' \) -type f -ls
The -ls option prints extended information, and the example finds any file whose name ends with either 'jsp' or
'java'. Note that the parentheses are required. Also note that the operator "or" can be abbreviated as "o". The "and"
operator is assumed where no operator is given. In many shells the parentheses must be escaped with a backslash,
"\(" and "\)", to prevent them from being interpreted as special shell characters. The -ls option and the -or
operator are not available on all versions of find.
Execute an action
find /var/ftp/mp3 -name '*.mp3' -type f -exec chmod 644 {} \;
This command changes the permissions of all files with a name ending in .mp3 in the directory /var/ftp/mp3. The
action is carried out by specifying the option -exec chmod 644 {} \; in the command. For every file whose
name ends in .mp3, the command chmod 644 {} is executed replacing {} with the name of the file. The
semicolon (backslashed to avoid the shell interpreting it as a command separator) indicates the end of the command.
Permission 644, usually shown as rw-r--r--, gives the file owner full permission to read and write the file, while
other users have read-only access. In some shells, the {} must be quoted. The trailing ";" is customarily quoted with
a leading "\", but could just as effectively be enclosed in single quotes.
Note that the command itself should *not* be quoted; otherwise you get error messages like
find: echo "mv ./3bfn rel071204": No such file or directory
which means that find is trying to run a file called 'echo "mv ./3bfn rel071204"' and failing.
If you will be executing over many results, it is more efficient to pipe the results to the xargs command instead. xargs
is a more modern implementation, and handles long lists in a more intelligent way. The print0 option can be used
with this.
The following command will ensure that filenames with whitespaces are passed to the executed COMMAND
without being split up by the shell. It looks complicated at first glance, but is widely used.
find . -print0 | xargs -0 COMMAND
The list of files generated by find (whilst it is being generated) is simultaneously piped to xargs, which then
executes COMMAND with the files as arguments. See xargs for more examples and options.
Find
245
Delete files and directories
Delete empty files and directories and print the names
find /foo -empty -delete -print
Delete empty files
find /foo -type f -empty -delete
Delete empty directories
find /foo -type d -empty -delete
Delete files and directories (if empty) named bad
find /foo -name bad -empty -delete
Warning: -delete should be used with other operators such as -empty or -name.
find /foo -delete # this deletes all in /foo
Search for a string
This command will search for a string in all files from the /tmp directory and below:
$ find /tmp -exec grep 'search string' '{}' /dev/null \; -print
The /dev/null argument is used to show the name of the file before the text that is found. Without it, only the
text found is printed. An equivalent mechanism is to use the "-H" or "--with-filename" option to grep:
$ find /tmp -exec grep -H 'search string' '{}' ';' -print
GNU grep can be used on its own to perform this task:
$ grep -r 'search string' /tmp
Example of search for "LOG" in jsmith's home directory
$ find ~jsmith -exec grep LOG '{}' /dev/null \; -print
/home/jsmith/scripts/errpt.sh:cp $LOG $FIXEDLOGNAME
/home/jsmith/scripts/errpt.sh:cat $LOG
/home/jsmith/scripts/title:USER=$LOGNAME
Example of search for the string "ERROR" in all XML files in the current directory and all sub-directories
$ find . -name "*.xml" -exec grep "ERROR" '{}' \; -print
The double quotes (" ") surrounding the search string and single quotes (' ') surrounding the braces are optional in
this example, but needed to allow spaces and some other special characters in the string. Note with more complex
text (notably in most popular shells descended from `sh` and `csh`) single quotes are often the easier choice, since
double quotes do not prevent all special interpretation. Quoting filenames which have English contractions
demonstrates how this can get rather complicated, since a string with an apostrophe in it is easier to protect with
double quotes. Example:
$ find . -name "file-containing-can't" -exec grep "can't" '{}' \;
-print
Find
246
Search for all files owned by a user
find . -user <userid>
Search in case insensitive mode
find . -iname 'MyFile*'
If the -iname switch is not supported on your system then workaround techniques may be possible such as:
find . -name '[mM][yY][fF][iI][lL][eE]*'
This uses Perl to build the above command for you:
echo "'MyFile*'" |perl -pe 's/([a-zA-Z])/[\L\1\U\1]/g;s/(.*)/find . -name \1/'|sh
Search files by size
Example of searching files with size between 100 kilobytes and 500 kilobytes.
find . -size +100k -a -size -500k
Example of searching empty files.
find . -size 0k
Example of searching non-empty files.
find . -not -size 0k
Search files by name and size
find /usr/src -not \( -name '*,v' -o -name '.*,v' \) '{}' \; -print
This command will search in the /usr/src directory and all sub directories. All files that are of the form '*,v' and '.*,v'
are excluded. Important arguments to note are in the tooltip that is displayed on mouse-over.
for file in `find /opt \( -name error_log -o -name 'access_log' -o
-name 'ssl_engine_log' -o -name 'rewrite_log' -o
-name 'catalina.out' \) -size +300000k -a -size -5000000k`; do
cat /dev/null > $file
done
The units should be one of [bckw], 'b' means 512-byte blocks, 'c' means byte, 'k' means kilobytes and 'w' means
2-byte words. The size does not count indirect blocks, but it does count blocks in sparse files that are not actually
allocated.
Find
247
Related utilities
locate is a Unix search tool that searches through a prebuilt database of files instead of directory trees of a file
system. This is faster than find but less accurate because the database may not be up-to-date.
grep is a command-line utility for searching plain-text data sets for lines matching a regular expression and by
default reporting matching lines on standard output.
tree is a command-line utility that recursively lists files found in a directory tree, indenting the file names
according to their position in the file hierarchy.
GNU Find Utilities (also known as findutils) is a GNU package which contains implementations of the tools
find and xargs.
BusyBox is a utility that provides several stripped-down Unix tools in a single executable file, intended for
embedded operating systems with very limited resources. It also provides a version of find.
External links
find
[1]
:find filesCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open
Group
find(1)
[2]
:search for files in a directory hierarchyLinux User Commands Manual
Official webpage for GNU find
[3]
References
[1] http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ find. html
[2] http:/ / linux.die. net/ man/ 1/ find
[3] http:/ / www. gnu. org/ software/ findutils/ manual/ html_mono/ find. html
Grep
Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was
originally developed for the Unix operating system, but is available today for all Unix-like systems. Its name comes
from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a
global search with the regular expression and printing all matching lines.
[1]
History
Grep was created by Ken Thompson as a standalone application adapted from the regular expression parser he had
written for ed (which he also created). In ed, the command g/re/p would print all lines matching a previously defined
pattern.
[2][3]
Grep first appeared in the man page for Unix Version 4.
[4]
Grep
248
Usage
Grep searches files specified as arguments, or, if missing, the program's standard input. By default, it reports
matching lines on standard output, but specific modes of operation may be chosen with command line options.
A simple example of a common usage of grep is the following, which searches the file fruitlist.txt for lines
containing the text string apple:
$ grep apple fruitlist.txt
Matches occur when the specific sequence of characters is recognized, for example, lines containing pineapple or
apples are printed irrespective of word boundaries. However, the search pattern specified as an argument is case
sensitive by default, so this example's output does not include lines containing Apple (with a capital A) unless they
also contain apple. Case-insensitive matching occurs when the argument option -i (ignore case) is given.
Multiple file names may be specified in the argument list. For example, all files having the extension .txt in a given
directory may be searched if the shell supports globbing by using an asterisk as part of the filename:
$ grep apple *.txt
Regular expressions can be used to match more complicated text patterns. The following prints all lines in the file
that begin with the letter a, followed by any one character, followed by the letter sequence ple.
$ grep ^a.ple fruitlist.txt
The name of grep derives from a usage in the Unix text editor ed and related programs. Before grep existed as a
separate command, the same effect might have been achieved in an editor:
$ ed fruitlist.txt
g/^a.ple/p
q
where the second line is the command given to ed to print the relevant lines, and the third line is the command to exit
from the editor.
Like most Unix commands, grep accepts options in the form of command-line arguments to change its behavior. For
example, the option flag l (lower case L) provides a list of the files which have matching lines, rather than listing the
lines explicitly.
Selecting all lines containing the self-standing word apple, i.e. surrounded by white space or hyphens, may be
accomplished with the option flag w.
Exact line match is performed with the option flag x. Lines only containing exactly and solely apple are selected
with a line-regexp instead of word-regexp:
$ cat fruitlist.txt
apple
apples
pineapple
apple-
apple-fruit
fruit-apple
$ grep -x apple fruitlist.txt
apple
The v option reverses the sense of the match and prints all lines that do not contain apple, as in this example.
Grep
249
$ grep -v apple fruitlist.txt
banana
pear
peach
orange
Variations
A variety of grep implementations are available in many operating systems and software development environments.
Early variants included egrep and fgrep, introduced in Version 7 Unix. The "egrep" variant applies an extended
regular expression syntax that was added to Unix after Ken Thompson's original regular expression implementation.
The "fgrep" variant searches for any of a list of fixed strings using the AhoCorasick string matching algorithm.
These variants persist in most modern grep implementations as command-line switches (and standardized as -E and
-F in POSIX
[5]
). In such combined implementations, grep may also behave differently depending on the name by
which it is invoked, allowing fgrep, egrep, and grep to be links to the same program file.
Other commands contain the word "grep" to indicate that they search (usually for regular expression matches). The
pgrep utility, for instance, displays the processes whose names match a given regular expression.
In the Perl programming language, grep is the name of the built-in function that finds elements in a list that satisfy a
certain property. This higher-order function is typically named filter in functional programming languages.
The pcregrep command is an implementation of grep that uses Perl regular expression syntax. This functionality can
be invoked in the GNU version of grep with the -P flag.
[6]
Ports of grep (within Cygwin and GnuWin32, for example) also run under Microsoft Windows. Some versions of
Windows feature the similar qgrep or Findstr command.
Usage as a verb
In December 2003, the Oxford English Dictionary Online added draft entries for "grep" as both a noun and a verb.
A common verb usage is the phrase "You can't grep dead trees"meaning one can more easily search through
digital media, using tools such as grep, than one could with a hard copy (i.e., one made from dead trees, paper).
[7]
Compare with google.
Notes
[1] [1] Hauben et al. 1997, Ch. 9
[2] http:/ / perl. plover.com/ classes/ HoldSpace/ samples/ slide012. html
[3] http:/ / robots.thoughtbot.com/ how-grep-got-its-name
[4] http:/ / minnie.tuhs.org/ cgi-bin/ utree. pl?file=V4/ man/ man1/ grep. 1
[5] grep (http:/ / www. opengroup.org/ onlinepubs/ 009695399/ utilities/ grep. html) Commands & Utilities Reference, The Single UNIX
Specification, Issue 7 from The Open Group
[6] http:/ / linux.die. net/ man/ 1/ grep
[7] Jargon File, article "Documentation"
Grep
250
References
Alain Magloire (August 2000). Grep: Searching for a Pattern. Iuniverse Inc. ISBN0-595-10039-2.
Hume, Andrew A tale of two greps (http:/ / onlinelibrary. wiley. com/ doi/ 10. 1002/ spe. 4380181105/ abstract),
SoftwarePractice and Experience 18, ( 11 ), 10631072 ( 1988).
Hume, Andrew Grep wars: The strategic search initiative. In Peter Collinson, editor, Proceedings of the EUUG
Spring 88 Conference, pages 237245, Buntingford, UK, 1988. European UNIX User Group.
Michael Hauben et al. (April 1997). Netizens: On the History and Impact of Usenet and the Internet
(Perspectives). Wiley-IEEE Computer Society Press. ISBN978-0-8186-7706-9.
External links
GNU grep (german) (https:/ / www. grepmaster. eu)
grep (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ grep. html):search a file for a
patternCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
Network grep (http:/ / ngrep. sourceforge. net) - A packet analyzer used to match patterns at the network layer
"why GNU grep is fast" (http:/ / lists. freebsd. org/ pipermail/ freebsd-current/ 2010-August/ 019310. html) -
implementation details from GNU grep's author.
locate
locate, a Unix utility first created in 1983,
[1]
serves to find files on filesystems. It searches through a prebuilt
database of files generated by updatedb or by a daemon and compressed using incremental encoding. It operates
significantly faster than find, but requires regular updating of the database. This sacrifices overall efficiency
(because of the regular interrogation of filesystems even when no user needs information) and absolute accuracy
(since the database does not update in real time) for significant speed improvements (particularly on very large
filesystems).
The GNU version forms a part of GNU Findutils.
Some versions can also index network filesystems.
References
[1] Ref: Usenix ;login:, Vol 8, No 1, February/March, 1983, p. 8.
External links
locate(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=locate& sektion=1)FreeBSD General
Commands Manual
GNU Findutils (http:/ / www. gnu. org/ software/ findutils/ findutils. html)
Variants:
slocate (Secure Locate) (https:/ / web. archive. org/ web/ 20090204031919/ http:/ / slocate. trakker. ca/ ) at the
Wayback Machine (archived February 4, 2009)
locate(1) (http:/ / www. linuxmanpages. com/ man1/ locate. 1. php):slocateLinux General Commands
Manual on linuxmanpages.com (http:/ / www. linuxmanpages. com/ )
mlocate (http:/ / carolina. mff. cuni. cz/ ~trmac/ blog/ mlocate/ ) - faster updates
locate(1) (http:/ / linux. die. net/ man/ 1/ locate):mlocateLinux User Commands Manual
rlocate (http:/ / rlocate. sourceforge. net/ ) - always up-to-date
locate
251
KwickFind (http:/ / www. kde-apps. org/ content/ show. php/ KwickFind+ (Locate+ GUI+
Frontend)?content=54817) - KDE GUI frontend for locate
Locate32 for Windows (http:/ / www. locate32. net/ ) Windows analog of GNU locate with GUI, released under
GNU license
Whatis
whatis searches a set of database files containing short descriptions of system commands for keywords and displays
the result on the standard output. Only complete word matches are displayed. The whatis command is commonly
found on Unix-like operating systems. The whatis database is created using the command makewhatis. Closely
related commands include apropos and man.
Sample output:
$ whatis whatis
whatis(1) - search the whatis database for complete words
Whereis
whereis is a Unix command used to locate some special files of a Unix command like the binary, source and manual
page files. Unix which is usually preferred to locate a binary file, because it is POSIX and it can identify shell
aliases.
Here is an example usage from the man page:
# Find all files in /usr/bin which are not documented in /usr/man/man1
with source in /usr/src:
% cd /usr/bin
% whereis -u -M /usr/man/man1 -S /usr/src -f *
References
External links
man page of whereis command (http:/ / www. linuxmanpages. com/ man1/ whereis. 1. php)
which
252
which
which is a Unix command used to identify the location of executables.
The command takes one or more arguments; for each of these arguments, it prints the full path of the executable to
stdout that would have been executed if this argument had been entered into the shell. It does this by searching for an
executable or script in the directories listed in the environment variable PATH.
[1]
The which command is part of
most Unix-like computers. It is also part of the C Shell, and is available as a separate package for Microsoft
Windows
[2]
or use the similar where.exe.
The functionality of the which command is similar to some implementations of the type command. POSIX specifies
a command named command that also covers this functionality.
References
[1] which man page (http:/ / unixhelp.ed. ac.uk/ CGI/ man-cgi?which)
[2] which for Windows (http:/ / gnuwin32.sourceforge. net/ packages/ which. htm) from the GnuWin32 project
External links
GNU Which official page (http:/ / savannah. gnu. org/ projects/ which)
253
Documentation
apropos
In computing, apropos is a command to search the man page files in Unix and Unix-like operating systems.
Behavior
Often a wrapper for the "man -k" command, the apropos command is used to search all manual pages for the string
specified. This is often useful if one knows the action that is desired, but does not remember the exact command
Sample usage
The following example demonstrates the output of the apropos command:
$ apropos mount
free (1) - Display amount of free and used memory in the system
mklost+found (8) - create a lost+found directory on a mounted Linux second extended file system
mount (8) - mount a file system
mountpoint (1) - see if a directory is a mountpoint
ntfsmount (8) - Read/Write userspace NTFS driver.
sleep (1) - delay for a specified amount of time
switch_root (8) - switch to another filesystem as the root of the mount tree.
umount (8) - unmount file systems
$
In this example, apropos is used to search for the string "mount", and apropos returns the indicated man pages
that include the term "mount".
External links
apropos(1)
[1]
Linux User Commands Manual
Apropos
[2]
at the LinuxQuestions.org wiki
References
[1] http:/ / linux.die. net/ man/ 1/ apropos
[2] http:/ / wiki. linuxquestions. org/ wiki/ apropos
help
254
help
In computing, help is a command in various command line shells such as COMMAND.COM, cmd.exe, Bash,
4DOS/4NT, Windows PowerShell, Singularity shell, Python and GNU Octave. It provides online information about
available commands and the shell environment. It is analogous to the Unix man command.
Syntax
help [command]
Arguments:
command This command-line argument specifies the name of the command about which information is to be
displayed.
Implementations
DOS
The help command is available in MS-DOS 5.x and later. If no arguments are provided, the command lists the
contents of DOSHELP.HLP. In MS-DOS 6.x this command exists as FASTHELP. In DR-DOS, HELP is a batch file
that launches DR-DOS' internal help program, DOSBOOK.
The MS-DOS 6.xx help command uses QBasic to view a quickhelp HELP.HLP file, which contains more
extensive information on the commands, with some hyperlinking etc. The MS-DOS 6.22 help system is included
on Windows 9x CD-ROM versions as well.
PC DOS 7.xx help uses view.exe to open OS/2 style INF files (cmdref.inf, dosrexx.inf and
doserror.inf), opening these to the appropriate pages.
4DOS/4NT
The 4DOS/4NT help command uses a text user interface to display the online help.
cmd.exe
Used without parameters, help lists and briefly describes every system command. Windows NT-based versions use
MS-DOS 5 style help. Versions before Windows Vista also have a Windows help file (NTCMDS.HLP or
NTCMDS.INF) in a similar style to MS-DOS 6.
Windows PowerShell
In Windows PowerShell, help is a short form (implemented as a PowerShell function) for access to the Get-Help
Cmdlet.
Windows PowerShell includes an extensive, console-based help system, reminiscent of man pages in Unix. The help
topics include help for cmdlets, providers, and concepts in PowerShell.
help
255
GNU Bash
In Bash, the builtin command help lists all Bash builtin commands if used without arguments. Otherwise, it prints a
brief summary of a command. Its syntax is:
help [-dms] [pattern]
Examples
DOS
Z:\>help
If you want a list of all supported commands type help /all .
A short list of the most often used commands:
<DIR > Directory View.
<CD > Display/changes the current directory.
<CLS > Clear screen.
<COPY > Copy files.
...
Python
>>> help
Type help() for interactive help, or help(object) for help about object.
>>> help()
Welcome to Python 2.5! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://www.python.org/doc/tut/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
...
GNU Octave
octave-3.0.0.exe:1> help
Help is available for the topics listed below.
Additional help for built-in functions and operators is
available in the on-line version of the manual. Use the command
`doc <topic>' to search the manual index.
...
help
256
References
Microsoft TechNet Help article
[1]
[1] http:/ / technet. microsoft. com/ en-us/ library/ bb490917. aspx
info
Info
Latest stable 4.11
Operating system GNU
Type Documentation Viewer
License GNU General Public License
Website [1]
info is a software utility which forms a hypertextual, multipage documentation and help viewer working on a
command line interface, useful when there is no GUI available.
info processes info files, which are files in a special format
[citation needed]
, (often generated from a Texinfo source),
and presents the documentation as a tree, with simple commands to traverse the tree and to follow cross references.
For instance
n goes to the next page.
p goes to the previous page.
u goes to the upper page.
l goes to the last visited node
Moving the cursor over a link (a word preceded by a * ) and pressing the enter key follows a cross reference.
The C implementation of info was designed as the main documentation system of GNU based Operating Systems
and was then ported to other Unix-like operating systems. However, info files had already been in use on ITS emacs.
List of Info readers
info
pinfo
tkman
tkinfo
khelpcenter (click "Browse Info Pages")
emacs
References
[1] http:/ / www. gnu. org/ software/ texinfo/
man
257
man
The man page on man
A man page (short for manual page) is a form of online software
documentation usually found on a Unix or Unix-like operating system.
Topics covered include computer programs (including library and
system calls), formal standards and conventions, and even abstract
concepts. A user may invoke a man page by issuing the man
command.
Usage
To read a manual page for a Unix command, one can use
man <command_name>
at a shell prompt: for example, "man ftp". In order to simplify navigation through the output, man generally uses
the less terminal pager.
Pages are traditionally referred to using the notation "name(section)": for example, ftp(1)
[1]
. The same page
name may appear in more than one section of the manual, such as when the names of system calls, user commands,
or macro packages coincide. Examples are man(1)
[2]
and man(7)
[3]
, or exit(2)
[4]
and exit(3)
[5]
.
The syntax for accessing the non-default manual section varies between different man implementations. On Solaris,
for example, the syntax for reading printf(3)
[6]
is:
man -s 3c printf
On Linux and BSD derivatives the same invocation would be:
man 3 printf
which searches for printf in section 3 of the man pages.
History
xman, an early X11 application for viewing
manual pages
The UNIX Programmer's Manual
[7]
was first published on November
3, 1971. The first actual man pages were written by Dennis Ritchie and
Ken Thompson at the insistence of their manager Doug McIlroy in
1971. Aside from the man pages, the Programmer's Manual also
accumulated a set of short papers, some of them tutorials (e.g. for
general Unix usage, the C programming language, and tools such as
Yacc), and others more detailed descriptions of operating system
features. The printed version of the manual initially fit into a single
binder, but as of PWB/UNIX and the 7th Edition of Research Unix, it
was split into two volumes with the printed man pages forming
Volume 1.
[8]
The man pages were formatted using the troff typesetting package and
its set of -man macros (which were completely revised between the
Sixth and Seventh Editions of the Manual, but have since not
man
258
OpenBSD section 8 intro manpage, displaying in
a text console
drastically changed). At the time, the availability of online
documentation through the manual page system was regarded as a
great advance. To this day, virtually every Unix command line
application comes with a man page, and many Unix users perceive a
program's lack of man pages as a sign of low quality; indeed, some
projects, such as Debian, go out of their way to write man pages for
programs lacking one. The modern descendants of 4.4BSD also
distribute man pages as one of the primary forms of system
documentation (having replaced the old -man macros with the newer
-mdoc).
Few alternatives to man have enjoyed much popularity, with the possible exception of GNU Project's "info"
system, an early and simple hypertext system. In addition, some Unix GUI applications (particularly those built
using the GNOME and KDE development environments) now provide end-user documentation in HTML and
include embedded HTML viewers such as yelp for reading the help within the application.
Man pages are usually written in English, but translations into other languages may be available on the system.
The default format of the man pages is troff, with either the macro package man (appearance oriented) or mdoc
(semantic oriented). This makes it possible to typeset a man page into PostScript, PDF, and various other formats for
viewing or printing.
Most Unix systems have a package for the man2html command, which enables users to browse their man pages
using an html browser (textproc/man2html on FreeBSD or man on some Linux distribution).
In 2010, OpenBSD deprecated troff for formatting manpages in favour of mandoc, a specialised compiler/formatter
for manpages with native support for output in PostScript, HTML, XHTML, and the terminal.
Manual sections
The manual is generally split into eight numbered sections, organized as follows (on Research Unix, BSD, OS X and
Linux):
Section Description
1 General commands
2 System calls
3 Library functions, covering in particular the C standard library
4 Special files (usually devices, those found in /dev) and drivers
5 File formats and conventions
6 Games and screensavers
7 Miscellanea
8 System administration commands and daemons
Unix System V uses a similar numbering scheme, except in a different order:
man
259
Section Description
1 General commands
1M System administration commands and daemons
2 System calls
3 C library functions
4 File formats and conventions
5 Miscellanea
6 Games and screensavers
7 Special files (usually devices, those found in /dev) and drivers
On some systems some of the following sections are available:
Section Description
0 C library header files
9 Kernel routines
n Tcl/Tk keywords
x The X Window System
Some sections are further subdivided by means of a suffix; for example, in some systems, section 3C is for C library
calls, 3M is for the math library, and so on. A consequence of this is that section 8 (system administration
commands) is sometimes relegated to the 1M subsection of the main commands section. Some subsection suffixes
have a general meaning across sections:
Subsection Description
p POSIX specifications
x X Window System documentation
Some versions of man cache the formatted versions of the last several pages viewed.
Layout
All man pages follow a common layout that is optimized for presentation on a simple ASCII text display, possibly
without any form of highlighting or font control. Sections present may include:
NAME
The name of the command or function, followed by a one-line description of what it does.
SYNOPSIS
In the case of a command, a formal description of how to run it and what command line options it takes. For
program functions, a list of the parameters the function takes and which header file contains its definition.
DESCRIPTION
A textual description of the functioning of the command or function.
EXAMPLES
Some examples of common usage.
SEE ALSO
A list of related commands or functions.
man
260
Other sections may be present, but these are not well standardized across man pages. Common examples include:
OPTIONS, EXIT STATUS, ENVIRONMENT, BUGS, FILES, AUTHOR, REPORTING BUGS, HISTORY and
COPYRIGHT.
External links
Deep Recursive Man Page Search Engine
[9]
: Unique recursive search engine for many unix and linux man page
sets.
Unix Programmer's Manual of November 3, 1971
[7]
(see also the original scans in PS and PDF format
[10]
).
History of UNIX Manpages
[11]
for a primary-source history of UNIX manpages.
Online man pages
[12]
from Polarhome's more than 30 running Operating Systems including AIX, HP-UX, IRIX,
different Linux and BSD distributions, Darwin (operating system), UnixWare, OpenServer etc.
Online man pages
[13]
for many versions of Unix, Linux, Macintosh Darwin and similar operating systems.
mdoc.su
[14]
short manual page URLs for FreeBSD, NetBSD, OpenBSD and DragonFly BSD
man
[15]
: One open-source implementation of man; used on Red Hat Enterprise Linux, Fedora (until 13), Gentoo,
Slackware, Mac OS-X and others.
man-db
[16]
: Alternative implementation of man; used in Fedora (since 14), Debian/Ubuntu, SUSE and others.
Practical UNIX Manuals: mdoc
[17]
: Guide to writing mdoc UNIX manual pages.
man(1)
[2]
:format and display the on-line manual pagesLinux User Commands Manual
ManDrake
[18]
: open-source man page editor for Mac OS X
References
[1] http:/ / linux.die. net/ man/ 1/ ftp
[2] http:/ / linux.die. net/ man/ 1/ man
[3] http:/ / linux.die. net/ man/ 7/ man
[4] http:/ / linux.die. net/ man/ 2/ exit
[5] http:/ / linux.die. net/ man/ 3/ exit
[6] http:/ / linux.die. net/ man/ 3/ printf
[7] http:/ / man.cat-v. org/ unix-1st/
[8] . Originally published in Microsystems 5(11), November 1984.
[9] http:/ / www. unix. com/ man-page/ opensolaris/ 1/ man/
[10] http:/ / cm. bell-labs.com/ cm/ cs/ who/ dmr/ 1stEdman.html
[11] http:/ / manpages.bsd.lv/ history. html
[12] http:/ / www.polarhome. com/ service/ man/
[13] http:/ / www.freebsd. org/ cgi/ man. cgi
[14] http:/ / mdoc.su/
[15] http:/ / primates. ximian. com/ ~flucifredi/ man/
[16] http:/ / man-db.nongnu. org/
[17] http:/ / manpages.bsd.lv
[18] http:/ / sveinbjorn.org/ mandrake
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and
incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
261
Miscellaneous
bc
bc, for basic calculator, is "an arbitrary precision calculator language" with syntax similar to the C programming
language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.
bc is often referred to as bench calculator.
A typical interactive usage is typing the command bc on a Unix command prompt and entering a mathematical
expression, such as (1 + 3) * 2, whereupon 8 will be output. While bc can work with arbitrary precision, it actually
defaults to zero digits after the decimal point - so the expression 2/3 yields 0. This can surprise new bc users unaware
of this fact. The "-l" option to bc sets the default scale (digits after the decimal point) to 20, and adds several
additional mathematical functions to the language.
bc first appeared in Version 6 Unix in 1975, and was written by Robert Morris and Lorinda Cherry of Bell Labs. Bc
was preceded by dc, an earlier arbitrary precision calculator written by the same authors. Dc could do
arbitrary-precision calculations, but its reverse polish notation syntax was inconvenient for users, and therefore Bc
was written as a front-end to Dc. Bc was a very simple compiler (a single yacc source file with a few hundred lines)
which converted the new, C-like, bc syntax into dc's reverse polish notation, and piped the results through dc.
In 1991, POSIX rigorously defined and standardized bc. Two implementations of this standard survive today: The
first is the traditional Unix implementation, a front-end to dc, which survives in Unix and Plan 9 systems. The
second is the free software GNU bc, first released in 1991 by Philip A. Nelson. The GNU implementation has
numerous extensions beyond the POSIX standard, and is no longer a front-end to dc (it is a bytecode interpreter).
POSIX bc
The POSIX standardized bc language is traditionally written as a program in the dc programming language to
provide a higher level of access to the features of the dc language without the complexities of dc's terse syntax.
In this form, the bc language contains single letter variable, array and function names and most standard arithmetic
operators as well as the familiar control flow constructs, (if(cond)..., while(cond)... and
for(init;cond;inc)...) from C. Unlike C, an if clause may not be followed by an else.
Functions are defined using a define keyword and values are returned from them using a return followed by
the return value in parentheses. The auto keyword (optional in C) is used to declare a variable as local to a
function.
All numbers and variable contents are arbitrary precision numbers whose precision (in decimal places) is determined
by the global scale variable.
The numeric base of input (in interactive mode), output and program constants may be specified by setting the
reserved ibase (input base) and obase (output base) variables.
Output is generated by deliberately not assigning the result of a calculation to a variable.
Comments may be added to bc code by use of the C /* and */ (start and end comment) symbols.
bc
262
Mathematical operators
Exactly as C
The following POSIX bc operators behave exactly like their C counterparts:
+ - * /
+= -= *= /=
++ -- < >
== != <= >=
( ) [ ] { }
Similar to C
The modulus operators:
% %=
... behave exactly like their C counterparts only when the global scale variable is set to 0, i.e. all calculations are
integer-only. Otherwise the computation is done with the appropriate scale. a%b is defined as a-(a/b)*b .
Examples:
$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale=0; 5%3
2
scale=1; 5%3
.2
scale=20; 5%3
.00000000000000000002
Only resembling C
The operators:
^ ^=
... resemble the C bitwise exclusive-or operators, but are in fact the bc integer exponentiation operators.
'Missing' operators relative to C
The bitwise, boolean and conditional operators:
& | ^ && ||
&= |= ^= &&= ||=
<< >>
<<= >>=
?:
... are not available in POSIX bc.
bc
263
Built-in functions
The sqrt() function for calculating square roots is POSIX bc's only built-in mathematical function. Other
functions are available in an external standard library.
The scale() function for determining the precision (as with the scale variable) of its argument and the
length() function for determining the number of significant decimal digits in its argument are also built-in.
Standard library functions
bc's standard math library (defined with the -l option) contains functions for calculating sine, cosine, arctangent,
natural logarithm, the exponential function and the two parameter Bessel function J. Most standard mathematical
functions (including the other inverse trigonometric functions) can be constructed using these. See external links for
implementations of many other functions.
The -l option changes the scale to 20 (source)
[1]
, so things such as modulo may work unexpectedly. For example,
write "bc -l" and then the command "print 3%2" outputs 0, instead of 1. But if you do it like "bc -l", "scale=0" and
then the command "print 3%2" has 1 as output.
Plan 9 bc
Plan 9 bc is just like POSIX bc but for an additional print statement.
GNU bc
GNU bc derives from the POSIX standard and includes many enhancements. It is entirely separate from dc-based
implementations of the POSIX standard and is instead written in C. Nevertheless, it is fully backwards compatible as
all POSIX bc programs will run unmodified as GNU bc programs.
GNU bc variables, arrays and function names may contain more than one character, some more operators have been
included from C, and notably, an if clause may be followed by an else.
Output is achieved either by deliberately not assigning a result of a calculation to a variable (the POSIX way) or by
using the added print statement.
Furthermore, a read statement allows the interactive input of a number into a running calculation.
In addition to C-style comments, a # character will cause everything after it until the next new-line to be ignored.
The value of the last calculation is always stored within the additional built-in last variable.
Extra operators
The following logical operators are additional to those in POSIX bc:
&& || !
... and are available for use in conditional statements (such as within an if statement). Note, however, that there are
still no equivalent bitwise or assignment operations.
Functions
All functions available in GNU bc are inherited from POSIX. No further functions are provided as standard with the
GNU distribution.
bc
264
Example code
Since the bc ^ operator only allows an integer power to its right, one of the first functions a bc user might write is a
power function with a floating point exponent. Both of the below assume the standard library has been included:
A 'Power' function in POSIX bc
/* A function to return the integer part of x */
define i(x) {
auto s
s = scale
scale = 0
x /= 1 /* round x down */
scale = s
return (x)
}
/* Use the fact that x^y == e^(y*log(x)) */
define p(x,y) {
if (y == i(y)) {
return (x ^ y)
}
return ( e( y * l(x) ) )
}
An equivalent 'Power' function in GNU bc
# A function to return the integer part of a number
define int(number) {
auto oldscale
oldscale = scale
scale = 0
number /= 1 /* round number down */
scale = oldscale
return number
}

# Use the fact that number^exponent == e^(exponent*log(number))
define power(number,exponent) {
if (exponent == int(exponent)) {
return number ^ int(exponent)
} else {
return e( exponent * l(number) )
}
}
bc
265
Calculating Pi to 10000 places
Calculate Pi using the builtin arctangent function, a().
# The atan of 1 is 45 degrees, which is pi/4 in radians.
$ bc -l
scale=10000
4*a(1)
# This may take several minutes to calculate.
A translated C function
Because the syntax of bc is similar to that of C, published numerical functions written in C can often be translated
into BC quite easily, which immediately provides the arbitrary precision of BC. For example, in the Journal of
Statistical Software (July 2004, Volume 11, Issue 5), George Marsaglia published the following C code for the
cumulative normal distribution:
double Phi(double x)
{
long double s=x,t=0,b=x,q=x*x,i=1;
while(s!=t)
s=(t=s)+(b*=q/(i+=2));
return .5+s*exp(-.5*q-.91893853320467274178L);
}
With some necessary changes to accommodate bc's different syntax, and realizing that the constant "0.9189..." is
actually log(2*PI)/2, this can be translated to the following GNU bc code:
define phi(x) {
auto s,t,b,q,i,const
s=x; t=0; b=x; q=x*x; i=1
while(s!=t)
s=(t=s)+(b*=q/(i+=2))
const=0.5*l(8*a(1)) # 0.91893...
return .5+s*e(-.5*q-const)
}
Using bc in shell scripts
bc can be used non-interactively, with input via a pipe. This is useful inside shell scripts. For example:
$ result=$(echo "scale=2; 5 * 7 /3;" | bc)
$ echo $result
11.66
In contrast, note that the bash shell only performs integer arithmetic, e.g.:
$ result=$((5 * 7 /3))
$ echo $result
11
One can also use the here-string idiom (in bash, ksh, csh):
bc
266
$ bc -l <<< "5*7/3"
11.66666666666666666666
References
[1] http:/ / www. gnu. org/ software/ bc/ manual/ html_mono/ bc. html#SEC18
bc (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ bc. html):arbitrary-precision arithmetic
languageCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
GNU bc manual page (http:/ / www. gnu. org/ software/ bc/ manual/ html_mono/ bc. html)
POSIX bc manual page (http:/ / manpages. ubuntu. com/ manpages/ jaunty/ en/ man1/ bc. 1posix. html)
Plan 9 bc manual page (http:/ / plan9. bell-labs. com/ magic/ man2html/ 1/ bc)
7th Edition Unix bc manual page (http:/ / plan9. bell-labs. com/ 7thEdMan/ vol2/ bc)
A comp.compilers article on the design and implementation of C-BC (http:/ / compilers. iecc. com/ comparch/
article/ 95-09-015)
6th Edition Unix bc source code (http:/ / minnie. tuhs. org/ cgi-bin/ utree. pl?file=V6/ usr/ source/ s1/ bc. y), the
first release of bc, from May 1975, compiling bc syntax into dc syntax
External links
Dittmer, I. 1993. Error in Unix commands dc and bc for multiple-precision-arithmetic. SIGNUM Newsl. 28, 2
(Apr. 1993), 811. (http:/ / doi. acm. org/ 10. 1145/ 152923. 152925)
Online version of GNU bc (http:/ / sciencesoft. at/ index. jsp?link=bc& lang=en)
Collection of useful GNU bc functions (http:/ / www. phodd. net/ cyrek/ gnu-bc/ )
GNU bc (http:/ / directory. fsf. org/ gnu/ bc. html) (and an alpha version (http:/ / alpha. gnu. org/ gnu/ bc/ )) from
the Free Software Foundation
Bc for Windows (http:/ / gnuwin32. sourceforge. net/ packages/ bc. htm) from GnuWin32
X-Bc (http:/ / x-bc. sourceforge. net/ ) - A Graphical User Interface to Bc
extensions.bc (http:/ / x-bc. sourceforge. net/ extensions_bc. html) - contains functions of trigonometry,
exponential functions, functions of number theory and some mathematical constants
scientific_constants.bc (http:/ / x-bc. sourceforge. net/ scientific_constants_bc. html) - contains particle masses,
basic constants, such as speed of light in the vacuum and the gravitational constant
BC Mobile (http:/ / www. donutsystemlsi. com/ appstore/ ibc/ ) - A Graphical User Interface to Bc for iPhone
dc
267
dc
dc is a cross-platform reverse-polish desk calculator which supports arbitrary-precision arithmetic. It is one of the
oldest Unix utilities, predating even the invention of the C programming language; like other utilities of that vintage,
it has a powerful set of features but an extremely terse syntax. Traditionally, the more user-friendly (with its infix
notation) bc calculator program was implemented on top of dc, although more modern implementations are related in
the opposite fashion: dc uses bc's library for arithmetic.
This article provides some examples in an attempt to give a general flavour of the language; for a complete list of
commands and syntax, one should consult the man page for one's specific implementation.
Basic operations
To multiply four and five in dc (note that most of the whitespace is optional):
4 5 *
p
Notes: Saved in a file, such as cal.txt, the command: dc cal.txt, calculates the result. Run "q" to exit from dc.
You can also get the result with the commands:
echo "4 5 * p" |dc
or
dc -
4 5*pq
This translates into "push four and five onto the stack, then, with the multiplication operator, pop two elements from
the stack, multiply them and push the result back on the stack." Then the 'p' command is used to examine (print out
to the screen) the top element on the stack. The 'q' command quits the invoked instance of dc. Note that numbers
must be spaced from each other even as some operators need not be.
The arithmetic precision is changed with the command 'k', which sets the number of fractional digits (the number of
digits following the point) to be used for arithmetic operations. Since the default precision is zero, this sequence of
commands produces '0' as a result:
2 3 / p
By adjusting the precision with 'k', arbitrary number of decimal places can be produced. This command sequence
outputs '.66666'.
5 k
2 3 / p
To evaluate : ('v' computes the square root of the top of the stack and '_' is used to input a
negative number):
12 _3 4 ^ + 11 / v 22 -
p
To swap the top two elements of the stack, use the 'r' command. To duplicate the top element, use the 'd' command.
dc
268
Input/Output
To read a line from stdin, use the '?' command. This will evaluate the line as if it were a dc command, and so it is
necessary that it be syntactically correct and potentially be a security problem since the '!' dc command will allow
arbitrary command execution.
As mentioned above, 'p' will print the top of the stack with a newline after it. 'n' will pop the top of the stack and
output it without a trailing newline. 'f' will dump the entire stack with one entry per line.
dc also supports arbitrary input and output radices. The 'i' command will pop the top of the stack and use it for the
input base. Hex digits must be in upper case to avoid collisions with dc commands and are not limited to A-F if the
input radix is larger than 16. The 'o' command does the same for the output base, but keep in mind that the input base
will affect the parsing of every numeric value afterwards so it is usually advisable to set the output base first. To read
the values, the 'K', 'I' and 'O' commands will push the current precision, input radix and output radix on to the top of
the stack.
As an example, to convert from hex to binary:
16i2o DEADBEEFp
outputs 11011110101011011011111011101111.
Language Features
Registers
In addition to these basic arithmetic and stack operations, dc includes support for macros, conditionals and storing of
results for later retrieval.
The mechanism underlying macros and conditionals is the register, which in dc is a storage location with a single
character name which can be stored to and retrieved from: 'sc' pops the top of the stack and stores it in register c, and
'lc' pushes the value of register c onto the stack. For example:
3 sc 4 lc * p
Registers can also be treated as secondary stacks, so values can be pushed and popped between them and the main
stack using the 'S' and 'L' commands.
Strings
String values are enclosed in '[' and ']' characters and may be pushed on the stack and stored in registers. The 'a'
command will convert the low order byte of the numeric value into an ASCII character, or if the top of the stack is a
string it will replace it with the first character of the string. There are no ways to build up strings or perform string
manipulation other than executing it with the 'x' command, or printing it with the 'P' command.
The '#' character begins a comment to the end of the line.
dc
269
Macros
Macros are then implemented by allowing registers and stack entries to be strings as well as numbers. A string can
be printed, but it can also be executed (i.e. processed as a sequence of dc commands). So for instance we can store a
macro to add one and then multiply by 2 into register m:
[1 + 2 *] sm
and then (using the 'x' command which executes the top of the stack) we can use it like this:
3 lm x p
Conditionals
Finally, we can use this macro mechanism to provide conditionals. The command '=r' will pop two values from the
stack, and execute the macro stored in register 'r' only if they are equal. So this will print the string 'equal' only if the
top of the stack is equal to 5:
[[equal]p] sm 5 =m
Other conditionals are '>', '!>', '<', '!<', '!=', which will execute the specified macro if the top two values on the stack
are greater, less than or equal to ("not greater"), less than, greater than or equal to ("not less than"), and not equals,
respectively.
Loops
Looping is then possible by defining a macro which (conditionally) reinvokes itself. A simple factorial of the top of
the stack might be implemented as:
# F(x): return x!
# if x-1 > 1
# return x * F(x-1)
# otherwise
# return x
[d1-d1<F*]dsFxp
The '1Q' command will exit from a macro, allowing an early return. 'q' will quit from two levels of macros (and dc
itself if there are less than two levels on the call stack). 'z' will push the current stack depth before the 'z' operation.
Examples
Print prime numbers :
echo '2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x'|dc
As an example of a relatively simple program in dc, this command (in 1 line):
dc -e '[[Enter a number (metres), or 0 to
exit]psj]sh[q]sz[lhx?d0=z10k39.370079*.5+0k12~1/rn[ feet ]
Pn[ inches]P10Pdx]dx'
will convert distances from metres to feet and inches; the bulk of it is concerned with prompting for input, printing
output in a suitable format and looping round to convert another number.
As an example, here is an implementation of the Euclidean algorithm to find the GCD:
dc
270
dc -e '??[dSarLa%d0<a]dsax+p' # shortest
dc -e '[a=]P?[b=]P?[dSarLa%d0<a]dsax+[GCD:]Pp' # easier-to-read version
Computing the factorial of an input value,
dc -e '?[q]sQ[d1=Qd1-lFx*]dsFxp'
A more complex example of dc use embedded in a perl script performs a Diffie-Hellman key exchange. This was
popular as a signature block among cypherpunks during the ITAR debates, where the short script could be run with
only perl and dc, ubiquitous programs on unix-like operating systems:
#!/usr/bin/perl -- -export-a-crypto-system-sig Diffie-Hellman-2-lines
($g,$e,$m)=@ARGV,$m||die"$0 gen exp mod\n";print`echo "16dio1[d2%Sa2/d0<X+d
*La1=z\U$m%0]SX$e"[$g*]\EszlXx+p|dc`
A commented version is slightly easier to understand and shows how to use loops, conditionals, and the 'q' command
to return from a macro. With a modern version of dc, the '|' command can be used to do arbitrary precision modular
exponentiation without needing to write the X function.
#!/usr/bin/perl
my ($g,$e,$m) = map { "\U$_" } @ARGV;
die "$0 gen exp mod\n" unless $m;
print `echo $g $e $m | dc -e '
# Hex input and output
16dio
# Read m, e and g from stdin on one line
?SmSeSg
# Function z: return g * top of stack
[lg*]sz
# Function Q: remove the top of the stack and return 1
[sb1q]sQ
# Function X(e): recursively compute g^e % m
# It is the same as Sm^Lm%, but handles arbitrarily large exponents.
# Stack at entry: e
# Stack at exit: g^e % m
# Since e may be very large, this uses the property that g^e % m ==
# if( e == 0 )
# return 1
# x = (g^(e/2)) ^ 2
# if( e % 2 == 1 )
# x *= g
# return x %
[
d 0=Q # return 1 if e==0 (otherwise, stack: e)
dc
271
d 2% Sa # Store e%2 in a (stack: e)
2/ # compute e/2
lXx # call X(e/2)
d* # compute X(e/2)^2
La1=z # multiply by g if e%2==1
lm % # compute (g^e) % m
] SX
le # Load e from the register
lXx # compute g^e % m
p # Print the result
'`;
References
External links
Package dc (http:/ / packages. debian. org/ search?keywords=dc& searchon=names& exact=1& suite=all&
section=all) in Debian GNU/Linux repositories
Native Windows port (http:/ / gnuwin32. sourceforge. net/ packages/ bc. htm) of bc, which includes dc.
cal
cal is a standard program on Unix and Unix-like operating systems that prints an ASCII calendar of the given
month or year. If the user does not specify any command-line options, cal will print a calendar of the current
month.
Examples
$ cal
March 2012
S M Tu W Th F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
$ cal 1992
1992
January February March
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 1 1 2 3 4 5 6 7
5 6 7 8 9 10 11 2 3 4 5 6 7 8 8 9 10 11 12 13 14
12 13 14 15 16 17 18 9 10 11 12 13 14 15 15 16 17 18 19 20 21
19 20 21 22 23 24 25 16 17 18 19 20 21 22 22 23 24 25 26 27 28
26 27 28 29 30 31 23 24 25 26 27 28 29 29 30 31
cal
272
April May June
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 1 2 1 2 3 4 5 6
5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13
12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20
19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27
26 27 28 29 30 24 25 26 27 28 29 30 28 29 30
31
July August September
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 4 1 1 2 3 4 5
5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12
12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19
19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26
26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30
30 31
October November December
S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S
1 2 3 1 2 3 4 5 6 7 1 2 3 4 5
4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12
11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19
18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26
25 26 27 28 29 30 31 29 30 27 28 29 30 31
$ cal -3
May 2009 June 2009 July 2009
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4
3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11
10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18
17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25
24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31
31
Features
$ cal 9 1752
September 1752
S M Tu W Th F S
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
The Gregorian reformation was adopted by the Kingdom of Great Britain, including its possessions in North
America (later to become eastern USA), in September 1752. As a result the September 1752 cal shows the adjusted
days missing. This month was the official (British) adoption of the Gregorian calendar from the previously used
Julian calendar. This has been documented in the man pages for Sun Solaris as follows. "An unusual calendar is
printed for September 1752. That is the month when 11 days were skipped to make up for lack of leap year
cal
273
adjustments." The Plan 9 from Bell Labs manual states: "Try cal sep 1752."
The cal command was present in 1st Edition Unix.
References
cal (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ cal. html):print a calendarCommands &
Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
External links
cal(1) (http:/ / netbsd. gw. com/ cgi-bin/ man-cgi?cal+ 1+ NetBSD-current)NetBSD General Commands
Manual
Source of explanation of cal 9 1752 phenomena (http:/ / www. csd. uwo. ca/ staff/ magi/ personal/ humour/
Computer_Audience/ 'cal 9 1752' explained. html) (humor)
date
Unix date command
The Unix date command displays and
sets the time and date of the system
clock. Setting the clock is restricted to
the superuser.
The Single Unix Specification (SUS)
mandates only one option: -u, where the date and time are printed or set in Coordinated Universal Time, as if the
time zone were UTC+0. Other Unix and Unix-like systems provide extra options.
Displaying the date
Usage
With no options, the date command displays the current date and time, including the abbreviated day name,
abbreviated month name, day of the month, the time separated by colons, the time zone name, and the year. For
example:
$ date
Fri Jul 27 14:12:06 EDT 2007
Note that the implementation of the date command differs between Unix flavors (see references below). Specifically
the GNU coreutils based command is much different than other POSIX implementations.
date
274
Formatting
To format a date, a parameter string beginning with a plus sign (+) is given. The formatting specifiers below are
supported by most implementations.
Format specifiers (format string starts with +)
Specifier Description Values or example
Day
%a weekday, abbreviated Thu
%A weekday, full Thursday
%d day of the month, two digits, zero filled 08
%e day of the month 8
%j day of year, zero filled 001366
%u day of week from Monday to Sunday 17
%w day of week from Sunday to Saturday 06
Week
%U week number, Sunday as first day of week 0053
%W week number, Monday as first day of week 0053
%V ISO standard week of the year 0153
Month
%m two-digit month number 0112
%h month name, abbreviated Apr
%b month name, localised abbreviation Apr
%B locale's full month, variable length April
Year
%y two-digit year 0099
%Y four-digit year 2014
%g two-digit year corresponding to the %V week number
%G four-digit year corresponding to the %V week number
Century
%C two century digits from year 0099
Date
%D mm/dd/yy 04/3/14
%x locale's date representation 04/3/2014
%F %Y-%m-%d 2014-04-03
Hours
%l hour (12 hour) 5
%I hour (12 hour), zero-filled 05
%k hour (24 hour) 5
%H hour (24 hour), zero-padded 05
%p locale's upper case AM or PM (blank in many locales) AM
date
275
%P locale's lower case am or pm am
Minutes
%M two-digit minute number 35
Seconds
%s seconds since 00:00:00 1970-01-01 UTC (Unix epoch) 1396503301
%S two-digit second number 0060 (Includes 60 to accommodate a leap second)
%N nanoseconds 000000000999999999
Time
%r hours, minutes, seconds (12-hour clock) 05:35:01 AM
%R hours, minutes (24 hour clock) 05:35
%T hours, minutes, seconds (24-hour clock) 05:35:01
%X locale's time representation 11:07:26 AM
Date and time
%c locale's date and time Sat Nov 04 12:02:33 EST 1989
Time zone
%z RFC-822 style numeric time zone -0500
%Z time zone name; nothing if no time zone is determinable EST, EDT
literals: %n newline %% percent %t horizontal tab
By default, date normally fills numeric fields with zeroes. GNU date, but not BSD date, recognizes a modifier
between the per cent sign (%) and the format specifier:
hyphen (-): do not fill the field
underscore (_): pad the field with spaces
TZ Specifies the time zone, unless overridden by command line parameters. If neither is specified, the setting from
/etc/localtime is used.
GNU date options
-d, --date=string display time described by string, not now. It is a human readable format such as "next Thursday" or
"1 month ago". A date string may contain items indicating calendar date, time of day, time zone, day of week,
relative time, relative date, and numbers. This is also known as relative GNU date formats. Here are a few examples
of relative date:
date --date="1 days ago"
date --date="yesterday"
date --date='10 month ago'
date --date='2 hour ago'
date --date='Second Friday'
-e=datefile like de once for each line of datefile
-ITIMESPEC, --iso-8601[=TIMESPEC] output date/time in ISO 8601 format. TIMESPEC=date for date only, hours,
minutes, or seconds for date and time to the indicated precision.
--iso-8601 without TIMESPEC defaults to `date'.
-R, --rfc-822 output RFC-822 compliant date string, example: Wed, 16 Dec 2009 15:18:11 +0100
date
276
Examples
$ date "+%m/%d/%y"
7/4/06
$ date "+%Y%m%d"
20060704
To assign the time to a variable
$ START=`date '+%r'`
$ echo $START
03:06:02 PM
$ sleep 5
$ echo $START
03:06:02 PM
N.B. the variable has the time when it was assigned.
Yesterday assigned to variable
$ DATE=$(date -d yesterday +"%Y%m%d")
$ echo $DATE
20060704
The TZ environment variable specifies the time zone. Valid values are in /usr/share/zoneinfo
$ TZ=GMT; echo "GMT: `date +\"%R (%Z)\"`"
GMT: 12:30 (GMT)
$ TZ=Europe/Stockholm; echo "Stockholm: `date +\"%R (%Z)\"`"
Stockholm: 13:30 (CET)
$ TZ=Asia/Kuala_Lumpur; echo "Kuala Lumpur: `date +\"%R (%Z)\"`"
Kuala Lumpur: 20:30 (MYT)
$ TZ=US/Central; echo "Dallas: `date +\"%R (%Z)\"`"
Dallas: 07:30 (CDT)
Converting between time zones Example: What time is it in Moscow when it will be 17:35 in Los Angeles
$ TZ=Europe/Moscow date "+%F %R (%Z%z)" -d 'TZ="America/Los_Angeles"
17:35'
2013-03-22 04:35 (MSK+0400)
Other valid time strings
date
277
GNU date BSD date output
$ date +"%Y%m%d" -d sunday $ date -v +sun +"%Y%m%d" 20060709
$ date +"%Y%m%d" -d last-sunday $ date -v -sun +"%Y%m%d" 20060702
$ date +"%Y%m%d" -d last-week $ date -v -1w +"%Y%m%d" 20060627
$ date +"%Y%m%d" -d last-month $ date -v -1m +"%Y%m%d" 20060604
$ date +"%Y%m%d" -d last-year $ date -v -1y +"%Y%m%d" 20050704
$ date +"%Y%m%d" -d next-week $ date -v 1w +"%Y%m%d" 20060711
$ date +"%Y%m%d" -d next-month $ date -v 1m +"%Y%m%d" 20060804
$ date +"%Y%m%d" -d next-year $ date -v 1y +"%Y%m%d" 20070704
$ date +"%Y%m%d" -d "2 days ago" $ date -v -2d +"%Y%m%d" 20060702
$ date +"%Y%m%d" -d "2 months ago" $ date -v -2m +"%Y%m%d" 20060504
$ date +"%Y%m%d" -d "2 years ago" $ date -v -2y +"%Y%m%d" 20040704
To show the time in seconds since 1970-01-01 (Unix epoch):
$ date +"%s" -d "Fri Apr 24 13:14:39 CDT 2009"
1240596879
To convert Unix epoch time (seconds since 1970-01-01) to a human readable format:
$ date -d "UTC 1970-01-01 1240596879 secs"
Fri Apr 24 13:14:39 CDT 2009
Or:
$ date -ud @1000000000
Sun Sep 9 01:46:40 UTC 2001
Output based on locale
> export LC_ALL=""
> date
Mon Apr 23 20:47:18 EDT 2012
> export LC_ALL="en_US.UTF-8"
> date
Mon Apr 23 20:46:59 EDT 2012
> export LC_ALL="de_DE"
> date
Mo 23. Apr 20:47:05 EDT 2012
> export LC_ALL="danish"
> date
man apr 23 20:48:09 EDT 2012
date
278
Setting the date
The XSI extension to the SUS specifies that the date command can also be used to set the date. The new date is
specified as an option to date in the format MMddhhmm[[cc]yy], where MM specifies the two-digit numeric
month, dd specifies the two-digit numeric day, hh specifies the two-digit numeric hour, mm specifies the two-digit
numeric minutes. Optionally cc specifies the first two digits of the year, and yy specifies the last two digits of the
year.
The date command from GNU Coreutils (often used on Linux) allows another method with a different format,
for example to set the date and time to
April 26, 2013 18:00:
date --set="20130426 18:00"
Options
-s, --set=string set time described by string
-n do not synchronize the clocks on groups of machines using the utility timed(8). By default, if timed is running,
date will set the time on all of the machines in the local group. -n inhibits that.
References
External links
date (http:/ / www. opengroup. org/ onlinepubs/ 9699919799/ utilities/ date. html):write the date and
timeCommands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
date(1) (http:/ / linux. die. net/ man/ 1/ date):print or set the system date and timeLinux User Commands
Manual
date(1) (http:/ / www. freebsd. org/ cgi/ man. cgi?query=date& sektion=1)FreeBSD General Commands
Manual
UNIX date command (http:/ / www. cyberciti. biz/ faq/ unix-date-command-howto-see-set-date-time/ ) examples.
lp
279
lp
The lp command is used to assign jobs to printer queues on UNIX, some Unix-like OSes like Linux, and the
Common Unix Printing System utilized by Linux and Mac OSX.
While similar in name and function, it is a different program from Plan 9's lp, fellow UNIX-like BSD's lpr, or
MS-DOS's LPT. The LPRng project provides lp as a wrapper to the lpr command.
The first appearance of lp as a print (command) was as the System V printing system on UNIX System V. Like
similarly-named commands on ITS, DEC, CP/M, and 86-DOS, it was originally an acronym for terms like line
print(er) and local print(er). However, the commands stopped being specific to line- or local- devices in the 1980s,
and today are used with any printer compatible with the operating system itself.
References
Lpr
The lpr command is used on many Unix-like systems to assign jobs to printer queues. The name derives from line
printer, though it has become the commonly used command for any sort of printer. The command originally
appeared as part of the Berkeley printing system, and for some time served as a shibboleth to distinguish between
System V and BSD systems. lpr is the standard name for the BSD printer command. It is also the standard name
for the printer command in the LPRng project. The Common Unix Printing System, used on Linux and Mac OS X
among other systems, provides an lpr command for compatibility with BSD systems.
Microsoft Windows provides an lpr command that prints to printers supporting the Line Printer Daemon protocol.
References
Article Sources and Contributors
280
Article Sources and Contributors
cat Source: http://en.wikipedia.org/w/index.php?oldid=591478207 Contributors: 16@r, Agarvin, Alan Peakall, Anderbubble, Asraam, Brolin Empey, Cpiral, Cyanoir, Damian Yerrick, Daniel
Mietchen, DanielPharos, Der Messer, Dingar, Druiloor, Dysprosia, EdC, Ejdzej, Ethan, Exlex, Eyrian, Falcon9x5, Ghettoblaster, Glenn, GoonerW, Graue, Haza-w, HopeSeekr of xMule, Incnis
Mrsi, Jarble, Jelena1, Jengelh, John of Reading, Joy, Kanjy, Kbrose, Kevinratmansky, Korg, LOL, Larsinio, Loadmaster, Lost.goblin, Mac, Marudubshinki, Mattingly23, Meiskam,
Michaelbluejay, Mikhail Ryazanov, Miko3k, Mipadi, Mnudelman, Mormegil, Musiphil, Mwtoews, NawlinWiki, Nbarth, Notheruser, Olawlor, One.Ouch.Zero, PMG, PhilKnight, Ponder,
RandalSchwartz, Random832, RedWolf, Reisio, Shiggity, Skarebo, Sun Creator, Superp, Tedickey, Teratornis, Tim Starling, ToadMan667, Tobias Bergemann, Trasz, Umlemmesee, Unixguy,
Unixtastic, Usien6, WakiMiko, Werddemer, William Avery, Yellow1996, Ysyoon, Zanimum, Zawersh, Zigger, 75 anonymous edits
cd Source: http://en.wikipedia.org/w/index.php?oldid=597089505 Contributors: ,c xmvml, 16@r, AThing, Austin Hair, Beta m, Bevo, Brandonforgod, BrotherE, Caesura, CanisRufus, CesarB,
Chaitrabhat7, Darklilac, Docu, Downtown dan seattle, Dude1818, Ebraminio, EdC, Edurant, Eequor, Emre D., Enquire, Ghettoblaster, Glenn, Gtz, Incnis Mrsi, JackPotte, Jengelh, JonHarder,
Josh the Nerd, Joy, King sorks, Larsinio, Lowk, MBParker, Marko75, Matthiaspaul, Minesweeper, Mohitb3, Msikma, Naaman Brown, Nate Silva, Nikai, Paraknight, PhiLiP, Priyesh Ghamandi,
R'n'B, Radiojon, Reisio, Ryan Roos, SQGibbon, Salty-horse, Sanketj, SimonP, Sun Creator, Suruena, Ta bu shi da yu, Tannin, Thumperward, Tohd8BohaithuGh1, Tom Hek, Unixguy, Vadmium,
Voidxor, Wayne Hardman, Wermlandsdata, Xjs, Yath, Yurik, 37 anonymous edits
Chmod Source: http://en.wikipedia.org/w/index.php?oldid=601389546 Contributors: Adamtheclown, Alansohn, AnotherRandomLurker, Aoidh, Apokrif, Asraam, Austin Hair, AzaToth,
B1naryatr0phy, Ballenato, BarrelProof, BiT, BigrTex, Bikerfreak, Bjones410, BodyTag, Born2cycle, Cafce25, CanisRufus, CesarB, Chealer, Chrisrule, Closedmouth, Computergeek84,
Crowsnest, DGerman, DVdm, Dalillama, Daniel.Cardenas, Deineka, Dillivision, Dingar, Dittaeva, Dsmryder, Dysprosia, EdC, Elian, Emre D., Epachamo, F. Cosoleto, Flyer22, Forderud,
Fresheneesz, Gbeeker, Gilliam, Glenn, Guzenkov, Hftf, HopeSeekr of xMule, I already forgot, Ice Ardor, Ifasehun, InverseHypercube, JIP, Jaalto, JackPotte, Japo, Jarble, Jengelh, Jfmantis, Jiang,
John of Reading, Johnjosephbachir, Jojhutton, Jonas AGX, Jp107, Kbolino, Keyesc, Kha0sK1d, Larsinio, Lethe, Mac Davis, Marchash, Maurice Carbonaro, Mbush78, Mikemaccana, Mortense,
Mpiper, MrOllie, Nevyn, Nikosapi, Nohat, Null Nihils, Peak Freak, Pieleric, Professor Ninja, RedWolf, Reisio, Rfsmit, Rich Farmbrough, Rob Cranfill, Rythie, Schmiteye, Shredwheat, SimonP,
Snezzy, SpecMode, Srpnor, Sverdrup, Tapir Terrific, Tas50, That Guy, From That Show!, The wub, Thorwald, TreyHarris, Underdone, UnixJohn47, Unixguy, Urhixidur, Uselesswarrior,
Vadmium, WaddSpoiley, Warren, Wei.cs, WikHead, Wolfmankurd, Xdenizen, Yngvarr, Z10x, 195 anonymous edits
Chown Source: http://en.wikipedia.org/w/index.php?oldid=575102139 Contributors: Albmont, AndrewKeenanRichardson, Apokrif, Billhcarr, Brianshaw8, Bryan Derksen, Cedar101, Chealer,
Denniss, Dingar, Djgriffith789, Dreftymac, Dysprosia, Ed g2s, Eddie Nixon, EggplantWizard, EminoMeneko, Filu, Florian Blaschke, FredChown, Gavenko a, Gbeeker, Gf uip, Glenn, Gwern,
HopeSeekr of xMule, Ihope127, JackPotte, Jarble, Jengelh, Jeremy.postlethwaite, Kate, Kbolino, Kuru, Larsinio, Lotje, Mikebrand, Netoholic, Nohat, Pcb21, Phluid61, Rectec794613, RedWolf,
Rjwilmsi, Robocoder, Smokizzy, Smyth, Starsong, Staszek Lem, SteveJothen, Tabledhote, Tigga, TinaSDCE, Tom.troyer, Unforgettableid, Unixguy, Warren, Wingedsubmariner, Ysangkok,
Ysyoon, 49 anonymous edits
Chgrp Source: http://en.wikipedia.org/w/index.php?oldid=592134512 Contributors: Alan012, Andreas Rejbrand, BiT, Bryan Derksen, DGerman, DaBler, Dingar, Dysprosia, Eddie Nixon,
Ericlee0492, Fduarte, Filu, Gbeeker, Gf uip, Ghettoblaster, Glenn, Glosser.ca, Gribeco, HopeSeekr of xMule, JackPotte, Jengelh, Johayek, Joy, Kbolino, Lancevortex, Larsinio, Longhair,
Marudubshinki, Remember the dot, Remuel, SteveJothen, Unixguy, Warren, 19 anonymous edits
Cksum Source: http://en.wikipedia.org/w/index.php?oldid=596349504 Contributors: Alan012, CanisRufus, Chmod007, Ciphergoth, Closeapple, Code65536, Danomagnum, Dingar, Druiloor,
Eddie Nixon, Edward, Etatoby, Frap, Gerbrant, Gf uip, Glenn, Hadrianheugh, Inkling, JackPotte, Jengelh, Jfmantis, Jonelo, LPfi, Longhair, Marshall Williams2, Matt Crypto, Mutoso,
NocNokNeo, Nyh, Piyush.kansal, Rharner, Spoon!, TPK, Tcho, Thorwald, Thumperward, Tim Chambers, Unixguy, Vanished user 5zariu3jisj0j4irj, XQYZ, 17 anonymous edits
cmp Source: http://en.wikipedia.org/w/index.php?oldid=543846287 Contributors: -Barry-, Deineka, Druiloor, Gbeeker, Gf uip, Ghettoblaster, Glenn, GraemeLeggett, Gwalla, HopeSeekr of
xMule, Intgr, Johnteslade, Jonathan Drain, Mairi, NBS, Polyparadigm, RJHall, Rwxrwxrwx, Sietse Snel, Sjc, Tcho, Tedickey, Thorwald, Uncle G, Unixguy, 20 anonymous edits
cp Source: http://en.wikipedia.org/w/index.php?oldid=600698408 Contributors: 16@r, AhmadSherif, Akerans, Apokrif, Bernd.Brincken, Bersam, DGerman, DanielPharos, DavidDouthitt,
Deineka, Dgordon562, Dingar, Dispenser, Dmarquard, Dysprosia, Emperorbma, Frap, Gbeeker, Glenn, Grendelkhan, Gwern, HopeSeekr of xMule, Htmlland, Huds, Jamelan, Joy, Jwchong, Kate,
Kay Dekker, Kbrose, Larley, Larsinio, MarkMankins, Marudubshinki, Meno25, OM, Paul Bonneau, Ptyxs, RainerZufall, RedWolf, Rojomoke, Schmloof, Servant74, Spoon!, Stassats, Svnpenn,
Tamal4tammy, Tedickey, Tsemii, Twinxor, Tyomitch, Unara, Uncle G, Unixguy, Unyoyega, Vanished user 5zariu3jisj0j4irj, Wag2639, Ykhwong, ZeroOne, 33 anonymous edits
dd Source: http://en.wikipedia.org/w/index.php?oldid=601043758 Contributors: 5gon12eder, A More Perfect Onion, AHMartin, Ablonus, Akulo, AlistairMcMillan, Ant diaz, Aoidh, Apokrif,
ArielGold, Asdasd1997, Asraam, AwesomeMachine, BenFrantzDale, Bgwhite, Bh3u4m, BiT, Blaxthos, Bratch, CarlosJHernandez, CesarB, Ceyockey, Charles Matthews, Chealer, Comatmebro,
Conrado.buhrer, Cpiral, Crispmuncher, DanielPharos, Dantheox, Datobig, DavidCary, Death7354, Derphysiker, Dhtwiki, Dingar, Dispenser, Djringjr, Drakedevel, Druiloor, Dsimic, Dynaflow,
EdC, Ermingol, Eshwarmedagam, Expression libre, FatalError, Fdesiecle, Felipe1982, Fibonacci, Fifo, Flankk, Frap, GGShinobi, Gadfium, Gallaiis, Gareth Griffith-Jones, Gbeeker, Georg Peter,
Glenn, Gogo Dodo, Gordonjcp, Groganus, Haikupoet, Hairy Dude, Hgrosser, Hm2k, HopeSeekr of xMule, Hu12, Ike-bana, Ikorolev, Imz, Inkington, Interiot, Itu, JGXenite, JIP, JROakley,
Jacosi, Jeffq, Jengelh, Jerome Charles Potts, JesseLukeWalker, Jleedev, John Kronenwetter, John Nowak, John Vandenberg, JohnAdriaan, Johnlcf, Kenneth Cate, Kingboyk, LN2, LaMenta3,
Lengau, LilHelpa, Lumenos, MMuzammils, Mac, Mark viking, MarkMLl, MarkSweep, MattGiuca, Mattventura, Maximus Rex, Me and, Michael Frind, Michael Hardy, Michael R Bax, Midgley,
Mihai Capot, MikeSpiers, Mortense, Mpaget, Mys 721tx, Nassarmu, Nbarth, Ned Scott, Nephron, NerdyNSK, Nukeless, OhioGuy814, Omegatron, Owenh000, Pak21, Palosirkka, Paul Stansifer,
Paulox, Pentap101, Pettefar, Phil websurfer@yahoo.com, Pot, Prsturges, Pweltz, Rebroad, RedWolf, Reisio, Rjwilmsi, Roo72, SF007, Saeger, Sebleouf, Sim astro, SkonesMickLoud, SlamDiego,
Snaxe920, Splintercellguy, StaticGull, Stevan White, Surv1v4l1st, Swestlake, Szrc, TMC1221, Tentinator, Theosch, Thorwald, Thumperward, Thringer, Tikurion, Tobias Bergemann, Tom k&e,
Trevie, Tzadikv, Ugnich Anton, Underpants, Unixguy, Vaceituno, Vadmium, Venkat.raghavulu, Voomoo, Vsurlan, W-C, W8AN, WikiWizard, Wwwwolf, X96lee15, Xiaomao123, Yath,
Ysangkok, Zero Thrust, 234 anonymous edits
du Source: http://en.wikipedia.org/w/index.php?oldid=564921335 Contributors: (:Julien:), 16@r, Asraam, Bewildebeast, BiT, Bobby D. DS., Bryan Derksen, David Gerard, Deineka, Dingar,
Dittaeva, Dreinhold, Dysprosia, EdoDodo, Enfwm, ErkinBatu, Franciscouzo, Gary, Gbeeker, Glenn, HopeSeekr of xMule, Jidanni, Jni, Kymacpherson, Larsinio, PuerExMachina, RockMFR,
SPUI, Seraphimblade, Skagedal, Sun Creator, Sven, Svick, Tcho, Thorfinn, Thunderbird2, Tonywalton, Ukepedia, Unforgettableid, Unixguy, Ysangkok, 35 anonymous edits
df Source: http://en.wikipedia.org/w/index.php?oldid=572721675 Contributors: AS, Alansohn, Asraam, BiT, Bill william compton, Bobo192, Bryan Derksen, Can't sleep, clown will eat me,
Carpetsmoker, DBrane, DavidLeighEllis, Dingar, Dittaeva, Dysprosia, Fraggle81, Gbeeker, Glenn, Gwern, HappyDog, HopeSeekr of xMule, JackPotte, Kadin2048, Larsinio, Lethosor,
Mentifisto, Nurg, PhilKnight, RedWolf, Reisio, RockMFR, SPUI, Ssd, Sun Creator, Tbhotch, Tcho, Tide rolls, TimBentley, Tohd8BohaithuGh1, Unara, Unixguy, Vanished user 39948282,
Wikieditor06, Writer99, Ysyoon, 43 anonymous edits
file Source: http://en.wikipedia.org/w/index.php?oldid=588621844 Contributors: Aflyhorse, Bunnyhop11, Cedar101, Chealer, Chris Chittleborough, CyberSkull, Dysprosia, Fredrik, George
wen, Glenn, Guy Harris, Grkan Sengn, HopeSeekr of xMule, Jay, John Vandenberg, Kai Burghardt, LPfi, Larsinio, Longhair, MarcMFresko, Mlibby, NicM, Nintendude, Phil
websurfer@yahoo.com, Rholton, RockMFR, Sleske, Stuartyeates, SvartMan, Tedickey, Tetromino, Thryduulf, Ugnich Anton, Unixguy, Utcursch, Wolfmankurd, Ysangkok, 29 anonymous edits
Fsck Source: http://en.wikipedia.org/w/index.php?oldid=602392824 Contributors: A Geek Tragedy, Abb3w, Adavidb, Affiray, AgentSteel, Ajsh, Alikhtarov, AlistairMcMillan, Andrewpmk,
Anetode, Aoidh, Arny, Arved, BCube, Bdesham, Benjamin Barenblat, Bloodshedder, CAPS LOCK, Capricorn42, CesarB, Chris Roy, ChrisGualtieri, Cprompt, Damian Yerrick, Darolew, David
Gerard, Decltype, Dingar, Don't give an Ameriflag, Download, Eddie Nixon, Evice, Fede.Campana, Frap, Fubar Obfusco, FunBob1986, Gilliam, Glenn, Goid, Green egg, Guyjohnston, Hairy
Dude, Hm2k, HopeSeekr of xMule, IO Device, Ixfd64, JackPotte, Jcarroll, Jfmantis, John, Jonathandeamer, Jonkerz, Jrnewton, Julle, Jwz, LGagnon, Larsinio, Lhbts, Mateo LeFou,
Mattias.Campe, Mbp (usurped), Mike J B, Mike Rosoft, Mrichmon, Ms. 45, Mschamschula, NiveusLuna, Nixeagle, Nullmind, OmidPLuS, PCHS-NJROTC, Pankkake, Peyre, Phil Boswell,
Prara, Qwitchibo, Richardgaywood, RockMFR, Romanc19s, Roy hu, Rst, Rufous, Santurwoman, Seidenstud, Sk8ajoe, Smalljim, SmartGuy Old, Snaxe920, Spinningspark, Stephan Leeds,
Storkk, Tannin, Tbarron, Teddyb, Termine, TheRanger, Theda, Thumperward, Timc, Tomalak geretkal, Trasz, Tulkas, VanGore, Vanished user g454XxNpUVWvxzlr, Vicki Rosenzweig,
Wildthing61476, Winston Chuen-Shih Yang, Winterheat, Wmahan, Worldmaster0, Writtenonsand, Wwwwolf, 127 anonymous edits
fuser Source: http://en.wikipedia.org/w/index.php?oldid=575102239 Contributors: Alan012, AndyBQ, Brandon, Cedar101, Deineka, Dingar, Glenn, Hlangeveld, KaySL, Mackstann, Malcolma,
Memset, Milan Kerlger, MrOllie, Quuxplusone, SheeEttin, Xsspider, 17 anonymous edits
ln Source: http://en.wikipedia.org/w/index.php?oldid=574613919 Contributors: 16@r, Alerante, Aliekens, Apapadop, Asraam, AttoRenato, BodyTag, Bryan Derksen, CXCV, Caesar, Ciaran H,
Cybertoast, Daimanta, Dainomite, Dana boomer, Dingar, Docu, Dysprosia, EoGuy, Exlex, Furrykef, Gbeeker, Ghettoblaster, Glenn, Hairy Dude, Henridv, HopeSeekr of xMule, Ishdarian, Jarble,
Jose Ramos, Kaldari, Kazabubu, Kbolino, Larsinio, Lotje, Lupin, Moocha, Nitinlbs07, R'n'B, Rcsprinter123, RedWolf, RockMFR, Santoshijd, Shamatt, Subrata23, Superm401, Swpb, Tabletop,
Thorwald, Tobias Bergemann, Unixguy, Urmom243, Wahwahpedal, Widefox, Yath, Yrodro, Zoohouse, 51 anonymous edits
Ls Source: http://en.wikipedia.org/w/index.php?oldid=594862344 Contributors: 16@r, A333, Alf Boggis, AlistairMcMillan, Alt Content, Anarchivist, Asraam, Austin Hair, BiT, Bogdangiusca,
Brandonforgod, Brianreading, CanisRufus, Cbdorsett, CesarB, Chadders, Channabasava gola, Chowbok, DGerman, DW1492, Davejohnsan, Davidzuccaro, DerHexer, Dhaluza, Diberri, Dra,
Article Sources and Contributors
281
Dysprosia, EdC, Ehn, Emperorbma, Emre D., Eric B. and Rakim, Falcorian, Fintler, Fragglet, Gbeeker, Ghettoblaster, Glenn, Guy Harris, Hgrosser, HopeSeekr of xMule, Horus the falcon,
Huihermit, Husond, Ilya, Ish ishwar, J.delanoy, JackPotte, Jake Wartenberg, Jarble, Jason Quinn, Jedidan747, Jeltz, Jkeroes, Jketola, Jleedev, JohnOwens, Josh the Nerd, Jthestump, KGasso,
Kbolino, Kerumen, Kubanczyk, Larsinio, Loopkid, Markhurd, MattGiuca, Mikm, Mipadi, Mqduck, MrOllie, Mulad, Mwtoews, Myconix, Naddy, NawlinWiki, Nikai, Nn123645, Nurg,
Perspectoff, Peyre, Ponder, Python eggs, Quercusrobur, R3ap3R, RTC, Random832, RedWolf, Res2216firestar, Rjwilmsi, Robert Illes, Rogerdpack, Sasonaix, SimonP, Stassats, SuperGerbil,
Sverdrup, Swapnilnshelar, Tannin, Tarquin, Tedickey, Teratornis, The Font, Thumperward, Tom Duff, Umcanes05, Uncle Dick, Uniwersalista, Unixguy, VIFV, Vicki Rosenzweig, Vriullop,
WikHead, Williamvergara, Winterheat, Xmoogle, Yath, Zoicon5, ZxxZxxZ, , 117 anonymous edits
Lsattr Source: http://en.wikipedia.org/w/index.php?oldid=578628422 Contributors: BiT, ChrisGualtieri, DNewhall, Dingar, Glenn, JackPotte, Meebey, Rror, Sfan00 IMG, ZyMOS, 4
anonymous edits
Lsof Source: http://en.wikipedia.org/w/index.php?oldid=565997689 Contributors: AlistairMcMillan, Apollo42, Apotheon, BiT, Biohazd, Boggie, Bryan Derksen, ChP94, Codename Lisa,
Curps, Danielmiessler, Dingar, Emperorbma, Enigmasoldier, Frap, Gaius Cornelius, Gary, Gene Thomas, Glenn, Gnele, HopeSeekr of xMule, HorsePunchKid, Iida-yosiaki, Ixfd64, JackPotte,
Jamelan, Kbolino, Kjoonlee, Kumarat9pm, Larsinio, Lexi Marie, Magioladitis, Mlpkr, Mortense, PeteVerdon, PhilKnight, Pm5, Pmsyyz, R'n'B, RJHall, Safalra, Sebleblanc, SpaceFlight89,
Storkk, Thorwald, Thumperward, Toddintr, Unixguy, Xezbeth, 17 anonymous edits
Mkdir Source: http://en.wikipedia.org/w/index.php?oldid=592137241 Contributors: 16@r, Acdx, AhmadSherif, AjayKumarBasuthkar, Andre Engels, Andreas Rejbrand, Byassine52, CesarB,
Derekleungtszhei, Emre D., Ghettoblaster, Glenn, GoingBatty, Gwern, Harryboyles, HopeSeekr of xMule, Huds, JackPotte, Jamelan, Jengelh, Jthestump, Larsinio, Martnym, Matthiaspaul, Mild
Bill Hiccup, Mod.torrentrealm, Nate Silva, Nathael, Rajah, RedWolf, Rohanch, Snodnipper, Svnpenn, Tannin, Tizio, Tohd8BohaithuGh1, Unixguy, VARGUX, 22 anonymous edits
mount Source: http://en.wikipedia.org/w/index.php?oldid=591426323 Contributors: Andrewman327, BiT, Blainster, DGerman, Dingar, Druiloor, Drwily95, EagleOne, Ecwinslow, Edupedro,
Elinruby, FleetCommand, Friday, Furrykef, Ghettoblaster, Glenn, Intgr, JIP, Japo, Juno the pregnant little girl, Kiore, Loqi, Luckyz, Mac, Maherseif, Mblumber, NapoliRoma, Nbarth, RockMFR,
SpeedyGonsales, Thumperward, TravisAF, Unforgettableid, WilliamJE, 22 anonymous edits
Mv Source: http://en.wikipedia.org/w/index.php?oldid=598541953 Contributors: 16@r, Amaccuish, Audriusa, Bosemilton, Calebpburns, CesarB, DGerman, Dappaduppa, Deineka, Dingar,
EEMIV, EdC, Efitu, Eli the Bearded, Emperorbma, Eschnett, EspadaV8, Falcon9x5, Frap, Fred Bauder, Frederickhoyles, Gbatramhw, Ghettoblaster, Gilliam, Glenn, Grendelkhan, HopeSeekr of
xMule, Huds, Itu, JackPotte, Joy, Larsinio, Magioladitis, N5iln, Nurg, Peyre, Qwerty0, Reinoutr, Romaine, STATicVapor, Sadangel, Secfan, Soimless, Spoon!, Stefanbs, SterlingNorth,
Thattommyguy, The wub, Uncle G, Unixguy, WakiMiko, Zigbigidorlu, 24 anonymous edits
pax Source: http://en.wikipedia.org/w/index.php?oldid=568665940 Contributors: AKMask, Bwooce, Carpetsmoker, Darrien, Destynova, Edward.in.Edmonton, Estragon, Everyking, Frap,
Fryed-peach, FuFoFuEd, Gbeeker, Glenn, Grendelkhan, GreyCat, NerdyNSK, Oneiros, Plombex342, PolarYukon, Polemon, Polluks, Riannucci, SamIAmNot, Schily, Thumperward, Unixguy,
Vadmium, 23 anonymous edits
Pwd Source: http://en.wikipedia.org/w/index.php?oldid=574148391 Contributors: 16@r, Aaron Rotenberg, Beta m, BiT, Caesura, Chepry, Ciceronl, Daigaku2051, Damian Yerrick, Deineka,
Dysprosia, EEMIV, FF2010, Frap, Fredrik, Furrykef, Gf uip, Ghettoblaster, Glenn, HopeSeekr of xMule, Ivostefanov, JackPotte, John Vandenberg, Kauczuk, LukeSurl, Lus Felipe Braga, Mairi,
Minesweeper, Philip Trueman, Playstationman, Ponder, Psb777, RJHall, Runefurb, SlaveToTheWage, TakuyaMurata, Tannin, Tcho, Tedickey, Teratornis, Tim Starling, Unixguy, Utcursch,
Waggers, ZxxZxxZ, 42 anonymous edits
rm Source: http://en.wikipedia.org/w/index.php?oldid=600022331 Contributors: 16@r, Alan012, Alerante, Altenmann, Apokrif, Archon 2488, Argv, Austin Hair, BD2412, Biscuittin, Black
Rainbow 999, C. A. Russell, Carnildo, Certes, Cmastudios, Creidieki, Dingar, Drugonot, Dysprosia, Eman2129, Eternal Agony, Fishnet37222, Fmarier, Frap, Ghettoblaster, Glenn, Graingert,
Hm2k, Homerjay, HopeSeekr of xMule, Huds, Informationtheory, JHP, JLaTondre, Jac16888, Jarble, Jjclarkson, John of Reading, Joy, Jthestump, Kevin Steinhardt, Larsinio, Leolaursen,
MattGiuca, Naddy, Nate Silva, Otrfan, Oxyphenbutazone, Penfold, Plasmagunman, PoccilScript, Ponder, RJaguar3, RedWolf, RiverStyx23, RockMFR, Sam Hocevar, Scarfy, SimonP, Siodhe,
Soren121, Spoon!, Stork, Tannin, Thattommyguy, Thumperward, Thv, Tokino, Trasz, Trevie, Turki, Ugnich Anton, Uncle G, Unixguy, WorldFamousBigB, var Arnfjr Bjarmason, 59
anonymous edits
Rmdir Source: http://en.wikipedia.org/w/index.php?oldid=579765863 Contributors: AhmadSherif, AlexPlank, Andreas Rejbrand, Bryan Derksen, Comp.arch, Cynical, Dillee1, Dingar, Edurant,
Emre D., Evercat, Furrykef, Ghettoblaster, Glenn, HopeSeekr of xMule, Huds, Isaac Sanolnacov, Itu, JackPotte, Larsinio, Mac, Matthiaspaul, Mild Bill Hiccup, RedWolf, Skinhat, Slaterhatwik,
Spoon!, Spug, Tannin, TexasAndroid, Unixguy, Visik, Wermlandsdata, Ysyoon, 26 anonymous edits
size Source: http://en.wikipedia.org/w/index.php?oldid=575102420 Contributors: Cedar101, Csabo, Gf uip, Glenn, Isilanes, ItsProgrammable, Jfmantis, Katanzag, Kl4m-AWB, RockMFR,
Stepheng3, Sun Creator, Yutsi, 3 anonymous edits
split Source: http://en.wikipedia.org/w/index.php?oldid=570278657 Contributors: BiT, Bryan Derksen, CesarB, ChP94, ChrisGualtieri, Cybercobra, Dingar, Dysprosia, EdC, EncMstr,
Falcorian, Fibonacci, Fram, Gf uip, Glenn, Graham king 3, HopeSeekr of xMule, Jamelan, Jodi.a.schneider, Jonnabuz, Joy, Lambtron, Larsinio, Logiphile, Materialscientist, Pentagonpie,
RedWolf, RockMFR, SPUI, Sjc, Strait, TaylorSteiner, Thumperward, Tobias Bergemann, Ygfperson, 14 anonymous edits
tee Source: http://en.wikipedia.org/w/index.php?oldid=585485844 Contributors: 4C, Aillema, Allens, Andrew walker, BiT, Bkouhi, Cedar101, Chrisahn, Ckreo, CyberSkull, Cybercobra,
DGerman, Dangerousnerd, Doctor J, Frap, Frappyjohn, Gbeeker, Ghettoblaster, Glenn, Jaapkroe, Jason Quinn, Johayek, Longhair, Majeedokostovich, Markhobley, Mattventura, Mortense,
Mrzaius, Ramckay, Reisio, Rockfang, Ryan.gates, Svnpenn, Tedickey, Tomgibbons, Unixguy, W2bh, 31 anonymous edits
touch Source: http://en.wikipedia.org/w/index.php?oldid=600972662 Contributors: 16@r, Alksub, Asraam, Bgwhite, Bruce1ee, Bryan Derksen, Cherdt, ChrisGualtieri, Christoph Franzen,
Dingar, Dl2000, Drkirkby, Dysprosia, Fred Foobar, Glenn, Hephaestos, HopeSeekr of xMule, Hyungjin Ahn, Joeblakesley, Kaimiddleton, Larsinio, Loadmaster, Mark Arsten, Mumuwenwu, N
Yo FACE, Nikai, Paul Stansifer, PeterCooperJr, Raceprouk, RedWolf, Sick bug, Spoon!, Tassedethe, Thivierr, Tomabuct, Unixguy, Yath, 37 anonymous edits
type Source: http://en.wikipedia.org/w/index.php?oldid=558374008 Contributors: DBigXray, Glenn, Jgbreezer, Lifeformnoho, Nicolas1981, Prmshepherd, Stardust85, SteveChervitzTrutane,
Vadmium, 4 anonymous edits
Umask Source: http://en.wikipedia.org/w/index.php?oldid=596226869 Contributors: Aeonx, Babbage, Bryan Derksen, Caltas, Chrullrich, Cmglee, Ctewary, Ctm314, DGerman, DarthShrine,
Dingar, Eyreland, Gaius Cornelius, Glenn, GregorB, Hakamadare, Japo, John of Reading, JohnMashey, K001, Lankiveil, Macrakis, Mandarax, Massysett, Maurice Carbonaro, Mild Bill Hiccup,
Mohsen Ekhtiari, Nbarth, Netoholic, Nikevich, Offby1, Oleg Alexandrov, Pdfrod, Pimlottc, Psychonaut, R'n'B, SPUI, Scientus, Set theorist, Smile4ever, Sparkie82, Splatterbug, Stadler, TJRC,
Thorwald, Umawera, Vincix, Widr, 112 anonymous edits
at Source: http://en.wikipedia.org/w/index.php?oldid=578010791 Contributors: Abhijitpai, Beren, Bryan Derksen, Colonies Chris, CyberSkull, Cybercobra, DGerman, DaBler, Danhash,
Deineka, Dingar, Dosman, Druiloor, EdC, Egil, Filu, Gf uip, Glenn, HopeSeekr of xMule, Jak86, Jamelan, Jfmantis, Jgrahn, Jpp, Kentborg, Klaser, Klemen Kocjancic, Larsinio, Loadmaster,
Lotje, MeekMark, Mike Rosoft, Ohconfucius, Psychonaut, Radiojon, RedWolf, RockMFR, ScotXW, Simon Marchese, Unixguy, 20 anonymous edits
bg Source: http://en.wikipedia.org/w/index.php?oldid=549050046 Contributors: Abdull, Casablanca2000in, Gf uip, Ghettoblaster, Glenn, Kha0sK1d, Kri, Loadmaster, Rtcoles, SajjadF,
ZyMOS, , 1 anonymous edits
Chroot Source: http://en.wikipedia.org/w/index.php?oldid=587173894 Contributors: AndrewProgrammer, Andrewman327, Antoinel, Apokrif, B^4, Ben.c.roberts, Bikepunk2, Bovineone,
Bryan Derksen, Cab88, Chris the speller, ChrisHodgesUK, Chruck, Chych, Crazycomputers, Damian Yerrick, Dillee1, EdC, Electricmuffin11, Erhudy, Furrykef, Ghakko, Glenn, Gwern, Hoteit,
Improv, Jamelan, Jburfoot, Jebba, Jfmantis, JimD, JonHarder, Joy, KiloByte, Kim Bruning, KitchM, Kwi, LPfi, Larsinio, Marudubshinki, Masterhomer, Materialscientist, Me and, Mesoderm,
Mirokado, Ninly, PGibbons, PJTraill, PseudoSudo, PuerExMachina, Radagast83, RedWolf, Rudd-O, SF007, Scheibenzahl, SecurityBulletins.com, Seraphimblade, Steve Gertz, StoneIsle,
Thumperward, Tobias Bergemann, Trasz, Unixguy, Vanished user g454XxNpUVWvxzlr, Wikante, William Avery, Woohookitty, Ysangkok, 109 , anonymous edits
Cron Source: http://en.wikipedia.org/w/index.php?oldid=601507177 Contributors: 1badninja, 28421u2232nfenfcenc, 90, Adam Brody, Alan012, AllenJB, Altonbr, Amcbride, ArchiSchmedes,
Arda Xi, Artcava, Arto95, Arvindn, Aschesiegen, BigMaverick, BioStu, Bkonrath, Blanchardb, BraveryOnions, Breadtk, Brest, Bxj, Byraul, C xong, Callidior, Cameltrader, Centrx, CiaPan,
Codename Lisa, CogitoErgoSum14, Curtlee2002, CyberShadow, Cybercobra, DanPope, DancingMan, DanielPharos, Danielx, DanilaKutkevich, DavidBlackwell, DavidDouthitt, Deepesh16,
DemonThing, Devewm, Dgw, Dingar, Djkrajnik, DocRuby, Dogaru Florin, Dront, Durrantm, Ed g2s, Endcrash, ErkinBatu, Escaladix, Estevoaei, Euloiix, Felipe1982, FiskFisk33, Fly2ananth,
Fraggle81, Fribbler, Fridim, Frt975, Gal Buki, Galoubet, Ghettoblaster, Glenn, Globbet, Golbez, Gorba, Gourami Watcher, Gpky, Greenpickle, Gronky, Guymer, Gwernol, Healthyelijah, Heron,
Highpriority, Hkdobrev, Iach5jalbOifNelb, Iggymwangi, Ilyaroz, Imom39a, Iviney, JNW, JackPotte, James.Denholm, Jasper Deng, Jefe2000, Jlin, Jon077, Jorgenev, Jorl17, Joshenders, Juice-qr,
KVDP, Kapow, Knoxvillejeff, Kriplozoik, Kromped, Ktheory, Kukini, LGee LGee, Lambiam, Lavers, Ldfifty, Ling.Nut, Lopifalko, Lotje, MBread, MDfoo, Mabdul, Madman91,
Mahbubur-r-aaman, Manop, Markluffel, Matj Grabovsk, Mdwyer, Me and, Meandtheshell, Migaber, Mirkon, MonoAV, Morte, MrOllie, Neosys, Nicol, NormG, Nurg, Ndvornk,
OrenBochman, Oxymoron83, P199, Peyre, Pimlottc, Pmerson, Pnm, PuerExMachina, QuackGuru, Reedy, Reisio, Rich Farmbrough, Richard Taytor, Riksweeney, Rlb408, Roshan baladhanvi,
Rwxrwxrwx, SF007, Sangram.takmoge, Sceptre, ScotXW, Scottmacpherson, Sean.hoyland, Sleske, Smeelsmudge, Snaxe920, Sparr, Stephen, Stupendous Man!, Sun Creator, Svick, Sydius,
Article Sources and Contributors
282
Tanketz, Tardis, Themfromspace, Thomas d stewart, ThomasMueller, Thumperward, Tide rolls, Tim Parenti, Tingrin87, TomMcCann, Triona, UKER, Ugen64, User A1, Velella, Versageek,
Versus22, VinayKumarNP, Vipinhari, Voidxor, VoodooChild88, Welsh, Wereon, Whammyhammer, Widr, Wikidudester, William Graham, Wrs1864, Yanico, Yves.Christophe, Zenecan, Zk
deng, , , 375 anonymous edits
fg Source: http://en.wikipedia.org/w/index.php?oldid=549286914 Contributors: Casablanca2000in, Gf uip, Ghettoblaster, Glenn, Kri, Loadmaster, Rtcoles, Tony Sidaway, ZyMOS, , 5
anonymous edits
kill Source: http://en.wikipedia.org/w/index.php?oldid=305001210 Contributors: Abdull, AhmadSherif, AlbertCahalan, Andreas Kaufmann, Andybernardino, Arthena, Bryan Derksen,
CTZMSC3, CWenger, Cedar101, Dingar, Dysprosia, EdC, Engmark, Fibonacci, Frap, Gbeeker, Ghettoblaster, Glenn, Harryboyles, Hcagri, HelenWatt, Hello71, Hgrosser, Honza Zruba,
HopeSeekr of xMule, Hvn0413, Icallitvera, IronGargoyle, JLaTondre, Jerryobject, JesseW, John of Reading, Karpoke, Keenan Pepper, Korg, Larsinio, Loadmaster, MSGJ, Mark Foskey, Mulad,
Mushroom, Neilc, Neptune5000, PGSONIC, Poulpy, PrestonH, Ready, RockMFR, SPUI, Sevela.p, Sklein, Snezzy, SoCalSuperEagle, Spatian116, Spug, SpuriousQ, Superborsuk, Superspring,
Terrible Tim, Thine Antique Pen, Tigga, Tzadikv, Ugnich Anton, Uncle G, Unixguy, Windoze96, Woohookitty, Ydam, ZbySz, iedas, 85 anonymous edits
Killall Source: http://en.wikipedia.org/w/index.php?oldid=576947368 Contributors: AlbertCahalan, Bgwhite, BiT, Corti, DaBler, Dingar, Dylan Lake, Eddpayne, Eli the Bearded, Emperorbma,
Frank Lofaro Jr., Glenn, Hvn0413, JackPotte, Jamelan, Jamesmorrison, Jerryobject, John Nevard, Joy, Karpoke, Katanzag, Kl4m-AWB, Microsofkid, Parcly Taxel, Rambler, Rich Farmbrough,
Square87, Tetromino, Tigga, Tobias Bergemann, Ugnich Anton, 15 anonymous edits
nice Source: http://en.wikipedia.org/w/index.php?oldid=600479003 Contributors: 4pq1injbok, A.R., AVB, Aleksey Gerasimov, Bdesham, BiT, CailinH, CanisRufus, DavidDouthitt, Deflective,
Deineka, Eleschinski2000, Frap, Fudoreaper, Ghettoblaster, Glenn, Goudzovski, Hairy Dude, HopeSeekr of xMule, Jesse V., Joy, Kaldari, Kazuo Ishiguro, KitchM, Koffieyahoo, Kotniski,
Kwamikagami, Larsinio, Luxdormiens, Marudubshinki, MinorContributor, Munford, Nat682, Paramesh2016, Pgan002, Proxyma, QTCaptain, Qwertyus, SchfiftyThree, Scientus, Summentier,
The Event Horizon, Theodolite, Thorwald, Thumperward, Ugnich Anton, Unixguy, VictorianMutant, ZeroOne, Zigger, 41 anonymous edits
Pgrep Source: http://en.wikipedia.org/w/index.php?oldid=587229946 Contributors: AlbertCahalan, BiT, Cedar101, DaBler, Deineka, Dingar, Druiloor, Dylan Lake, Fibonacci, Ghettoblaster,
Glenn, Jamelan, Jerome Charles Potts, Karpoke, Katanzag, Kl4m-AWB, Tetromino, Uberkermit, Ugnich Anton, Vanthorn, 10 anonymous edits
Pidof Source: http://en.wikipedia.org/w/index.php?oldid=585988154 Contributors: Adailton, AlbertCahalan, BiT, Deineka, Dingar, Druiloor, Emperorbma, EngineerScotty, Euna8815,
Furrykef, Glenn, Isilanes, Jerome Charles Potts, Jfmantis, John Nevard, Joy, JustAGal, Karpoke, Katanzag, Kl4m-AWB, Saimhe, Square87, Tetromino, Travelbird, Ugnich Anton, Vlad,
Wmryder, 6 anonymous edits
Pkill Source: http://en.wikipedia.org/w/index.php?oldid=587375870 Contributors: A.depasquale, AlbertCahalan, BiT, Brookie, Deineka, Dingar, Dylan Lake, Glenn, Hvn0413, Isilanes, Jerome
Charles Potts, Karpoke, Katanzag, Kl4m-AWB, LarryJeff, MinorContributor, Rich Farmbrough, Square87, 9 anonymous edits
ps Source: http://en.wikipedia.org/w/index.php?oldid=593440925 Contributors: .:Ajvol:., 16@r, Adamacious, Arthur Rubin, Bearcat, Beland, Berlowex, BiT, Booyabazooka, Brighterorange,
Btmiller, Dalesit, Dingar, Edward, Gene93k, Gf uip, Ghettoblaster, Glenn, HopeSeekr of xMule, Jebba, Lom Konkreta, Lowellian, Mlpkr, Pearle, Pwjb, RJFJR, RedWolf, Reisio, Romanc19s,
Skgget, Spoon!, StephenWeber, Thumperward, Tizio, Twinxor, Ugnich Anton, Unixguy, Voomoo, Yangfl, 37 anonymous edits
Pstree Source: http://en.wikipedia.org/w/index.php?oldid=554523607 Contributors: 16@r, Frap, Ghettoblaster, Glenn, GregorB, IvarTJ, Kephir, Mlpkr, Tobias Bergemann, Tothwolf, WGH,
Waldo the terrible, 21 anonymous edits
time Source: http://en.wikipedia.org/w/index.php?oldid=576608234 Contributors: ChP94, Darkskynet, Delirium, Dingar, Druiloor, Ghettoblaster, Glenn, Hameryko, HopeSeekr of xMule,
Ithyus, JamesPaulWhite, Joy, Jrdioko, Keyed In, Larsinio, Loadmaster, Marudubshinki, Matthiaspaul, Mpeylo, RedWolf, RockMFR, Satak Azat', Stillwaterising, Toussaint, Ugnich Anton,
Unixguy, Zigger, 13 anonymous edits
top Source: http://en.wikipedia.org/w/index.php?oldid=586618208 Contributors: AlbertCahalan, Alexander.stohr, Beland, Bobbo, Bryan Derksen, CanisRufus, CoolingGibbon, Cybercobra,
Danhuby, Danvillemikek, ElBenevolente, ElationAviation, Electron9, Emufarmers, Fordsfords, FrankB, Furrykef, Gaius Maximus Lollius, Gaury989, Gbeeker, Ghettoblaster, Glenn, HopeSeekr
of xMule, Ivoras, Jebba, John of Reading, Jolomo, Joy, Korg, Larsinio, LodeRunner, Mlpkr, Mwtoews, Nick Number, Omerod, RedWolf, Rjwilmsi, RockMFR, Ryulong, Saintp, Slatedorg,
Tobias Bergemann, Txuspe, Tyw7, Unixguy, Widefox, Wnl, Yangfl, -, 51 anonymous edits
clear Source: http://en.wikipedia.org/w/index.php?oldid=596587142 Contributors: Angelito7, BiT, Emperorbma, Fanra, Gf uip, Gpvos, JPaestpreornJeolhlna, Jake Wasdin, Lotje, Mysdaao,
PhilippWeissenbacher, Potatoswatter, Ratiocinate, Tedickey, Tom12519, Vadmium
Env Source: http://en.wikipedia.org/w/index.php?oldid=557134096 Contributors: Abdull, Alessandroandcharlie, Asraam, Bongwarrior, Brim, Cesium 133, CyclePat, Eddie Nixon, Ego White
Tray, Flarn2006, Furrykef, Gf uip, Ghettoblaster, Glenn, Gotgrapes, GregorB, Harej, Heptite, JHunterJ, Kerrick Staley, Larsinio, Magioladitis, Mairi, Marudubshinki, MinorContributor, Mion,
Mrzaius, PranksterTurtle, RandalSchwartz, Redsymbol, Teh tennisman, Ugnich Anton, Unixguy, Weyes, 21 anonymous edits
exit Source: http://en.wikipedia.org/w/index.php?oldid=580890561 Contributors: Cander0000, DaBler, Deep silence, Druiloor, EdC, Ghettoblaster, Glenn, Goldenrowley, H3llbringer, Ilyaroz,
JackPotte, L736E, Loadmaster, NSR, Niceguyedc, RainbowCrane, Ronhjones, Rwwww, Wbm1058, 3 anonymous edits
finger Source: http://en.wikipedia.org/w/index.php?oldid=585783910 Contributors: (, A*-search, Abdull, Ambrosen, Andypandy.UK, Arvindn, Baffle gab1978, Borgx, Bradtem, Brianski,
CapitalR, Csalmon, DGerman, Damian Yerrick, DavidDouthitt, Dawnseeker2000, Dennis714, Drable, Duk, Dwayne, Emperorbma, Fnordly, Frap, Fratrep, Gardar Rurak, Ghettoblaster, Glenn,
Hashar, Iam, Ijustam, Irishguy, JTN, Jamelan, Jay, Joonga, Joy, Jschot, Koavf, Kraftlos, Krushia, Lentower, Mabdul, Mark Richards, Matt Crypto, Michael Angelkovich, MichaelBillington,
Muhandes, Nbarth, Neelix, Nirvanko, Notheruser, PetesGuide, Phoe6, Pmsyyz, Posix memalign, Radiojon, RedWolf, Richard W.M. Jones, RockMFR, Shadow1, Shirulashem, Strait,
TenPoundHammer, The Inedible Bulk, Tobias Bergemann, Toussaint, Tristanb, Unixguy, Valacosa, Vanished User 1004, Versus22, Vicki Rosenzweig, Wesley, Wimmeljan, Zfr, Zoicon5, 62
anonymous edits
history Source: http://en.wikipedia.org/w/index.php?oldid=584061701 Contributors: Alex.Uvarov, Berny68, Billposer, EQ5afN2M, Hammy603, Wdev005, 2 anonymous edits
id Source: http://en.wikipedia.org/w/index.php?oldid=544208104 Contributors: Absolwent, BiT, Deineka, Dingar, Frap, Gf uip, Ghettoblaster, Glenn, Jamelan, RockMFR, Theodolite, 5
anonymous edits
Logname Source: http://en.wikipedia.org/w/index.php?oldid=540558045 Contributors: Deineka, Dingar, Fabrictramp, Frap, Gf uip, Ghettoblaster, Glenn, Nisselua, Pnm, Psychonaut, Tigga,
Unconcerned, Watermellonman, 5 anonymous edits
Mesg Source: http://en.wikipedia.org/w/index.php?oldid=541329818 Contributors: BiT, Brothers, Dingar, Ghettoblaster, Glenn, Heptite, Larsinio, Tetromino, The Rambling Man, Thingg,
Ugnich Anton, 3 anonymous edits
passwd Source: http://en.wikipedia.org/w/index.php?oldid=538884991 Contributors: Alerante, ArnoldReinhold, Ayeomans, Bneely, Bobo192, Bryan Derksen, CelloerTB, CesarB, Charles
Matthews, Csabo, DavidCary, Dekart, Drugonot, Dual1tyx, EagleOne, EdC, Fibonacci, Filelakeshoe, Finlay McWalter, Fitzhugh, Gbeeker, Ghettoblaster, Hmwith, HopeSeekr of xMule,
Jac16888, Jonstanley, Larsinio, MacGyverMagic, Manifestation, Mikemaccana, NapoliRoma, Norm, Rotpunkt, Srasku, Ssd, Stermeau, Thumperward, Umawera, Unixguy, Wagner, Wouterbeek,
Xoneca, 29 anonymous edits
su Source: http://en.wikipedia.org/w/index.php?oldid=587518464 Contributors: 1exec1, Abdull, Absolwent, Admrboltz, Alerante, Alessandra Napolitano, Asraam, BiT, Bryan Beicker, Bryan
Derksen, Carpetsmoker, Cbuckley, Dcljr, Dereckson, DerekHe, Dungodung, E.balani, Ebraminio, EdC, Eddie Nixon, Eleland, Frap, Ghettoblaster, Glenn, Greeneto, HopeSeekr of xMule, Htonl,
Jack-A-Roe, James Foster, Jeff3000, JimD, Johnleemk, Joy, Kernel.package, Korg, Larsinio, LilHelpa, Maven111, Melchoir, Moppet65535, Nightstallion, Omegatron, Pagesmasher, Pakaran,
Palosirkka, Pieterpo, RDailey79, RJFJR, RedWolf, Reinyday, Remember the dot, Reutermen, Runarb, Seliopou, Spoon!, Stewartadcock, Superborsuk, T3h 1337 b0y, Thumperward,
Tommy2010, Unixguy, Unyoyega, Vanessaezekowitz, Warren, 37 anonymous edits
Sudo Source: http://en.wikipedia.org/w/index.php?oldid=602272316 Contributors: 777sms, AdamJacobMuller, AhmadSherif, Alan012, Alerante, Aoidh, Auraceon, Aurochs, Baron1984,
Belovedfreak, Beno1000, BiT, BlanchardJ, Borgx, Burgundavia, BurritoBazooka, CQJ, Calvinps, Chameleon, Chmod007, ChrisGualtieri, Clayton Hynfield, Clorox, Cmdrjameson, Coggs,
Commander, CommonsDelinker, CorporateM, Cosmo0, CountZ, Cparker, CyberSkull, Damian Yerrick, Danny sepley, DaveInAustin, Deflective, Dhanks, Dingar, Dinojerm, Dravecky,
Druid816, Eddie Nixon, Egsan Bacon, Ehheh, Elomis, Erik9, Estoy Aqu, Ev149, Feedmecereal, Felipe1982, Fennessy, Fibonacci, Fo0bar, Frank Lofaro Jr., Frap, Frecklefoot, GDallimore,
Gabriel Acquistapace, Garo, Ghettoblaster, Gilliam, Glenn, Grahamperrin, GuyPaddock, GyroMagician, Gtz, Hac13, Herakleitoszefesu, Hgrosser, HopeSeekr of xMule, Hydrargyrum,
IlliterateSage, Imtiazbailian, Ineuw, Iridescent, Jandalhandler, Janizary, Jasonzhuocn, Jeltz, Jengelh, Jeremy Visser, JesseHogan, JimD, Jon vs, Joy, Kakurady, Karnesky, Kdjalaskdjf, Kelly
Martin, Keramida, Kl4m-AWB, Ktdreyer, Ktower, Kumarat9pm, Kusma, Kwamikagami, Laogeodritt, Larsinio, Lasse Havelund, Lenschulwitz, Lifeformnoho, Lordalpha1, M4gnum0n, Makwy2,
Masamafo, Mboverload, Mewtu, MichaelLefkowitz, Mintrick, Mortense, MrOllie, Mrzaius, Msnicki, Nan0bug00, Nanominori, NicM, NickGarvey, Nikai, Nimbex, NinjaCross, Ntsimp,
Article Sources and Contributors
283
Ohnoitsjamie, Omniuser, Oneiros, Owen, Oyd11, PAStheLoD, Pedant17, Pgilman, PhilippeAntras, Pmlineditor, Pottmi, Pozcircuitboy, RAdams, RE, Reikon, Remember the dot, Rezonansowy,
Ricordisamoa, Rlaager, Rprpr, SF007, Safalra, Sara wiki, Sbmehta, Shroffabhishek, Simoneau, Siruguri, Sladen, SlamDiego, Snori, SpaceFlight89, Srrrgei, Swat671, T34, THC Loadee, Tarquin,
Thaodan, TheIntersect, TheMuuj, Thiseye, Thumperward, Tobias Bergemann, Topbanana, Tyciol, Unity74, Unixguy, Vanessaezekowitz, Vivekmishra 100, Voomoo, Waded, Wailer, Warren,
Wikante, Wiknerd, WolfgangRieger, Xmoogle, Yrodro, Zazpot, 255 anonymous edits
uptime Source: http://en.wikipedia.org/w/index.php?oldid=598583755 Contributors: 16@r, AVRS, Adamorjames, Ahy1, Akolyth, Alaniaris, Alerante, AlistairMcMillan, Alnokta, Amigokin,
Apecat, Ardonik, Atleta.hu, Banjodog, Barrylb, Blaufish, Bushmeister, Callidior, Ccreighton, Cedar101, Chris Capoccia, Cmdrjameson, Courbd, Credema, Daverocks, DavidArthur, Davidmgray
de, Drmies, Ducknish, Dylan Lake, Dysprosia, EarthPerson, Echoray, Fergie4000, Frap, Fusionfoto, Gbeeker, George Shuklin, Ghettoblaster, Glenn, Graeme Bartlett, Grim23, Hafthor,
HappyInGeneral, Hashar, Havoyan, HitLines, Hm2k, Hostinghelp, Htmlland, Ignoll, Itsyousuf, Jafoman, Jleq, John Quincy Adding Machine, JonHarder, Jonomacdrones, Joy, Jpo, Kb, Kenyon,
Khazar2, Kincess, Kmweber, Kubanczyk, Kukini, Lcarsdata, Le ars, Liu Bei, Loadmaster, Lotje, Maury Markowitz, Mel Etitis, Merterhenz, Michael Hardy, MmGTi, Monkeyman, Neo139,
Nimphious, Nneonneo, Notheruser, Nuujinn, Onetuc, Osklil, Pariator, Penguin, Pete Broad, Picink, Pmsyyz, Pnm, Provider uk, Psb777, Pseudomonas, Psychonaut, Puttsy, Rich Farmbrough,
Rjwilmsi, Rmashhadi, Ruud Koot, Saturn49, Scriberius, Sean Kelly, Sfcatalan, Shadowjams, ShortBus, Sim tcr, SiuzannaV, Sohale, SolarisBigot, Stybn, Suso, T0ny, Taxman, Tentacleguy,
Theodolite, Twirligig, Ugnich Anton, Umutm, Unixguy, Uptimex, WCityMike, WakingLili, Walter Grlitz, WikianJim, William Avery, Woohookitty, Xaje, Zac67, Zazpot, 171 anonymous edits
talk Source: http://en.wikipedia.org/w/index.php?oldid=597812882 Contributors: 5 albert square, Alai, AlixMtl, Antandrus, Beland, BiT, Brion VIBBER, Btball, Ccrrccrr, Chaos5023,
Conversion script, Curps, Czarkoff, Discospinster, Djr xi, Druiloor, Epbr123, Esprit15d, Feezo, Figs, Filu, Gaurav, GeoffmTurner, Glenn, HighHopes, Hoshie, JHK, JYOuyang, Karnesky,
Kendroberts, Kertrats, Larry_Sanger, Lightmouse, Lotje, Maximus Rex, Miami33139, Milan Kerlger, Nbarth, Oldmanbiker, Orbixx, OrgasGirl, Patrick, Peter Winnberg, Phoenix-forgotten,
PseudoSudo, Quintote, R'n'B, Ra1n, Readro, Rich Farmbrough, Rjwilmsi, Rl, Rnt20, Robert Brockway, Sadads, Sietse Snel, Siodhe, Snori, Stefan Weil, Stinkyhobo321, Tempnegro3, Tempshill,
TheObtuseAngleOfDoom, Timwi, Tinus, Unixguy, Ventura, Wa3frp, Wasell, Wiki Wikardo, Ysyoon, 40 anonymous edits
Tput Source: http://en.wikipedia.org/w/index.php?oldid=591173973 Contributors: Abdull, Amorymeltzer, Frap, Ghettoblaster, Glenn, Jarble, Jfmantis, Jonathan de Boyne Pollard, Logiphile,
Martin Kealey, Mortense, Stevei, Techlivezheng, Tedickey, Thorwald, 5 anonymous edits
Uname Source: http://en.wikipedia.org/w/index.php?oldid=602121855 Contributors: Abdull, Absolwent, Agarvin, Charles Merriam, Christopher Mahan, CommonsDelinker, Cow2001,
Crispyslice, Deineka, Dori, Dysprosia, Eddie Nixon, Elandy2009, EncMstr, EoD, Everplays, Frap, Gavenko a, Gbeeker, Ghettoblaster, Glenn, GoingBatty, Golftheman, Guy Harris, Grkan
Sengn, Henk Langeveld, HopeSeekr of xMule, Hvn0413, Hyad, Jengelh, Jerryobject, Jesdisciple, JohnOwens, Joy, Kate, Larsinio, Marat Dukhan, Meebey, N1mie, Odalcet, Prabash.A,
Qwertyus, Rcsheets, RedWolf, Runlevel1, Scaredpoet, Scarpy, Scuppers, Sderose, Shamatt, Takeshita kenji, TakuyaMurata, Tetromino, ThePI, Themortal, Thumperward, TimBuchheim,
Towopedia, Typhoon, Tzafrir, Ugnich Anton, Ultrabill, Unixguy, Unixguy69, Unixi, Userw014, Vchapman, Welsh, Wik, Zundark, 84 anonymous edits
w Source: http://en.wikipedia.org/w/index.php?oldid=596917166 Contributors: Daemorris, Dingar, Dysprosia, Freakofnurture, Gf uip, Glenn, JackPotte, Konob5, Larsinio, Makaristos,
Psychonaut, Qquchn, RockMFR, Unixguy, Userask, Ysyoon, Zacatecnik, 2 anonymous edits
wall Source: http://en.wikipedia.org/w/index.php?oldid=576359243 Contributors: Amsvk, ApolloCreed, Benito, BiT, Bk314159, Crusoe8181, Deineka, Dingar, EdC, Glenn, JackPotte, Jfmantis,
Microsofkid, Queenmomcat, R'n'B, RockMFR, SlaveToTheWage, The Wednesday Island, Veritos, Wolfmankurd, 3 anonymous edits
who Source: http://en.wikipedia.org/w/index.php?oldid=584346745 Contributors: AVB, Asraam, BiT, Christopherlin, Csabo, DragonHawk, Druiloor, Dysprosia, EncMstr, Frap, Gf uip, Glenn,
HopeSeekr of xMule, Icoolucool, Katanzag, Ketiltrout, Larsinio, Makaristos, NapoliRoma, Tedickey, Thumperward, Turnstep, Unixguy, Vadmium, 40 anonymous edits
Whoami Source: http://en.wikipedia.org/w/index.php?oldid=564765189 Contributors: Amakuru, BiT, Deineka, DragonHawk, Frap, Gf uip, Ghettoblaster, Glenn, Hunterd, Idarwin,
Kl4m-AWB, LFaraone, Matthiaspaul, Mattventura, NeonMerlin, Poc, Psychonaut, Rich Farmbrough, Rmsuperstar99, RockMFR, Sisyph, Subanark, TheIntersect, Theunruled, , 17
anonymous edits
write Source: http://en.wikipedia.org/w/index.php?oldid=541380037 Contributors: Agarvin, Czarkoff, DNewhall, Dingar, Emperorbma, Esowteric, Frap, Gf uip, Ghettoblaster, Glenn,
Greatonixdragyn, Grendelkhan, JIP, Jandalhandler, Jfmantis, Kidane, Larsinio, Leksey, Microsofkid, Nn123645, Sadads, Snori, Strait, Tjwagner, Ugnich Anton, Unixguy, 10 anonymous edits
awk Source: http://en.wikipedia.org/w/index.php?oldid=597354578 Contributors: 4th-otaku, 96.186, AHMartin, Abu ali, Alan Millar, Altenmann, Amnonc, Andre Engels, AnonMoos, Ar283,
Atanamir, BD2412, Baconevi, Bdesham, Beinsane, Beno1000, Bevo, Binary.koala, Black Falcon, CFeyecare, Calid1984, Cameronc, CanisRufus, Captain Conundrum, Cedar101, Chealer,
Cheusov, ChrisGualtieri, Clefevre, Cmdrjameson, Cogiati, Conversion script, Cpiral, Cybercobra, Cyde, DNewhall, Danakil, Danallen46, Danfuzz, DavidDouthitt, Dawnseeker2000, Dcoetzee,
Demonkoryu, Drilnoth, Druiloor, Dulciana, Dustin gayler, Ebasconp, EdJohnston, Eeroh, ElBenevolente, Eluchil404, Emc2, Ems2, Ericamick, Erkcan, Falcorian, Foobaz, Gbeeker, Gf uip,
Ghewgill, Gilgamesh, Gioto, Glenn, GraemeMcRae, Gronky, Groogle, Guy Harris, Harald Hansen, HopeSeekr of xMule, Huibc, Huon, IntrigueBlue, Ispringer, Ithabitin, JLaTondre, Jarble, Jason
Quinn, Jerryobject, Jhart, Jonik, Jorge Stolfi, Kinema, Koavf, Kojot350, Komarov om, Krauss, Lee J Haywood, Lent, Lfwlfw, LinguistManiac, Lost.goblin, M7, Makaristos, Markhobley,
Markpeak, Masnevets, Materialscientist, Matt.forestpath, Mav, Mctpyt, MeekMark, Michael Hardy, Mike6271, Mikeblas, Mogigoma, MrKappa, MrWeeble, Msswp, NYKevin, Nanshu, Nbarth,
NipplesMeCool, Nixdorf, Nocturnalnerd, Npauljetpack, Nuno Tavares, Obuli, Od Mishehu, Omphaloscope, PGSONIC, Patrick O'Leary, Paul C. Anagnostopoulos, PauloCalipari, Perique des
Palottes, Pgan002, Pharaoh of the Wizards, Phil Boswell, Pmc, Prolog, Qwertyus, Ralph Corderoy, Reedy, Reuben.cornel, Ristonj, Rjwilmsi, Rockypedia, Romanskolduns, RuM, Ruud Koot,
Ryulong, SF007, Scythia, Sealican, Senator Palpatine, Shizhao, Shoffsta, Skew-t, Slashme, Sligocki, Snori, StDanielAllenPoe, Sun Creator, Taibah U, Tedickey, The morgawr, Thefourtheye,
Thereisnospoon, Timmenzies, Tobias Bergemann, Tobias Hoevekamp, Tom harrison, Tonydanza100, Tothwolf, Traroth, Trasz, Tsemii, Tweisbach, Two Bananas, Unixguy, Vanished user
ikijeirw34iuaeolaseriffic, Voomoo, Wasabi5, WhisperToMe, Wkoorts, Xojo, Yoshm, ZoeB, var Arnfjr Bjarmason, 227 anonymous edits
banner Source: http://en.wikipedia.org/w/index.php?oldid=594459513 Contributors: Cedar101, Cybercobra, Dthomsen8, Electron9, Frap, Fred Bradstadt, Fubar Obfusco, Glenn, Harmil, Hyad,
Larsinio, Macbookair3140, Materialscientist, Mikeblas, PseudoSudo, Randability, RockMFR, Strobie, Svick, Tofergregg, Uncle G, Unixguy, Varlaam, Vquex, Wspencer11, 10 anonymous edits
Basename Source: http://en.wikipedia.org/w/index.php?oldid=596111185 Contributors: Bomkia, Caerwine, Carpetsmoker, Chrisbolt, Deineka, Druiloor, EdC, Gf uip, Glenn, HopeSeekr of
xMule, Jamelan, Jengelh, Joseluisfb, Klemen Kocjancic, ML fan, Marudubshinki, Mcswell, Merphant, Najoj, RedWolf, Tcho, Tedickey, TheParanoidOne, WayneMokane, 17 anonymous edits
Comm Source: http://en.wikipedia.org/w/index.php?oldid=590617799 Contributors: Alansohn, Beland, Cedar101, CesarB, Discospinster, Druiloor, Geeklizzard, Ghettoblaster, Glenn, Gpvos,
HopeSeekr of xMule, Klemen Kocjancic, Linuxbeak, MaxEnt, Nightstallion, Peteforsyth, Raise exception, RedWolf, Snaxe920, Taibah U, Tedickey, Unixguy, ZeroOne, 26 anonymous edits
Csplit Source: http://en.wikipedia.org/w/index.php?oldid=537020046 Contributors: Jfmantis, Psychonaut, Thorwald
cut Source: http://en.wikipedia.org/w/index.php?oldid=598578143 Contributors: Andyluciano, Daniel Mietchen, Deepak J Shah, Eulerianpath, Fred Bradstadt, Gbatramhw, Gearhead Shem Tov,
Ghettoblaster, Glenn, GregorB, Heptite, HopeSeekr of xMule, Jamelan, Jonsafari, Juancnuno, Larsinio, Matma Rex, Mdarwin2003, Nbarth, Opticyclic, RedWolf, Rjwilmsi, RockMFR,
Runlevel1, Sjc, Strait, SuperJew, Tedickey, Thorwald, Unixguy, Viking59, Yangfl, 28 anonymous edits
Dirname Source: http://en.wikipedia.org/w/index.php?oldid=596111217 Contributors: Ailanto, Carpetsmoker, Druiloor, Gf uip, Glenn, Jengelh, Jfmantis, Joz3d, Revolus, 2 anonymous edits
ed Source: http://en.wikipedia.org/w/index.php?oldid=589835992 Contributors: -- April, .:Ajvol:., 128.12.93.xxx, 217.1.189.xxx, AlistairMcMillan, Apokrif, Arjayay, Ayengar, Bgcaus,
Bignose, Bomazi, Bovineone, Bryan Derksen, CYD, Cackletta76, CanisRufus, Cavrdg, Centrx, CesarB, Chocolateboy, Cimon Avaro, Conversion script, Curly Turkey, CyberSkull, DKqwerty,
Daf, Danceswithzerglings, Deineka, Denmon, Docu, Don4of4, Douglas W. Jones, Dougmerritt, Drj, Druiloor, Edward, Ellmist, Elwikipedista, Eric S. Raymond, ErkinBatu, Fraggle81, Gazpacho,
Geo Swan, Ghettoblaster, Glenn, Gmilza, Gnfnrf, Gpvos, Graham87, Helpsloose, HopeSeekr of xMule, IMneme, IanOsgood, Ich, InverseHypercube, Isilanes, Itai, Jahilia, JimD, Jleedev,
JoanneB, Johnmarkh, JustinForce, Kja98, Komischn, Letdorf, LodeRunner, Lost.goblin, MarkusHagenlocher, Marqueed, MasonM, Mav, Mic, Minghong, Monkeyblue, Moritz37, Mpj17, Mulad,
Nakon, Nyh, Pagrashtak, Pembers, Phpirate, Pixi, Polemon, Pred, Qwertyus, Rdsmith4, RedWolf, Reisio, Selig5, Shanes, Sharcho, Snori, Spalding, Stevertigo, Strait, Stubblyhead, Sushi Tax, The
Anome, TheJames, Thumperward, Tobias Bergemann, Tyler Oderkirk, Unixguy, Veledan, Vladashram, Weatherman667, Wwwwolf, Yonkie, Zoggie50, 95 anonymous edits
ex Source: http://en.wikipedia.org/w/index.php?oldid=596430766 Contributors: AhmadSherif, Berteun, Brujo, CesarB, DAID, Emperorbma, Gf uip, Glenn, GregorB, Gwern, Ixfd64, JYOuyang,
Jesse V., Joy, MathsPoetry, Milan Kerlger, Per Abrahamsen, PigFlu Oink, Plaes, Reisio, RockMFR, Sharcho, Sj, Ssd, Tedickey, Unixguy, Ww, Yath, 11 anonymous edits
fmt Source: http://en.wikipedia.org/w/index.php?oldid=300544842 Contributors: Abovelarge1, Afaber012, Asraam, BiT, Chris the speller, Christian Juner, Christian75, DataWraith, Deineka,
Dreaded Walrus, Druiloor, Favonian, Glenn, Lotje, Maxim Leyenson, NapoliRoma, Owain, Realwhz, Reisio, Svick, Termininja, Thorwald, Unconcerned, Watermellonman, 7 anonymous edits
head Source: http://en.wikipedia.org/w/index.php?oldid=593089727 Contributors: Asraam, Biot, Bruce1ee, Bryan Derksen, DGerman, Daniel.Cardenas, Deineka, Dispenser, Docu, Dysprosia,
Eddie Nixon, Gf uip, Glenn, HopeSeekr of xMule, Jamelan, Jni, Juancnuno, Larsinio, Lost.goblin, PGSONIC, Porges, RedWolf, Reedy, Salvatore Ingala, Stuart Morrow, Tedickey, Vclaw, 7
anonymous edits
Article Sources and Contributors
284
Iconv Source: http://en.wikipedia.org/w/index.php?oldid=580816662 Contributors: Abu ali, Anirvan, AnonMoos, CesarB, Cybercobra, Deineka, Earthengine, Eugene-elgato, Frap, Glenn,
Graham87, Guy Harris, HappyDog, IBlender, Japanese Searobin, KAtremer, Korval, Larsinio, Levin, Majumda, Mboverload, Plop, Pmsyyz, Power piglet, SKvalen, Sdteffen, Shandris,
Thumperward, Tizio, Trivelt, Unixguy, Vanished user 9i39j3, Wyrds, X-Fi6, YUL89YYZ, 32 anonymous edits
join Source: http://en.wikipedia.org/w/index.php?oldid=587714750 Contributors: BenJWoodcroft, Bryan Derksen, CesarB, ChP94, Dysprosia, ElBenevolente, Emperorbma, Frosty, Generica,
Ghettoblaster, Glenn, Gwern, Joy, Mark Renier, Maximus Rex, Read class, RockMFR, Sole Soul, Taral, Tizio, Unixguy, YUL89YYZ, 16 anonymous edits
less Source: http://en.wikipedia.org/w/index.php?oldid=591933401 Contributors: 16@r, 45054, Abdull, Alishahss75ali, Alksentrs, And3k, BiT, BlueAzure, Bruce1ee, DStoykov, David Gerard,
Deansfa, Deineka, Eadmund, Fiftyquid, GEUMUED, George1975, Ghettoblaster, Glenn, Gwern, Hede2000, HopeSeekr of xMule, Horselover Frost, Imamathwiz, Jeberle, Jhoyos, JoatOrion,
Joeknize, Joy, Juancnuno, Justynb, Kiore, Larsinio, Longhair, Lotje, MinorContributor, Mnudelman, Mwtoews, Myconix, Nbarth, Niteowlneils, Polluks, RockMFR, RokerHRO, SPUI,
Senkoshai, Spoon!, Stargazer7121, ThFabba, Tsman, Vanessaezekowitz, Vector Mike Bravo Sierra, Widefox, Zeromind, 50 anonymous edits
more Source: http://en.wikipedia.org/w/index.php?oldid=600321663 Contributors: 16@r, Agroten, Andewulfe, Bruce1ee, David Gerard, Eddie Nixon, Edward, Ghettoblaster, Glenn, Hede2000,
Imamathwiz, Jordandanford, Larsinio, Matthiaspaul, MinorContributor, Reisio, RockMFR, Switchercat, Voomoo, Wdaher, Widefox, Wikiloop, 14 anonymous edits
paste Source: http://en.wikipedia.org/w/index.php?oldid=580857428 Contributors: A2Kafir, Ahy1, Cybercobra, Deineka, Dmr2, Gbeeker, Glenn, Heptite, Jonbca, Jonsafari, Larsinio, Raphman,
Schuhpuppe, Sharcho, Sjc, Topbanana, Trivelt, Unixguy, 13 anonymous edits
Sed Source: http://en.wikipedia.org/w/index.php?oldid=601465445 Contributors: .:Ajvol:., 4C, Abdull, Acornett, Alansohn, Anclation, AnnaFrance, Anr, Antonielly, Awesomeshaq, AxelBoldt,
Bemoeial, Bevo, Bgwhite, Billposer, Bkkbrad, Bloupikkewyn, Bookandcoffee, BrucebWiki, Bryanlharris, CFeyecare, CanisRufus, CatherineMunro, Cedar101, CesarB, Cesarth, Coco, Codename
Lisa, Conrad.Irwin, Conversion script, Cowplopmorris, Cronos, D.robert.adams, Damian Yerrick, Daniel.Cardenas, Darkwind, Dcljr, Decltype, Demonkoryu, Deon Steyn, DerHexer, Dewritech,
Discospinster, Dispenser, Donkdonk, Droll, Dsm, EdC, Eloquence, Elsendero, Emperorbma, Eric Pement, Eugenwpg, Feezo, Fox Wilson, Frap, Frasar1234, Furrykef, Gaius Cornelius, Gareth
Griffith-Jones, Gaul, Gioto, Glenn, Greenleaf, GregU, GregUbben, Gronky, Gwern, Hairy Dude, Hirzel, HopeSeekr of xMule, Ida Shaw, Jason Quinn, Jeff3000, Jeronimo, Jni, John Price,
Johnmarkh, Jorge Stolfi, Jozef.sovcik, Jthill, Kertrats, Kgro, Kompik, Kpjas, Kwertii, Larsinio, Leemanning35, Lost.goblin, Lotje, Lulzmango, Lupinoid, MZMcBride, MagnaMopus, Manuel
Anastcio, MartinGallagher, Matthewdunsdon, Matthias Blume, Mchl, MeekMark, Mogism, Moskvax, Mysdaao, Nbarth, Neutrality, Ntsimp, PGSONIC, Patrick, Paxinum, Peterl, Piet Delport,
Plutoniumboss, Pne, Prolog, PseudoSudo, Quizzicus, RCX, RedWolf, Reisio, Rich Farmbrough, Rushbugled13, ST47, Sagaciousuk, Sakimori, Seans Potato Business, Serviscope Minor,
Shaliniverma21, SiriusB, Sjc, Snori, Stevertigo, Stj6, Sun Creator, SvendTofte, Tarquin, TedDunning, Tedickey, Tgkprog, The Anome, The Thing That Should Not Be, The Transhumanist,
Thumperward, Timmyc21, Timwi, Tobias Bergemann, Tom harrison, Tony Sidaway, Tritium6, Twanvl, Uncle G, Unixguy, Uriber, Vachigaggl, Vincenzo.romano, Vlad, Voomoo, W-C,
West.andrew.g, Wikante, Wikidrone, Yath, Zundark, 306 anonymous edits
sort Source: http://en.wikipedia.org/w/index.php?oldid=602272820 Contributors: BiT, Billposer, Cedar101, ChrisGualtieri, Fdleersn, Firsfron, Ghettoblaster, Glenn, Globaldomestic, Gwern,
Jasminek, Jjclarkson, Larsinio, Lent, Qwertyus, Revolus, Rhododendrites, RockMFR, Sbose7890, Shenme, Spoon!, Sven nestle2, T1750, Thorwald, Unixguy, Vadmium, Virendra, 28 anonymous
edits
spell Source: http://en.wikipedia.org/w/index.php?oldid=535023509 Contributors: AndrewWTaylor, Korrawit, Magioladitis, Nyh, PamD, Tedickey, 2 anonymous edits
strings Source: http://en.wikipedia.org/w/index.php?oldid=587646337 Contributors: Deineka, EdC, Eddie Nixon, Edurant, Frap, Glenn, Jamelan, Kl4m-AWB, Larsinio, Mdupont, Mikeblas,
O18, Pemu, RockMFR, Sanao, Synergy, Thorwald, Thumperward, Vadmium, Yngvarr, 4 anonymous edits
tail Source: http://en.wikipedia.org/w/index.php?oldid=577190502 Contributors: Alksentrs, Benash, Bkouhi, Bruce1ee, Chealer, DGerman, Danroa, Deineka, Dodo von den Bergen, Druiloor,
Eddie Nixon, Ejl389, Flok, Gf uip, Glenn, Gsharma081190, Hugo-cs, Intelliproject, Jamelan, Jjclarkson, Larsinio, Nurg, Pyerre, RevRagnarok, RockMFR, Salvatore Ingala, Shreevatsa, Tedickey,
Tony Sidaway, Ulric1313, Unixguy, 21 anonymous edits
tr Source: http://en.wikipedia.org/w/index.php?oldid=540874839 Contributors: Aarktica, Abdull, Absolwent, Anonymous Dissident, Antilived, BiT, Billposer, Bryan Derksen, Capricorn42,
Deineka, Glenn, GoodDay, Grendelkhan, Heptite, HopeSeekr of xMule, Iida-yosiaki, JLaTondre, Jamelan, Joy, Kbrose, L888Y5, Larsinio, LeilaniLad, Malleus Fatuorum, Maximus Rex,
MeekMark, Mortense, NickGarvey, Nightstallion, Otrfan, Pennstatephil, Ponder, Quasiscroto, RJFJR, RedWolf, Reisio, RockMFR, StaticGull, Svnpenn, Unixguy, 28 anonymous edits
Uniq Source: http://en.wikipedia.org/w/index.php?oldid=580967184 Contributors: Beland, Billyoneal, Brainfsck, ChrisGualtieri, Craftyminion, Deineka, Drj, Fdleersn, Flooey, Gazpacho, Gf
uip, Glenn, Gpvos, HopeSeekr of xMule, Hyad, JIP, Jamelan, Larry laptop, Mairi, Marudubshinki, Mikhail Ryazanov, Natalya, PierreAbbat, RedWolf, Rich Farmbrough, Rjwilmsi, Rkielty, Sjc,
Tedickey, Unixguy, 10 anonymous edits
Vi Source: http://en.wikipedia.org/w/index.php?oldid=601163258 Contributors: 10metreh, 4lex, 65.162.26.xxx, 66.8.50.xxx, Adam Newbold, Adam1213, Aeusoes1, Agarvin, Aisaac,
Akhristov, AlexLibman, Ancheta Wis, Andrew Rodland, Ansible, Antlersantlers, Apokrif, Apotheon, Ashdurbat, Atlant, Autopilot, Benwing, Betterworld, Bkell, Black Kite, Black Walnut, Bob
A, Boggie, Brad4321, Brighterorange, Bruno-me, Bubbl07, CFeyecare, Cameltrader, Cameron Scott, Carders, Cdean, Centrx, CesarB, Ceyockey, CharlotteWebb, Comp.arch, Conversion script,
Cornellier, Css, CyberSkull, DHN, DIG, Damian Yerrick, DangerousPanda, Danomagnum, David Gerard, Dawnseeker2000, Dcallen, Dcoetzee, Deflective, Dismas, Dlrohrer2003, DocWatson42,
Doceddi, Docu, DominicCronin, Don Quixote de la Mancha, Donfbreed2, Drj, Dtgriscom, Dysprosia, Edward, Ehamberg, Ellmist, Ericd, Erik Garrison, Faisal.akeel, Falcorian, Fang 23, Fbriere,
Feezo, FourWinds1111, Gazotz, Ghettoblaster, GhostPilot, Glenn, Golfandme, Graham87, GrahamDavies, Gronky, Guanaco, Gupdidi, Guy Harris, Gwen Gale, H2g2bob, Haeleth, Hairy Dude,
Hamster128, Hazard-SJ, Headbomb, Henrikholm, Henry W. Schmitt, Honta, HopeSeekr of xMule, Huihermit, Hvn0413, Hyad, Hydratab, IMneme, Ianking, Immunize, InverseHypercube,
Isilanes, Itai, JLaTondre, Jacekartymiak, Jakew, JamesBrownJr, Jj137, JohnChrysostom, Johnmarkh, Jonsafari, Jookti, JoshuaGolbez, Julesd, Karnesky, Kate, Kavera, Kazkaskazkasako,
Kieransmallbone, Kim Bruning, Kku, Kl4m-AWB, Koavf, Krsont, Kwamikagami, Leal Nightrunner, LeaveSleaves, Letdorf, Lifefeed, LilHelpa, LinkTiger, Ljfranklin, Loadmaster, Lupin, MCB,
Mahanga, Mako098765, Mardus, Matthew Woodcraft, Max Terry, Maxcantor, Mayank.jainn, Mboverload, Michael Hardy, Michael.Paoli, Michael.Urban, Millimon, Mindmatrix, Minghong,
Mjager, Mlewan, Mpol, Mrdanny99, Muskisold, Nanoatzin, Nate Silva, NawlinWiki, Neelix, NeilSantos, NewEnglandYankee, Ninedotnine 9.9, Ninly, Noldoaran, Norm mit, Oconnor663,
Ohconfucius, Ohnoitsjamie, Olexandr Kravchuk, Pamdirac, Paul Stansifer, Paulkramer, Pcb21, Per Abrahamsen, Personman, Pgf, Philip Torchinsky, Phlegat, Phoe6, Phpirate, Pile0nades, Pne,
Qwertyus, Ram einstein, Rdsmith4, Rebrane, RedWolf, ReyBrujo, Rich Farmbrough, Ross Burgess, RoyArnon, Sarefo, Scott w, Seb az86556, Shamanx, Shawn K. Quinn, Shoujun, SimonP,
Skarebo, SkonesMickLoud, Slaytanic-3, Smily6, SpaceFlight89, Spencer, Splibubay, Srjskam, Starnestommy, Stephenb, Storkk, Svick, Ta bu shi da yu, Tarquin, Technion, Tedder, Tedickey,
The Deviant, The Evil IP address, Thumperward, Timrollpickering, TinaSDCE, Tmmm, Tobias Bergemann, TobinFricke, Triddle, Tyomitch, Unforgettableid, Unixguy, Unnikuttan1990, Uriyan,
Uucp, Vadmium, Vermillion trade, Victor, Viznut, Vrenator, Wahkeenah, Wanted, Wavelength, Weedwhacker128, Wereon, Wernher, Wesley, Whbjr, Wolfrock, Yath, Yintan, Zundark, var
Arnfjr Bjarmason, 295 anonymous edits
wc Source: http://en.wikipedia.org/w/index.php?oldid=581785449 Contributors: 16@r, AlSweigart, Albmont, BiT, Bryan Derksen, CesarB, David Eppstein, Dodecki, EncMstr,
Flaming-tubesock, Gf uip, Glenn, Grendelkhan, HopeSeekr of xMule, Ikorolev, Jamelan, Jamesx12345, Joy, Larsinio, Marcok, MrOllie, Quuxplusone, Robert Illes, RockMFR, SpecMode,
Staszek Lem, Tedickey, Unixguy, Vidarlo, Yesval, Ysyoon, Z10x, 24 anonymous edits
Xargs Source: http://en.wikipedia.org/w/index.php?oldid=597642746 Contributors: AlanUS, Amroamroamro, Arkpog, Astatine, Avicennasis, Bdoserror, Bgwhite, Bomazi, Brw12, Bryan
Derksen, Cema, Dandv, Daranz, David Woodward, Debuti, Der Messer, Dmytro, Doboy0, Dragon695, Dsm08873, Efecanerdur, Efitu, Eggsyntax, Emre D., Enstatite, Faizan, Garandel, Glenn,
GoingBatty, HopeSeekr of xMule, John.james, Joy, Kareeser, Korath, MKC, Mairi, Mikeblas, Mortense, Mr walsh, Mulad, Musiphil, Ndemou, Northamerica1000, Nurg, OverlordQ, PenguiN42,
Pm215, Ralfoide, RedWolf, Reisio, Sam Hocevar, Second Quantization, Slashme, Snippy the heavily-templated snail, Spoon!, Svnpenn, Tange, Tedickey, TenPoundHammer, Thomas Bull,
Thorwald, Wernight, Wifione, Wilmoore, XTaran, 80 anonymous edits
alias Source: http://en.wikipedia.org/w/index.php?oldid=601604201 Contributors: Ah, AlexAndrews, Bkil, Carpetsmoker, Cedar101, Cmglee, Darkuranium, Diego Moya, Dolinsky296,
Druiloor, Dthomsen8, Eman2129, Feline Hymnic, Galaxia92, Gary, Gesslein, Ghettoblaster, Glenn, Johnnykimble, Jthestump, Larry V, MagnaMopus, Masterhaines, MrOllie, PCJockey, Pabouk,
Peter Grey, R'n'B, Riley Huntley, ScumCoder, Siodhe, Spoon!, Ssd, Svnpenn, Vidarlo, Voomoo, WangPublic, , 39 anonymous edits
echo Source: http://en.wikipedia.org/w/index.php?oldid=594308913 Contributors: 16@r, Abdull, Alerante, Anuradhamenon, Attys, Bkouhi, Cedar101, Colin Watson, DStoykov, Deineka, Gf
uip, Ghettoblaster, Glenn, Gwern, KevinFixesThings, Larsinio, Matthiaspaul, Matthus Wander, Michael Hardy, Mikeblas, Neelix, Nitroxxx, OlEnglish, Pne, RJFJR, Roue2, RoyBoy, Shlomif,
Sietse Snel, Strait, T0ny, Tedickey, Tisane, Unixguy, Valiumstash, Vezhlys, Wenli, ZeroOne, 43 anonymous edits
Expr Source: http://en.wikipedia.org/w/index.php?oldid=578352696 Contributors: Abdull, ChrisGualtieri, Dawnseeker2000, Dominus, Druiloor, EncMstr, Glenn, Gwinkless, Mark Arsten,
Outlyer, R'n'B, Reedy, Soulmerge, Yoderj, ZyMOS, 3 anonymous edits
Printf Source: http://en.wikipedia.org/w/index.php?oldid=456571588 Contributors: 16@r, 1exec1, Akihabara, AlexChurchill, AlistairMcMillan, Altenmann, Alvin-cs, Amd, AndrewHowse,
Andybuckle, Antonrojo, Aparecki, Aprock, ArsenalTechKB, Astatine, Audriusa, Az1568, B jonas, Bajsejohannes, BenRG, Betekenis, Bevo, BiT, Blaufish, Bradzo, Brendan642, Bryan Derksen,
Btx40, Bughunter2, Can't sleep, clown will eat me, Cedar101, Chitetskoy, Christian75, Colin Watson, Cybercobra, DGerman, Dalamori, Dampam, DanielWeinreb, Darrel francis, DavidCary,
Davidhorman, Dawdler, Decltype, DemonThing, Derek farn, Deryck Chan, Dinjiin, Dorotheus, Druiloor, Dtgriscom, Dysprosia, Ed Poor, EdC, Edward, Eli the Bearded, Evaluist, Evercat,
Article Sources and Contributors
285
Exelban, Fabio Gori, Finlay McWalter, Forderud, Frap, Fredrik, Free Software Knight, Furrykef, Fvw, Gareth Owen, George V Reilly, Ghiaurul, Gmwils, Graue, Grue, Gyopi, Hao2lian,
Happyrabbit, Hires an editor, Hu12, Iorsh, Isaac Dupree, JHunterJ, Jerryobject, Jimw338, Jni, Joe Decker, Johnuniq, Jokes Free4Me, Jonathan de Boyne Pollard, Jsd, Julian Andres Klode,
Juliancolton, Jwmwalrus, K12u, Lotje, M3tainfo, MarSch, Martnym, Masklinn, MattGiuca, Mcpancakes, Metricopolus, Michaeldadmum, Mobius, Mortense, Musiphil, Mwtoews, Mysidia,
N0YKG, Nancy, Nbarth, Nbertram, NevilleDNZ, Nevyn, New Thought, NewEnglandYankee, Nick Number, Nickgsuperstar, Nickj, Nikai, Nsda, Ofarook, Oneiros, OrangeDog, Ost316,
P100011011, PanagosTheOther, Pedant17, Pepsi Lite, Personman, Plugwash, Rbonvall, Reedy, Richfife, Royote, Runtime, Sbmeirow, Schoen, Shellreef, Sikon, SimonP, Siodhe, Spitzak, Spoon!,
Steev42, Surachit, TSylvester, Tiny plastic Grey Knight, Tobias Bergemann, Tommy2010, Tony Sidaway, Uninverted, Uppe, Uppfinnarn, Vadmium, Valandilalandil, Vieque, Virtuald, Volfy,
WISo, Wavelength, William Allen Simpson, Yellowdesk, Zachlipton, Zanthra, Zapodot, Zoonfafer, Zvn, 222 anonymous edits
sleep Source: http://en.wikipedia.org/w/index.php?oldid=591709763 Contributors: BWDuncan, Cogburnd02, David Carron, Deineka, Dingar, Emersoni, Fang Aili, Gamaliel, Ghettoblaster,
Glenn, Hyju, Larsinio, Loadmaster, M gol, Melaen, Nlitement, PseudoSudo, RockMFR, Tarret, Towel401, Twinxor, Ugnich Anton, Unixguy, Xtremejames183, Zotel, 15 anonymous edits
test Source: http://en.wikipedia.org/w/index.php?oldid=599842840 Contributors: Abdull, Anonymous Dissident, Apokrif, AzaToth, BsBsBs, Cedar101, ChP94, Colin Watson, Deineka, Dpv,
Druiloor, Electron9, Emre D., Ezeu, Gbeeker, Glane23, Glenn, Grendelkhan, J.delanoy, Jason Quinn, LFaraone, LennyCZ, LeoNomis, Loadmaster, Matthewrbowker, MrOllie, Murukeshm,
Noommos, OlEnglish, PigFlu Oink, R'n'B, Reisio, Rockfang, Schewek, Spartas, Stephenb, Svend, TheMadBaron, Trasz, TuukkaH, Unixguy, Vieque, WikHead, 54 anonymous edits
true and false Source: http://en.wikipedia.org/w/index.php?oldid=592865487 Contributors: Abdull, Amr.rs, Apokrif, Bgwhite, Brian R Hunter, CBM, Carpetsmoker, Cedar101, Colin Watson,
DaBler, Deineka, EdC, Fievarsty, Fixman, Giftlite, Glenn, Kephir, LodeRunner, Magioladitis, Me and, MeekMark, Michael Hardy, My another account, Oleg Alexandrov, PauloCalipari, R'n'B,
RossPatterson, Strait, Tedickey, The Evil IP address, Timwi, Tizio, Trasz, Ttwo, Vadmium, Winterst, Zak9876, 12 anonymous edits
Unset Source: http://en.wikipedia.org/w/index.php?oldid=556972884 Contributors: Abdull, Chowbok, Deineka, Druiloor, Frap, Gf uip, Glenn, Heptite, Jeandr du Toit, Larsinio, Longhair, Lus
Felipe Braga, Rbrwr, Sbowers3, 9 anonymous edits
wait Source: http://en.wikipedia.org/w/index.php?oldid=541334262 Contributors: BWDuncan, ChP94, Cravix, Deineka, Dingar, EdC, Gf uip, Ghettoblaster, Glenn, I do not exist, JackPotte,
Khoikhoi, Larsinio, Loadmaster, PartyC9, Rosenbluh, Tony Sidaway, Voomoo, 9 anonymous edits
yes Source: http://en.wikipedia.org/w/index.php?oldid=593341626 Contributors: Ben Ben, Bkouhi, CPColin, CyberSkull, Dakoman, DennisTheTiger, Deyyaz, Dyaa, Dysprosia, EALacey, EdC,
Gbeeker, Hairy Dude, Hyad, Jfmantis, Kenny Strawn, Mairi, Mboverload, Oliver Crow, RockMFR, Skagedal, Spoon!, Tcho, Tedickey, The Fish, Thumperward, Ttam, Tuomok, Twinxor,
UkPaolo, Unixguy, Yakiv Gluck, 20 anonymous edits
dig Source: http://en.wikipedia.org/w/index.php?oldid=497756641 Contributors: 16@r, Adrian13, Anwarrhce, Axonizer, Bongwarrior, Boredzo, Cybjit, DGerman, Deineka, GGShinobi,
Gawaxay, Grawity, HLHJ, Hm2k, JackPotte, Johnnykimble, Jonasmike, Kansal15, Kbrose, Kjkolb, Langpavel, MalcolmScott, Matj Grabovsk, Mindmatrix, Nockerbk, Rsduhamel, Sadeq,
ShelfSkewed, Timarcher52, Widefox, Wrs1864, 32 anonymous edits
Inetd Source: http://en.wikipedia.org/w/index.php?oldid=602435567 Contributors: Ale2006, AlistairMcMillan, Apeiron, Bisyork, Chbarts, Druiloor, EagleOne, Emperorbma, Equendil,
Fleminra, Fluzwup, Glenn, GregorB, J Clear, JJuran, Jamelan, Ketiltrout, LFaraone, Lightdarkness, Mipadi, Mortense, Musiphil, Napalm Llama, P0lyglut, PseudoSudo, Qbeep, Rurik, Scientus,
SeanTater, Sietse Snel, Stormie, TheJJJunk, TheParanoidOne, Thumperward, Tothwolf, Unixguy, Widefox, Wiki104, 32 anonymous edits
host Source: http://en.wikipedia.org/w/index.php?oldid=580034584 Contributors: ChrisGualtieri, Exxolon, Frap, JackPotte, MuffledThud, ShadowRangerRIT, Suhanashiyas, 4 anonymous edits
Ifconfig Source: http://en.wikipedia.org/w/index.php?oldid=602102730 Contributors: 32RB17, Ackepenek, Adavidb, AlistairMcMillan, Amcfreely, AzertyFab, Ben Ben, BenM, BiT,
Brianseeders, CanisRufus, ColinHogben, Da Vandal 1.17, Daniel Roethlisberger, Darklilac, Fiftyquid, Franl, Glenn, HappyDog, Helix84, Houseofhack, Ifconfig, Ifconfiginfo, Jake Nelson,
Jengelh, Jglyon, Jonasmike, Joy, Kbrose, Kim Bruning, KnightRider, Manny1208, Materialscientist, Michael Hardy, Mrzaius, NapoliRoma, Pedant17, Pengu, Pnm, Popelin, Reisio, Rich
Farmbrough, Ronz, Rror, ScotXW, Sebastian Goll, Speck-Made, Strcat, Syscomet, Tcsetattr, Thumperward, TinaSDCE, Trasz, Trixx, Unixguy, Userask, Vapier, Vidarlo, Voidgk, Yvtong, 63
anonymous edits
Netstat Source: http://en.wikipedia.org/w/index.php?oldid=600564807 Contributors: Akhristov, Apokrif, Astralune, Banej, Baseballfan, Bear475, BeatYou, Beetstra, BiT, Blue Em, Callidior,
Coderzombie, Csabo, Cwolfsheep, DKqwerty, Dananderson, DavidDHaese, Dharris, DirkvdM, DoriSmith, Dysprosia, Ebraminio, EdgeOfEpsilon, Electracool, Frankenpuppy, Frap, Fresheneesz,
George Steinmetz, Ghettoblaster, Glenn, Guy Harris, H3llbringer, Hemalrana, Hiro42, I dream of horses, Icos, JLaTondre, Jabowery, Jamelan, James eite, Jcvamp, Joy, Katieh5584, Kephir,
KnightRider, Knudvaneeden, Krellis, Larsinio, Luisramos0, Magioladitis, MattGiuca, Milan Kerlger, Mortenoesterlundjoergensen, Nick Number, Nurg, Oleg Alexandrov, Phatom87, Pmsyyz,
Pradeepsomani, Prashantgupta, RatOmeter, Robert Weemeyer, RyanDolan123, SJK, SeanJames44, Siodhe, Slakr, Sourcejedi, Srasku, Srdemircan, Strcat, Surv1v4l1st, TheGeneralUser,
TheParanoidOne, Thumperward, Trasz, Treekids, Userw014, Warren, Who, WikiJuggernaut, Willlsteele, Ysangkok, 85 anonymous edits
Nslookup Source: http://en.wikipedia.org/w/index.php?oldid=592626088 Contributors: 15turnsm, A3r0, Aapo Laitinen, AlistairMcMillan, AnK, Arthena, Arvindn, Bastique, Betacommand,
Bob Stein - VisiBone, Bookofjude, Chowbok, CrownedEagle, DNSstuff, DarlArthurS, David.pitt, Deineka, Dispenser, Elvey, Femto, Flyingtoaster1337, Gareth Griffith-Jones, Gdr, Gf uip,
Ghettoblaster, Glenn, Hksamuello, Hm2k, Hgsippe Cormier, Imroy, JackPotte, Jengelh, Jesse Viviano, Jhawkinson, Jitaaa89, JonHarder, Jonathan de Boyne Pollard, KAtremer, Kbrose, Ksid,
Kusma, Langpavel, Michael Bednarek, Mindmatrix, Mortense, Mvgfr, Netsnipe, None but shining hours, Nurg, Omar35880, P0per, Plasticup, Pmsyyz, Rantsroamer, Rich Farmbrough, Rjwilmsi,
Ronmore, Schapel, Scouten, Spoon!, Steveprutz, THEN WHO WAS PHONE?, Terrible Tim, That Guy, From That Show!, TheParanoidOne, Uncle G, Varlaam, Voidvector, Webmaster4india,
Whippen, Yaronf, 98 anonymous edits
Ping Source: http://en.wikipedia.org/w/index.php?oldid=601538479 Contributors: A bit iffy, AThing, AddWittyNameHere, Ahoerstemeier, Anomalocaris, Aydee, B7T, B9 hummingbird
hovering, BarrelProof, Bcnstony, Bobblehead, Borgx, BrianMakesEdits, Bryan Derksen, C628, Capricorn42, Carolfrog, Chriswaterguy, Clarityfiend, Codename Lisa, Cybernetichero, Dawud,
Deskana, Donner60, Dresdnhope, Edchi, Edward Z. Yang, Everyking, Ezeu, Favonian, Florian Blaschke, Flowerparty, Fluzwup, Foetusized, Gary, Gene Nygaard, Gilliam, Gobonobo, Grunt,
Hereticam, Imwritinganovel, InkQuill, Interiot, J3ff, Jed2347, Jirii, Joaquin008, JoeMK, Kadiation23, Kusma, LGagnon, Lapin rossignol, LittleWink, Maerk, Manuelhp42, Mark Schierbecker,
Mike Rosoft, Mormegil, Mr. Lefty, Muchness, Mulad, Mungs, Nick R Hill, NickD, Nono64, Nv8200p, Nycmstar, O18, Ojw, Omicronpersei8, Pne, Pratyya Ghosh, Real decimic, Rjanag,
Rjwilmsi, Robertmerrill, Scarlettail, Scheinwerfermann, Sdgjake, Securel, Snarius, Stoneage113319, Thingg, Tikiwont, Tomchiukc, Torchpratt, Umeboshi, Usgnus, VegKilla, Weppos,
Whitejay251, Widefox, Xyzzyplugh, , 99 anonymous edits
Rdate Source: http://en.wikipedia.org/w/index.php?oldid=601247611 Contributors: Arafel2, Audriusa, Fabrictramp, Jim no.6, Kbrose, Melancholie, Widefox, 2 anonymous edits
Rlogin Source: http://en.wikipedia.org/w/index.php?oldid=571061960 Contributors: Ahoerstemeier, Beno1000, Bryan Derksen, Byrial, CanisRufus, DeadEyeArrow, Delirium, Deville,
Emperorbma, Equendil, Finlay McWalter, Gardar Rurak, Glenn, Grawity, Hammadi2100, HopeSeekr of xMule, Itai, JTN, Janizary, Jebba, Jlehen, Josephf, Mikeblas, Mwtoews, Pearle, RedWolf,
Sbmeirow, Strait, Thue, Thumperward, Vincenzo.romano, Widefox, Wknight94, Wrs1864, 24 anonymous edits
Netcat Source: http://en.wikipedia.org/w/index.php?oldid=601336267 Contributors: Akb4, Andreas Bischoff, Antaeus Feldspar, Apnicsolutions, Axonizer, Bamed, Bauani, Bonadea,
Bruceblacklaws, Byrial, CL, Calaka, CanisRufus, Carnesc, Chealer, Claym001, Crh0872, DARTH SIDIOUS 2, Diblidabliduu, Diegocr, Djmckee1, Druiloor, EagleOne, Efa, Ellmist, Episiarch,
Family Guy Guy, Feezo, Frap, Frencheigh, Furrybeagle, Gareth McCaughan, Geir3542, Glenn, Gnot, H2g2bob, HopeSeekr of xMule, Incnis Mrsi, Inductiveload, Interiot, Isilanes, IttanZ, Itu,
Jesse V., Jesset77, Jimfbleak, John Vandenberg, Johnanth, Joy, KTC, Kace7, Kalsira, Khatru2, Kl4m-AWB, Kundor, Lorn, Mamaoyot, Mindmatrix, Mortense, Myleslong, Netol, Nnkx00, Nohus,
Oracle Techie, Pavlixnet, Pmj005, Polluks, Pradameinhoff, Priyeshgpatel, Prolog, PuerExMachina, Qartis, Qbeep, Rchandra, Redraiment, Remember the dot, Rjwilmsi, Romanc19s,
Rosslagerwall, Rousselmanu, Rurik, SPUI, Saifikhan, Samermaz, Scwerllguy, Sietse Snel, SmitherIsGod, Smurfix, Sockseh, Stephan Leeds, Sverdrup, Svick, SymlynX, Techtonik, ThG, The
imp, TheParanoidOne, Thorwald, Tobias Bergemann, Tomalak geretkal, Twindruff, Vadmium, Voomoo, Welsh, Widefox, Wiebel, Wikipiero, Wrs1864, Xrblsnggt, Zero Thrust, `Orum, 238
anonymous edits
ssh Source: http://en.wikipedia.org/w/index.php?oldid=599838379 Contributors: ++Martin++, 5T111S29, Ahoerstemeier, Ahsen, Ahunt, AlistairMcMillan, Alonbl, Anshelm, Aquatics, Arcade,
Argav, B4hand, Balder de Odin, Bgibbs2, Bgwhite, BiT, Bignose, Bolwerk, Bookofjude, Bovineone, Byrial, CanisRufus, Chealer, Chowbok, ChrisRuvolo, Cmgross, Code65536,
CommonsDelinker, Danny, David Gerard, Dcirovic, Deeahbz, Den fjttrade ankan, Derek R Bullamore, Djmdjm, Doradus, Dugosz, Earthpigg, Edward, Efa, Ekafem, Ergil, Evice,
FlashSheridan, Fleminra, Frap, Generic Player, Gidoca, Gioto, Gosub, Graham87, Grazer, Gronky, Gurch, Guy Harris, Hagedis, Hawk777, Henryk Pltz, Hlein, ICEAGE, Inquam, Isilanes, JTN,
Janizary, Jarble, Joe Jarvis, John Vandenberg, JonHarder, Jonkerz, Joy, Juhtolv, JzG, Karam.Anthony.K, Karnesky, Kawana, Kentborg, Kenyon, Kgfleischmann, Kim Bruning, Kl4m-AWB,
Koavf, LFaraone, Lee Daniel Crocker, Ligulem, Lucero del Alba, MK8, MPerel, Magioladitis, Mark Bergsma, Mark Richards, Matt Crypto, Mblumber, Meandtheshell, Melancholie, MikeRS,
Mindmatrix, Morisien, Moulding, Netanel h, Nevyn, NicM, Nrwilk, Ntsimp, Nunojpg, Olivier, Oneiros, Openbsd.as.a.desktop, Ozguroot, P0lyglut, Palosirkka, Patrias, Paulbayer, Pearle, Peter
Winnberg, PhilipMW, Pyav, Pyro3d, RandalSchwartz, Reedy, Reid, Rich Farmbrough, Rjwilmsi, Rvalles, Rzoch, SURIV, Scientus, Skeezix1000, Sn1per, SolarStarSpire, Sorset,
SuburbaniteFury, Terence626, Tero, Tevkar, The Anome, Thewikipedian, Thumperward, Tianjiao, Tobias Bergemann, Tobias Hoevekamp, Tony Sidaway, TonyW, Tothwolf, Valodzka, Vlad,
Voomoo, Voorlandt, Wik, Wilbern Cobb, WojPob, Writermonique, XDanielx, Xan2, YannTech, Yrithinnd, 112 anonymous edits
Article Sources and Contributors
286
Traceroute Source: http://en.wikipedia.org/w/index.php?oldid=597207081 Contributors: A876, Aapo Laitinen, Abhisatya, Adrian13, Aegicen, Akrycek, AlisonW, AlistairMcMillan,
Anastrophe, AndreasWittenstein, Anon user, Ayeowch, Beland, Bilbo1507, Blaxthos, Bonadea, Borgx, Breante, Briansp, Burn, Calvin08, CanisRufus, CardinalDan, Cbustapeck, Cherkash,
Chmarkine, Ciscozine, Codename Lisa, Conversion script, Cosmonaut3030, Cybjit, D0762, DGerman, Dawnseeker2000, Denelson83, Digital infinity, Dionyziz, Dman727, Dnas, Druiloor,
Dsimic, Dusti, Dysprosia, Ebraminio, Eeekster, Electron9, Equendil, Er.punit, ErikStewart, Favonian, Femto, Finlay McWalter, Fl, Freshacconci, Fresheneesz, GDR!, Gary, Ghettoblaster,
Gilliam, GoShow, GoingBatty, Gurch, Guy Harris, Haakon, Harryboyles, Hm2k, Htaccess, Ibc111, Intgr, Ixfd64, Jahoe, JamesBWatson, Janaagaard, Jhawkinson, Jmath666, Johnuniq, JohnyDog,
JonHarder, Josefnpat, Jovianeye, Joy, Jrash, Kathleen.wright5, Kbh3rd, Kbrose, Kgfleischmann, Khalid hassani, Kooo, Kotasik, Krich, Larsinio, Lcarsdata, Lightmouse, LimoWreck, MJaap,
MKoltnow, MSTCrow, Mark Arsten, Martijn Hoekstra, Massysett, Materialscientist, Matt.T, Mdwyer, Meco, MessiFCB, Mike the k, Mion, Moltonlava, Mooses, Mortein, Mortense, Mylogon,
Nabber00, Nikai, Nikolas Karalis, Nimiew, Northumbrian, Oli Filth, Ott, Peruvianllama, PeterBrooks, Pgan002, Philip Trueman, PierreAbbat, Pine, Playphil, Pwforaker, Quuxplusone,
Rajrajmarley, Ramorum, RedWolf, Richman35, Rlcw0630, Robocoder, RockMFR, Rotationx, Rowan Moore, Ryanmshea, Salinix, Samdutton, Sdfisher, Shaggyjacobs, Shierro, Shii, Sietse Snel,
Skarebo, Slogsweep, Snoyes, Spasemunki, Sreeji, StephenFalken, Stepshep, Strcat, T23c, THEN WHO WAS PHONE?, Tagishsimon, Tasior, Template namespace initialisation script, TheJJJunk,
Themfromspace, Thenor, TheoryCloud, Thomas Springer, TimurFriedman, Todd Peng, Trismegister, Versus22, Vieque, Vikasminda, Viritrudis, Warren, Wes!, Weyes, Weylin.piegorsch, White
rotten rabbit, Widefox, WikiJackool, Wrs1864, Wtmitchell, Yappy2bhere, Yath, Zeno Gantner, , 274 anonymous edits
Find Source: http://en.wikipedia.org/w/index.php?oldid=601892330 Contributors: 16@r, Ajaxfiore, Anonymous Dissident, Aoidh, B k, Bkell, Brianreading, Bruce1ee, Carrasco, Ccyber5,
Cedar101, Cmjrees, Corti, Daniel.Cardenas, Dappaduppa, Daveliney, Devtakh, DollarQube, EdC, Emilyjiajia, Emre D., Evercat, Evlekis, Fivemack, Gaius Cornelius, Gbeeker, Ggrab,
Ghettoblaster, Glanis, Glenn, GregorB, Griselda79, HarryCane, Herpingdo, HopeSeekr of xMule, IEEE, IEEE, Iansteiner, Ikorolev, Incu, Jamelan, Jevansen, JonHarder, Jonnat, Joy, Justrick,
Kha0sK1d, Lectonar, Lolzer20, Lost.goblin, Lsloan, Lueckless, Lunchsure, MSMayo, Mastinder, Materialscientist, Mattcobb, Me and, Methecooldude, Minna Sora no Shita, Mortense, MrOllie,
MrTree, Mumuwenwu, Neuguotd, Norm mit, Nurg, Pavel Ozogn, PuerExMachina, Qwertyus, Relszot, Remag Kee, Rice Yao, Rmallins, Sapoguapo, Shamatt, Shriram, Siodhe, Snodnipper,
SpeedyGonsales, Spoon!, Stevertigo, Stimpak, Strait, Tedickey, Telewatho, TheOpenFreeFan, TitusD, Tizio, Tobias Bergemann, Tommy2010, Unixguy, Vidarlo, Vt5491, Wikiloop, Xtyangjie,
Yath, Yuvraj3010, x, 139 anonymous edits
Grep Source: http://en.wikipedia.org/w/index.php?oldid=602489612 Contributors: .:Ajvol:., Adam Knox, Adamhauner, Adil mujeeb, Adrianwn, Adys, Ajaxfiore, Angela, Aoidh, Argaen, Art
LaPella, Asmoore82, Asukite, Attys, Aude, Austin Hair, Av, Banej, Bearware, Benc, Bevo, Billposer, Bkell, Brianski, CRGreathouse, Cdwn, Cedar101, CesarB, CharlesC, Chomwitt, Chowbok,
Corti, Crebert, DNewhall, Darkone, Dcoetzee, Deineka, Denisarona, Dennis714, Diomidis Spinellis, Dlrohrer2003, Dominus, E2daipi, Edward, EivindJ, ElementFire, Elsendero, Ember of Light,
Emvee, Eric B. and Rakim, Evercat, Fangz, File Not Found, Foxwolfblood, Frap, Fromgermany, Fubar Obfusco, Func, Geoffrey, Ghettoblaster, Glenn, Gogobera, Gomez3000adams, Gronky,
Gsharma081190, Guaca, Gwern, Haham hanuka, Hairhorn, Hairy Dude, Harmil, Hede2000, Hello71, HopeSeekr of xMule, Howardjp, Howcheng, Hyad, Ikorolev, Isilanes, JLaTondre, Ja 62,
JackPotte, Jdimpson, Jengelh, Jmahood, Jni, Johnmarkh, Joshome4489, Juliensorelnyc, Justinc, KAtremer, Kaie, Karelj, Kbolino, Kbrose, Kgaughan, Kimiko, Kl4m-AWB, Korg,
Kristjan.Jonasson, Kx1186, L Kensington, LOL, Lent, Letshaveanadventure, LilHelpa, Lost.goblin, M. B., Jr., MER-C, MagnusA, MattieTK, Mattworld, Mbroshi, Michael B. Trausch,
MikeVitale, Milindz, Mindmatrix, Minijooj, Minimac, Mksrg, Moreschi, MrOllie, Nbarth, Newmanbe, Ngavarta, Nyxos, Panozzaj, PerryTachett, PierreAbbat, Piet Delport, Plamoa,
Potatoswatter, PrimeHunter, Prosfilaes, Proxyma, PseudoSudo, Rbarreira, RedWolf, Requestion, Rjwilmsi, Root4(one), Rootless, Runlevel1, SaschaKuehl, Sengork, Shoeofdeath, Silvonen,
SimonP, Spearhead, SpeedyGonsales, SqueakBox, Staszek Lem, Subfader, SummerWithMorons, Svick, TCN7JM, Tarquin, Tedickey, The Evil IP address, Thumperward, Tintamarre, Tommyjb,
Toussaint, TreyHarris, Tului, UnHoly, Uncle G, Unixguy, Uzma Gamal, Vadmium, Wereon, Winterst, Witharebelyell, Wnt, Worrydream, Wthrower, XJaM, Xoddf2, Xpi6, Yrithinnd, Zanaq,
Zenohockey, Zondor, 270 anonymous edits
locate Source: http://en.wikipedia.org/w/index.php?oldid=600246934 Contributors: 16@r, A5b, Aleksio, Biscuittin, Brz7, Christian75, DNewhall, Glenn, Hughcharlesparker, Kathleen.wright5,
Liangent, Marokwitz, MrBlueSky, NeonMerlin, Playstationman, PrimeHunter, Psychonaut, PuerExMachina, Spoon!, Tobias Bergemann, Winterst, Ysyoon, x, 12 anonymous edits
Whatis Source: http://en.wikipedia.org/w/index.php?oldid=602042323 Contributors: Abcjared, Adkapx, Glenn, Rich Farmbrough, 4 anonymous edits
Whereis Source: http://en.wikipedia.org/w/index.php?oldid=574269542 Contributors: AManWithNoPlan, Cedar101, Fcn, FranklinPiat, Glenn, Jfmantis, Loop202, Mild Bill Hiccup, Sisyph, 4
anonymous edits
which Source: http://en.wikipedia.org/w/index.php?oldid=572658068 Contributors: Aarktica, Aubergene, Baristarim, DE, FranklinPiat, Glenn, Graham87, HelgeHan, Mortense, Mwtoews,
Polluks, Spartaz, Unconcerned, Vadmium, WikHead, 6 anonymous edits
apropos Source: http://en.wikipedia.org/w/index.php?oldid=566050920 Contributors: AoV2, Csigabi, Glenn, Jeffdcooper, Lee Carre, Sofakingon, Thorwald, 4 anonymous edits
help Source: http://en.wikipedia.org/w/index.php?oldid=602513621 Contributors: Bevo, Cedar101, Chris857, Dolescum, Epbr123, Franamax, Ghettoblaster, Hameras, Indeed, Jfmantis,
Matthiaspaul, OlEnglish, Propeng, Solidwings1256, The Mag Gab 2012, The lolololol, Wbm1058, Zzomtceo, 16 anonymous edits
info Source: http://en.wikipedia.org/w/index.php?oldid=591222796 Contributors: Dylan Lake, Echosmoke, Edward, Frap, Isilanes, Janek Kozicki, Jfmantis, Katanzag, Kl4m-AWB,
Msreeharsha, Niculecchio, Phoz, Rrostrom, Rtc, Sderose, Thumperward, Zearin, 8 anonymous edits
man Source: http://en.wikipedia.org/w/index.php?oldid=598641122 Contributors: AVB, Abdull, Admrboltz, Aervanath, Agarvin, Alf7e, AndyHe829, Andyluciano, Atlant, B4hand, Bevo,
Bidgee, Buzzbo, C. A. Russell, Chealer, Chengiz, ChrisGualtieri, Codex24, Conan, Cy21, CyberSkull, DAGwyn, Daedalus-Prime, Damian Yerrick, Dekart, Diberri, Dingar, Dkasak, EdC,
Edcolins, Edward, Egil, Eli the Bearded, Elzbal, Emperorbma, Everyking, Fluff, Fluffy 543, Frap, Freakinbock, Gary, Ghettoblaster, Glenn, Graham87, Graue, Guy Harris, Haakon, Hede2000,
Heron, Hgrosser, Horovits, Huihermit, Isaac Rabinovitch, Jarble, Javifs, Jeffq, Jerome Charles Potts, Jfmantis, Jgrahn, Jic, JohnnyMrNinja, JorgePeixoto, Joy, Jsnx, Juhtolv, Kingoftherings, Ksn,
LAMurakami, LOL, LVC, Larsinio, LeeHunter, Lindberg G Williams Jr, LinuxSneaker, Lost.goblin, Lucifred, MarkMLl, Markhobley, Marudubshinki, Massysett, Mieciu K, MikeRS, Mikeblas,
Morte, MrOllie, MureninC, My name is not dave, Narendra Sisodiya, Newmanbe, Nfearnley, Npnguy, Nsda, Ohnoitsjamie, Owain, Palthrow, Panarjedde, Pascalv, Perique des Palottes, Peter L,
Pharos, Pieleric, Pooryorick, Prara, Psychonaut, Quuxplusone, Qwertyus, Raymond Pasco, Reisio, Rich Farmbrough, Ringbang, Rnabioullin, Robert Merkel, Rocket2DMn, Rpop, Sicking,
Snydergc, SonicTheHedgehog, Squids and Chips, Stassats, Stefano85, SteveBaker, Tanguy Ortolo, Technion, Tedickey, Teratornis, The Thing That Should Not Be, Theusername, Thumperward,
Timtrent, Torywhe, Uncle G, Unixguy, Voomoo, Vosteam, Wonderfl, Yath, Yutsi, Zoicon5, , 112 anonymous edits
bc Source: http://en.wikipedia.org/w/index.php?oldid=551529924 Contributors: Abdull, Alan De Smet, AndrewHowse, Anthony Appleyard, Ary29, BRPXQZME, Bratch, CRGreathouse,
Carel.jonkhout, Cedar101, Cyrek, Danakil, Dantheox, Dbenbenn, Dispenser, Dominus, Drilnoth, Druiloor, Edward, Emperorbma, Farbicky, Filu, Flyer22, Gesslein, Ghettoblaster, Glenn,
Graham87, HopeSeekr of xMule, Hu12, Ian13, Int21h, InverseHypercube, J'raxis, JaGa, Jarble, Jdm64, Jesdisciple, Kallikanzarid, Kirananils, Lovek323, Lpele, Massysett, Michael Hardy, Mild
Bill Hiccup, Mpaget, Nagy, Niksoft, Nsgb, Nyh, Pnm, Ralph Corderoy, RealSebix, Reedy, Ronz, Shibboleth, Sixt06, Spearhead, Spiel496, Sukiari, Template namespace initialisation script,
Thegeneralguy, Udo.bellack, Unara, Vanished user 34958, Zero Thrust, ZeroOne, Zoicon5, Zorakoid, 69 anonymous edits
dc Source: http://en.wikipedia.org/w/index.php?oldid=250281997 Contributors: A.Ou, Ahy1, Autopilot, Cedar101, Conrad.Irwin, Danakil, Derek farn, Dicklyon, Gadfium, Gaius Cornelius,
Gioto, Gronau, Homerjay, HopeSeekr of xMule, Itai, Jamiemichelle, Jfmantis, Michael Hardy, Nickj, Nikevich, Palosirkka, PhilipMW, Pm215, Polluks, RedWolf, Revolus, Shandris, Sydius,
TimBentley, Tobias Bergemann, Voidxor, Wprlh, ZeroOne, 46 anonymous edits
cal Source: http://en.wikipedia.org/w/index.php?oldid=583957806 Contributors: AnonMoos, Apokrif, BiT, Chillum, Compass35, Dolda2000, Gf uip, Ghettoblaster, Glenn, Larsinio,
LeszekKrupinski, Lotje, Merphant, Mike Dillon, Mikeblas, PGSONIC, Potatoswatter, Psiphiorg, RockMFR, Sbmeirow, Scientus, Strawbaby, Tedickey, 30 anonymous edits
date Source: http://en.wikipedia.org/w/index.php?oldid=586044324 Contributors: Ah, AlastairIrvine, Altenmann, Anakata, Bellerophon, Bgwhite, Bryan Derksen, Cal27, Cedar101, Chris319,
ChrisGualtieri, DGerman, Deon Steyn, Dysprosia, Elmimmo, Elofgren, Eric B. and Rakim, Ghen, Ghettoblaster, Glenn, Hargraver, Hudolejev, JYOuyang, John of Reading, Jshadias,
KelleyCook, Knobo, KnowledgeOfSelf, Kusunose, Loadmaster, M-le-mot-dit, Marudubshinki, Matthiaspaul, Mdornseif, Mykolas OK, Nasnema, R'n'B, Rjwilmsi, RockMFR, SPUI, Skalmelid,
Streapadair, Sun Creator, Tas50, Teehee123, Tetromino, Thorshammer4283, Timc, Tizio, Ugnich Anton, Unixguy, Vadmium, Wilee, Wizpig64, 44 anonymous edits
lp Source: http://en.wikipedia.org/w/index.php?oldid=581254513 Contributors: Alerante, Astronautics, Bryan Derksen, ChP94, Ghettoblaster, Glenn, Guy Harris, Haikupoet, HopeSeekr of
xMule, Kbolino, Larsinio, Netoholic, RlyehRising, RockMFR, Xyzzyavatar, 5 anonymous edits
Lpr Source: http://en.wikipedia.org/w/index.php?oldid=595762912 Contributors: Ahoerstemeier, Codename Lisa, Guy Harris, Hu12, Jfmantis, Ketiltrout, Pare Mo, Roskey44
Image Sources, Licenses and Contributors
287
Image Sources, Licenses and Contributors
File:chdir example.png Source: http://en.wikipedia.org/w/index.php?title=File:Chdir_example.png License: Creative Commons Attribution-Sharealike 2.0 Contributors: Helix84, Nikai, Sven
Image:Du unix output.png Source: http://en.wikipedia.org/w/index.php?title=File:Du_unix_output.png License: Creative Commons Attribution-ShareAlike 3.0 Unported Contributors:
RedAndr
File:What's the fsck?.jpg Source: http://en.wikipedia.org/w/index.php?title=File:What's_the_fsck?.jpg License: Creative Commons Attribution-Sharealike 2.0 Contributors: Alexandre
Duret-Lutz from Paris, France
File:OpenBSD Long File Listing.png Source: http://en.wikipedia.org/w/index.php?title=File:OpenBSD_Long_File_Listing.png License: Creative Commons Zero Contributors:
User:Huihermit
Image:Tee.svg Source: http://en.wikipedia.org/w/index.php?title=File:Tee.svg License: Creative Commons Attribution-Share Alike Contributors: Sven
Image:Pstree freebsd.png Source: http://en.wikipedia.org/w/index.php?title=File:Pstree_freebsd.png License: GNU General Public License Contributors: Original uploader was Waldo the
terrible at en.wikipedia
File:BSD-unix-top-plain.png Source: http://en.wikipedia.org/w/index.php?title=File:BSD-unix-top-plain.png License: Public Domain Contributors: Ivan Voras
Image:Clear-gnulinux.gif Source: http://en.wikipedia.org/w/index.php?title=File:Clear-gnulinux.gif License: GNU General Public License Contributors: Drsquirlz, Dschwen, Jake Wasdin,
WikipediaMaster
Image:Sudo logo.png Source: http://en.wikipedia.org/w/index.php?title=File:Sudo_logo.png License: GNU General Public License Contributors: Rezonansowy
Image:Sudo on Ubuntu.png Source: http://en.wikipedia.org/w/index.php?title=File:Sudo_on_Ubuntu.png License: GNU General Public License Contributors: Original uploader was
Remember the dot at en.wikipedia
File:Htop-uptime.png Source: http://en.wikipedia.org/w/index.php?title=File:Htop-uptime.png License: Creative Commons Attribution-Sharealike 3.0 Contributors: User:Neo139
Image:Win7-tskman-perf.png Source: http://en.wikipedia.org/w/index.php?title=File:Win7-tskman-perf.png License: Creative Commons Attribution 3.0 Contributors: Fergie4000
File:Unix talk screenshot 01.png Source: http://en.wikipedia.org/w/index.php?title=File:Unix_talk_screenshot_01.png License: unknown Contributors: Fluteflute, Porao, Shooke, StuartBrady,
Sven
image:Less.jpg Source: http://en.wikipedia.org/w/index.php?title=File:Less.jpg License: unknown Contributors: Dominic Schwbel
Image:Unix_more_output.png Source: http://en.wikipedia.org/w/index.php?title=File:Unix_more_output.png License: Public domain Contributors: Andewulfe at en.wikipedia
File:NetBSD 6.1 vi C Hello World.png Source: http://en.wikipedia.org/w/index.php?title=File:NetBSD_6.1_vi_C_Hello_World.png License: Creative Commons Zero Contributors:
User:Huihermit
File:Bill joy.jpg Source: http://en.wikipedia.org/w/index.php?title=File:Bill_joy.jpg License: Creative Commons Attribution 2.0 Contributors: Original uploader was SqueakBox at
en.wikipedia
File:KB Terminal ADM3A.svg Source: http://en.wikipedia.org/w/index.ph