Chap.1 Usefule Commands
1, How to check your Linux release version?
A: cat /etc/issue
Example:
28849079@cnbjlx1288:~$ cat /etc/issue
Ubuntu 9.10 \n \l
2, How to check the detailed release version of your Linux?
A: lsb_release -a ---------> I think the "a" is equal to "all"
Example:
28849079@cnbjlx1288:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic
3, How to check the Linux Kernel version? take Ubuntu as example
A: uname -r ----------> r == release, I think
Example:
28849079@cnbjlx1288:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic
4, How to check a file's access attribution ?
A: ls -l <filename> ------->ls == list
Example :
28849079@cnbjlx1288:~/Downloads$ ls -l The\ Unix\ Programming\ Environment\ .pdf
-rw-r--r-- 1 28849079 domain^users 839306 2010-04-23 10:18 The Unix Programming Environment .pdf
Comments on "-rw-r--r--":
1) The first "-" in result means it's a file, should be "d" if it is a directory.
2) "rwx" describes the related user right on this file, r == read, w == write, x == execute.
3) the first "rwx" is indicates the current user, the 2nd "rwx" indicates group user, the 3rd "rwx" means other user.
5. How to change a file's access attribute ?
A: chmod xxx <filename>
Example:
chmod rwxr--r-- file.txt or
chmod 744 file.txt
6. How to create a symbolic links ?
A: ln -s src newfile ------> src is the existing file, and newfile is the one that to be created
Example:
touch testdir/testfile
ln testdir/testfile CopyOftestfile
7. How to change password ?
A: passwd
Example:
...
8. How to rename file ?
A: mv -----> mv == move
Example:
mv oldname newname -----> oldname must exist
9. How to copy a file or a directory ?
A: cp -----> cp == copy
Example:
cp src dest
10. How to print a file content on screen
A: cat
Example:
cat test.txt -----> test.txt contains some simple charactics.
Others:
head & tail -----> head print the beginning n lines, and tail for the end n lines.
11. How to check the system process information ?
A: ps
Example:
NA
12. How to terminate a process ?
A: kill
Example:
kill pid -----> pid is a process id, it can be retreived via the above command ps
13. How to run a job in background ?
A: with a postfix '& '
Example:
sleep 10
sleep 10 & -----> with '&' will not block the current process
14. Difference between '>' & '>> ' & ‘>|’
A: All of them are redirection operation, '>' overwrite and '>>' append, both of them would create a new file if no the specific file is not exist, '>|' would force redirection and overwrite the destination file.
Example:
15. The functionality of pipe '|'
A: A pipe, as a classic method of interprocess communication, sends the <stdout> of one process to the <stdin> of another. In a typical case, a command, such as cat or echo, pipes a stream of data to a "filter" for processing, like:
Example:
cat $filename1 $filename2 | grep $search_wordNotes:
Note: The stdout of each process in a pipe must be read as the stdin of the next. otherwise, the data stream will block.
16. The functionality of dash '-'
A: redirection from/to stdin or stdout, Where a filename is expected, dash '-' redirects output to stdout, or accepts input from stdin, rather than from a file.
Example:
/BashWorkSpace$ file --mime-type - ----> with a dash '-' in the end of the command
你好 ----> This is user input in stdin(terminal)
/dev/stdin: text/plain
17. 查看打开的文件
lsof ----> list open files
http://www.ibm.com/developerworks/cn/aix/library/au-lsof.html
13. TBD...
more, less, cc, grep, ps, which, env
// lp, more, less ?
查找文件find:
find DIR [OPTIONS] [NAME]
find ~/ -size +1000c
find ~/ -size -1000c
find / -name http_conf*.c 2>/dev/null
find / -size +1000c -and -atime -1
others: -atime -cmin .....
http://wenku.baidu.com/view/c2be82254b35eefdc8d3336a.html
chown, chgrp ----> change owner, change group
find Search for les from a speci ed directory using various criteria.
locate Fast search in a global le database for les containing a search-string.
whereis Look for a command and its documentation on the system.
du -->disk usage
df
ps - process
vmstat --> virtual memory status : list kernel vm stastics
netstat -> network status/stastics: list network connection and stastics
hostname -> show the name of this host
Chap.2 Control Characters
change the behavior of the terminal or text display.
Ctrl + l => Clear
Ctrl + c => Break, terminate a foreground job.
Ctrl + d => Log out from a shell; In vi, it scroll half screen
Ctrl + b => Backspace, In vi, it scroll back a screen
Ctrl + f => In vi, it scroll foward a screen
Ctrl + u => Erase a line of input, from the cursor backward to beginning of line. In some settings, Ctl−U erases the entire line of input, regardless of cursor position.
Ctrl + W => Erases from the character under the cursor backwards to the first instance of whitespace. In some settings, it erases backwards to first non−alphanumeric character.
Chap. 3 Tips
Q: manual about apt-get
http://baike.baidu.com/view/1580236.htm
Q: Linux下运行交互式脚本的时候用回车键无法删除前面的字符
解决方法:用Ctrl + Backspace
浙公网安备 33010602011771号