在Liunx当中严格区分大小写 在Linux当中一切皆文本
Linux中,如何获得命令帮助 help (内部命令) cd,kill 56条
- ex:help cd--help (适用于大多数外部命令查找) ls
- ls --help使用man手册进行命令查看(man:命令阅读手册)
- “男人没有什么搞不定的”
- man 命令字
- 上下键滚动文本
- Page down & Page Up 上下翻页
- 空格也支持翻页,回车键走一行
- 输入 / ,可以查找info 也可进行命令帮助查找(使用与man接近)pinfo 命令字 以浏览器的形式查看详细的GUN信息/usr/share/doc # 所有已安装软件的说明文件
- firefox file:///usr/share/doc
- 格式: ls [选项] [目录或文件名]
- 选项:
- -l 以长格式显示
- -a 显示所有文件目录信息,包括隐藏文件
- -d 显示目录本身的属性
- -h 显示详情信息,变换了统计单位
- --color 以颜色区分不同类型的文件
- ll == ls -lmkdir: 创建一个新目录
- 格式: mkdir 选项-p 目录名
- -p: 递归创建多级目录
- mkdir -p b/c/e/f/grmdir: 删除一个空目录
- -p: 递归删除
- 格式: rm [选项] 文件或者目录
- -r: 递归删除整个目录树
- -f: 强制删除不给任何提示
[root@localhost ~]# find / -name initial-setup-ks.cfg
/root/initial-setup-ks.cfg
[root@localhost ~]# find / -name initial-*
/root/initial-setup-ks.cfg
[root@localhost ~]# find / -name initial-*-*
/root/initial-setup-ks.cfg
[root@localhost ~]#
- -type: 按文件类型查找
- f: 普通文件
- d: 目录
- b: 块设备文件
- c: 字符设备文件
[root@localhost ~]# find / -name text -type d
- -user: 按文件属主查找(这个文件是谁的)
[root@localhost ~]# find / -user ruochen -name initial-setup-ks.cfg -type f
[root@localhost ~]# find / -user ruochen -type f -name ruochen.initial-setup-ks.cfg
- -size: 按文件大小进行查找
[root@localhost ~]# find /var/ -size +10k -type f
[root@localhost ~]# find /var/ -size -1k -type f
[root@localhost ~]# find /var/ -size +10k -size -11k -type f
- -a: 逻辑与
- -o: 逻辑或
[root@localhost ~]# find / -name anaconda-ks.cfg -o -name initial-setup-ks.cfg
/root/anaconda-ks.cfg
/root/initial-setup-ks.cfg
- !: 逻辑非
[root@localhost ~]# find / ! -name temp -type f
grep -c 'boot' initial-setup-ks.cfg
7
[root@localhost ~]# alias aa="grep -c 'boot' initial-setup-ks.cfg "
[root@localhost ~]# alias aa
alias aa='grep -c '\''boot'\'' initial-setup-ks.cfg '
[root@localhost ~]# aa
7
- 取消别名: unalias [别名/-a]
- -a: 取消所有别名
[root@localhost ~]# unalias aa
- 让别名永久生效
- 将别名设置在~/.bashrc文件中
- vim .bashrc
cd cd. cd.. 针对目录来说 . 当前位置/目录 pwd 针对文件来讲 . 在Linux中代表隐藏文件
cd | cd. | cd ..
~ 代表用户家目录上次所操作的目录
[root@localhost ~]# head -n 5 initial-setup-ks.cfg
[root@localhost ~]# tail -n 5 initial-setup-ks.cfg
[root@localhost ~]# wc initial-setup-ks.cfg
- 选项: - -w: 统计字数 一个字被定义为由空白,跳格(制表符),换行以这些为分割字符串 - -l: 行数 - -c: 字节数 - -m: 字符数 -m -c不能一起使用 - -L: 打印最长行的长度
[root@localhost ~]# wc -l -c -w -L initial-setup-ks.cfg
[root@localhost ~]# grep -c 'boot' initial-setup-ks.cfg
7
[root@localhost ~]# grep -c -v 'boot' initial-setup-ks.cfg
42
[root@localhost ~]# grep -i 'agent' initial-setup-ks.cfg
- 查找条件设置:
1. 查找条件用引号引起来
2. "^...": 表示以... 开头
3. "...$": 表示以... 结尾
4. "^$": 匹配空行
[root@localhost ~]# grep -c '^$' anaconda-ks.cfg
[root@localhost ~]# grep -cv '^$' anaconda-ks.cfg
[root@localhost ~]# grep -c '^#' anaconda-ks.cfg
12
[root@localhost ~]# grep -c 'ation$' anaconda-ks.cfg
5
tar -czvf text.tar.gz text
tar -cjvf text.tar.bz2 text
tar -czvf /root/var.tar.gz /var/
tar -cjvf /root/var.tar.bz2 /var/
tar -czvf a.tar.gz text-1 text-2
[root@localhost ~]# tar -xzvf text.tar.gz
[root@localhost ~]# tar -xjvf text.tar.bz2
[root@localhost ~]# tar -xjvf text.tar.bz2 -C test
.gz格式
.bz2格式
.bz2格式压缩率比.gz格式压缩率高
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。