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     .
相关推荐
Android系统攻城狮1 小时前
Linux PipeWire深度解析之pw_factory_create_object调用流程与实战(七十二)
linux·音频进阶·pipewire音频进阶
lsh曙光2 小时前
playbook剧本(2)--Ansible变量
linux·运维·网络
START_GAME2 小时前
MSSQL$SQL2016
java·服务器·前端
lengjingzju2 小时前
编译与调试完全指南—第14章 系统配置与调优
linux
ly76892 小时前
Docker 从入门到实践:镜像、容器、Dockerfile 与 Docker Compose 详解
运维·docker·容器
大鹏的NLP博客3 小时前
通用 Linux 嵌入式板端 C/C++ ABI 与 Glibc 依赖治理规范
linux·c++·交叉编译
用户3169353811833 小时前
ry.bat和ry.sh部署
运维
mennekes3 小时前
自动化产线临时配电:明装工业插座 vs 面板式工业插座 vs 模块化插座箱取舍
运维·科技·安全·制造
tedcloud1233 小时前
book-to-skill 怎么部署?把技术书和项目文档变成 AI Agent 可复用知识
linux·运维·服务器·人工智能·开源
旗开得胜马到成功3 小时前
SK海力士SSD售后翻车:企业备份介质裸奔风险与中科热备技术选型拆解
运维·服务器·网络