linux常用命令

2013-04-01

入门必学的一些Linux常用命令实例.

§※§ FILE COMMANDS

1) ls -lrt —directory listing
2) ls -al —formatted listing with hidden files
3) cd dir —change directory to directory to dir
4) cd - —change to home
5) pwd —show current directory
6) mkdir dir —create a directory dir
7) rm file —delete file
8) rm –r dir —delete directory dir
9) rm –f file —force remove file
10) rm –rf dir —force remove directory dir
11) cp file1 file2 —copy file1 to file2
12) cp –r dir1 dir2—copy dir1 to dir2,create dir2 if dir2 doesn’t exist
13) mv file1 file2 —rename of move file1 to file2,if file2 is an existing directory,moves file1 into directory file2
14) ln –s /opt/reuters /reuters —create symbolic link link to reuters
15) touch file —create or update file
16) cat > file2—places standard input into file2
17) more file —output the contents of file
18) head file —output the first 10 lines of file
19) tail file —output the last 10 lines of file
20) tail –f file —output the contents of file as it grow,starting with the last 10 lines

§※§ SEARCHING

21) grep pattern files —search for pattern in files
22) grep –r pattern dir—search recursively for pattern in dir
23) command |grep pattern —search for pattern in the output of command
24) locate file —find all instances of file

§※§ PROCESS MANAGEMENT

25) ps —display your currently active processes
26) top —display all running processes
27) kill pid —kill process id pid
28) killall proc —kill all processes named proc
(use with extreme caution)
29) bg —lists stopped or background jobs,resume a stopped job in the backgroud
30) fg —brings the most recent job to foreground
31) fg n —brings job n to the foreground

§※§SHORTCUTS

32) Ctrl+C —halts the current command
33) Ctrl+Z —stops the current command,resume with fg in the foreground or bg in the background
34) Ctrl+D —log out of current session,similar to exit
35) Ctrl+W —erases on word in the current line
36) Ctrl+U —erases the whole line
37) Ctrl+R —type to bring up a recent command
38) !! —repeats the last command
39) !num —repeats the command,history tell num
40) exit —log out of current session

§※§ SYSTEM INFO

41) date —show the current date and time
42) cal —show this month’s calendar
43) uptime —show current uptime
44) w —display who is online
45) whoami —who you are logged in as
46) finger user —diplay information about user
47) uname –a —show kernel information
48) cat /proc/cpuinfo —cpu information
49) cat /pro/meminfo —memory information
50) man command —show the manual for comman
51) df —show disk usage
52) du —show directory space usage
53) free —show memory and swap usage
54) whereis app —show possible locations of app
55) which app —show which app will be run by default

§※§COMMPRESSION

56) tar cf file.tar files —create a tar named file.tar containing files
57) tar xf file.tar —extract the files from file.tar
58) tar zcf file.tar.gz files —create a tar with Gzip compression
59) tar zxf file.tar.gz —extract a tar with Gzip
60) tar jcf file.tar.bz2 files —create a tar with Bzip2
61) tar jxf file.tar.bz2 —extract a tar with Bzip2
62) gzip file —compresses file and renames it to file.gz
63) gzip –d file.gz —decompresses file.gz back to file
64) unzip a.zip
65) unrar a.rar

§※§NETWORK

66) ping host —ping host and output results
67) whois domain —get whois information for domain
68) dig domain —get DNS info for domain
69) dig +x host —reverse lookup hosts
70) wget file —download file
71) wget –c file —continue a stopped download
72) netstat –rn —show the route
73) ifconfig —like ipconfig

§※§INSTALLATION

74) install from source
a) ./configure
b) make;make install
75) dpkg –i pkg.deb — install a package (Debian)
76) rpm –ivh pkg.rpm —install a package (RPM)

§※§FILE PERMISSIONS

77) chmod octal file —change the permissions of file to octal,which can be found separately for user
78) goup,and world by adding
 4 read (r)
 2 write (w)
 1 execute(x)
79) Example:
a) chmod 777 file —rwx for all
b) chmod 755 rwx —rwx for owner,rx for group and world,for more options see man chmod

分类:Linux | 标签: |

相关日志

评论被关闭!