Print this article Edit this article
UNIX Commands: Quick Reference
This is a guide to some of the most commonly used commands in UNIX terminal mode. Most of the commands will work the same way in *NIX variants such as Linux and Mac OS X's terminal.
Examining Files
cat | display file |
cat file.. | display contents of file |
more | display file by screenful (BSD) |
more file.. |
display one screenful at time. Use SPACE BAR to display next screenful. Use RETURN to display next line. |
tail | display last part of file |
tail[+/-n] [file].. | by default, displays text from tenth line from end of text |
Managing Files
cp | copy file |
cp file.1 file.2 | make copy of "file.1" called "file.2" |
ls | list contents of directory |
ls[-ltdru] file.. |
list contents of directory options: -l long format -t by time of modification -d directory status -r list in reverse order -u by time of last access |
mv | move or rename files and directories |
mv file.1 file.2 | change name of "file.1" to "file.2" |
mv file...directory | move one or more files to specified directory |
mv directory.1 directory.2 | change name of "directory.1" to "directory.2" |
rm | remove files or directories |
rm [-ir] file... |
remove one or more files or directories options: -i interrogative -r remove specified directories and their contents |
Text Editing
vi | invoke visual editor | |
vi file... |
invokes vi text editor to edit specified file(s) option: -r recover lost file |
Formatting Files
pr | prepare file for printing |
pr [option] file | paginate file for printing options: -h change header -t suppress header |
nroff | format text |
nroff [-mm,-ms] file.. |
format text according to commands and defaults options: -mm specifies use of mm macros package -ms specifies use of ms macros package |
checkmm | check mm macro input |
checkmm file.. | check input files for formatting errors |
checknr | check ms macro input (BSD) |
checknr file.. | check input files for formatting errors |
Printing Files
lp | print file on line printer |
lp [options] file.. |
puts specified file(s) in line printer queue options: -c send copy of file for printing -m send mail when file printed -n# make #- number of copies of printout -d destination printer |
lpstat | display information about the status of the LP print |
cancel | cancel lp command |
Communication
send or receive mail among users | |
mail username | sends electronic mail to specified users |
who | lists users currently on-line |
who [am i] [am I | displays login name, tty number, and login time for users currently logged in. |
write | write to another user |
write username[tty.no] | send lines from your terminal to another. to end message, type ^D. |
mesg | permit or deny write messages |
mesg [n] [y] |
with n argument, prohibit messages sent to you via write with y argument, permission to write to you is restored |
Working With Directories
cd | change directory |
cd dir.name | establish specified directory as working directory |
cd .. | establish parent of working directory as working directory |
mkdir | create directory |
mkdir dir.name.. | make one or more directories |
pwd | print working directory |
pwd | display absolute pathname of working directory |
rmdir | remove directory |
rmdir dir.name.. |
remove specified directories only if empty. Also see rm -r. |
Managing Background Processes
Account Management
passwd | change your password |
On-Line Documentation
help | provides help |
help [args] | explains use of command or meaning of diagnostic |
man | display on-line UNIX manual |
man [option][chapter] [title... |
prints section for any specified UNIX command |
Other Utilities
cal cal [month] year |
display calendar displays calendar for any year or month between 1 and 9999 A.D. |
cmp | compare two files |
cmp file.1 file.2 | compares two files: if different, displays line and character number where first difference appears, then stops |
chmod chmod[who] operator permission file... |
change mode changes read, write, and execute privileges for file for owner, group, others, or all
|
date
|
display date and time | ||
diff diff[-bh] file.1 file.2 |
display differences between files Compares two files and indicates what lines must be changed to make first file identical to second:
|
echo echo argument |
repeat command line arguments displays its arguments |
find find pathname..directive.. |
search for files in hierarchy processes each file beneath specified directory pathnames, applying specified directive until it encounters directive whose result is false. Directives:
|
grep grep [option].. pattern [file]... |
Search file for pattern Searches for patterns in specified list of files or in standard input
|
sh sh file [args]... |
Execute shell file Executes commands read from a shell file |
sort sort [-bdfntu] [+field] [-o] [file] ... |
sort or merge files Sort files Options:
|
spell spell [options] file ... |
Find spelling and typing errors Check words in file against spell's dictionary Options: +sup.file refer to specified supplemental spelling list |
tee tee [-a] file |
Pipe fitting Sends input simultaneously to standard output and specified file Options:-a appends to specified file |
wc wc [file...] ... |
Word count Count words, characters and lines in specified files or standard input |
Shell Syntax
manipulating standard input and output
< | Redirect standard input. Takes standard input from file rather than keyboard. | |
> | Redirect standard output. Redirects standard output to file. | |
>> | Append standard output. Appends standard output to end of file. | |
| | Pipes connect commands by sending standard output from one command to standard input of another. |
File Name Shorthand
* | Asterisk. Stands for "any sequence of zero or more characters. |
? | Question mark. Stands for any single character |
[...] | Brackets. Groups of characters within square brackets match any single character contained within brackets. |
Last Modified:
Dec 19, 2016 11:12 am US/Eastern
Created:
May 24, 2007 2:20 pm GMT-4
by
admin
JumpURL: