Share my knowledge, feel my life. Eric Shan' Blog myBloggie 2.1.6 © 2005   
Mar 2025 April 2025 May 2025
S M T W T 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    
Categories
About[5]
Blackberry[1]
dotNet and C Charp[1]
IPhone[10]
Life[4]
Unix&Linux[19]
WEB programming[16]
Windows API[5]
Windows Mobile[1]
Windows Multimedia[4]
Recent
CentOS mount CDrom and USB
CentOS GHOST(幽灵)漏洞修复方法
centos 改变语言并立即生效
centos vpn 接通后无法连接internet
让vlc播放中文字幕不出乱码
centos 取消屏保
php中ob_flush和flush的用法
CentOS检查,添加,删除自启动服务
CentOS中开机自动启动某个服务
Top命令中的翻页
Archives
February 2010[4]
September 2009[1]
August 2009[1]
January 2009[7]
October 2008[10]
June 2008[2]
December 2007[14]
November 2007[5]
May 2007[9]
April 2007[3]
March 2007[10]
User List
Eric Shan[66]
Search
Syndication
22 Dec 2007 09:48:25 am
Linux/Unix Command quick reference
http://sunsite.utk.edu/UNIX-help/quickref.html

Unix Help
UNIX Quick Reference Sheet
This a summary of some common Unix commands. Some of these commands may not be on your Unix Systems and some commands may not work exactly as show. - The Management



1 Log In Session

1.1 Log In
Enter username at login: prompt. Be carefull - Unix is case sensitive.
Enter password at password: prompt.


1.2 Change Password
passwd


1.3 Log Out
logout or exit


2 File System

2.1 Create a File

cat > file Enter text and end with ctrl-D
vi file Edit file using the vi editor

2.2 Make a Directory

mkdir directory-name
2.3 Display File Contents

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.

2.4 Comparing Files

diff file1 file2 line by comparison
cmp file1 file2 byte by byte comparison

2.5 Changing Access Modes

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.


2.6 List Files and Directories

ls list contents of directory
ls -a include files with "." (dot files)
ls -l list contents in long format (show modes)

2.7 Move (or Rename) Files and Directories

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

2.8 Copy Files

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

2.9 Remove File

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


2.10 Compressing files

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


2.11 Find Name of Current Directory

pwd display absolute path of working directory


2.12 Pathnames

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

2.13 Directory Abbreviations

~ Your home (login) directory
~username Another user's home directory
. Working (current) directory
.. Parent of working directory
../.. Parent of parent directory

2.14 Change Working 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

3.0 Commands

3.1 Date

date display date and time

3.2 Wild Cards

? single character wild card
* Arbitrary number of characters

3.3 Printing

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)

3.4 Redirection

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

4 Search Files

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

5 Information on Users

finger user or
finger user@machine get information on a user
finger @machine list users on machine
who list current users

6 Timesavers

6.1 Aliases

alias string command abbreviate command to string

6.2 History: Command Repetition
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

7.0 Process and Job Control

7.1 Important Terms

pid Process IDentification number. See section 7.2.
job-id Job identification number. See section 7.2.


7.2 Display Process and/or Job IDs
ps report processes and pid numbers
ps gx as above, but include "hidden" processes
jobs report current jobs and job id numbers

7.3 Stop (Suspend) a Job

ctrl-Z NOTErocess still exists!

7.4 Run a Job in the Background

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


7.5 Bring a Job to the Foreground

fg bring a job to foreground
fg %job-id foreground by job-id (see 7.2)


7.6 Kill a Process or Job

ctrl-C kill foreground process
kill -KILL pid# see 7.2 for
kill -KILL %job-id# displaying pids & job-ids


8.0 Mail Handler (MH)
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.

9.0 On-line Assistance
On-line Documentation

man command-name display on-line manual pages
man -k string list one-line summaries of manual pages containing string

--------------------------------------------------------------------------------
Category : Unix&Linux | Posted By : Eric Shan | Comments [0] | Trackbacks [0]
Trackbacks
The URI to TrackBack this entry is :
http://blog.tntsoft.com/trackback.php/16
Comments

Add Your Comment

Subject

Comments

Name

Email Address (Optional)

Home Page (Optional)

Security Code

Please enter the security code as displayed :



Template theme : aura
Powered by myBloggie Copyright © 2004 2006
-- myWebland --

Sponsed by TNTSoft Store