Linux基本命令

來源:互聯網
上載者:User

標籤:http   java   使用   os   io   檔案   for   ar   

Linux基本命令

1、系統資訊

arch // 顯示機器的處理器架構
uname -m // 顯示機器的處理器架構
uname -r // 顯示正在使用的核心版本
uname -a // 查看核心/作業系統/CPU資訊

cat /proc/cpuinfo // 顯示cpu info的資訊
cat /proc/interrupts // 顯示中斷
cat /proc/meminfo // 檢驗記憶體使用量
cat /proc/swaps // 顯示哪些swap被使用
cat /proc/version // 顯示核心的版本
cat /proc/mounts // 顯示已載入的檔案系統

hostname // 查看電腦名稱
lspci -tv // 列出所有pci裝置
lsusb -tv // 列出所有usb裝置
lsmod // 列出載入的核心模組
env // 查看環境變數

date // 顯示系統日期
cal 2014 // 顯示2014年的日曆表

2、檔案和目錄

cd /home // 進入‘/home‘目錄
cd .. // 返回上一級目錄
cd ../.. // 返回上兩級目錄
cd ~user1 // 進入個人的主目錄,比如:/home/huxiusong/
cd - // 返回上次所在的目錄
pwd // 顯示工作路徑
ls // 查看目錄下的檔案
ls -F // 查看目錄中的檔案
ls -l // 顯示檔案和目錄的詳細資料
ls -a // 顯示隱藏檔案

mkdir dir1 // 建立一個叫做‘dir1‘的目錄
mkdir dir1 dir2 // 同時建立兩個目錄
mkdir -p /tmp/dir1/dir2 // 建立一個分類樹

rm -f file1 // 刪除一個叫做file1的檔案
rmdir dir1 // 刪除一個叫做dir1的目錄
rm -rf dir1 // 刪除一個叫做dir1的目錄並同時刪除其內容
rm -rf dir1 dir2 // 同時刪除兩個目錄以及它們的內容

mv dir1 new_dir // 重新命名/移動一個目錄
cp file1 file2 // 複製一個檔案
cp dir/* . // 複製一個目錄下的所有檔案到當前工作目錄
cp -a /tmp/dir1 . // 複製一個工作目錄到當前工作目錄
cp -a dir1 dir2 // 複製一個目錄

mv file1 /usr/local/servers/fddseller/ // 移動檔案

ln -s file1 lnk1 // 建立一個指向檔案或目錄的軟連結
ln file1 lnk1 // 建立一個指向檔案或目錄的物理連結

3、檔案搜尋

find / -name file1 // 從‘/‘開始進入根檔案系統搜尋檔案和目錄
find / -user user1 // 搜尋屬於使用者‘user1‘的檔案和目錄
find /usr/bin -type f -atime +100 // 搜尋在過去100天內未被使用過的執行檔案
find /usr/bin -type f -mtime -10 // 搜尋在10天之內被建立或者修改過的檔案

4、磁碟空間

free -m // 查看記憶體使用量量和交換區使用量
df -h // 顯示已經掛載的分區列表
du -sh <目錄名> // 查看指定目錄的大小
grep MemTotal /proc/meminfo // 查看記憶體總量
grep MemFree /proc/meminfo // 查看空閑記憶體量
uptime // 查看系統已耗用時間、使用者數、負載

cat /proc/loadavg // 查看系統負載
ls -lSr |more // 以尺寸大小排列檔案和目錄
mount |column -t // 查看掛接的分區狀態
fdisk -l // 查看所有交換分區

5、檔案的許可權

chmod ugo+rwx dir // 設定目錄的所有人u,群組g以及其他人o以讀r,寫w和執行x的許可權
chmod go-rwx dir // 刪除群組g與其他人o對目錄的讀寫執行許可權
chown user1 file1 // 改變一個檔案的所有人屬性
chown -R user1 dir1 // 改變一個目錄的所有人屬性並同時改變該目錄下所有檔案的屬性
chown group1 file1 // 改變檔案的群組
chown user1:group1 file1 // 改變一個檔案的所有人和群組屬性
chmod +x *.sh // 對*.sh檔案設定執行許可權,+x

6、進程網路

ifconfig // 查看所有網路介面的屬性
iptables -L // 查看防火牆設定
route -n // 查看路由表
kill -9 pid // 殺掉進程pid
netstat -lntp // 查看所有監聽連接埠
netstat -s // 查看網路統計資訊
netstat -anp | grep pid // 顯示網路連接埠資訊
netstat -anp | grep port // 測試port連接埠是否在監聽處理
ps -ef|grep java // 列出java進程pid
top // 即時顯示進程狀態

參考文章:
http://www.oschina.net/translate/useful-linux-commands-for-newbies
http://www.php100.com/html/webkaifa/Linux/2009/1106/3485.html

設定Ubuntu網路ip地址,設定檔案地址為:
/etc/network/interfaces
設定完畢後,ifdown eth0/ifup eth0,然後查看ifconfig即可

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.