Unix Command Review
时间:2010-09-09 来源:Jerry Chou
Important UNIX conventions
1, Command Format
Commands must be typed all on one line, with spaces between the command, options, and arguments.
2,Naming Files
Filenames consist of alphanumeric characters, underscores, dashes, and periods. DO NOT use spaces or other punctuation in filenames!
3,Case Sensitivity
Commands and filenames in UNIX are case sensitive!!
4,Filename Completiom
After typeing a unique prefix of a filename, pressing the Tab key will cause the Unix shell to complete the filename.
5,Command Editing
The up arrow key will retrieve a previous command. This command may be edited using the left/right arrow keys and backspace.
6,^C (control-C)
In UNIX, this terminates a currently running process when typed in the window the process is running in.
7,^Z (control-Z)
In UNIX, this sends a process to run in the background. The process will still exist; you just won't see it. Type "fg" to bring it back so that you can exit properly. Don't exit Unix with processes running in the background.
Working with Directories
0,Directory Notes
In UNIX pathnames, slashes (/) separate the directory and filenames
e.g. /home/mcb/myfile.txt [ here home and mcb are directories and myfile.txt is a file ]. The current directory is referred to as . (‘dot’) and the parent directory is referred to as .. (‘dot dot’). The home directory is called ~ (‘tilde’).
1,Display present working directory
pwd echo present working directory on screen
2,Change directory
cd dirname Change current working directory to specific directory.
cd or cd ~ Go to your home directory, i.e. the directory you start in when you login.
cd .. Go to the parent of the directory you are in now [ move up by 1 directory ]
3,Create/Delete directory
mkdir dirname Creates a directory called dirname in the current directory
rmdir dirname Delete (remove) empty directory
rm –r dirname Delete directory and the content inside it(files,subdirectoris)
4,Lists directory contents
ls dirname lists contents within specific directory
ls –l shows a "long", detailed listing
ls –a lists all of contents ,including hide directoris,files(starting with “.”)