linux的基本指令(下)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux的基本指令(下)相关的知识,希望对你有一定的参考价值。
(文章目录)
1.man指令
1.安装
[root@VM-8-8-centos lesson1]# yum install -y
[root@VM-8-8-centos lesson1]# yum install man-pages -y
2.用法
3.man+数字
1. printf函数的查询
[root@VM-8-8-centos lesson1]# man printf
[root@VM-8-8-centos lesson1]# printf "hello linux"\\n
hello linux
hello linuxn[root@VM-8-8-centos lesson1]# man 3 printf
2.cp指令
1.cp +文件
1.拷贝到当前目录
[root@VM-8-8-centos 9.9]# cp file.txt file.txt.bak
[root@VM-8-8-centos 9.9]# cat file.txt
hello world
[root@VM-8-8-centos 9.9]# cat file.txt.bak
hello world
2.拷贝到 其他目录中
[root@VM-8-8-centos lesson1]# ls -la
total 20
drwxr-xr-x 3 root root 4096 Sep 30 13:51 .
drwxr-xr-x 5 root root 4096 Sep 30 13:48 ..
-rw-r--r-- 1 root root 12 Sep 30 13:49 file.txt
-rw-r--r-- 1 root root 12 Sep 30 13:49 file.txt.bak
drwxr-xr-x 2 root root 4096 Sep 30 13:51 touch
[root@VM-8-8-centos lesson1]# cp file.txt touch
[root@VM-8-8-centos lesson1]# tree touch
touch
`-- file.txt
3. 拷贝到上一级目录
[root@VM-8-8-centos 9.9]# ls
lesson1 lesson2
[root@VM-8-8-centos 9.9]# cd lesson1
[root@VM-8-8-centos lesson1]# ls
file.txt file.txt.bak touch
[root@VM-8-8-centos lesson1]# cp file.txt ..
[root@VM-8-8-centos lesson1]# ls ..
file.txt lesson1 lesson2
2.cp +目录
1.返回上一级目录
[root@VM-8-8-centos 9.9]# ls
lesson1 lesson2
[root@VM-8-8-centos 9.9]# cd lesson1
[root@VM-8-8-centos lesson1]# ls
file.txt file.txt.bak touch
[root@VM-8-8-centos lesson1]# cp -r touch ..
[root@VM-8-8-centos lesson1]# ls ..
lesson1 lesson2 touch
3. mv指令
1.剪切
[root@VM-8-8-centos lesson1]# ls
dir file.txt file.txt.bak
[root@VM-8-8-centos lesson1]# mv file.txt ..
[root@VM-8-8-centos lesson1]# ls
dir file.txt.bak
[root@VM-8-8-centos lesson1]# ls ..
file.txt lesson1 lesson2 touch
[root@VM-8-8-centos lesson1]# ls
dir file.txt.bak
[root@VM-8-8-centos lesson1]# mv dir ..
[root@VM-8-8-centos lesson1]# ls
file.txt.bak
[root@VM-8-8-centos lesson1]# ls ..
dir file.txt lesson1 lesson2 touch
2. 文件的重命名
[root@VM-8-8-centos lesson1]# ls
file.txt.bak
[root@VM-8-8-centos lesson1]# mv file.txt.bak file.c
[root@VM-8-8-centos lesson1]# ls
file.c
4. cat指令
1.显示文件的全部内容并且不可以修改
[root@VM-8-8-centos lesson1]# ls
file.c
[root@VM-8-8-centos lesson1]# cat file.c
hello world
2.cat -n指令
[root@VM-8-8-centos lesson1]# cat -n file.c
1 hello world
5. date指令
1.日期
[root@VM-8-8-centos lesson1]# date +%Y:%m:%d-%H:%M:%S
2022:09:30-15:00:37
2.时间戳
[root@VM-8-8-centos lesson1]# date +%s
1664521420
[root@VM-8-8-centos lesson1]# date +%s
1664521425
[root@VM-8-8-centos lesson1]# date +%s
1664521429
[root@VM-8-8-centos lesson1]# date +%s
1664521434
[root@VM-8-8-centos lesson1]# date +%Y:%m:%d-%H:%M:%S -d @0
1970:01:01-08:00:00
3.cal +年份
[root@VM-8-8-centos lesson1]# cal 2022
2022
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3 4 5
2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12
9 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
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 7 1 2 3 4
3 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
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3
3 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
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3
2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10
9 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
1. cal -1
[root@VM-8-8-centos lesson1]# cal -1
September 2022
Su Mo Tu We Th Fr Sa
1 2 3
4 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
2. cal -3
[root@VM-8-8-centos lesson1]# cal -3
August 2022 September 2022 October 2022
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 1 2 3 1
7 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 29
30 31
6. top指令
1. 退出
以上是关于linux的基本指令(下)的主要内容,如果未能解决你的问题,请参考以下文章