首页 >> 大全

Linux常用指令和选项

2023-12-20 大全 21 作者:考证青年

目录 cal指令find指令:(very ) -指令zip/unzip指令tar指令(重要):打包/解包,不打开它,直接看内容bc指令(浮点数运算)uname –r指令重要的几个热键[Tab],[ctrl]-c, [ctrl]-d

前言

本篇文章进行Linux指令的学习!!!

ls指令

语法:ls [选项][目录或文件]

功能:对于目录,该命令列出该目录下的所有子目录与文件。对于文件,将列出文件名以及其他信息

常用选项:

演示几个常用的:

[@localhost 2022_9_7]$ ls -a
.  ..  makefile  test  test.cpp
[@localhost 2022_9_7]$ ls -l
总用量 28
-rw-rw-r--. 1 lyh_sky lyh_sky    73 99 11:07 makefile
-rwxrwxr-x. 1 lyh_sky lyh_sky 19672 99 11:07 test
-rw-rw-r--. 1 lyh_sky lyh_sky   185 99 11:07 test.cpp
[@localhost 2022_9_7]$ ls -al
总用量 28
drwxrwxr-x. 2 lyh_sky lyh_sky    50 99 11:07 .
drwxrwxr-x. 6 lyh_sky lyh_sky    79 97 23:27 ..
-rw-rw-r--. 1 lyh_sky lyh_sky    73 99 11:07 makefile
-rwxrwxr-x. 1 lyh_sky lyh_sky 19672 99 11:07 test
-rw-rw-r--. 1 lyh_sky lyh_sky   185 99 11:07 test.cpp

注意:" 点 "和 " 点点 " 隐藏文件是保存当前路径和上一个路径的文件

如果我们创建一个文件并且不写入数据,在磁盘中占据空间吗???

答案是:是的!磁盘需要保存文件属性的数据,文件 = 属性 + 数据

注意:属性是文件创建时的日期时间,文件名等等…

pwd指令

语法:pwd

功能:显示当前用户所在的路径

常用选项:无

[@localhost ~]$ pwd // 显示当前工作目录下的路径
/home/lyh_sky

cd指令

语法:cd 目录名

功能:改变工作目录,将当前工作目录改变到指定的目录下

常用选项:无

cd .. : 返回上级目录
cd /home/litao/linux/ : 绝对路径
cd ../day02/ : 相对路径
cd ~:进入用户家目
cd -:返回最近(上一次)访问的目录

touch指令

语法:touch [选项] [文件名]

功能: 它可更改文档或目录的日期时间,包括存取时间和更改时间,或者新建一个不存在的文件

常用选项:

[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 23 2022 test
[@localhost test]$ touch -d 5:20 test // 指定修改时间
[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 99 05:20 test[@localhost test]$ touch -m test // 默认设置日期时间为系统时间
[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 99 23:13 test[@localhost test]$ touch -t '202210011200' test // 更改日期时间为2022年10月1日12:00
[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 101 2022 test[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 101 2022 test
-rw-rw-r--. 1 lyh_sky lyh_sky 0 99 23:15 test2
[@localhost test]$ touch -r test2 test //将test的日期时间更改为test2的日期时间
[@localhost test]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 99 23:15 test
-rw-rw-r--. 1 lyh_sky lyh_sky 0 99 23:15 test2

注意:一般直接使用创建文件,或者直接vim创建文件

mkdir指令()

语法: mkdir [选项] [目录名]

功能:在当前工作目录下创建一个空目录

常用选项:

[@localhost test]$ mkdir dir // 创建空目录
[@localhost test]$ ll
drwxrwxr-x. 2 lyh_sky lyh_sky 6 99 23:26 dir[lyh_sky@localhost test]$ cd dir // 进入dir目录
[lyh_sky@localhost dir]$ pwd 		// 显示当前路径
/home/lyh_sky/test/dir
[lyh_sky@localhost dir]$ mkdir -p dir1 dir2 dir3 // 在当前目录递归创建三个目录
[lyh_sky@localhost dir]$ tree . // 以树形结构显示当前目录下的结构
. // 点是dir目录的路径
├── dir1
├── dir2
└── dir33 directories, 0 files //三个目录。0个文件

rmdir指令 && rm指令()

rmdir是一个与mkdir相对应的命令。 mkdir是建立目录,而rmdir是删除命令

语法:rmdir [-p] [目录名]

适用对象:具有当前目录操作权限的所有使用者

功能:删除空目录

[@localhost test]$ tree dir
dir
├── dir1
├── dir2
└── dir3
[@localhost test]$ rmdir -p dir
rmdir: 删除 "dir" 失败: 目录非空[@localhost test]$ ll
drwxrwxr-x. 2 lyh_sky lyh_sky 6 99 23:46 dir1
[@localhost test]$ tree dir1
dir1 // dir1目录为空目录0 directories, 0 files
[@localhost test]$ rmdir -p dir1
[@localhost test]$ ll

注意:rmdir只能删除空目录,不能删除文件

rm指令可以同时删除目录和文件

语法: rm [选项][目录/文件名]

适用对象:适合所有操作者

功能:可以删除目录和文件

常用选项:

[@localhost ~]$ ls -al test/
总用量 4
drwxrwxr-x.  4 lyh_sky lyh_sky   30 99 23:54 .
drwx------. 22 lyh_sky lyh_sky 4096 99 22:57 ..
drwxrwxr-x.  2 lyh_sky lyh_sky   18 99 23:54 dir1
drwxrwxr-x.  2 lyh_sky lyh_sky   18 99 23:55 dir2
[@localhost ~]$ tree test/
test/
├── dir1
│   └── test
└── dir2└── test2 directories, 2 files // 二个目录,二个文件[@localhost ~]$ rm -rf test		// 一般这两个选项一起用
[lyh_sky@localhost ~]$ ls -al test
ls: 无法访问test/: 没有那个文件或目录

注意:在Linux系统下不要随便删文件,因为他不像一样有回收站

man指令()

Linux的命令有很多参数,我们不可能全记住,我们可以通过查看联机手册获取帮助

我们可以使用man来进行查询:man [选项] 命令

常用选项:

解释一下,面手册分为8章:

第1章是普通的命令

linux命令选项是什么__linux基本指令的用法

第2章是是系统调用,如open,write之类的(通过这个,至少可以很方便的查到调用这个函数,需要加什么头文件,还有就是怎么使用它)

第三章是库函数,如,是特殊文件,也就是/dev下的各种设备文件

第五章是指文件的格式,比如, 就会说明这个文件中各个字段的含义

第六章是给游戏留的,由各个游戏自己定义

第七章是附件还有一些变量,比如向这种全局变量在这里就有说明

第八章是系统管理用的命令,这些命令只能由root使用,如

cp指令()

语法: cp [选项] [源文件或目录] [目标文件或目录]

功能: 复制文件或目录

说明:

常用功能选项:

// 拷贝文件
[@localhost test1]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 0 910 11:19 file
drwxrwxr-x. 2 lyh_sky lyh_sky 6 910 11:18 test
[@localhost test1]$ cp ./file ./test/
[@localhost test1]$ ll ./test/
-rw-rw-r--. 1 lyh_sky lyh_sky 0 910 11:19 file// 使用-r选项递归拷贝目录
[lyh_sky@localhost test1]$ ll
drwxrwxr-x. 2 lyh_sky lyh_sky 57 910 11:22 test
drwxrwxr-x. 2 lyh_sky lyh_sky  6 910 11:22 test2
[lyh_sky@localhost test1]$ tree test
test
├── file
├── file1
├── file2
└── file30 directories, 4 files
[lyh_sky@localhost test1]$ cp -r ./test ./test2
[lyh_sky@localhost test1]$ tree test2
test2
└── test├── file├── file1├── file2└── file31 directory, 4 files

mv指令(剪切/重命名)()

说明:mv命令是move的缩写,可以用来移动文件或者将文件改名(move () files),是Linux系统下常用的命令,经常用来备份文件或者目录

语法:mv [选项] [源文件或目录] [目标文件或目录]

功能:

常用选项:

[@localhost test1]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky  0 910 11:40 file
drwxrwxr-x. 3 lyh_sky lyh_sky 18 910 11:23 test[@localhost test1]$ mv file file2 // 将file文件重命名为file2
[@localhost test1]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky  0 910 11:40 file2
drwxrwxr-x. 3 lyh_sky lyh_sky 18 910 11:23 test[@localhost test1]$ mv file2 test/
[@localhost test1]$ ll
drwxrwxr-x. 3 lyh_sky lyh_sky 31 910 11:43 test
[@localhost test1]$ tree test/
test/
├── file2
└── test├── file├── file1├── file2└── file31 directory, 5 files[@localhost test1]$ ll
drwxrwxr-x. 3 lyh_sky lyh_sky 18 910 11:43 test[@localhost test1]$ mv test test2 // 将test目录重命名为test2
drwxrwxr-x. 3 lyh_sky lyh_sky 31 910 11:43 test2

cat指令

语法: cat [选项][文件]

功能: 查看目标文件的内容

常用选项:

[@localhost Test_Make]$ ll
总用量 5
-rw-rw-r--. 1 lyh_sky lyh_sky   79 95 10:54 main.cpp[@localhost Test_Make]$ cat main.cpp // 显示文件内容
#include "test.h"int main()
{Show();cout << Num << endl;return 0;
}[@localhost Test_Make]$ cat -n main.cpp // 对输出行编号1	#include "test.h"2	3	int main()4	{5	  Show();6	  cout << Num << endl;7	  return 0;8	}[@localhost Test_Make]$ cat -s main.cpp // 不输出多行空格
#include "test.h"int main()
{Show();cout << Num << endl;return 0;
}[lyh_sky@localhost Test_Make]$ cat -b main.cpp // 不输出空行且对行进行编号1	#include "test.h"2	int main()3	{4	  Show();5	  cout << Num << endl;6	  return 0;7	}

more指令

语法:more [选项] [文件名]

功能:该命令类似于cat,用于阅读量比较大的文本文件,支持往前翻阅读文件

常用选项:

// 这是一个while语句,将1w个hello world输入到123.txt中,并且编号
[@localhost Linux_Study]$ cnt=1; while [ $cnt -le 10000 ]; do echo "hello world $cnt"; let cnt++; done > 123.txt[lyh_sky@localhost Linux_Study]$ ll
-rw-rw-r--. 1 lyh_sky lyh_sky 168894 910 20:27 123.txt
[lyh_sky@localhost Linux_Study]$ less 123.txt 

注意:进入more指令后,按下键可以对文件内容进行前翻

less指令()

语法:less [选项] [文件名]

功能:less与more类似,但使用less可以随意浏览文件,而more仅能向前移动,却不能向后移动,而且less在查看之前不会加载整个文件

常用选项:

这个自己去试试,不好截图和粘贴代码
[@localhost Linux_Study]$ cnt=1; while [ $cnt -le 10 ]; do echo "hello world $cnt"; let cnt++; done > 123.txt
[@localhost Linux_Study]$ less -N 123.txt // 显示每行的行号
1 hello world 1
2 hello world 2
3 hello world 3
4 hello world 4
5 hello world 5
6 hello world 6
7 hello world 7
8 hello world 8
9 hello world 9
10 hello world 10[@localhost Linux_Study]$ less -N 123.txt // 忽略搜索时的大小写
hello world 1
hello world 2
hello world 3
hello world 4
hello world 5
hello world 6
hello world 7
hello world 8
hello world 9
hello world 10

输入/输出/追加重定向(/>>)

输入重定向():将输入(键盘)的数据流入到文件当中,如果文件中有数据,将会被清空

[@localhost lesson8]$ echo "aaaaaaaaa,bbbbbbbbbbbb" > file.txt 
[@localhost lesson8]$ cat file.txt 
aaaaaaaaa,bbbbbbbbbbbb

追加重定向(>>):与输出重定向一样,但是不会清空文件中的数据,而是在下一行增加

[@localhost lesson8]$ cat file.txt 
aaaaaaaaa,bbbbbbbbbbbb
[@localhost lesson8]$ echo "hello world" >> file.txt 
[@localhost lesson8]$ cat file.txt 
aaaaaaaaa,bbbbbbbbbbbb
hello world

管道

管道(|):顾名思义就是我们生活中传输天然气、石油、水源等等的东西

管道的基本应用,后面再研究原理:

[lyh_sky@localhost lesson8]$ cat file.txt 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[lyh_sky@localhost lesson8]$ head -10 file.txt  | tail -5 | tail -2
9
10

head指令

前言:head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中

语法:head [选项] [文件]

功能:head 用来显示档案的开头至标准输出中,默认head命令打印其相应文件的开头10行

常用选项:

[@localhost Linux_Study]$ vim test.txt
[@localhost Linux_Study]$ cat test.txt 
123
abc
456
def
789
hlj
101112
klm
[@localhost Linux_Study]$ head -3 test.txt // 显示前三行
123
abc
456
[lyh_sky@localhost Linux_Study]$ head test.txt // 默认显示前10行
123
abc
456
def
789
hlj
101112
klm

tail指令

前言:tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f 会把里最尾部的内容显示在屏幕上,并且不但刷新,使你看到最新的文件内容

语法:tail [选项] [文件名]

_linux命令选项是什么_linux基本指令的用法

功能:用于显示指定文件末尾内容,不指定文件时,作为输入信息进行处理。常用查看日志文件

常用选项:

[lyh_sky@localhost Linux_Study]$ cat test.txt 
123
abc
456
def
789
hlj
101112
klm
1111
1111
2222
[lyh_sky@localhost Linux_Study]$ tail test.txt // 不加任何选项,默认显示后十行
abc
456
def
789
hlj
101112
klm
1111
1111
2222
[lyh_sky@localhost Linux_Study]$ tail -3 test.txt // 显示后三行
1111
1111
2222

【-f选项只能截图进行演示…】

时间相关指令 date指令

date 指定格式显示时间: date +%Y:%m:%d

date 用法: date [选项] [格式]

在显示方面,使用者可以设定欲显示的格式,格式设定为一个加号后接数个标记,其中常用的标记列表如下: 在时间设定方面 时间戳

[lyh_sky@localhost Linux_Study]$ date +%s
1662818381 // 时间戳

cal指令

前言:cal命令可以用来显示公历(阳历)日历。公历是现在国际通用的历法,又称格列历,通称阳历。 “阳历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”。

语法:cal [选项] [月份] [年份]

功能:用于查看日历等时间信息,如只有一个参数,则表示年份(1-9999),如有两个参数,则表示月份和年份

常用选项:

[lyh_sky@localhost Linux_Study]$ cal // 无选项,显示当前月月历九月 2022     
日 一 二 三 四 五 六1  2  34  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30[lyh_sky@localhost Linux_Study]$ cal -3 // 显示上一个月,当前月,下个月的月历八月 2022             九月 2022             十月 2022     
日 一 二 三 四 五 六  日 一 二 三 四 五 六  日 一 二 三 四 五 六1  2  3  4  5  6               1  2  3                     17  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 2930 31               
[lyh_sky@localhost Linux_Study]$ cal -j // 显示当年中的第几天九月 2022         日  一  二  三  四  五  六244 245 246
247 248 249 250 251 252 253
254 255 256 257 258 259 260
261 262 263 264 265 266 267
268 269 270 271 272 273[lyh_sky@localhost Linux_Study]$ cal -y // 显示当年的全部月历2022                               一月                   二月                   三月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六1          1  2  3  4  5          1  2  3  4  52  3  4  5  6  7  8    6  7  8  9 10 11 12    6  7  8  9 10 11 129 10 11 12 13 14 15   13 14 15 16 17 18 19   13 14 15 16 17 18 19
16 17 18 19 20 21 22   20 21 22 23 24 25 26   20 21 22 23 24 25 26
23 24 25 26 27 28 29   27 28                  27 28 29 30 31
30 31四月                   五月                   六月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六1  2    1  2  3  4  5  6  7             1  2  3  43  4  5  6  7  8  9    8  9 10 11 12 13 14    5  6  7  8  9 10 11
10 11 12 13 14 15 16   15 16 17 18 19 20 21   12 13 14 15 16 17 18
17 18 19 20 21 22 23   22 23 24 25 26 27 28   19 20 21 22 23 24 25
24 25 26 27 28 29 30   29 30 31               26 27 28 29 30七月                   八月                   九月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六1  2       1  2  3  4  5  6                1  2  33  4  5  6  7  8  9    7  8  9 10 11 12 13    4  5  6  7  8  9 10
10 11 12 13 14 15 16   14 15 16 17 18 19 20   11 12 13 14 15 16 17
17 18 19 20 21 22 23   21 22 23 24 25 26 27   18 19 20 21 22 23 24
24 25 26 27 28 29 30   28 29 30 31            25 26 27 28 29 30
31十月                  十一月                 十二月       
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六1          1  2  3  4  5                1  2  32  3  4  5  6  7  8    6  7  8  9 10 11 12    4  5  6  7  8  9 109 10 11 12 13 14 15   13 14 15 16 17 18 19   11 12 13 14 15 16 17
16 17 18 19 20 21 22   20 21 22 23 24 25 26   18 19 20 21 22 23 24
23 24 25 26 27 28 29   27 28 29 30            25 26 27 28 29 30 31
30 31

find指令:(very ) -name

语法: find -

功能: 用于在文件树种查找文件,并作出相应的处理(可能访问磁盘)

常用选项:

[@localhost lesson8]$ ll
总用量 4
-rw-rw-r--. 1 lyh_sky lyh_sky 52 1025 16:55 file.txt
[@localhost lesson8]$ find file.txt
file.txt
[@localhost lesson8]$ find abc.txt
find: ‘abc.txt’: 没有那个文件或目录

grep指令

【grep指令参考文档】

语法: grep [选项] 搜寻字符串 文件

功能: 在文件中搜索字符串,将找到的行打印出来

常用指令:

[@localhost lesson8]$ cat file.txt 
C/C++
c/c++
Java
java
Python
python
Shell
shell
Hello world
hello world// 默认输出想匹配的字符的整行数据
[@localhost lesson8]$ grep 'c' file.txt 
c/c++// 忽略大小写的不同,输出匹配大小写的字符的整行数据
[lyh_sky@localhost lesson8]$ grep -i 'c' file.txt 
C/C++
c/c++// 附带行号
[@localhost lesson8]$ grep -in 'h' file.txt 
5:Python
6:python
7:Shell
8:shell
9:Hello world
10:hello world// 反向输出不匹配的字符的整行内容
[lyh_sky@localhost lesson8]$ grep -v 'm' file.txt 
C/C++
c/c++
Java
java
Python
python
Shell
shell
Hello world
hello world

zip/unzip指令

语法: zip 压缩文件.zip 目录或文件

功能: 将目录或文件压缩成zip格式

常用选项:

压缩解压普通文件:

[@localhost lesson8]$ zip file.zip file.txt adding: file.txt (deflated 28%)
[@localhost lesson8]$ ll
总用量 8
-rw-rw-r--. 1 lyh_sky lyh_sky  72 1025 22:38 file.txt
-rw-rw-r--. 1 lyh_sky lyh_sky 218 1025 22:56 file.zip// 解压到指定位置
[@localhost lesson8]$ mkdir test
[@localhost lesson8]$ ll
总用量 8
-rw-rw-r--. 1 lyh_sky lyh_sky  72 1025 22:38 file.txt
-rw-rw-r--. 1 lyh_sky lyh_sky 218 1025 22:56 file.zip
drwxrwxr-x. 2 lyh_sky lyh_sky   6 1025 22:57 test
[@localhost lesson8]$ unzip file.zip -d test/
Archive:  file.zipinflating: test/file.txt           
[@localhost lesson8]$ tree test/
test/
└── file.txt0 directories, 1 file

压缩解压目录:

[@localhost lesson8]$ ls
file1
[@localhost lesson8]$ tree file1/
file1/
└── file2└── file3[@localhost lesson8]$ zip -r file.zip file1/adding: file1/ (stored 0%)adding: file1/file2/ (stored 0%)adding: file1/file2/file3/ (stored 0%)
[@localhost lesson8]$ ls
file1  file.zip// 解压到指定位置
[@localhost lesson8]$ mkdir test
[@localhost lesson8]$ ls
file1  file.zip  test
[@localhost lesson8]$ unzip file.zip -d test/
Archive:  file.zipcreating: test/file1/creating: test/file1/file2/creating: test/file1/file2/file3/
[@localhost lesson8]$ tree test/
test/
└── file1└── file2└── file3

tar指令(重要):打包/解包,不打开它,直接看内容

tar [-] 文件与目录 …参数:

基本的打包压缩和解压过程 -zcf/xcf

[lyh_sky@localhost lesson8]$ ls
file.txt
[lyh_sky@localhost lesson8]$ cat file.txt
hello world
// 建立一个压缩文件
[lyh_sky@localhost lesson8]$ tar czf file.tgz file.txt 
[lyh_sky@localhost lesson8]$ ls
file.tgz  file.txt[lyh_sky@localhost lesson8]$ rm file.txt
[lyh_sky@localhost lesson8]$ ls
file.tgz
// 解压,默认解压到当前路径
[lyh_sky@localhost lesson8]$ tar xzf file.tgz
[lyh_sky@localhost lesson8]$ ls
file.tgz  file.txt[lyh_sky@localhost lesson8]$ mkdir test
[lyh_sky@localhost lesson8]$ ls
file.tgz  file.txt  test
// 解压到指定目录中
[lyh_sky@localhost lesson8]$ tar xzf file.tgz -C test/
[lyh_sky@localhost lesson8]$ tree test/
test/
└── file.txt0 directories, 1 file

压缩和解压的过程中显示文件 -zvcf/xvcf

[lyh_sky@localhost lesson8]$ ls
test
[lyh_sky@localhost lesson8]$ tree test/
test/
└── file1└── file2└── file33 directories, 0 files
// 打包压缩过程中显示文件
[lyh_sky@localhost lesson8]$ tar cvzf test.tgz test
test/
test/file1/
test/file1/file2/
test/file1/file2/file3/
[lyh_sky@localhost lesson8]$ ls
test  test.tgz[lyh_sky@localhost lesson8]$ rm -rf test
[lyh_sky@localhost lesson8]$ ls
test.tgz
//解包过程中显示文件
[lyh_sky@localhost lesson8]$ tar xvzf test.tgz
test/
test/file1/
test/file1/file2/
test/file1/file2/file3/
[lyh_sky@localhost lesson8]$ ls
test  test.tgz
[lyh_sky@localhost lesson8]$ tree test
test
└── file1└── file2└── file33 directories, 0 files

bc指令(浮点数运算)

bc命令可以很方便的进行浮点运算

[@localhost ~]$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
13.14 * 13.14
172.65
12.5 * 25.4
317.5

注意:如果想要推出bc指令,可以直接ctrl+c结束该进程

uname –r指令

语法: uname [选项]

功能: uname用来获取电脑和操作系统的相关信息

补充说明: uname可显示linux主机所用的操作系统的版本、硬件的名称等基本信息

常用选项:

[@localhost ~]$ uname
Linux
[@localhost ~]$ uname -r
3.10.0-1160.76.1.el7.x86_64
[@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

重要的几个热键[Tab],[ctrl]-c, [ctrl]-d

// 按下Ctrl+r -- 然后搜索(输入对应的字符串)
(reverse-i-search)`while': cnt=1; while [ $cnt -le 10000 ]; do echo "hello world"; cnt++; done > 123.txt// Ctrl+d是退出当前用户,如果用户是管理员,则退出终端

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了