linux的基本指令(下)

简介: man基本指令的用法保姆级详解

@TOC

1.man指令

1.安装

如果是云服务器 ,则需要要安装配置

[root@VM-8-8-centos lesson1]# yum install -y

安装了这个可以使用基本命令,但是不能调用库里的函数

[root@VM-8-8-centos lesson1]# yum install man-pages -y

安装这个后,就可以使用基本的指令了

2.用法

man +man

查询man指令的用法

在这里插入图片描述

3.man+数字

在这里插入图片描述一般默认1号手册——调用基本命令2号手册为系统调用接口3号手册为库函数

1. printf函数的查询

一般想到 printf函数想到的都是 c语言库函数

[root@VM-8-8-centos lesson1]# man printf

此时的printf是linux上一条基本的打印语句

[root@VM-8-8-centos lesson1]#  printf  "hello linux"\n
hello linux

在这里插入图片描述

hello linuxn[root@VM-8-8-centos lesson1]#  man 3 printf

man+3才为 c语言库函数

在这里插入图片描述

1.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

将file.txt 文件拷贝到 file.txt.bak文件中

此时分别打印 file.txt 文件与 file.txt.bak文件发现 都可以打印出 hello world

这里的 fille.txt.bak文件不需要创建

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

将 file.txt 文件拷贝到 touch目录中

使用 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

将 lesson1目录中的 file.txt 文件拷贝到 上一级目录

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

将 lesson1目录下的  touch目录 ,拷贝到 上一级目录

需要用 cp -r +目录

2. 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/9.9/lesson1 中的 file.txt 文件移动到 /root/9.9中

[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

将 dir目录移动到 上一级目录 ,只需 mv+目录 即可

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

将 file.txt文件重命名为 file.c文件

3. cat指令

1.显示文件的全部内容并且不可以修改

[root@VM-8-8-centos lesson1]# ls
file.c
[root@VM-8-8-centos lesson1]#  cat file.c
hello world

打印出file.c的内容 hello world

2.cat -n指令

显示行号

[root@VM-8-8-centos lesson1]# cat -n file.c
     1    hello world

4. date指令

1.日期

[root@VM-8-8-centos lesson1]# date +%Y:%m:%d-%H:%M:%S
2022:09:30-15:00:37

Y代表 年,m代表月,d代表日,H代表小时,M代表分钟,S代表秒

20220年 9月30日 ——15点 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

图中有一个很大的数在一直变化

是从1970年1月1日开始到现在累计的秒数 即时间戳

时间戳的价值: 单项递增,不重复,比较适合作为一条关键信息的索引值

将时间戳转换成普通时间:

[root@VM-8-8-centos lesson1]# date +%Y:%m:%d-%H:%M:%S -d @0
1970:01:01-08:00:00

正常来说应该为 1970.1.1 ——0点0分

但是由于我们与欧洲有8个小时的时差,所以显示为8点

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

5. top指令

在linux中启用top相当于 windows中任务管理器

定期更新数据

输入 top 后

在这里插入图片描述  

1. 退出

使用 q 或者 CTRL +c都可以退出top

在这里插入图片描述
目录
相关文章
|
29天前
|
Linux Windows
Linux之基本指令操作
Linux之基本指令操作
|
4天前
|
Unix Linux Windows
Linux的学习之路:3、基础指令(2)
Linux的学习之路:3、基础指令(2)
28 0
|
3天前
|
算法 Linux
工作中常用的一些Linux指令,简单易记还实用(三)
工作中,离不开Linux系统,很多刚步入职场的小白,往往对于Linux操作系统的使用都显得生疏,最主要的就是对一些常用的指令记忆不熟练,下面就罗列一些使用度比较高的一些Linux指令,一起来巩固学习一下。这一部分的指令就稍微偏一点了,是接着上一篇博客后面写的,感兴趣的朋友可以回头看看前一篇,再回来看这个。
18 1
|
3天前
|
Linux Shell
工作中常用的一些Linux指令,简单易记还实用
工作中常用的一些Linux指令,简单易记还实用
10 2
|
9天前
|
安全 Linux
Linux基本指令(下)——“Linux”
Linux基本指令(下)——“Linux”
|
10天前
|
人工智能 Unix Linux
Linux基本指令
Linux基本指令
|
13天前
|
Linux Windows
|
13天前
|
Linux
Linux 指令|date|cal|find|grep|热键
Linux 指令|date|cal|find|grep|热键
|
13天前
|
Linux
Linux简单指令|cd|touch|mkdir|rmdir|rm
Linux简单指令|cd|touch|mkdir|rmdir|rm
|
14天前
|
存储 安全 Unix
Linux基本指令汇总
Linux基本指令汇总
50 2