1. whoami–查看当前登录的用户名
book@100ask:~/linux$ whoami
book
2. echo–打印命令,配合’>’或者’>>’使用
echo 打印信息 //输出信息到终端
echo 打印信息 > 文件名 //先清空文件里面的内容,然后将输出信息保存到文件中
echo 打印信息 > 文件名 //在文件末尾追加信息
============================================================================
book@100ask:~/linux$ echo hello
hello
book@100ask:~/linux$ touch hello.txt
book@100ask:~/linux$ echo hello > hello.txt
book@100ask:~/linux$ cat hello.txt
hello
book@100ask:~/linux$ echo hello1 > hello.txt
book@100ask:~/linux$ cat hello.txt
hello1
book@100ask:~/linux$ echo hello2 >> hello.txt
book@100ask:~/linux$ cat hello.txt
hello1
hello2
3. find–查找命令
find 路径 -name 文件名
find /usr/include -name stdio.h
===========================================================================
/usr/include/x86_64-linux-gnu/bits/stdio.h
/usr/include/stdio.h
/usr/include/c++/7/tr1/stdio.h
4. grep–在文件中搜索字符串信息
grep -Rn "搜索信息" 文件名
===========================================================================
book@100ask:~/linux$ cat hello.txt -n
1 hello1
2 hello2
3 hello world
4 132456
book@100ask:~/linux$ grep -Rn "456" ./hello.txt
4:132456
book@100ask:~/linux$ grep -Rn "hello1" ./hello.txt
1:hello1
5. tar–打包命令
打包:
tar -jcvf 压缩包名.tar.bz2 目录或文件 //把目录和文件打包成bz2格式
tar -zcvf 压缩包名.tar.gz 目录或文件 //把目录和文件打包成gz格式
解包:
tar -xvf 压缩包名.tar.bz2/压缩包名.tar.gz
注意:
windows的rar格式压缩包,linux系统需要安装两个命令,步骤如下:
sudo apt-get install unrar //首先利用网络在ubuntu系统安装rar格式的解压命令
unrar x 压缩包名.rar //对rar压缩包进行解包
uname–查看Linux系统版本信息
book@100ask:~/linux/c01$ uname -a
Linux 100ask 5.4.0-125-generic #141~18.04.1-Ubuntu SMP Thu Aug 11 20:15:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Original: https://www.cnblogs.com/emolife/p/16688246.html
Author: imagelife
Title: Linux命令之find、grep、echo、tar、whoami、uname
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/577810/
转载文章受原作者版权保护。转载请注明原作者出处!