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     .
相关推荐
本尊是喵11 分钟前
AutoDL--FileZilla--VS Code远程连接
运维·服务器
FREEDOM_X12 分钟前
Linux 进程间通讯(IPC)——总结
linux·c语言·前端·嵌入式硬件·struts
天空'之城16 分钟前
Linux 系统编程 17:零拷贝技术全解
linux·嵌入式·零拷贝技术全解
网络小白不怕黑38 分钟前
11.虚拟机模拟路由器实验
linux·运维·服务器·网络
Mapleay44 分钟前
Linux 内核编程基础
linux·运维·服务器
小则又沐风a1 小时前
深入理解文件系统(二)
java·服务器·前端
大博士.J1 小时前
浏览器自动化工具选型实战
运维·自动化
承渊政道1 小时前
OneNav书签导航实操:极空间Docker部署、分类整理与公网访问
运维·docker·内网穿透·cpolar·nas·onenav·轻量级部署
2601_963016261 小时前
统一消息与事件调用:如何用微信接口把微信自动化做成稳健中台?
大数据·运维·人工智能·微信·自动化
天蓝的想1 小时前
Kueue 如何管理 DRA 模式下的 GPU 配额
运维·服务器