1.Linux系統下的幫助命令mannode
Linux下的幫助指令,經過man指令能夠查看Linux中的指令幫助、配置文件幫助和編程幫助等信息編程
man 命令
2.爲了方便查看系統目錄結構,使用tree(樹狀)命令:centos
[root@yolks1 ~]# tree -bash: tree: 未找到命令 [root@yolks1 ~]# yum install -y tree 已加載插件:fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 166 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 147 kB 00:00:00 (3/4): base/7/x86_64/primary_db | 5.9 MB 00:00:03 (4/4): updates/7/x86_64/primary_db | 2.0 MB 00:00:03 Determining fastest mirrors * base: mirrors.cn99.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 tree.x86_64.0.1.6.0-10.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 ============================================================================================= Package 架構 版本 源 大小 ============================================================================================= 正在安裝: tree x86_64 1.6.0-10.el7 base 46 k 事務概要 ============================================================================================= 安裝 1 軟件包 總下載量:46 k 安裝大小:87 k Downloading packages: 警告:/var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY tree-1.6.0-10.el7.x86_64.rpm 的公鑰還沒有安裝 tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索密鑰 導入 GPG key 0xF4A80EB5: 用戶ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" 指紋 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 軟件包 : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda) 來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : tree-1.6.0-10.el7.x86_64 1/1 驗證中 : tree-1.6.0-10.el7.x86_64 1/1 已安裝: tree.x86_64 0:1.6.0-10.el7 完畢!
// yum安裝 yum install -y tree // 幫助命令(不經常使用) tree --help // man查詢用法(經常使用) man tree // 示例:查看根目錄如下兩級 tree -L 2 /
3.Linux根目錄下各子目錄詳解bash
用來顯示目標列表,在Linux中是使用率較高的命令。ls命令的輸出信息能夠進行彩色加亮顯示,以分區不一樣類型的文件。架構
l 詳細信息 == ll(ls -l)ssh
[root@yolks1 ~]# ls -l 總用量 4 -rw-------. 1 root root 1418 5月 25 05:32 anaconda-ks.cfg
[root@yolks1 ~]# which ll alias ll='ls -l --color=auto' /usr/bin/ls
i inode號,記錄建立/修改時間、大小、所屬組、全部者等信息插件
[root@yolks1 ~]# ls -i anaconda-ks.cfg 33574978 anaconda-ks.cfg
a 顯示出包含隱藏文件或目錄所有信息3d
[root@yolks1 ~]# ls anaconda-ks.cfg [root@yolks1 ~]# ls -a . anaconda-ks.cfg .bash_logout .bashrc .ssh .. .bash_history .bash_profile .cshrc .tcshrc
// 結合使用 [root@yolks1 ~]# ls -la 總用量 28 dr-xr-x---. 3 root root 147 5月 27 16:50 . dr-xr-xr-x. 17 root root 265 5月 27 18:02 .. -rw-------. 1 root root 1418 5月 25 05:32 anaconda-ks.cfg -rw-------. 1 root root 482 5月 27 19:39 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc drwx------. 2 root root 80 5月 27 19:48 .ssh -rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
t 用文件和目錄的更改時間排序(默認倒序排列,即最新的在頂)日誌
[root@yolks1 ~]# ls -lt /var/ 總用量 12 drwxr-xr-x. 7 root root 4096 6月 1 20:27 log drwxrwxrwt. 14 root root 4096 6月 1 20:21 tmp drwxr-xr-x. 25 root root 4096 5月 25 05:34 lib drwxr-xr-x. 3 root root 34 5月 25 05:29 db drwxr-xr-x. 5 root root 44 5月 25 05:29 cache drwxr-xr-x. 3 root root 18 5月 25 05:29 empty drwxr-xr-x. 8 root root 87 5月 25 05:29 spool drwxr-xr-x. 3 root root 18 5月 25 05:28 kerberos lrwxrwxrwx. 1 root root 10 5月 25 05:28 mail -> spool/mail lrwxrwxrwx. 1 root root 11 5月 25 05:28 lock -> ../run/lock lrwxrwxrwx. 1 root root 6 5月 25 05:28 run -> ../run drwxr-xr-x. 2 root root 6 8月 7 2017 crash drwxr-xr-x. 2 root root 6 11月 5 2016 adm drwxr-xr-x. 2 root root 6 11月 5 2016 games drwxr-xr-x. 2 root root 6 11月 5 2016 gopher drwxr-xr-x. 2 root root 6 11月 5 2016 local drwxr-xr-x. 2 root root 6 11月 5 2016 nis drwxr-xr-x. 2 root root 6 11月 5 2016 opt drwxr-xr-x. 2 root root 6 11月 5 2016 preserve drwxr-xr-x. 2 root root 6 11月 5 2016 yp
d 僅顯示查看目錄,不會顯示目錄下的文件code
[root@yolks1 ~]# ls -d /root/ /root/
[root@yolks1 ~]# ls -ld /root/ dr-xr-x---. 3 root root 147 5月 27 16:50 /root/
h 以最合適的大小顯示文件大小
[root@yolks1 ~]# ls anaconda-ks.cfg [root@yolks1 ~]# ls -lh anaconda-ks.cfg -rw-------. 1 root root 1.4K 5月 25 05:32 anaconda-ks.cfg
更多詳細用法詳見 man ls命令幫助選項
- 普通文件 (能夠cat打開)
d 目錄
c 字符串設備(鼠標、鍵盤)
l 軟連接 (至關於Windows快捷方式)
b 塊設備(光盤、磁盤)
s 機器內通訊文件 (進程間通訊文件)
用來設置指令的別名。咱們可使用該命令能夠將一些較長的命令進行簡化。使用alias時,用戶必須使用單引號''將原來的命令引發來,防止特殊字符致使錯誤。
查詢具體某個命令別名詳細信息
which 命令
[root@yolks1 ~]# which man /usr/bin/man [root@yolks1 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls [root@yolks1 ~]# which cd /usr/bin/cd
顯示當前系統所有別名
[root@yolks1 ~]# alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
環境變量(Windows也有此概念) PATH
[root@yolks1 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
alias 新的命令='原命令 -選項/參數'
示例 :
[root@yolks1 ~]# alias yolks='ls -lha' [root@yolks1 ~]# yolks 總用量 28K dr-xr-x---. 3 root root 147 5月 27 16:50 . dr-xr-xr-x. 17 root root 265 5月 27 18:02 .. -rw-------. 1 root root 1.4K 5月 25 05:32 anaconda-ks.cfg -rw-------. 1 root root 482 5月 27 19:39 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc drwx------. 2 root root 80 5月 27 19:48 .ssh -rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
查看來源
[root@yolks1 ~]# which yolks alias yolks='ls -lha' /usr/bin/ls
[root@yolks1 ~]# unalias yolks [root@yolks1 ~]# yolks -bash: yolks: 未找到命令 [root@yolks1 ~]# which yolks /usr/bin/which: no yolks in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)