LINUX命令補充

2021-10-24 10:59:39 字數 4177 閱讀 2109

方式一:利用–help選項

[root@localhost ~]

# useradd --help

方式二:利用man幫助

[root@localhost ~]

# man useradd

支援上下鍵滾動,支援 / 進行查詢,按q進行退出

[root@localhost ~]

# man 5 passwd #數字5表示是幫助資訊的型別

#數字5表示配置檔案的幫助資訊

管理/呼叫曾經執行過的命令

history:檢視歷史命令列表

history -c:清空歷史命令

!n:執行命令歷史中的第n條命令

!str:執行最近一次以str開頭的歷史命令

[root@localhost ~]

# vim /etc/profile #修改此檔案內容,重啟系統生效

histsize=1000 #預設記錄1000條

[root@localhost ~]

# history #檢視歷史命令列表

[root@localhost ~]

# history -c #清空歷史命令

[root@localhost ~]

# history

[root@localhost ~]

# cat /etc/redhat-release

[root@localhost ~]

# ls /root/

[root@localhost ~]

# history

[root@localhost ~]

# !cat #執行歷史命令中,最近一條以cat開頭的命令

-s:只統計每個引數所占用的總空間大小

-h:提供易讀容量單位(k、m等)

[root@localhost ~]

# du -sh /etc

[root@localhost ~]

# du -sh /boot/

[root@localhost ~]

# du -sh /

[root@localhost ~]

# du -sh /root

–	date  +

%f、date +

%r– date +

"%y-%m-%d %h:%m:%s"

– date -s "yyyy-mm-dd hh:mm:ss"

[root@localhost ~]

# date

[root@localhost ~]

# date +%y #顯示年

[root@localhost ~]

# date +%m #顯示月

[root@localhost ~]

# date +%d #顯示日

[root@localhost ~]

# date +%f #顯示年-月-日

[root@localhost ~]

# date +%h #顯示時

[root@localhost ~]

# date +%m #顯示分

[root@localhost ~]

# date +%s #顯示秒

[root@localhost ~]

# date +%r #顯示 時:分

[root@localhost ~]

# date

[root@localhost ~]

# date -s "2008-10-1 12:10:01"

[root@localhost ~]

# date

[root@localhost ~]

# date -s "2020-9-8 12:22"

2023年 09月 08日 星期三 12:22:00 cst

[root@localhost ~]

# date

格式:ln   -s    /路徑/源資料     /路徑/快捷方式名字    #軟連線

[root@localhost ~]

# ln -s /etc/hosts /ho

[root@localhost ~]

# ls /

[root@localhost ~]

# ls -l /ho #檢視快捷方式詳細資訊

[root@localhost ~]

# cat /ho

[root@localhost ~]

# cat /etc/hosts

[root@localhost ~]

# ls /etc/sysconfig/network-scripts/

[root@localhost ~]

# ln -s /etc/sysconfig/network-scripts/ /ns

[root@localhost ~]

# ls /

[root@localhost ~]

# ls /ns

[root@localhost ~]

# mkdir /ns/shukehebeita

[root@localhost ~]

# ls /ns

[root@localhost ~]

# ls /etc/sysconfig/network-scripts/

軟連線:

1.可以針對目錄製作快捷方式

2.可以跨越分割槽

3.源資料的消失,快捷方式失效

格式:ln /路徑/源資料 /路徑/快捷方式名字 #硬鏈結

1.不可以針對目錄製作快捷方式

2.不可以跨越分割槽

3.源資料的消失,快捷方式仍然有效

[root@localhost ~]

# echo 123456 > /opt/dc.txt

[root@localhost ~]

# ln -s /opt/dc.txt /opt/tc.txt #軟連線

[root@localhost ~]

# ls /opt/

[root@localhost ~]

# ln /opt/dc.txt /opt/tc.txt #硬鏈結

[root@localhost ~]

# ls /opt/

[root@localhost ~]

# rm -rf /opt/dc.txt

[root@localhost ~]

# ls /opt/

[root@localhost ~]

# cat /opt/tc.txt #硬鏈結仍然有效

歸檔+壓縮操作

格式:zip  [

-r] 備份檔案.zip 被歸檔的文件...

[root@localhost ~]

# zip -r /root/test.zip /home/ /etc/passwd

[root@localhost ~]

# ls /root/

釋放歸檔+解壓操作

格式:unzip  備份檔案.zip   [

-d 目標資料夾]

[root@localhost ~]

# mkdir /test

[root@localhost ~]

# unzip /root/test.zip -d /test

[root@localhost ~]

# ls /test

linux命令補充

新建檔案 cat create linux file.txt 顯示程序 ps eaf grep 檢視服務監聽埠 netstat tln 檢視程序號 netstat 全部程序檢視 ps aux more 強制殺掉程序號 kill 9 常用修改許可權的命令 sudo chmod 600 只有所有者有讀和...

Linux命令補充

命令列模式常用的快捷鍵 dd刪除當前行 dg刪除游標以下的所有行 ndd刪除游標以下的n行 gg跳轉到第一行的第乙個字母 g跳轉到當前行的最後乙個字母 行尾 當想要清空乙個檔案時 1 gg dg 2 echo log 偽清空 清空完檔案大小為1kb shell判斷檔案是否清空一般是根據位元組大小來判...

持續補充 linux命令

1.修改主機名 hostnamectl set hostname 主機名 su 或者 bash 2.建立使用者 useradd 使用者名稱 3.解壓tar.gz到指定目錄 tar xzvf 檔名.tar.gz c 解壓目錄 解壓到當前目錄 tar xvf 檔名.tar.gz 4.檢視伺服器資訊 檢視...