一.ls
用途:清單(List)顯示目錄内容
格式:ls [選項]… [目錄或檔案名]
常用指令選項
-l :以長格式顯示 --》詳細資訊
-d:顯示目錄本身的屬性
-t: 按檔案修改時間進行排序
-r :将目錄的内容清單以英文字母順序的逆序顯示
-a:顯示所有子目錄和檔案的資訊,包括隐藏檔案 -->以.開頭的檔案,是隐藏檔案
-A:類似于“-a”,但不顯示“.”和“..”目錄的資訊
-h:以更易讀的位元組機關(K、M等)顯示資訊
-R:遞歸顯示内容
[[email protected] ~]# ls -l
總用量 16
-rw-------. 1 root root 1241 2月 15 16:24 anaconda-ks.cfg
-rw-r--r--. 1 root root 22 2月 17 14:46 chenlin.txt
drwxr-xr-x. 3 root root 19 2月 17 15:08 china
-rw-r--r--. 1 root root 22 2月 17 14:46 chenlin.txt
-表示檔案的類型為普通的檔案
d 表示是檔案夾 directory
l 表示是連結檔案 link
rwxr–r-- 表示是檔案的權限 r是讀 read w是寫 write x是執行權限 execute - 此處沒有權限
rwx rwx rwx
使用者 組 其他人
rwxr–r-- 自己有rwx的權限,組裡的人隻有讀,其他人也隻有讀
二.alias(别名)
alias 起别名–》一個簡稱–》不需要輸入很多的字–》節約時間、友善
[[email protected] lianxi]# alias 檢視系統裡有哪些别名,可以使用
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[[email protected] lianxi]# alias c=clear 定義c是clear的别名
别名可以自己定義,但是不能後系統裡的已經存在的指令沖突,如果有沖突,會導緻原來的指令不能使用
[[email protected] lianxi]# unalias cd 取消别名cd
[[email protected] liuyongqian]# alias ck='mkdir -p' 當定義别名的時候,指令有選項,中間有空格,就需要使用雙引号或者單引号擴起來
三.pstree
檢視整個linux裡的程序樹,所有的程序以及它們之間的關系
[[email protected] ~]# pstree 檢視整個linux裡的程序樹,所有的程序以及它們之間的關系
systemd─┬─NetworkManager───2*[{NetworkManager}]
├─VGAuthService
├─auditd───{auditd}
├─crond
├─dbus-daemon───{dbus-daemon}
├─firewalld───{firewalld}
├─irqbalance───{irqbalance}
├─login───bash
├─polkitd───5*[{polkitd}]
├─rngd───{rngd}
├─rsyslogd───2*[{rsyslogd}]
├─sshd─┬─sshd───sshd───bash───su───bash───su───bash───su───bash───pstree
│ └─sshd───sshd───bash
├─sssd─┬─sssd_be
│ └─sssd_nss
├─2*[systemd───(sd-pam)]
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─tuned───3*[{tuned}]
└─vmtoolsd───{vmtoolsd}
[[email protected] ~]#
[[email protected] ~]# pstree -p (顯示端口号)
systemd(1)─┬─NetworkManager(49038)─┬─dhclient(49070)
│ ├─{NetworkManager}(49039)
│ └─{NetworkManager}(49041)
├─VGAuthService(759)
├─auditd(734)───{auditd}(735)
├─crond(19258)
├─dbus-daemon(766)───{dbus-daemon}(777)
├─irqbalance(761)
├─login(787)───bash(8117)
├─lvmetad(548)
├─master(1492)─┬─pickup(49005)
│ └─qmgr(1512)
├─polkitd(762)─┬─{polkitd}(774)
│ ├─{polkitd}(778)
│ ├─{polkitd}(780)
│ ├─{polkitd}(784)
│ ├─{polkitd}(785)
│ └─{polkitd}(788)
├─rsyslogd(1183)─┬─{rsyslogd}(1187)
│ └─{rsyslogd}(1189)
├─sshd(1181)─┬─sshd(48207)───bash(48211)
│ └─sshd(49121)───bash(49125)───pstree(49168)
├─systemd-journal(528)
├─systemd-logind(779)
├─systemd-udevd(559)
├─tuned(1182)─┬─{tuned}(1841)
│ ├─{tuned}(1842)
│ ├─{tuned}(1850)
│ └─{tuned}(1856)
└─vmtoolsd(760)───{vmtoolsd}(815)
四.rm(删除)
rm - remove files or directories --》非常危險的指令–》危險指數5顆星
Linux裡預設是沒有資源回收筒,删除後不能通過資源回收筒恢複,可以使用一些恢複軟體恢複。
要求我們平時做好備份
災備: --》購買伺服器和磁盤存放資料
-f, --force 強制
ignore nonexistent files and arguments, never prompt
删除檔案的時候,如果檔案不存在,直接忽略不報錯,也不給予任何提醒和提示
-r, -R, --recursive 遞歸
remove directories and their contents recursively
[[email protected] lianxi]# rm -r china
rm:是否進入目錄'china'? y
rm:是否進入目錄'china/hunan'? y
rm指令
用途:删除(Remove)檔案或目錄
格式:rm [選項]… 檔案或目錄
-f:強行删除檔案或目錄,不進行提醒
-r:遞歸删除整個目錄樹
[[email protected] lianxi]# rm -rf a?
[[email protected] lianxi]# rm -rf a?? 删除檔案名有3位,以a開頭的,全部删除
[[email protected] lianxi]# rm -rf ?bc?
[[email protected] lianxi]# rm -rf *.txt 删除檔案名以.txt結尾的檔案或者檔案夾
[[email protected] lianxi]# rm -rf a*