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 19:53
下一篇 2016-10-30 20:00

相關推薦

  • 內核相關

    內核兩大流派單內核微內核 grub分為三個階段:1階段 1.5階段 2階段 內核階段 通過/proc/cmdline找到根并掛載2階段內容是放在/boot/grub目錄下Centos6 實驗:丟失除grub.conf外所有文件沒有修復過的時候/boot/grub下文件是放在磁盤上某個位置的修復過一次后/boot/grub下文件就起作用了,一旦執行過grub-…

    Linux干貨 2018-01-03
  • Linux網絡屬性管理(一)

    MarkdownPad Document Linux網絡屬性管理(一) 將一臺linux主機接入互聯網一般需要配置以下幾個方面的參數: IP/mask –>  IP地址和子網掩碼 路由 –> 默認網關 DNS服務器 配置方式 靜態指定:   1、ifcfg:ifconfig,route,netstat   2、i…

    Linux干貨 2016-06-12
  • ?N22-℡浮生.若夢 ╮第五周作業

    1、顯示當前系統上root、fedora或user1用戶的默認shell; ~]# grep -E "^(root|user1|fedora)" /etc/passwd |cut -d: -f1,7 root:/bin/bash user1:/bin/bash fedo…

    Linux干貨 2016-10-09
  • Nginx反向代理、負載均衡的實現

    概述:     上篇介紹了Nginx作為web服務器的一些常用配置的說明,但是在實際生產環境中,Nginx更多是作為前端的負載均衡器,反代前端用戶請求到后端真實的web服務器上,完成LNAMP的組合的方式存在。本篇就介紹一些Nginx作為http的反向代理和前端負載均衡調度器的一些常用配置,具體包括:  &n…

    Linux干貨 2016-11-01
  • Network Teaming網絡組總結

    一、Network Teaming網絡組的創建 第一步;準備工作,建立兩個網絡接口eth0、eth1,把原有網卡配置文件刪除; 命令:cd /etc/sysconfig/network-scripts                rm -rf ifcfg-* &nbs…

    2017-03-26
  • HAproxy reload config file with uninterrupt session

    HAProxy is a high performance load balancer. It is very light-weight, and free, making it a great option if you are in the market for a load balancer and need to keep your cos…

    Linux干貨 2015-04-03

評論列表(1條)

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

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

欧美性久久久久