Linux 命令精讲(博客案例)

Linux 命令精讲

1、Linux 复习

1.1 提问
markdown 复制代码
# 1、shell 是干嘛的?
# 2、什么是相对路径、绝对路径 
# 3、命令字格式:
命令:核心:(基本功能) 
选项:核心:(附加、额外功能)
参数:指令功能处理的对象

2、Linux 学习

2.1 ls 选项
markdown 复制代码
# ls -R 选项 ,递归显示指定目录的所有子目录的文件列表
[root@localhost usr]# ls -R local/
local/:
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
....省略
local/sbin:

local/share:
applications  info  man

local/share/applications:

local/share/info:

local/share/man:
man1   man2   man3   man4   man5   man6   man7   man8   man9   mann
man1x  man2x  man3x  man4x  man5x  man6x  man7x  man8x  man9x

local/share/man/man1:

local/share/man/man1x:
....省略

# ls -h ,友好显示(简单来说就是显示单位)
[root@localhost opt]# ls -l
总用量 4
-rw-r--r--. 1 root root   0 4月  13 16:04 1.txt
-rw-r--r--. 1 root root 310 4月  13 14:49 ifcfg-ens33
[root@localhost opt]# ls -lh
总用量 4.0K
-rw-r--r--. 1 root root   0 4月  13 16:04 1.txt
-rw-r--r--. 1 root root 310 4月  13 14:49 ifcfg-ens33

小结:ls -R 表示递归显示,递归:逐级目录进行操作

2.2 通配符

**定义:**通配符是系统自带的用于模糊匹配的功能

markdown 复制代码
# 通配符 "?"
[root@localhost opt]# ls
1.txt  2.txt  3.txt  4.txt  ifcfg-ens33
[root@localhost opt]# ls ?.txt
1.txt  2.txt  3.txt  4.txt
[root@localhost opt]# ls 1.tx?
1.txt
[root@localhost opt]# ls 1?txt
1.txt
[root@localhost opt]# ls ????t
1.txt  2.txt  3.txt  4.txt

# 通配符 "*"
[root@localhost opt]# ls *txt
1txt  1.txt  2.txt  3.txt  4.txt
[root@localhost opt]# touch txt
[root@localhost opt]# ls
1txt  1.txt  2.txt  3.txt  4.txt  ifcfg-ens33  txt
[root@localhost opt]# ls *txt
1txt  1.txt  2.txt  3.txt  4.txt  txt
[root@localhost opt]# ls 1*t
1txt  1.txt

小结:"?":匹配文件名中的一个未知字符,而 "*":匹配文件名中的任意多个字符

2.3 du 查看目录和文件占用磁盘的信息
markdown 复制代码
# 命令字格式
du [选项] [文件或目录... ]
du 基本功能:统计目录或文件的大小
# 选项 -a -h -s 
-a 选项:表示统计所有目录及其子目录/子文件的大小,最后求和,例如:
[root@localhost etc]# du -ah
...省略
8.0K    ./man_db.conf
4.0K    ./e2fsck.conf
4.0K    ./mke2fs.conf
4.0K    ./sudo-ldap.conf
4.0K    ./sudo.conf
8.0K    ./sudoers
0       ./sudoers.d
4.0K    ./vconsole.conf
4.0K    ./locale.conf
4.0K    ./hostname
4.0K    ./.updated
12K     ./aliases.db
31M     .

-h 友好显示

-s 只统计总占用空间
[root@localhost etc]# du -sh
31M     .
相关推荐
A小辣椒9 小时前
TShark:Wireshark CLI 功能
linux
A小辣椒13 小时前
TShark:基础知识
linux
AlfredZhao15 小时前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao1 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334661 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪2 天前
linux 拷贝文件或目录到指定的位置
linux
大树882 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠2 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质2 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
bush42 天前
嵌入式linux学习记录十四、术语
linux·嵌入式