Linux基本指令,對路徑的認識

引言

? ? ? ? 簡單介紹一些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…