Posted on 4:47 AM by Hamid and filed under
UNIX Commads
Enter username at login: prompt. Be carefull - Unix is case sensitive.
Enter password at password: prompt.
passwd
logout or exit
cat > file Enter text and end with ctrl-D
vi file Edit file using the vi editor
mkdir directory-name
cat file display contents of file
more file display contents of file one screenfull at a time.
view file a read only version of vi.
less file similar to, but more powerfull than more.
See the man page for more infomation on less.
diff file1 file2 line by comparison
cmp file1 file2 byte by byte comparison
chmod mode file1 file2 ...
chmod -R mode dir (changes all files in dir )
Mode Settings
u user (owner)
g group
o other
+ add permission
- remove permission
r read
w write
x execute
Example: chmod go+rwx public.html adds read, write, and execute permissions for group and other on public.html.
ls list contents of directory
ls -a include files with "." (dot files)
ls -l list contents in long format (show modes)
mv src-file dest-file rename src-file to dest-file
mv src-file dest-dir move a file into a directory
mv src-dir dest-dir rename src-dir, or move to dest-dir
mv -i src dest copy & prompt before overwriting
cp src-file dest-file copy src-file to dest-file
cp src-file dest-dir copy a file into a directory
cp -R src-dir dest-dir copy one directory into another
cp -i src dest copy & prompt before overwriting
rm file remove (delete) a file
rmdir dir remove an empty directory
rm -r dir remove a directory and its contents
rm -i file remove file, but prompt before deleting
compress file encode file, replacing it with file.Z
zcat file.Z display compressed file
uncompress file.Z decode file.Z, replacing it with file
pwd display absolute path of working directory
- simple:
- One filename or directory name for accessing local file or directory.
Example: foo.c
- absolute:
- List of directory names from root directory to desired file or directory name, each separated by /.
Example: /src/shared
- relative:
- List of directory names from working directory to desired file or directory name, each separated by /.
Example: Mail/inbox/23
~ Your home (login) directory
~username Another user's home directory
. Working (current) directory
.. Parent of working directory
../.. Parent of parent directory
cd / go to the root directory
cd go to your login (home) directory
cd ~username go to username's login (home) directory
not allowed in the Bourne shell
cd ~username/directory go to username's indicated directory
cd .. go up one directory level from here
cd ../.. go up two directory levels from here
cd /full/path/name/from/root change directory to absolute path named
note the leading slash
cd path/from/current/directory change directory to path relative to here.
note there is no leading slash
date display date and time
? single character wild card
* Arbitrary number of characters
lpr file print file on default printer
lpr -Pprinter file print file on printer
lpr -c# file print # copies of file
lpr -d file interpret file as a dvi file
lpq show print queue (-Pprinter also valid)
lprm -# remove print request # (listed with lpq)
command > file direct output of command to file instead of
to standard output (screen), replacing current
contents of file
command > > file as above, except output is appended to the current
contents of file
command < file command receives input from file instead of
from standard input (keyboard)
cmd1 | cmd2 "pipe" output of cmd1 to input of cmd2
script file log everything displayed on the terminal to file;
end with exit
grep string filelist show lines containing string in any file
in filelist
grep -v string filelist show lines not containing string
grep -i string filelist show lines containing string, ignore case
finger user or
finger user@machine get information on a user
finger @machine list users on machine
who list current users
alias string command abbreviate command to string
Commands may be recalled
history show command history
!num repeat command with history number num
!str repeat last command beginning with string str
!! repeat entire last command line
!$ repeat last word of last command line
pid Process IDentification number. See section 7.2.
job-id Job identification number. See section 7.2.
ps report processes and pid numbers
ps gx as above, but include "hidden" processes
jobs report current jobs and job id numbers
ctrl-Z NOTE:process still exists!
To start a job in background add & to the end of the command.
Example: xv foo.gif &
To force a running job into the background:
ctrl-Z stop the job
bg "push" the job into the background
fg bring a job to foreground
fg %job-id foreground by job-id (see 7.2)
ctrl-C kill foreground process
kill -KILL pid# see 7.2 for
kill -KILL %job-id# displaying pids & job-ids
MH commands are issued directly to the terminal.
inc incorporate new mail
scan show list of mail messages
show show current message
next show next message
prev show previous message
repl reply to current message
forw forward current message
comp compose a mail message
rmm remove current mail message
cmd -help print help on mh commmand cmd
The file .mh_profile is used to enable/disable MH features. man mh-profile for more information.
On-line Documentation
man command-name display on-line manual pages
man -k string list one-line summaries of manual pages containing string
Post a Comment