linux全方位掌握一個命令–思路比方法更重要

Linux命令眾多,當不清楚一個命令的使用方法時,我們該怎樣了解命令的屬性和幫助?

1.  用type命令了解一個命令的屬性

[root@zejin240 testdir]# type cd
cd is a shell builtin
[root@zejin240 testdir]# type rm
rm is aliased to `rm -i'
[root@zejin240 testdir]# type mysql
mysql is /opt/lamp/mysql/bin/mysql
cd屬于linux的內置命令,可以用man type查看所有的內置命令,rm是我們設置的一個別名,mysql是一個外部命令

2. 用which命令查看命令的全路徑在哪

[root@zejin240 testdir]# which mkdir
/bin/mkdir
[root@zejin240 testdir]# which mysql
/opt/lamp/mysql/bin/mysql
[root@zejin240 testdir]# which cp
alias cp='cp -i'
/bin/cp

3. 用whatis命令來查看命令的簡要信息

[root@zejin240 testdir]# whatis rm
rm (1p) – remove directory entries
rm (1) – remove files or directories
[root@zejin240 testdir]# whatis passwd
passwd (1) – update user's authentication tokens
passwd (5) – password file
passwd [sslpasswd] (1ssl) – compute password hashes

4. 對于內置命令,我們可以用help command來獲取命令幫助信息

[root@zejin240 testdir]# help exit
exit: exit [n]
Exit the shell.

Exits the shell with a status of N. If N is omitted, the exit status
is that of the last command executed.

內置命令有哪些,再強調一次,用man type命令可以查看得到

5. 對于非內置命令,一般可以用command –help來獲取幫助信息

[root@zejin240 testdir]# mysql –help
mysql Ver 14.14 Distrib 5.7.12, for linux-glibc2.5 (x86_64) using EditLine wrapper
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
……
-e, –execute=name Execute command and quit. (Disables –force and history
file.)
-E, –vertical Print the output of a query (rows) vertically.
-f, –force Continue even if we get an SQL error.
……

6. 對于非內置命令,也可以用man command命令查看

[root@zejin240 tmp]# man pwd
   

linux全方位掌握一個命令--思路比方法更重要

在彈出的頁面中,左上角為其章節,man總共有8個章節,還記得上面提到的whatis命令么,命令顯示出來的括號里面的1、1p、5是man和頁面中的章節對應的。
那么man命令里面的8個章節都有特定的描述規定,它們分別是
第一章節:描述用戶命令的使用方法
第二章節:描述系統調用的使用方法
第三章節:描述C的庫函數使用方法
第四章節:描述設備及特殊文件
第五章節:描述配置文件的格式及約定
第六章節:描述游戲信息
第七章節:描述其它雜項
第八章節:描述系統管理工具及后臺進程

這八個章節的描述可以用man man查看得到。

如果用man command進去的話會顯示第一個它搜索到的章節,那像上面提到的passwd命令,我們知道它有第五章節,那怎么進去呢?
用:man 5 passwd即可,類似的還有man 1p rm
我們知道passwd命令對應的是/etc/passwd,所以它對應的就是此文件的介紹,每個字段對應的是什么含義,如下,可以打開/etc/passwd文件和下面的描述對應看看
   

linux全方位掌握一個命令--思路比方法更重要

類似的,man 5 shadow,描述的是/etc/shadow文件的格式介紹。

7. 用info command查看

  主要是一些命令的歷史介紹,平時很少用到

建議:

  多用help命令及man,英文不懂也要硬著看,甚至比去各種搜索都還強悍,而且這也是最官方,最權威的解讀。

原創文章,作者:chenzejin,如若轉載,請注明出處:http://www.www58058.com/56226

(0)
chenzejinchenzejin
上一篇 2016-10-30
下一篇 2016-10-30

相關推薦

  • 前兩天課程中學到的東西

    一、計算機組成部分 由CPU,存儲器和輸入輸出系統三大部分組成(或者可以說成四大部分) CPU:相當于大腦,用來執行最重要的任務:計算 存儲器:相當于身體,為CPU提供計算所需要的所有東西 輸入輸出設備:四肢,為整個系統提供需要計算的內容,吧需要給供給CPU的東西放入存儲器中 二、linux發行版,linux發行版主要有三個大類:debian,slackwa…

    Linux干貨 2016-10-30
  • N21-兔鍋-第四周作業

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。     cp -a /etc/skel /home/tuser1     chmod g-x /home/tuser1/     chmod o-x /home/t…

    Linux干貨 2016-07-26
  • Linux 學習基本

    環境配置主要分硬件和軟件兩種

    2018-03-26
  • linux文件管理類命令學習總結練習

    1、常用文件管理類命令:cp, mv, rm   cp: copy命令       單元復制 cp [OPTION]… [-T] SOURCE DEST                     DEST不存在…

    Linux干貨 2016-11-06
  • 正則表達式

    1、用正則表達式表示IP地址 擴展正表達式表示的: (\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>.){3}\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\> 2、用正則表達式表示手機號 "^1[3578…

    Linux干貨 2016-08-07
  • linux 磁盤管理

    磁盤管理 Linux思想一切皆文件: open(),read(),write(),close() I/O 設備地址 設備類型: 塊設備:block,存取單位“塊”,磁盤 (隨機訪問) 字符設備:char,存取單位“字符”,鍵盤 (邏輯訪問) 設備文件:關聯至一個設備驅動程序,進而能夠跟與之對應硬件設備進行通訊。 設備編號: ll /dev/sda* root…

    Linux干貨 2016-08-29

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-11-02 16:09

    內容格式把握得很好,不錯,希望你能熟知基礎命令知識,加油!

欧美性久久久久