linux中的各种指令

按文件的大小进行查找

cpp 复制代码
find / usr -size +100M

在home路径下创建txt文件

cpp 复制代码
touch test.txt

查看test.txt文件中的内容:

cpp 复制代码
cat test.txt

通过指令pwd可以查看当前所处路径。

切换超级用户的指令:

cpp 复制代码
su - root

离开时可以使用指令:exit

grep指令可以,从文件中通过关键字过滤文件行。

cpp 复制代码
grep -n "World" test.txt

效果:

2:printf("hello World");

管道符:|

含义:将管道符左边命令的结果,作为右边命令的输入。

cpp 复制代码
 cat test.txt | grep hello | grep Linux

统计文件中带hello的有几行:

cpp 复制代码
cat test.txt | grep hello | wc -l

统计文件中带world关键字的结果有多少个单词:

cpp 复制代码
 cat test.txt | grep World | wc -w

echo

cpp 复制代码
echo "hello,Linux"

输出

hello,Linux

cpp 复制代码
echo `pwd`
/home/lzy

使用echo 将当前工作目录写入work.txt

cpp 复制代码
echo `pwd` > work.txt

使用echo 将Linux写入work.txt,通过tail命令持续跟踪文件内容更改。

cpp 复制代码
echo "Linux" > work.txt
tail -f work.txt
cpp 复制代码
mv work.txt test/

将work.txt移动到test文件夹。

cpp 复制代码
mkdir test

创建test文件夹

cpp 复制代码
chmod u=rwx,g=r,o=w test.txt

修改test.txt的权限。

cpp 复制代码
mv code.c code

将code.c代码移动到code文件夹

cpp 复制代码
ls test

查看test文件夹中的内容。

cpp 复制代码
ls -l test

查看test文件夹中的内容

相关推荐
Lalolander3 分钟前
设备制造行业如何避免项目管理混乱?
运维·制造·工程项目管理·四算一控·epc·环保设备工程·设备制造
LucianaiB21 分钟前
【金仓数据库征文】_AI 赋能数据库运维:金仓KES的智能化未来
运维·数据库·人工智能·金仓数据库 2025 征文·数据库平替用金仓
prinrf('千寻)37 分钟前
nacos设置权重进行负载均衡不生效
运维·负载均衡
Lary_Rock1 小时前
Android 编译问题 prebuilts/clang/host/linux-x86
android·linux·运维
熬夜学编程的小王1 小时前
【Linux篇】理解信号:如何通过信号让程序听从操作系统的指令
linux·信号产生·软件条件产生信号
子非衣1 小时前
Windows云主机远程连接提示“出现了内部错误”
服务器·windows
绵绵细雨中的乡音1 小时前
Linux进程学习【基本认知】
linux·运维·学习
Johny_Zhao1 小时前
MySQL 高可用集群搭建部署
linux·人工智能·mysql·信息安全·云计算·shell·yum源·系统运维·itsm
lLinkl2 小时前
项目笔记2:post请求是什么,还有什么请求
服务器·网络协议·http
珹洺2 小时前
Linux操作系统从入门到实战(三)Linux基础指令(上)
linux·运维·服务器