Linux 基本命令

2021-10-23 21:57:29 字數 2097 閱讀 9481

1、檢視ip 位址

2、linux 啟動、關閉、重啟網路服務的兩種方式

//啟動 

service network start

//關閉

service network stop

//重啟

service network restart

//啟動 

/etc/init.d/network start

//關閉

/etc/init.d/network stop

//重啟

/etc/init.d/network restart

3、firewall 相關

systemctl status firewalld  // 檢視firewall狀態  

systemctl start firewalld //啟動

systemctl stop firewalld //停止

systemctl enable firewalld //開機啟動

systemctl disable firewalld //禁止開機啟動

firewall-cmd --reload #重啟防火牆

//檢視已經開放的埠

firewall-cmd --list-ports

#檢視某個埠是否開放

firewall-cmd --zone=public --query-port=80/tcp

#開啟埠

firewall-cmd --zone=public --add-port=80/tcp --permanent

//關閉埠

firewall-cmd --zone=public --remove-port=80/tcp --permanent

命令含義:

--zone #作用域

--add-port=80/tcp #新增埠,格式為:埠/通訊協議

--permanent #永久生效,沒有此引數重啟後失效

4、nginx 服務相關

cd /usr/local/nginx/sbin

./nginx //啟動

./nginx -s stop //停止

./nginx -s reload //重啟

./nginx -t //判斷配置檔案是否正確

5、以檔名查詢檔案

find -name filename
6、檢視檔案內容

tail -f filename
引數:

-f 迴圈讀取

-q 不顯示處理資訊

-v 顯示詳細的處理資訊

-c《數目》 顯示的位元組數

-n《行數》 顯示檔案的尾部 n 行內容

--pid=pid 與-f合用,表示在程序id,pid死掉之後結束

-q, --quiet, --silent 從不輸出給出檔名的首部

-s, --sleep-interval=s 與-f合用,表示在每次反覆的間隔休眠s秒

tail -n 5 filename  //檢視最後5行內容

tail +20 filename //從第20行至末尾

7、刪除檔案和目錄

rm ***.html // 刪除檔案

rm -rf test // 刪除目錄 (rmdir test // 刪除空目錄)

linux基本命令

linux常用命令 基礎 eg man ls 就可以檢視ls相關的用法 注 按q鍵或者ctrl c退出,在linux下可以使用ctrl c終止當前程式執行。2.ls 檢視目錄或者檔案的屬 列舉出任一目錄下面的檔案 eg ls usr man ls l a.d表示目錄 directory 如果是乙個 ...

《linux基本命令》

博主部落格 斷橋殘雪 uname 顯示版本資訊 同win2k的 ver dir 顯示當前目錄檔案,ls al 顯示包括隱藏檔案 同win2k的 dir pwd 查詢當前所在的目錄位置 cd cd 回到上一層目錄,注意cd 與.之間有空格。cd 返回到根目錄。cat 檔名 檢視檔案內容 cat abc...

LINUX 基本命令

檔案和目錄操作的基本命令 cat clear cmp cut diff du emacs fgrep file grep head ln less more pico pwd sort stat strings tail touch umask uniq vi wc whatis ls ls 選項 ...