引言

        简单介绍一些Linux的基本指令,快速上手Linux操作系统。

一、ls指令

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

功能::对于目录,该命令列出该目录下的所有子目录与文件。

               对于文件件,将列出文件名以及其他信息

常用选项:

  • -a 列出目录下的所以文件,包含以 . 开头的隐含文件
  • -l 列出文件的详细信息
  • -d 将目录像文件一样显示,而不是显示其下的文件。ls -d [指定目录]
  • 等等等等,后面遇到了再详细介绍。
[root@hcss-ecs-f571 ~]# ls
learn01
[root@hcss-ecs-f571 ~]# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .cache  .cshrc  .history  learn01  .pki  .ssh  .tcshrc
[root@hcss-ecs-f571 ~]# ls -l
total 4
drwxr-xr-x 2 root root 4096 Jul 29 22:12 learn01
[root@hcss-ecs-f571 ~]# ls -a -l
total 48
dr-xr-x---.  6 root root 4096 Jul 29 22:12 .
dr-xr-xr-x. 19 root root 4096 May 25 23:07 ..
-rw-r--r--   1 root root  475 Jul 29 22:12 .bash_history
-rw-r--r--.  1 root root   18 Dec 29  2013 .bash_logout
-rw-r--r--.  1 root root  176 Dec 29  2013 .bash_profile
-rw-r--r--.  1 root root  176 Dec 29  2013 .bashrc
drwx------   3 root root 4096 Jul 26  2024 .cache
-rw-r--r--.  1 root root  100 Dec 29  2013 .cshrc
-rw-------   1 root root    0 Jul 26  2024 .history
drwxr-xr-x   2 root root 4096 Jul 29 22:12 learn01
drwxr-----   3 root root 4096 Jul 26  2024 .pki
drwx------   2 root root 4096 May 25 23:07 .ssh
-rw-r--r--.  1 root root  129 Dec 29  2013 .tcshrc

二、pwd命令

语法:pwd

功能:显示用户当前所在的目录

常用选项:无

[root@hcss-ecs-f571 ~]# pwd
/root

 Linux理论知识:路径的认识

• Linux系统中,磁盘上的文件和目录被组成一棵目录树,每个节点都是目录或文件
• 其中普通文件⼀定是目录树的叶子节点
• 目录可能是叶子(空目录),也可能是路上节点
• 理解路径存在的意义:树状组织方式,保证快速定位查找到指定的文件,而定位文件就需要具有唯⼀性的方案来进行定位文件。其中任何⼀个节点,都只有⼀个父节点,所以,从根目录开始,定位指定文件,路径具有唯⼀性
• 绝对路径:⼀般从/开始,不依赖其他⽬录的定位文件的方式
• 相对路径:相对于当前用户所处⽬录,定位⽂件的路径方式
• 绝对路径⼀般不会随着用户的路径变化而丧失唯一性,一般在特定服务的配置文件中经常  被使用
• 相对路径因为它的便捷性,⼀般在命令行中使用较多

三、cd指令

语法:cd 目录名

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

常用选项:

  • cd ..  返回上级目录
  • cd ~ 快速进入自己的家目录
  • cd / 进入/目录
  • cd - 退回到上一次的目录中
  • cd 跟目录      
[root@hcss-ecs-f571 learn01]# cd ~
[root@hcss-ecs-f571 ~]# pwd
/root
[root@hcss-ecs-f571 ~]# cd /
[root@hcss-ecs-f571 /]# pwd
/
[root@hcss-ecs-f571 /]# cd /root/learn01
[root@hcss-ecs-f571 learn01]# pwd
/root/learn01
[root@hcss-ecs-f571 learn01]# cd -
/
[root@hcss-ecs-f571 /]# pwd
/
[root@hcss-ecs-f571 /]# cd ~
[root@hcss-ecs-f571 ~]# pwd
/root
[root@hcss-ecs-f571 ~]# 

四、touch指令

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

功能:touch命令参数可更改文档或目录的日期时间,包括存取时间和更改时间,或者新建⼀个不存在的文件。

常用选项:

  • -a:change only the access time
  • -c:change only the modification time
[root@hcss-ecs-f571 ~]# ls
learn01
[root@hcss-ecs-f571 ~]# cd learn01
[root@hcss-ecs-f571 learn01]# touch my.txt
[root@hcss-ecs-f571 learn01]# ls
my.txt
[root@hcss-ecs-f571 learn01]# ll
total 0
-rw-r--r-- 1 root root 0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# 

五、mkdir指令

语法:mkdir [选项] dirname

功能:在当前目录下创建一个名为“dirname”的目录

常用选项:-p/--parents: 可以是一个路径名称。此时若路径中的某些目录尚不存在,加上此选项后,系统将自动建好那些尚不存在的目录,即一次可以建立多个目录

[root@hcss-ecs-f571 learn01]# ll
total 8
drwxr-xr-x 2 root root 4096 Jul 29 23:40 dir1
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# mkdir dir3
[root@hcss-ecs-f571 learn01]# ll
total 12
drwxr-xr-x 2 root root 4096 Jul 29 23:40 dir1
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# mkdir -p dir4/dir5/dir6
[root@hcss-ecs-f571 learn01]# ll
total 16
drwxr-xr-x 2 root root 4096 Jul 29 23:40 dir1
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
drwxr-xr-x 3 root root 4096 Jul 29 23:42 dir4
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# tree dir4
dir4
└── dir5└── dir62 directories, 0 files
[root@hcss-ecs-f571 learn01]# 

六、rmdir指令

语法:rmdir [-p] [dirname]

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

功能:删除空目录

drwxr-xr-x 6 root root 4096 Jul 29 23:42 learn01
[root@hcss-ecs-f571 ~]# tree learn01
learn01
├── dir1
├── dir2
│   └── dir3
│       └── dir4
│           └── dir5
├── dir3
├── dir4
│   └── dir5
│       └── dir6
└── my.txt
[root@hcss-ecs-f571 learn01]# ll
total 16
drwxr-xr-x 2 root root 4096 Jul 29 23:40 dir1
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
drwxr-xr-x 3 root root 4096 Jul 29 23:42 dir4
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# rmdir dir1
# 直接删除目录dir1
[root@hcss-ecs-f571 learn01]# ll
total 12
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
drwxr-xr-x 3 root root 4096 Jul 29 23:42 dir4
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
[root@hcss-ecs-f571 learn01]# rmidr dir2
-bash: rmidr: command not found
[root@hcss-ecs-f571 learn01]# ll
total 12
drwxr-xr-x 3 root root 4096 Jul 29 23:41 dir2
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
drwxr-xr-x 3 root root 4096 Jul 29 23:42 dir4
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt
# 指定路径中有不为空的路径,便⽆法删除
[root@hcss-ecs-f571 learn01]# rmdir -p dir2/dir3/dir4
rmdir: failed to remove ‘dir2/dir3/dir4’: Directory not empty
[root@hcss-ecs-f571 learn01]# rmdir -p dir2/dir3/dir4/dir5
[root@hcss-ecs-f571 learn01]# ll
total 8
drwxr-xr-x 2 root root 4096 Jul 29 23:42 dir3
drwxr-xr-x 3 root root 4096 Jul 29 23:42 dir4
-rw-r--r-- 1 root root    0 Jul 29 23:28 my.txt

七、rm指令

语法: rm [-f-i-r-v] [dirName/dir]

适用对象:所有使用者

功能:删除文件或目录

常用选项:

  • -f 即使文件属性为只读(即写保护),亦直接删除
  • -i 删除前逐一询问确认
  • -r 删除目录及其下所有文件
[root@hcss-ecs-f571 learn01]# pwd
/root/learn01
[root@hcss-ecs-f571 learn01]# tree
.
├── dir3
├── dir4
│   └── dir5
│       └── dir6
├── my.txt
└── test.txt4 directories, 2 files
[root@hcss-ecs-f571 learn01]# rm dir3
rm: cannot remove ‘dir3’: Is a directory
[root@hcss-ecs-f571 learn01]# rm -f dir3
rm: cannot remove ‘dir3’: Is a directory
[root@hcss-ecs-f571 learn01]# rm -r dir3
rm: remove directory ‘dir3’? y[root@hcss-ecs-f571 learn01]# rm -r -i dir4
rm: descend into directory ‘dir4’? y
rm: descend into directory ‘dir4/dir5’? y
rm: remove directory ‘dir4/dir5/dir6’? y
rm: remove directory ‘dir4/dir5’? y
rm: remove directory ‘dir4’? y
[root@hcss-ecs-f571 learn01]# tree
.
├── my.txt
└── test.txt0 directories, 2 files
[root@hcss-ecs-f571 learn01]# rm my.txt
rm: remove regular empty file ‘my.txt’? y
[root@hcss-ecs-f571 learn01]# tree
.
└── test.txt0 directories, 1 file

八、man指令

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

语法:man [选项] 命令

常用选项

  • -k 根据关键字搜索联机帮助
  • num 只在第num章节查找
  • -a 将所有章节都显示出来

man手册分为9章(不同系统可能会有差别)

  • 1是普通的命令 
  • 2是系统调用,如open,write之类的(通过这个,至少可以很方便的查到调用这个函数,需要加什么头文件)
  • 3是库函数,如printf,fread4是特殊文件,也就是/dev下的各种设备文件
  • 4略
  • 5是指文件的格式,比如passwd,就会说明这个文件中各个字段的含义
  • 6是给游戏留的,由各个游戏⾃⼰定义
  • 7是附件还有⼀些变量,比如像environ这种全局变量在这里就有说明
  • 8是系统管理用的命令,这些命令只能由root使用,如ifconfig
  • 9略

按q退出手册

九、cp指令

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

功能:复制文件或目录

解释:

  • cp指令用于复制文件或目录
  • 如同时指定两个以上的文件或目录,且最后的目的地地是⼀个已经存在的⽬录,则它会把前面指定的所有文件或目录复制到此目录中

常用选项:

  • -f或--force强行复制文件或目录,不论目的文件或目录是否已经存在
  • -i或--interactive 覆盖文件之前先询问用户
  • -r递归处理,将指定目录下的文件与子目录⼀并处理。若源文件或目录的形态,不属于目录或符号链接,则⼀律视为普通文件处理
# cp普通文件
[root@hcss-ecs-f571 learn01]# echo "你好,世界">test.txt
[root@hcss-ecs-f571 learn01]# cat test.txt
你好,世界
[root@hcss-ecs-f571 learn01]# cp test.txt test2.txt
[root@hcss-ecs-f571 learn01]# ll
total 8
-rw-r--r-- 1 root root 16 Jul 30 15:29 test2.txt
-rw-r--r-- 1 root root 16 Jul 30 15:28 test.txt
[root@hcss-ecs-f571 learn01]# cat test2.txt
你好,世界# 将多个文件拷贝到指定路径下
[root@hcss-ecs-f571 learn01]# mkdir dir1
[root@hcss-ecs-f571 learn01]# cp *.txt dir1
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── test2.txt
└── test.txt1 directory, 4 files
[root@hcss-ecs-f571 learn01]# 
# cp目标文件存在,直接覆盖
[root@hcss-ecs-f571 learn01]# echo "hello word" > test.txt
[root@hcss-ecs-f571 learn01]# cat test.txt
hello word
[root@hcss-ecs-f571 learn01]# cp test.txt test2.txt
cp: overwrite ‘test2.txt’? y
[root@hcss-ecs-f571 learn01]# cat test2.txt
hello word
[root@hcss-ecs-f571 learn01]# 
# 递归强制拷贝整个目录
[root@hcss-ecs-f571 learn01]# cp -rf dir1 dir2
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── test2.txt
└── test.txt2 directories, 6 files
[root@hcss-ecs-f571 learn01]# 

十、mv指令

        mv命令是move的缩写,可以⽤来移动文件或者将文件改名(move(rename)files,经常⽤来备份文件或者目录(相当于剪切功能)

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

功能:

  • 视mv命令中第⼆个参数类型的不同(是目标文件还是目标目录),mv命令将文件重命名或将其移至⼀个新的目录中。

常用选项:

  • -f:force强制的意思,如果目标文件已经存在,不会询问而直接覆盖 
  • -i:若目标文件(destination)已经存在时,就会询问是否覆盖!
# 更改名称
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── dir3
├── test2.txt
└── test.txt3 directories, 6 files
[root@hcss-ecs-f571 learn01]# mv test.txt test1.txt
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── dir3
├── test1.txt
└── test2.txt3 directories, 6 files# 如果当前路径存在同名⽂件,改名即覆盖
[root@hcss-ecs-f571 learn01]# touch test3.txt
[root@hcss-ecs-f571 learn01]# mv test3.txt test2.txt
mv: overwrite ‘test2.txt’? y
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── dir3
├── test1.txt
└── test2.txt3 directories, 6 files
[root@hcss-ecs-f571 learn01]# # mv整个目录
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── dir3
├── test1.txt
└── test2.txt3 directories, 6 files
[root@hcss-ecs-f571 learn01]# mv dir3 dir1
[root@hcss-ecs-f571 learn01]# tree
.
├── dir1
│   ├── dir3
│   ├── test2.txt
│   └── test.txt
├── dir2
│   ├── test2.txt
│   └── test.txt
├── test1.txt
└── test2.txt3 directories, 6 files
[root@hcss-ecs-f571 learn01]# [root@hcss-ecs-f571 learn01]# mv dir1 ..
[root@hcss-ecs-f571 learn01]# cd ..
[root@hcss-ecs-f571 ~]# tree
.
├── dir1
│   ├── dir3
│   ├── test2.txt
│   └── test.txt
└── learn01├── dir2│   ├── test2.txt│   └── test.txt├── test1.txt└── test2.txt4 directories, 6 files

十一、cat指令

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

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

常用选项:

  • -b对非空输出行编号
  • -n对输出的所有行编号
  • -s不输出多行空行
# 命令⾏构建多⾏⽂本
[root@hcss-ecs-f571 ~]#  cnt=0; while [ $cnt -le 20 ]; do echo "hello word";let cnt++; done > temp.txt
[root@hcss-ecs-f571 ~]# cat temp.txt
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word# cat 输出携带行号
[root@hcss-ecs-f571 ~]# cat -b temp.txt1	hello word2	hello word3	hello word4	hello word5	hello word6	hello word7	hello word8	hello word9	hello word10	hello word11	hello word12	hello word13	hello word14	hello word15	hello word16	hello word17	hello word18	hello word19	hello word20	hello word21	hello word# 修改temp.txt,使其携带多行空行
[root@hcss-ecs-f571 ~]# vim temp.txt# -b 对⾮空输出⾏编号
[root@hcss-ecs-f571 ~]# cat -b temp.txt1	hello word2	hello word3	hello word4	hello word5	hello word6	hello word7	hello word8	hello word9	hello word10	hello word11	hello word12	hello word13	hello word14	hello word15	hello word16	hello word17	hello word18	hello word19	hello word20	hello word21	hello word
# -n 对输出的所有⾏编号
[root@hcss-ecs-f571 ~]# cat -n temp.txt1	hello word2	hello word3	hello word4	hello word5	hello word6	hello word7	hello word8	hello word9	hello word10	hello word11	hello word12	hello word13	hello word14	hello word15	hello word16	hello word17	hello word18	hello word19	20	21	22	23	hello word24	hello word25	26	27	hello word
# -s 不输出多⾏空⾏,多⾏空⾏压缩成为⼀⾏
[root@hcss-ecs-f571 ~]# cat -s temp.txt
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello wordhello word
hello wordhello word
[root@hcss-ecs-f571 ~]#

十二、more指令

语法:more [选项]

功能:more命令,功能类似cat

常用选项:

  • -n指定输出行数
  • q退出more
# 命令行输出2000行"hello word"
[root@hcss-ecs-f571 ~]#  cnt=0; while [ $cnt -le 2000 ]; do echo "hello word";let cnt++; done > temp.txt
# -n 指定输出的行数
[root@hcss-ecs-f571 ~]# more -10 temp.txt
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
hello word
--More--(0%)

十三、less指令

语法:less [参数] 文件

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

  • less⼯具也是对文件或其它输出进行分页显示的⼯具,应该说是linux正统查看文件内容的工具, 功能极其强⼤
  •  less的用法比起more更加的有弹性,在more的时候,我们并没有办法向前面翻,只能往后面看
  • 若使⽤了less,就可以使用[pageup][pagedown]等按键的功能来往前往后翻看文件,更 容易用来查看⼀个文件的内容
  •  除此之外,在less里头可以拥有更多的搜索功能,不止可以向下搜,也可以向上搜。

选项: 

  • -i 忽略搜索时的大小写
  • -N 显示每行的行号
  •  /字符串:向下搜索“字符串”的功能
  •  ?字符串:向上搜索“字符串”的功能
  •  n:重复前一个搜索(与/或?有关)
  •  N:反向重复前⼀个搜索(与/或?有关)
  •  q:quit
[root@hcss-ecs-f571 ~]# less -N temp.txt 1 hello 02 hello 13 hello 24 hello 35 hello 46 hello 57 hello 68 hello 79 hello 810 hello 911 hello 1012 hello 1113 hello 1214 hello 1315 hello 1416 hello 1517 hello 1618 hello 1719 hello 1820 hello 1921 hello 2022 hello 2123 hello 2224 hello 2325 hello 2426 hello 2527 hello 2628 hello 2729 hello 2830 hello 2931 hello 3032 hello 31
...

十四、head指令和tail指令

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

1.head指令

语法:head [参数] [文件]

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

选项:

  •  -n<行数>显示的行数
[root@hcss-ecs-f571 ~]# head temp.txt
hello 0
hello 1
hello 2
hello 3
hello 4
hello 5
hello 6
hello 7
hello 8
hello 9[root@hcss-ecs-f571 ~]# head -5 temp.txt
hello 0
hello 1
hello 2
hello 3
hello 4
[root@hcss-ecs-f571 ~]# 

2.tail指令

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

语法:tail 必要参数 [文件]

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

选项: 

  • -f 循环读取
  • -n<行数> 显示行数
[root@hcss-ecs-f571 ~]# tail temp.txt
hello 1991
hello 1992
hello 1993
hello 1994
hello 1995
hello 1996
hello 1997
hello 1998
hello 1999
hello 2000
[root@hcss-ecs-f571 ~]# 
[root@hcss-ecs-f571 ~]# tail -4 temp.txt
hello 1997
hello 1998
hello 1999
hello 2000
[root@hcss-ecs-f571 ~]# 

用管道对数据进行操作:显示文件[250, 300]

[root@hcss-ecs-f571 ~]# head -250 temp.txt | tail -50
hello 200
hello 201
hello 202
hello 203
hello 204
hello 205
hello 206
hello 207
hello 208
hello 209
hello 210
hello 211
hello 212
hello 213
hello 214
hello 215
hello 216
hello 217
hello 218
hello 219
hello 220
hello 221
hello 222
hello 223
hello 224
hello 225
hello 226
hello 227
hello 228
hello 229
hello 230
hello 231
hello 232
hello 233
hello 234
hello 235
hello 236
hello 237
hello 238
hello 239
hello 240
hello 241
hello 242
hello 243
hello 244
hello 245
hello 246
hello 247
hello 248
hello 249

十五、data指令

1.在显示方面:可以设定欲显示的格式,格式设定为⼀个加号后接数个标记,其中常用的标记列表如下:

  • %H:小时(00..23)
  •  %M:分钟(00..59)
  •  %S:秒(00..61)
  •  %X:相当于%H:%M:%S
  •  %d:日(01..31)
  •  %m:月份(01..12)
  •  %Y:完整年份(0000..9999)
  •  %F:相当于%Y-%m-%d

2.在设定时间方面:

  • date-s//设置当前时间,只有root权限才能设置,其他只能查看。
  •  date-s20080523//设置成20080523,这样会把具体时间设置成空00:00:00
  •  date-s01:01:01//设置具体时间,不会对日期做更改
  •  date-s“01:01:012008-05-23″//这样可以设置全部时间
  •  date-s“01:01:0120080523″//这样可以设置全部时间
  •  date-s“2008-05-2301:01:01″//这样可以设置全部时间
  •  date-s“2008052301:01:01″//这样可以设置全部时间

3. 时间戳

  • 时间->时间戳:date+%s
  •  时间戳->时间:date-d@1508749502
  •  Unix时间戳(英⽂为Unixepoch,Unixtime,POSIXtime或Unixtimestamp)是从1970年1⽉1 ⽇(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒
[root@hcss-ecs-f571 ~]# date
Wed Jul 30 17:53:13 CST 2025
[root@hcss-ecs-f571 ~]# date %Y
date: invalid date ‘%Y’
[root@hcss-ecs-f571 ~]# date +%Y
2025
[root@hcss-ecs-f571 ~]# date %Y
date: invalid date ‘%Y’
[root@hcss-ecs-f571 ~]# y
-bash: y: command not found
[root@hcss-ecs-f571 ~]# date +%Y/%m/%d-%H:%M:%S
2025/07/30-17:54:41
[root@hcss-ecs-f571 ~]# date +%Y/%m/%d-%H:%M:%S -d @0
1970/01/01-08:00:00
[root@hcss-ecs-f571 ~]# 

十六、cal指令

        cal命令可以用来显示公历(阳历)日历。

公历是现在国际通用的历法,又称格列历,通称阳历。

“阳 历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”。

命令格式:cal 参数 [年份]

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

常用选项:

  • -3显示系统前⼀个月,当前月,下一个月的月历
  • -j 显示在当年中的第几天(⼀年日期按天算,从1月1号算起,默认显示当前月在⼀年中的天数)
  • -y 显示当前年份的日历
[root@hcss-ecs-f571 ~]# cal -y2025                               January               February                 March       
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa1  2  3  4                      1                      15  6  7  8  9 10 11    2  3  4  5  6  7  8    2  3  4  5  6  7  8
12 13 14 15 16 17 18    9 10 11 12 13 14 15    9 10 11 12 13 14 15
19 20 21 22 23 24 25   16 17 18 19 20 21 22   16 17 18 19 20 21 22
26 27 28 29 30 31      23 24 25 26 27 28      23 24 25 26 27 28 2930 31April                   May                   June        
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa1  2  3  4  5                1  2  3    1  2  3  4  5  6  76  7  8  9 10 11 12    4  5  6  7  8  9 10    8  9 10 11 12 13 14
13 14 15 16 17 18 19   11 12 13 14 15 16 17   15 16 17 18 19 20 21
20 21 22 23 24 25 26   18 19 20 21 22 23 24   22 23 24 25 26 27 28
27 28 29 30            25 26 27 28 29 30 31   29 30July                  August                September     
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa1  2  3  4  5                   1  2       1  2  3  4  5  66  7  8  9 10 11 12    3  4  5  6  7  8  9    7  8  9 10 11 12 13
13 14 15 16 17 18 19   10 11 12 13 14 15 16   14 15 16 17 18 19 20
20 21 22 23 24 25 26   17 18 19 20 21 22 23   21 22 23 24 25 26 27
27 28 29 30 31         24 25 26 27 28 29 30   28 29 3031October               November               December      
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa1  2  3  4                      1       1  2  3  4  5  65  6  7  8  9 10 11    2  3  4  5  6  7  8    7  8  9 10 11 12 13
12 13 14 15 16 17 18    9 10 11 12 13 14 15   14 15 16 17 18 19 20
19 20 21 22 23 24 25   16 17 18 19 20 21 22   21 22 23 24 25 26 27
26 27 28 29 30 31      23 24 25 26 27 28 29   28 29 30 3130[root@hcss-ecs-f571 ~]# cal -jJuly 2025         
Sun Mon Tue Wed Thu Fri Sat182 183 184 185 186
187 188 189 190 191 192 193
194 195 196 197 198 199 200
201 202 203 204 205 206 207
208 209 210 211 212[root@hcss-ecs-f571 ~]# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/916898.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/916898.shtml
英文地址,请注明出处:http://en.pswp.cn/news/916898.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

25. html 使用的字符集是什么,有什么特点

总结 utf-8&#xff0c;支持所有语言一、HTML 默认使用的字符集✅ HTML 页面推荐使用 UTF-8 字符集<meta charset"UTF-8" />这是 HTML5 中推荐的标准字符编码&#xff0c;用于定义网页中字符的编码方式。二、什么是字符集&#xff08;Character Encoding&#…

MySQL 读写分离(含示例代码)

背景 面对日益增加的系统访问量,数据库的吞吐量面临着巨大瓶颈。对于同一时刻有大量并发读操作和较少写操作类型的应用系统来说,将数据库拆分为主库和从库,主库负责处理事务性的增删改操作,从库负责处理查询操作,能够有效的避免由数据更新导致的行锁,使得整个系统的查询性…

C#中Visual Studio平台按照OfficeOpenXml步骤

找到包的地址&#xff1a; NuGet Gallery | DocumentFormat.OpenXml.Framework 3.3.0 https://nuget.info/packages 报错&#xff1a; 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 无法解析依赖项“EPPlus”。使用的源: Officeopenxml, Mic…

【Linux】重生之从零开始学习运维之备份恢复

备份恢复准备工作16主机-ubuntu系统准备日志目录mkdir -p /data/mysql/logs/ chown mysql:mysql -R /data/mysql定制日志配置vim /etc/mysql/mariadb.conf.d/50-server.cnf log_bin/data/mysql/logs/binlog systemctl restart mariadb删除db1数据库drop database db1;13主机-ub…

VoIP技术全面深度学习指南:从原理到实践的认知进化

一、VoIP技术的本质认知与历史演进 1.1 技术本质的深层理解 VoIP&#xff08;Voice over Internet Protocol&#xff0c;IP语音传输&#xff09;从根本上代表了通信技术的范式转换。这不仅仅是将模拟语音信号数字化那么简单&#xff0c;而是将传统的电路交换模式彻底转向包交换…

CentOS Nginx 1.13.9 部署文档

以下是 Nginx 1.13.9 的详细安装步骤&#xff08;基于 CentOS/Ubuntu 系统&#xff09;&#xff1a;1. 安装依赖 CentOS/RHEL sudo yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-develUbuntu/Debian sudo apt update && sudo apt install -y b…

CSS-in-JS 动态主题切换与首屏渲染优化

动态主题切换的实现方式1. 使用 CSS 变量&#xff08;CSS Custom Properties&#xff09;CSS 变量是实现主题切换最直接的方式&#xff1a;:root {--primary-color: #4285f4;--background-color: #ffffff;--text-color: #333333; }[data-theme"dark"] {--primary-col…

不止 “听懂”,更能 “感知”!移远通信全新AI 音频模组 重新定义智能家居“听觉”逻辑

7月29日&#xff0c;在 2025 世界人工智能大会&#xff08;WAIC&#xff09;期间&#xff0c;移远通信正式发布全新 VA500-GL AI 音频模组。该产品基于本地化 AI 算法&#xff0c;为智能家电赋予精准 “听觉” 与主动交互能力&#xff0c;借助环境状态智能检测、离线语音控制及…

【Python】 切割图集的小脚本

Python 切割图片脚本 前言&#xff1a; 有短时间没写博客了&#xff0c;今天打算再写一篇MonoGame的教程&#xff0c;这篇是我再做我自己的2D 游戏项目的时候我需要一些已经切割好的图片但我得到图片是合在一起图集&#xff0c;这个脚本适合正在做2D游戏开发且不依赖于游戏引…

网络安全是什么?手把手教你认识网络安全

网络安全是什么&#xff1f;手把手教你认识网络安全 提到网络安全&#xff0c;不少人会联想到电影里黑客指尖翻飞攻破系统的炫酷场景。但实际上&#xff0c;它并非遥不可及的技术名词&#xff0c;而是与我们日常生活息息相关的 “数字保镖”。从手机支付密码到社交账号信息&am…

AtCoder Beginner Contest 416(2025.7.26)

文章目录A Vacation ValidationB 1D Akari&#xff08;补&#xff09;C Concat (X-th)&#xff08;补&#xff09;题目考查题意简述解法思路 &#xff1a;AC代码D Match, Mod, Minimize 2&#xff08;补&#xff09;题目分数/评级题目考查时间复杂度题意简述解法思路 &#xff…

基于 Hadoop 生态圈的数据仓库实践 —— OLAP 与数据可视化(五)

目录 五、Hue、Zeppelin 比较 1. Zeppelin 简介 2. Zeppelin 安装配置 &#xff08;1&#xff09;安装环境 &#xff08;2&#xff09;Zeppelin 及其相关组件 &#xff08;3&#xff09;配置 Zeppelin &#xff08;4&#xff09;启动 Zeppelin &#xff08;5&#xff0…

《消息队列学习指南:从 MQ 基础到 SpringAMQP 实践》

初识MQ 同步调用 目前我们采用的是基于OpenFeign的同步调用&#xff0c;也就是说业务执行流程是这样的&#xff1a; 支付服务需要先调用用户服务完成余额扣减 然后支付服务自己要更新支付流水单的状态 然后支付服务调用交易服务&#xff0c;更新业务订单状态为已支付 三个…

深度学习 --- 过拟合与欠拟合

深度学习 — 过拟合与欠拟合 文章目录深度学习 --- 过拟合与欠拟合一.概念1.1 过拟合1.2 欠拟合1.3 判断方式二&#xff0c;解决欠拟合三&#xff0c;解决过拟合3.1 L2正则化3.1.1 定义以及作用3.1.2 代码3.2 L1正则化3.3 L1与L2对比3.4 Dropout示例3.5 数据增强3.5.1 图片缩放…

Python 之抽象方法 @abstractmethod 的理解

如果你熟悉 Java 的话&#xff0c;Java 里有一个抽象接口的概念&#xff0c;Python 里的抽象方法基本上与其类似。在 Python 中&#xff0c;abstractmethod 是一个装饰器&#xff0c;用于定义抽象方法。它是实现抽象基类&#xff08;Abstract Base Class, ABC&#xff09;的核心…

深度学习·pytorch

广播机制 从末尾开始逐个维度遍历两个矩阵的shape&#xff0c;如果维度不相同&#xff0c;则考虑广播&#xff1a;任一方的维度为1或者维度不存在(小矩阵广播为大矩阵)&#xff0c;这样的运算可以广播 可以广播的例子 xtorch.empty(5,3,4,1) ytorch.empty(3,1,1) (x.add_(y)).s…

SpringBoot集成deepseek

pom文件&#xff1a;<?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org…

JetBrains Annotations:从入门到落地,彻底告别 NullPointerException

本文基于三篇高质量博客&#xff08;JetBrains Annotations官方文档、Jakarta Validation 规范、《Effective Java》第3版&#xff09;的原文内容&#xff0c;结合作者在一线研发团队落地 JetBrains Annotations 的实战经验&#xff0c;系统梳理了该注解库的核心能力、使用姿势…

基于Rust与HDFS、YARN、Hue、ZooKeeper、MySQL

基于Rust与HDFS、YARN、Hue、ZooKeeper、MySQL集合 以下是基于Rust与HDFS、YARN、Hue、ZooKeeper、MySQL等技术栈结合的实例,涵盖不同场景和应用方向: 数据处理与分析 使用Rust编写MapReduce作业,通过YARN提交到HDFS处理大规模数据集。Rust的高性能特性适合处理密集型计算…

芯片上市公司正在放弃射频业务

转载自--钟林谈芯射频芯片赛道本来不卷的&#xff0c;投资人多了也就卷了。本周&#xff0c;多家媒体报道某芯片上市公司终止射频业务&#xff0c;终止射频业务的何止一家芯片上市公司&#xff0c;从去年开始就逐渐有上市公司终止射频业务&#xff0c;开启清货模式。如人饮水&a…