Linux常用命令總結

基本正則表達式:


如何區分內建命令和外部命令:

type COMMAND


如何獲取命令的幫助:

內置命令help COMMAND
例如:help history
外部命令1、COMMAND --help
2、手冊:manual


命令是分章節的:man [#] COMMAND

如何查看指定命令在哪些章節有幫助
whatis COMMAND
注意:whatis根據數據庫執行查找操作,此庫系統定期更新,可以使用makewhatis手動更新


pwdprint name of current/working directory
dirnamestrip non-directory suffix from file name
basenamestrip directory and suffix from filenames
statdisplay file or file system status
whoshow who is logged on
hashRemember or display program locations.
whoamiprint effective userid
filedetermine file type
haltreboot, halt, poweroff - reboot or stop the system
reboot
poweroff
whichsearch the whatis database for complete words.
inforead Info documents
ntpdateset the date and time via NTP


命令名稱:history
命令用法:history [-c] [-d offset] [n] 
          history -anrw [filename] 
          history -ps arg [arg...]
命令作用:
1、Display or manipulate the history list.
2、Display the history list with line numbers, prefixing each modified
命令參數:
         N  顯示最近N條命令,包括當前命令本身
         -c 清空命令歷史
         -d 刪除指定偏移處的命令
         -a 將當前回話中的命令歷史寫入指定文件
相關變量:1、HISTSIZE      保存的條數
          2、HISTFILE      用戶退出時保存命令的位置
          3、HISTFILESIZE  此文件中可保存的最大條目
          4、HISTCONTROL   
              ignoredups  忽略重複的命令,連續相同的命令纔是重複
              ignorespace 忽略空白字符開頭的命令
              ignoreboth  以上二者同時生效


命令名稱:ls
命令作用:list directory contents
命令用法:ls [OPTION]... [FILE]...
命令參數:-l  use a long listing format
          -a  do not ignore entries starting with .
          -A  do not list implied . and ..
          -d  僅顯示目錄自身屬性
          -r  逆序顯示,reverse
          -R  遞歸顯示,recursive


命令名稱:cd
命令作用:Change the shell working directory.
命令參數:cd             #直接回到家目錄
cd ~           #
直接回到家目錄
cd ~USERNAME   #
進入某個用戶的家目錄
cd -           #
在前一個目錄和當前目錄之間反覆切換


pwdprint name of current/working directory
dirnamestrip non-directory suffix from file name
basenamestrip directory and suffix from filenames
statdisplay file or file system status


命令名稱:shutdown
命令作用:Bring the system down.
命令格式:shutdown [OPTION]... TIME [MESSAGE]
命令參數:-r reboot after shutdown
-h halt or power off after shutdown
-c cancel a running shutdown
now
+m
hh:mm


命名名稱:date
命令用法:date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
命令作用:Display the current time in the given FORMAT, or set the system date.
命令參數:%s  時間戳計時法,從Unix元年(1970-01-01 00:00:00)到此刻經過的秒數
%F  same as %Y-%m-%d
%D  same as %m/%d/%y
%T  same as %H:%M:%S
%Y  year
%m  month (01..12)
%d  day of month (e.g, 01)
%H  hour (00..23)
%M  minute (00..59)
%S  second (00..60)


命令名稱:hwclock
命令用法:hwclock [functions] [options]
命令作用:query and set the hardware clock (RTC)
命令參數:-s, --hctosys
              Set the System Time from the Hardware Clock.
          -w, --systohc
              Set the Hardware Clock to the current System Time.


文件類型表示方法
普通文件:-或者f
目錄文件:d
鏈接文件:l
設備文件:字符設備:c(線性設備)
塊設備:b(隨機設備)
命名管道:p
套接字文件:s(Unix Socket)


命令名稱:touch
命令用法:touch [OPTION]... FILE...
命令作用:
1、change file timestamps.
2、Update the access and modification times of each FILE to the current time.
命令參數:-a 僅改變atime
          -m 僅改變mtime
          -c 不創建空文件
          -t use [[CC]YY]MMDDhhmm[.ss] instead of current time


命令名稱:cat
命令作用:1、concatenate files and print on the standard output
2、Concatenate FILE(s), or standard input, to standard output.
使用格式:cat [OPTION]... [FILE]...
命令參數: -E display $ at end of each line
 -n number all output lines


分屏顯示命令:

morefile perusal filter for crt viewing
lessopposite of more


查看首部或者尾部:

head 命令作用:output the first part of files
     命令用法:head [OPTION]... [FILE]...
     參數選項:-n  print  the first K lines instead of the first 10

tail 命令作用:Print the last 10 lines of each FILE to standard output.
     命令用法:tail [OPTION]... [FILE]...
     參數選項:-f  output appended data as the file grows
          -n  output the last K lines


命令名稱:echo
命令作用:
1、Write arguments to the standard output.
2、Display the ARGs on the standard output followed by a newline.
命令的用法:-n  do not append a newline
            -t  horizontal tab
            -v  vertical tab


文件管理命令:

命令名稱:cp
命令作用:copy files and directories
命令參數:  -P  複製符號鏈接文件本身,而非其指向的目標文件
            -p  保留屬主和時間戳
            -a  保留文件所有的屬性,歸檔複製,常用備份
            -i  --interactive prompt before overwrite 
            -f  --force 強制
            cp [OPTION]... [-T] SOURCE DEST
            cp [OPTION]... SOURCE... DIRECTORY
            cp [OPTION]... -t DIRECTORY SOURCE...


命令名稱:mv
命令作用:move (rename) files
命令參數: -i  --interactive prompt before overwrite


命令名稱:rm
命令作用:remove files or directories
命令參數:   -f  --force ignore nonexistent files, never prompt
             -i  prompt before every removal
             --no-preserve-root  默認選項,不能刪除跟


文本處理類命令:

命令名稱:wc
命令作用:print newline, word, and byte counts for each file
命令參數:   -c, --bytes print the byte counts
             -l, --lines print the newline counts
             -w, --words print the word counts
             -m, --chars print the character counts


命令名稱:cut
命令用法:cut OPTION... [FILE]...
命令作用:remove sections from each line of files
命令參數: -d  use DELIM instead of TAB for field delimiter
           -f  select only these fields(m, m,n m-n)


命令名稱:sort
命令用法:sort [OPTION]... [FILE]...
命令作用:sort lines of text files
命令參數:-f  忽略字符大小寫
          -t  指定分隔符
          -k  指定分割之後要進行排序的字段
          -n  按照數值大小進行排序
          -u  排序之後去重


命令名稱:uniq
命令用法:uniq [OPTION]... [INPUT [OUTPUT]]
命令作用:report or omit repeated lines
命令參數:-d  only print duplicate lines
          -u  only print unique lines
          -c  prefix lines by the number of occurrences
注意事項:要連續相同行纔可以去重。


文本處理命令:

命令名稱:tr 
命令作用:translate or delete characters
命令用法:tr [OPTION]... SET1 [SET2]
參數選項:-d, --delete
          delete characters in SET1, do not translate



文件:
   r: 查看文件內容
   w: 修改文件內容
   x: 把此文件啓動爲一個運行的進程
目錄:
   r: 可使用ls命令查看目錄中的文件名列表
   w: 可以在目錄中創建或刪除文件
   x: 可以cd到此目錄中,以及使用ls -l顯示目錄中文件的元數據信息


命令名稱:useradd
命令作用:create a new user or update default new user
          information
命令用法:useradd [options] LOGIN
參數選項:-u:所屬的UID
          -g:所屬的基本組
          -G:所屬的附加組
          -c:註釋信息
          -d:指定家目錄,如果此目錄事先存在,會有警告信息
          -s:指定用戶的shell,shell必須事先存在
          -m:強制給用戶創建家目錄
          -M:不給用戶創建家目錄
          -r: 創建系統用戶


命令名稱:groupadd
命令作用:create a new group
命令用法:groupadd [options] group
參數選項:-g 指定GID
          -r 創建系統組


命令名稱:passwd
命令作用:update user's authentication tokens
命令用法:
           passwd  [-k]  [-l]  [-u [-f]] [-d] [-e] [-n mindays] [-x
           maxdays] [-w warndays] [-i inactivedays] [-S]  [--stdin]
           [username]
參數選項:--stdin 
          -l 鎖定用戶
          -u 解鎖用戶


命令名稱:passwd
命令作用:update user's authentication tokens
命令用法:
           passwd  [-k]  [-l]  [-u [-f]] [-d] [-e] [-n mindays] [-x
           maxdays] [-w warndays] [-i inactivedays] [-S]  [--stdin]
           [username]
參數選項:--stdin 從管道輸入設置密碼
          -l 鎖定用戶
          -u 解鎖用戶


命令名稱:userdel
命令作用:delete a user account and related files
命令用法:userdel [options] LOGIN
參數選項:-r 刪除用戶及家目錄


命令名稱:groupdel
命令作用:delete a group
命令用法:groupdel group
參數選項:


命令名稱:groupadd
命令作用:create a new group
命令用法:groupadd [options] group


命令名稱:gpasswd
命令作用:administer /etc/group and /etc/gshadow
命令用法:gpasswd [option] group


命令名稱:groupmod
命令作用:modify a group definition on the system
命令用法:groupmod [options] GROUP


命令名稱:newgrp
命令作用:log in to a new group(臨時切換基本組)
命令用法:newgrp [-] [group]


命令名稱:usermod
命令作用:modify a user account
命令用法:usermod [options] LOGIN
參數選項:-u 修改用戶UID
          -g 修改用戶GID
          -a 使用追加的方式添加附加組
          -G 修改用戶的附加組,默認是覆蓋添加,一般和-a一起使用
          -c 修改註釋信息
          -d 修改家目錄的位置,一般和-m一起使用
          -m 將用戶原有的文件移動至新的家目錄中;
          -s 修改用戶的shell
          -l 修改用戶名
          -L 鎖定用戶
          -U 解鎖用戶


命令名稱:chsh
命令作用:change your login shell
命令用法:chsh [-s shell] [-l] [-u] [-v] [username]


命令名稱:chfn
命令作用:change your finger information
命令用法:chfn  [-f  full-name] [-o office] ,RB [ -p office-phone]
          [-h home-phone] -u] [-v] [username]


encrypted password            加密密碼
date of last password change  最近一次修改密碼的時間
minimum password age          密碼最短使用期限
maximum password age          密碼最長使用期限
password warning period       密碼警告期限
password inactivity period    密碼非活動期限
account expiration date       賬戶過期時間
reserved field                保留字段


命令名稱:change
命令作用:change user password expiry(過期) information
命令用法:chage [options] [LOGIN]
參數選項:-d 最近一次的修改時間
          -E 過期時間
          -I 非活動時間
          -m 最短使用期限
          -M 最長使用時間
          -W 警告時間


命令名稱:id
命令作用:print real and effective user and group IDs
命令用法:id [OPTION]... [USERNAME]
參數選項:-g print only the effective group ID
          -G print all group IDs
          -u print only the effective user ID
          -n print a name instead of a number, for -ugG


命令名稱:chown
命令作用:change file owner and group
命令用法:chown [OPTION]... [OWNER][:[GROUP]] FILE...
          chown [OPTION]... --reference=RFILE FILE...
命令名稱:chgrp
命令作用:change group ownership
命令用法:chgrp [OPTION]... GROUP FILE...
          chgrp [OPTION]... --reference=RFILE FILE...

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章