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)