Unix/Linux命令參考

來源:互聯網
上載者:User
一、檔案命令

ls – 列出目錄
ls -al – 使用格式化列出隱藏檔案
cd dir - 更改目錄到 dir
cd – 更改到 home 目錄
pwd – 顯示目前的目錄
mkdir dir – 建立目錄 dir
rm file – 刪除 file
rm -r dir – 刪除目錄 dir
rm -f file – 強制移除 file
rm -rf dir – 強制移除目錄 dir *
cp file1 file2 – 將 file1 複製到 file2
cp -r dir1 dir2 – 將 dir1 複製到 dir2; 如果 dir2 不存在則建立它
mv file1 file2 – 將 file1 重新命名或移動到 file2; 如果 file2 是一個存在的目錄則將 file1 移動到目錄 file2 中
ln -s file link – 建立 file 的符號串連 link
touch file – 建立 file
cat > file – 將標準輸入添加到 file
more file – 查看 file 的內容
head file – 查看 file 的前 10 行
tail file – 查看 file 的後 10 行
tail -f file – 從後 10 行開始查看 file 的內容

二、進程管理

ps – 顯示當前的活動進程
top – 顯示所有正在啟動並執行進程
kill pid – 殺掉進程 id pid
killall proc – 殺掉所有名為 proc 的進程 *
bg – 列出已停止或背景作業
fg – 將最近的作業帶到前台
fg n – 將作業 n 帶到前台

三、檔案許可權

chmod octal file – 更改 file 的許可權
● 4 – 讀 (r)
● 2 – 寫 (w)
● 1 – 執行 (x)
樣本:
chmod 777 – 為所有使用者添加讀、寫、執行許可權
chmod 755 – 為所有者添加 rwx 許可權, 為組和其他使用者添加
rx 許可權
更多選項參閱 man chmod.

四、SSH

grep pattern files – 搜尋 files 中匹配 pattern 的內容
grep -r pattern dir – 遞迴搜尋 dir 中匹配 pattern 的內容
command | grep pattern – 搜尋 command 輸出中匹配 pattern 的內容

五、系統資訊

date – 顯示當前日期和時間
cal – 顯示當月的日曆
uptime – 顯示系統從開機到現在所啟動並執行時間
w – 顯示登入的使用者
whoami – 查看你的目前使用者名
finger user – 顯示 user 的相關資訊
uname -a – 顯示核心資訊
cat /proc/cpuinfo – 查看 cpu 資訊
cat /proc/meminfo – 查看記憶體資訊
man command – 顯示 command 的說明手冊
df – 顯示磁碟佔用情況
du – 顯示目錄空間佔用情況
free – 顯示記憶體及交換區佔用情況

六、壓縮

tar cf file.tar files – 建立包含 files 的 tar 檔案 file.tar
tar xf file.tar – 從 file.tar 提取檔案
tar czf file.tar.gz files – 使用 Gzip 壓縮建立 tar 檔案
tar xzf file.tar.gz – 使用 Gzip 提取 tar 檔案
tar cjf file.tar.bz2 – 使用 Bzip2 壓縮建立 tar 檔案
tar xjf file.tar.bz2 – 使用 Bzip2 提取 tar 檔案
gzip file – 壓縮 file 並重新命名為 file.gz
gzip -d file.gz – 將 file.gz 解壓縮為 file

七、網路

ping host – ping host 並輸出結果
whois domain – 擷取 domain 的 whois 資訊
dig domain – 擷取 domain 的 DNS 資訊
dig -x host – 逆向查詢 host
wget file – 下載 file
wget -c file – 斷點續傳

八、安裝

從原始碼安裝:
./configure
make
make install
dpkg -i pkg.deb – 安裝包 (Debian)
rpm -Uvh pkg.rpm – 安裝包 (RPM)

九、快速鍵

Ctrl+C – 停止當前命令
Ctrl+Z – 停止當前命令,並使用 fg 恢複
Ctrl+D – 登出當前會話,與 exit 相似
Ctrl+W – 刪除當前行中的字
Ctrl+U – 刪除整行
!! - 重複上次的命令
exit – 登出當前會話

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.