1. 程式人生 > >【計算機基礎】Linux與Windows命令對比

【計算機基礎】Linux與Windows命令對比

檔案目錄操作

Command Linux Windows
批處理 .sh .bat
幫助 cmd –help / -h
列出目錄檔案 ls/ ls -l dir
改變當前目錄 cd cd
進父目錄 cd .. cd ..
進home目錄 cd ~
複製 cp copy
刪除 rm file_name del file_name
建目錄 mkdir folderName md folderName
建檔案 touch fileName touch fileName
刪目錄 rmdir folderName rmdir folderName
設定目錄檔案許可權 chmod u+rwx file
設定目錄檔案所有者 chown user.group file

檔案內容操作

Command Linux Windows
顯示檔案內容 cat type
more,less more
head、tail
統計行數 wc
顯示檔案資訊 file
查詢檔案 find /bin -name ls
定位可執行檔案位置 which
在文字檔案內查詢 grep str1 1.txt find
啟動執行程式 gnome-open/open start

系統資訊查詢

Command Linux Windows
顯示核心版本 uname -a
顯示釋出版本 lsb_release -a
cat /etc/issue
顯示id資訊 id/whoami
顯示當前登陸使用者 who
顯示當前環境資訊 env
顯示啟動中檢測到的硬體資訊 dmesg
顯示系統的PCI裝置 lspci
顯示系統的USB lsusb
顯示cpu資訊 less /proc/cpuinfo
顯示記憶體 less /proc/menminfo
顯示硬碟儲存資訊 df -h

程序/任務控制

Command Linux Windows
顯示程序資訊 ps -auxf
殺死程序 kill proc_id
殺死所有 killall postgresql
暫停中斷當前前臺任務 ctrl - z
恢復任務到後臺 bg
恢復任務到前臺 fg

網路命令

Command Linux Windows
顯示啟動的網路服務 netstat -anli less netstat
顯示路由表資訊 netstat -r netstat -r
顯示ip ip a/ifconfig ipconfig
顯示防火牆資訊 iptables -list
遠端登陸 ssh [email protected]
傳送ping資訊 ping ip ping ip
命令列下載 wget url/curl -o url

使用者管理

Command Linux Windows
修改命令 passwd
建立使用者 useradd
刪除使用者 userdel
修改使用者 usermod
退出 exit / ctrl + D
切換使用者至(預設root) su [-]user
以su後的許可權執行 sudo -u user cmd

其他

Command Linux Windows
顯示日期時間 date date
日曆 cal2014
清除螢幕 clear cls
搜尋軟體包 yum search tree
刪除軟體包 yum remove pkg_name
安裝軟體包 yum install pkg_name
重啟系統 reboot
關閉系統 halt -p
設定環境變數 export PATH=SPATH:~/bin set
顯示資訊/環境變數 echo $HOME echo

vi/vim編輯器使用

在Linux下開啟vim的命令:vi 或者 vim

vi的三種模式:

  • ESC
  • :命令列
  • i 編輯模式

i: 編輯模式

I: 行首插入

a: 追加

A: 行尾插入

R: 替換文字

v: 選擇

ctrl-v: 選擇舉行區域

x: 刪除

dd: 剪下/刪除行

dw: 剪下/刪除字

yy: 拷貝行

p: 游標之後貼上

P: 游標之前貼上

r: 替換單個字元

J: 連線兩行

/: 搜尋

n: 下一個搜尋結果

:s///: substitute

cw: 修改詞語

. : 重複最後一個命令

u: 撤銷

ctr-r: 重做

:w 儲存

:q 關閉

參考部落格:
1.https://blog.csdn.net/xzwspy/article/details/80183849#t0