Linux學習筆記(6)Linux常用命令之協助命令與使用者管理命令

來源:互聯網
上載者:User

標籤:

(1)man

man命令用於獲得命令或設定檔的協助資訊,英文原意為manual,所在路徑為/usr/bin/man,其文法格式為:

man [命令或設定檔]

注意:查看設定檔的協助資訊時無需絕對路徑。

查看命令的協助資訊主要查看命令的用途(NAME)及相應的選項,而設定檔的協助主要是查看存放資訊(NAME)及其對應的格式。Linux中每個設定檔都有對應的格式。

如查看ls命令的協助,man ls,查看/ect下services設定檔的協助:man services。

特例:查看passwd配置文檔協助時,顯示出來的是passwd命令的協助資訊:

[[email protected] ~]# man passwdPASSWD(1)            User utilities               PASSWD(1)NAME       passwd - update user’s authentication tokens SYNOPSIS       passwd  [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays]       [-w warndays] [-i inactivedays] [-S] [--stdin] [username]

隨後使用whereis命令查看passwd的路徑:

[[email protected] ~]# whereis passwdpasswd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

可以看到passwd存在兩處,其中的man1/passwd.1.gz中的"1"表示的是命令的協助,man5/passwd.5.gz中的"5"表示的是設定檔的協助,因此,可通過如下方式查看設定檔的協助:

[[email protected] ~]# man 5 passwdPASSWD(5)           Linux Programmer’s Manual         PASSWD(5)NAME       passwd - password fileDESCRIPTION       Passwd  is  a  text  file, that contains a list of the system’s
(2)whatis

whatis命令可以得到命令簡短的介紹資訊,不用像man一樣完全顯示,其格式為:

man [命令]

例:顯示ls的簡短協助資訊:

[[email protected] ~]# whatis lsls                   (1)  - list directory contentsls                   (1p)  - list directory contents
(3)apropos

apropos命令用於查看設定檔的簡簡訊息,其文法格式為:

apropos [設定檔]

例:顯示/etc下inittab的簡短協助資訊:

[[email protected] ~]# apropos inittabinittab              (5)  - init daemon configuration
(4)--help

一個命令加—help,可以顯示該命令的主要選項,如顯示touch命令的主要選項:

[[email protected] ~]# touch --help用法:touch [選項]... 檔案...將每個檔案的訪問時間和修改時間改為目前時間。不存在的檔案將會被建立為空白檔案,除非使用-c 或-h 選項。如果檔案名稱為"-"則特殊處理,更改與標準輸出相關的檔案的訪問時間。長選項必須使用的參數對於短選項時也是必需使用的。  -a                    只更改訪問時間  -c, --no-create       不建立任何檔案  -d, --date=字串     使用指定字串表示時間而非目前時間  -f                    (忽略)
(5)help

help命令用於擷取shell內建命令的協助信息,內建命令即使用which,whereis命令無法找到所在路徑的命令,help為內建命令,其文法格式為:

help [命令]

例:尋找umask的協助:

[[email protected] ~]# help umaskumask: umask [-p] [-S] [mode]    Display or set file mode mask.

註:help也可以查看if、case、while等shell編程的協助資訊。

(6)useradd

useradd命令用於添加新使用者,所在路徑為/usr/sbin/useradd,其文法格式為:

useradd [使用者名稱]

(7)passwd

passwd命令用於設定使用者密碼,所在路徑為/usr/bin/passwd,其文法格式為:

passwd [使用者名稱]

註:密碼需符合密碼規範。

(8)who

who命令用於查看登陸使用者資訊,所在路徑為/usr/bin/who,

[[email protected] ~]# whoroot     tty1         2015-01-07 22:30root     pts/0        2015-01-07 22:37 

第一個root為登陸使用者名稱,第二個tty表示本地終端,pts表示遠程終端,最後欄位為登入時間。

(9)w

w命令用於查看登陸使用者的詳細資料,所在路徑為/usr/bin/w

[[email protected] ~]# w16:31:16 up  2:45,  2 users,  load average: 0.04, 0.02, 0.00USER   TTY       FROM            [email protected]   IDLE   JCPU   PCPU   WHATroot   tty1      -               Wed22    5days  0.63s  0.63s  -bashroot   pts/0     10.2.108.214    Wed22    0.00s  3.80s  0.01s  w

其中up顯示伺服器連續已耗用時間,load average表示伺服器的負載情況,WHAT表示目前使用者正在執行的命令,JCPU表示累計佔用CPU時間,PCPU表示當前執行命令佔用的CPU時間。

Linux學習筆記(6)Linux常用命令之協助命令與使用者管理命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.