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文件夹中的内容

相关推荐
2301_7809438424 分钟前
linux 对文件打补丁(Patch)
linux·运维·服务器
ICT董老师30 分钟前
通过kubernetes部署nginx + php网站环境
运维·nginx·云原生·容器·kubernetes·php
敬往事一杯酒哈35 分钟前
Ubuntu 20.04 安装Anacada
linux·运维·ubuntu
还在忙碌的吴小二36 分钟前
Jenkins CLI (jcli) 使用手册
运维·jenkins
Lam㊣37 分钟前
服务器端口转发的方法
linux·服务器
zxnbmk38 分钟前
【7】Kubernetes存储(本章知识密度较高,仅浅浅了解后续详解)
linux·云原生·容器·kubernetes
ChangYan.38 分钟前
Windows命令行(cmd)下快速查找文件路径(类似Linux下find命令)
linux·运维·服务器
tao3556671 小时前
VS Code登录codex,报错(os error 10013)
java·服务器·前端
Hey小孩1 小时前
[个人总结] LDD3:3.字符驱动 - scull(4)
linux·驱动开发