查看當前目錄下可見的文件、文件夾及其相關權限 經常使用參數:-l 列表式查看 -al 查看全部,包括隱藏的文件、文件夾
[root@qinshengfei bin]# ls --color 以彩色顯示 [root@qinshengfei bin]# ls -l 詳情列出目錄文件 [root@qinshengfei bin]# ls -a 顯示全部文件,包括隱藏文件 [root@qinshengfei bin]# ls -al 列表顯示全部文件 [root@qinshengfei bin]# ls -al|more 將目錄內容分佈顯示
經常使用參數 : 直接接文件夾名稱
[root@qinshengfei /home]# mkdir test
[root@qinshengfei bin]# pwd /usr/bin <== 顯示當前工做目錄
[root@qinshengfei /root]# cd .. <== 回到上一級目錄 [root@qinshengfei /]# cd <== 回到home目錄 [root@qinshengfei root]# cd /usr/bin <== 到 /usr/bin 目錄
若是要刪除的目錄裏面有文件或文件夾,是沒法移動的,這時,就須要加上參數 -rf 來強制操做刪除。
[root@qinshengfei /root]# rmdir ./test <== 刪除目錄 [root@qinshengfei /root]# rmdir ./test2 -rf <== 刪除目錄及子目錄、文件
[root@qinshengfei /root]# rm test
[root@qinshengfei /root]# cp .bashrc /home
[root@qinshengfei /root]# mv test.txt /home
[root@qinshengfei /mysql.conf.d]# cat mysqld.cnf
[root@qinshengfei /mysql.conf.d]# tail -n 5 mysqld.cnf
less命令可查看文件。 它使用起來速度更快,並且您不會無心間修改文件。 使用更少的光標,您可使用向上和向下箭頭鍵,PgUp和PgDn鍵以及Home和End鍵在文件中先後滾動。 按Q鍵退出。
[root@qinshengfei /mysql.conf.d]# less log.txt
例如使用 ps -aux 查詢進程,咱們只須要知道 tomcat 有不有運行,就可使用管道指令『|』加入 grep 這個命令同時操做。
[root@qinshengfei /]# ps -aux|grep tomcat
[root@qinshengfei /]# find / -name bin
[root@qinshengfei /root]# tar -zcvf app.tar.gz app
也是一壓縮命令,跟compress 很類似,指令的用法也相同!只是壓縮後綴名 .gz !
[root@qinshengfei /root]# gzip -d xxxxx.gz
[root@qinshengfei /root]# unzip app.zip 解壓一個叫作 'app.zip'的文件
[root@qinshengfei /root]# exit
[root@qinshengfei /root]# ping baidu.com
[root@qinshengfei /root]# telnet 47.2.30.289 8080
[root@qinshengfei /root]# who
[root@qinshengfei /root]# su qinshengfei
[root@qinshengfei /]# uname -a Linux qinshengfei 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux [root@qinshengfei /]#
使用alias命令能夠給命令或命令序列指定本身的名稱。 而後,您能夠輸入您的簡稱,而後Shell將爲您執行命令或命令序列。
[root@qinshengfei /]# alias pf="ps -e | grep $1" [root@qinshengfei /]# pf tomcat
0: No permission 1: Execute permission 2: Write permission 3: Write and execute permissions 4: Read permission 5: Read and execute permissions 6: Read and write permissions 7: Read, write and execute permissions
[root@qinshengfei /]# chmod 777 app -r <== -r 連同子目錄權限一塊兒修改
可使用chown更改文件的全部者或組,或二者。 必須提供全部者和組的名稱,以:字符分隔。
[root@qinshengfei /]# chown dave:mary example.txt
curl命令是從統一資源定位器(URL)或Internet地址檢索信息和文件的工具。
[root@qinshengfei /]# curl http://www.baidu.com index.html
echo命令將文本字符串打印(回顯)到終端窗口。也能夠將字符串打印到文件。
[root@qinshengfei /]# echo "hello world" hello world [root@qinshengfei /]#
free命令爲您提供計算機內存使用狀況的摘要。 它對主隨機存取存儲器(RAM)和交換存儲器都執行此操做。 -h(人類)選項用於提供人類友好的數字和單位。 沒有此選項,數字以字節爲單位。
[root@qinshengfei /]# free total used free shared buff/cache available Mem: 8000348 1554508 4549432 576 1896408 6194856 Swap: 0 0 0 [root@qinshengfei /]#
history命令列出了您先前在命令行上發出的命令。 您能夠經過鍵入感嘆號來重複歷史記錄中的任何命令! 以及歷史記錄列表中的命令編號。
[root@qinshengfei /]# [root@qinshengfei /]# history 1 yum install docker 2 yum install nginx 3 yum -y install docker-ce
咱們將使用上面關於別名命令的部分中的ps和grep技巧。 咱們能夠搜索快門過程並獲取其PID,以下所示:html
[root@qinshengfei /]# ps -ef|grep nginx root 31884 22980 0 16:19 pts/0 00:00:00 grep --color=auto nginx root 32400 1 0 Feb18 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 32401 32400 0 Feb18 ? 00:00:00 nginx: worker process nginx 32402 32400 0 Feb18 ? 00:00:00 nginx: worker process [root@qinshengfei /]# kill -9 32400
passwd命令使您能夠更改用戶密碼。 只需鍵入passwd便可更改您本身的密碼。
[root@qinshengfei /]# sudo passwd mary
使用ssh命令創建與遠程Linux計算機的鏈接並登陸到您的賬戶。 要創建鏈接,您必須提供您的用戶名以及遠程計算機的IP地址或域名。 在此示例中,用戶mary以192.168.4.23登陸到計算機。 創建鏈接後,將要求她輸入密碼。
[root@qinshengfei /]# ssh mary@192.168.4.23 mary@192.168.4.23's password:
[root@qinshengfei /]# df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 3986836 0 3986836 0% /dev tmpfs 4000172 0 4000172 0% /dev/shm tmpfs 4000172 576 3999596 1% /run tmpfs 4000172 0 4000172 0% /sys/fs/cgroup /dev/vda1 52417516 4031296 48386220 8% / overlay 52417516 4031296 48386220 8% /var/lib/docker/overlay2/650e5470981551bdd57ee3f9da79da55ef5170d11017e282c318f801b5c5ac4b/merged tmpfs 800032 0 800032 0% /run/user/0 [root@qinshengfei /]#
ps命令列出了正在運行的進程。 使用不帶任何選項的ps會致使它列出當前shell中正在運行的進程。
[root@qinshengfei /]# ps PID TTY TIME CMD 9191 pts/0 00:00:00 ps 16776 pts/0 00:00:00 bash 17212 pts/0 00:00:00 mysql 22980 pts/0 00:00:00 bash 23524 pts/0 00:00:44 java [root@qinshengfei /]#
要查詢關鍵字進程,能夠結合管道命令。
[root@qinshengfei /]# ps -ef|grep nginx root 10377 22980 0 16:26 pts/0 00:00:00 grep --color=auto nginx root 32400 1 0 Feb18 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 32401 32400 0 Feb18 ? 00:00:00 nginx: worker process nginx 32402 32400 0 Feb18 ? 00:00:00 nginx: worker process [root@qinshengfei /]#
[root@qinshengfei /]# top
[root@qinshengfei /]# reboot
使用不帶參數的關機將在一分鐘內關閉計算機。java
[root@qinshengfei /]# shutdown
使用 now 參數 ,馬上關機
[root@qinshengfei /]# shutdown -h now
使用 -r 參數 重啓 與reboot效果同樣 ,shutdown -r 能夠定時
[root@qinshengfei /]# shutdown -r now
centos環境下安裝軟件的命令
[root@qinshengfei /]# yum install nginx