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

相关推荐
码农101号13 分钟前
运维安全05 - iptables规则保存与恢复
运维·网络·安全
Empty_77716 分钟前
SELinux安全上下文
linux·服务器·安全
bug攻城狮1 小时前
解决Ubuntu中apt-get -y安装时弹出交互提示的问题
linux·运维·ubuntu
xiachong271 小时前
ubuntu18.04安装PCL1.14
linux·ubuntu
夜阑珊夭夭2 小时前
linux自定义网卡名字
linux·运维
czhc11400756632 小时前
Linux912 shell:$# $1 $?;RHEL 8 AppStream BaseOS
linux
佛天华2 小时前
centos 时间校准
linux·运维·centos
小柯J桑_3 小时前
Linux:线程封装
linux·运维·c++
先锋队长3 小时前
linux系统搭建nacos集群,并通过nginx实现负载均衡
linux·nginx·负载均衡