probably one of the most useful UNIX commands.
man shows a help file on a certain command, including all options
example: man ls
to show current location on directory tree (stands for "print
working directory") Example, after logging into the NIS system
you will be in your home directory; Issuing the command "pwd"
will return something like /u/people/joe_user
to list files, subdirectories and symbolic links in a directory
(the option gives "long format" which includes additional information
about the files, such as sizes, last modification date, ownership, etc)
Example: to look at the files in your home directory, issue
the command "ls -l"
lrwxr-xr-x 1 ahinck user 18 Jul 1 2000 bin -> /inept2/ahinck/bin
drwxr-xr-x 2 ahinck user 4096 Sep 12 1999 dumpster
-rw-r--r-- 1 ahinck user 53606 Jan 4 22:59 protein.jpeg
above, the first letter of the permissions (-rw-r--r--) shows the type
of the file. l is a symbolic link, d is a directory, and - is
a regular file. See description of chmod below for more information
to change to the directory specified by dir_spec (e.g.
cp file1 file2
to copy file1 to a new name: cp <file1> <file2>
withough argument, prints the calendar for the current month
Otherwise, prints a 12-month calendar for the specified year or month
example: cal 7 2003 -- prints the calendar for July of 2003
displays the names of the users currently logged onto the system
whoami prints the username of the invoking user
produce a full listing of all active processes on a given machine
often used in conjunction with the command grep: ps -ef | grep joe_user
lists all active processes for a given joe_user
grep exp file
search one or more files for a given expression
example: grep moo my_output.txt
create a new directory name
mkdir my_stuff -- creates a new directory my_stuff
remove one or more files
rm file.txt -- deletes the file file.txt
rm -r file
if removing a directory, remove it and all its contents,
make a recursive long format list of all subdirectories as well as
current directories. It is very useful for finding the name of the file
you might not quite remember.
example: ls -lR | grep string -- lists all the files in the current
directory and its subdirectories that contain the string in their filename
find /dir -name filename.x -print
search for a file with the name filename.x in the
given directory and, if found, print the path of the file
find /work -name blah -print -- lists all the files named
"blah" in the /work directory
calls a basic calculator that performs arithmetics
read one or more files and print then on standard output
you can use the > operator to combine several files into one
or the >> operator to append files to an existing one
cat ch1 ch2 ch3 > all -- combines three files into "all"
cat note5 >> notes -- add note5 to notes
print the current date and time
du -s directory
print disk usage recursively in number of 512-byte blocks
for each named directory
permissions (-rw-r--r--) specify who has who has access to a
given file. The first three letters are for user, the owner of
the file, second tripletis for group, and the last is for others.
r is read permission, w is write permission,and x is execute permission.
Thus, in the example above, the owner of the file can readand write to it,
the group and only read, and all others can only read it.chmod
command changes the access mode of one or more files. the access mode
is madefrom concatenating the following:
u -- user + -- add permission
g -- group - -- remove permission
o -- other = -- assign permission
a -- all (default)
r -- read
w -- write
x -- execute
chmod u=rwx, g=rx, o=x file -- sets read-write-execute permission
by owner, read-execute by group, and execute-only by others the
chown newowner files
change the ownership of one or more files to newowner
newowner is a username
open or create a file in vi editor.
vi editor tutorial
kill -9 IDs
kill one or more processes with specified IDs. These IDs can
be aquired by listing the processes with the ps -ef command.
lp -d laser1 filename
print a file to destination laser1, Hincklab HP4000
ln -s file1 file2
create a symbolic link from file1 to file2.
file2 can also be a directory. this command creates a link across the
system so that you don't need to copy the directory or file.
mv source target
move the souce file to a target file, i.e. delete the source
and copy it as target. This command is useful for renaming files.
mv cow.txt /farm/cow2.txt -- moves the file cow.txt to the directory
/farm and names it cow2.txt
displays the named file on the terminal, one screenful at a time.
Press spacebar for the next screnful.
create or change a password associated with a username.
only the actual user or the priveleged user can do this.
sort -op files
sort the lines of the files, usually in alphabetical order.
-b ignore leading spaces
-d sort in dictionary order
-f ignore upper/lowercase differences
-n sort numerically
create a shell with a username of another user.
If no username is specified, become a super user. Enter EOF to
copy files or restore files from tape. See the tape device help page
wc -l filename
count the lines in a given file.