-
觀察linux系統(tǒng)上虛擬內(nèi)存的當前狀態(tài)
[root@localhost ~]# cat/proc/meminfo MemTotal: 1010536 kB MemFree: 178716 kB MemAvailable: 249504 kB Buffers: 0 kB Cached: 100180 kB SwapCached: 53608 kB Active: 206116 kB Inactive: 260760 kB Active(anon): 171404 kB Inactive(anon): 214548 kB Active(file): 34712 kB Inactive(file): 46212 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 2097148 kB SwapFree: 1767952 kB Dirty: 72 kB Writeback: 0 kB AnonPages: 330732 kB Mapped: 30380 kB Shmem: 19256 kB Slab: 223204 kB SReclaimable: 142948 kB SUnreclaim: 80256 kB KernelStack: 7776 kB PageTables: 10864 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2602416 kB Committed_AS: 1452468 kB VmallocTotal: 34359738367 kB VmallocUsed: 59056 kB VmallocChunk: 34359621948 kB HardwareCorrupted: 0 kB AnonHugePages: 4096 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 178112 kB DirectMap2M: 870400 kB
-
查看系統(tǒng)當前共享內(nèi)存頁面
[root@localhost ~]# ipcs -m ------------共享內(nèi)存段-------------- 鍵 shmid| 擁有者 權限 字節(jié) nattch 狀態(tài) 0x0112e73f 0 root 600 1000 7 0x0112e742 32769 root 600 1200712 7
-
ls查看文件更多信息
[root@localhost ~]# ls -l 總用量 16 -rw-------. 1 root root 1219 8月 2 08:56 anaconda-ks.cfg -rw-r--r--. 1 root root 6140 11月 12 2015 mysql-community-release-el7-5.noarch.rpm drwxr-xr-x. 2 root root 21 10月 27 13:07 python3.0 drwxr-xr-x. 5 root root 64 11月 1 10:23 service drwxr-xr-x. 10 root root 4096 10月 19 17:07 web
-
創(chuàng)建文件touch
[root@localhost ~]# touch test1 [root@localhost ~]# ls -il test1 105094843 -rw-r--r--. 1 root root 0 11月 9 15:53 test1
touch命令創(chuàng)建了你指定的新文件法焰,并將你的用戶名作為文件的屬主鸦难。
-
復制文件cp sourece destination
[root@localhost ~]# cp test1 test2 [root@localhost ~]# ls -il total 0 105094843 -rw-r--r--. 1 root root 0 11月 9 15:53 test1 105094844 -rw-r--r--. 1 root root 0 11月 9 16:02 test2
如果目標文件test2存在,那么將覆蓋文件杂曲,如果新文件中和源文件同名难菌,需要用絕對路徑來表示渐夸。
-
重名文件
[root@localhost ~]# mv test1 test3 [root@localhost ~]# ls -il test* 105094844 -rw-r--r--. 1 root root 0 11月 9 16:02 test2 105094843 -rw-r--r--. 1 root root 0 11月 9 15:53 test3
-
刪除文件
[root@localhost ~]# rm test2 rm:是否刪除普通空文件 "test2"嗓蘑?y
注意,提示是否刪除文件虫溜,bash shell中沒有回收站或者垃圾箱,所以一旦刪除颂郎,就無法找回了吼渡。
-
創(chuàng)建目錄
[root@localhost ~]# mkdir dir1 37353231 drwxr-xr-x. 2 root root 6 11月 9 16:17 dir1
-
刪除目錄
[root@localhost ~]# rmdir dir1
這個命令刪空文件好用。如果需要刪除則是rm -r dir乓序;刪庫到跑路推薦用rm -rf file。
-
查看系統(tǒng)磁盤占用
[root@localhost ~]# df -h 文件系統(tǒng) 容量 已用 可用 已用% 掛載點 /dev/sda2 30G 5.4G 25G 18% / devtmpfs 486M 0 486M 0% /dev tmpfs 494M 20K 494M 1% /dev/shm tmpfs 494M 50M 444M 11% /run tmpfs 494M 0 494M 0% /sys/fs/cgroup /dev/sda5 95G 33M 95G 1% /home /dev/sda1 497M 102M 396M 21% /boot
-
搜索數(shù)據(jù)
[root@localhost ~]# grep a test3 a apple
加入函數(shù)可以grep -n a test3
-
打包和壓縮文件
bunzip2 file1.bz2 解壓一個叫做 'file1.bz2'的文件 bzip2 file1 壓縮一個叫做 'file1' 的文件 gunzip file1.gz 解壓一個叫做 'file1.gz'的文件 gzip file1 壓縮一個叫做 'file1'的文件 gzip -9 file1 最大程度壓縮 rar a file1.rar test_file 創(chuàng)建一個叫做 'file1.rar' 的包 rar a file1.rar file1 file2 dir1 同時壓縮 'file1', 'file2' 以及目錄 'dir1' rar x file1.rar 解壓rar包 unrar x file1.rar 解壓rar包 tar -cvf archive.tar file1 創(chuàng)建一個非壓縮的 tarball tar -cvf archive.tar file1 file2 dir1 創(chuàng)建一個包含了 'file1', 'file2' 以及 'dir1'的檔案文件 tar -tf archive.tar 顯示一個包中的內(nèi)容 tar -xvf archive.tar 釋放一個包 tar -xvf archive.tar -C /tmp 將壓縮包釋放到 /tmp目錄下 tar -cvfj archive.tar.bz2 dir1 創(chuàng)建一個bzip2格式的壓縮包 tar -xvfj archive.tar.bz2 解壓一個bzip2格式的壓縮包 tar -cvfz archive.tar.gz dir1 創(chuàng)建一個gzip格式的壓縮包 tar -xvfz archive.tar.gz 解壓一個gzip格式的壓縮包 zip file1.zip file1 創(chuàng)建一個zip格式的壓縮包 zip -r file1.zip file1 file2 dir1 將幾個文件和目錄同時壓縮成一個zip格式的壓縮包 unzip file1.zip 解壓一個zip格式壓縮包
-
文件的權限 - 使用 "+" 設置權限坎背,使用 "-" 用于取消
ls -lh 顯示權限 ls /tmp | pr -T5 -W$COLUMNS 將終端劃分成5欄顯示 chmod ugo+rwx directory1 設置目錄的所有人(u)替劈、群組(g)以及其他人(o)以讀(r )、寫(w)和執(zhí)行(x)的權限 chmod go-rwx directory1 刪除群組(g)與其他人(o)對目錄的讀寫執(zhí)行權限 chown user1 file1 改變一個文件的所有人屬性 chown -R user1 directory1 改變一個目錄的所有人屬性并同時改變改目錄下所有文件的屬性 chgrp group1 file1 改變文件的群組 chown user1:group1 file1 改變一個文件的所有人和群組屬性 find / -perm -u+s 羅列一個系統(tǒng)中所有使用了SUID控制的文件 chmod u+s /bin/file1 設置一個二進制文件的 SUID 位 - 運行該文件的用戶也被賦予和所有者同樣的權限 chmod u-s /bin/file1 禁用一個二進制文件的 SUID位 chmod g+s /home/public 設置一個目錄的SGID 位 - 類似SUID 得滤,不過這是針對目錄的 chmod g-s /home/public 禁用一個目錄的 SGID 位 chmod o+t /home/public 設置一個文件的 STIKY 位 - 只允許合法所有人刪除文件 chmod o-t /home/public 禁用一個目錄的 STIKY 位
-
文本處理
cat file1 file2 ... | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT cat file1 | command( sed, grep, awk, grep, etc...) > result.txt 合并一個文件的詳細說明文本陨献,并將簡介寫入一個新文件中 cat file1 | command( sed, grep, awk, grep, etc...) >> result.txt 合并一個文件的詳細說明文本,并將簡介寫入一個已有的文件中 grep Aug /var/log/messages 在文件 '/var/log/messages'中查找關鍵詞"Aug" grep ^Aug /var/log/messages 在文件 '/var/log/messages'中查找以"Aug"開始的詞匯 grep [0-9] /var/log/messages 選擇 '/var/log/messages' 文件中所有包含數(shù)字的行 grep Aug -R /var/log/* 在目錄 '/var/log' 及隨后的目錄中搜索字符串"Aug" sed 's/stringa1/stringa2/g' example.txt 將example.txt文件中的 "string1" 替換成 "string2" sed '/^$/d' example.txt 從example.txt文件中刪除所有空白行 sed '/ *#/d; /^$/d' example.txt 從example.txt文件中刪除所有注釋和空白行 echo 'esempio' | tr '[:lower:]' '[:upper:]' 合并上下單元格內(nèi)容 sed -e '1d' result.txt 從文件example.txt 中排除第一行 sed -n '/stringa1/p' 查看只包含詞匯 "string1"的行 sed -e 's/ *$//' example.txt 刪除每一行最后的空白字符 sed -e 's/stringa1//g' example.txt 從文檔中只刪除詞匯 "string1" 并保留剩余全部 sed -n '1,5p;5q' example.txt 查看從第一行到第5行內(nèi)容 sed -n '5p;5q' example.txt 查看第5行 sed -e 's/00*/0/g' example.txt 用單個零替換多個零 cat -n file1 標示文件的行數(shù) cat example.txt | awk 'NR%2==1' 刪除example.txt文件中的所有偶數(shù)行 echo a b c | awk '{print $1}' 查看一行第一欄 echo a b c | awk '{print $1,$3}' 查看一行的第一和第三欄 paste file1 file2 合并兩個文件或兩欄的內(nèi)容 paste -d '+' file1 file2 合并兩個文件或兩欄的內(nèi)容懂更,中間用"+"區(qū)分 sort file1 file2 排序兩個文件的內(nèi)容 sort file1 file2 | uniq 取出兩個文件的并集(重復的行只保留一份) sort file1 file2 | uniq -u 刪除交集眨业,留下其他的行 sort file1 file2 | uniq -d 取出兩個文件的交集(只留下同時存在于兩個文件中的文件) comm -1 file1 file2 比較兩個文件的內(nèi)容只刪除 'file1' 所包含的內(nèi)容 comm -2 file1 file2 比較兩個文件的內(nèi)容只刪除 'file2' 所包含的內(nèi)容 comm -3 file1 file2 比較兩個文件的內(nèi)容只刪除兩個文件共有的部分
-
網(wǎng)絡
ifconfig eth0 顯示一個以太網(wǎng)卡的配置 ifup eth0 啟用一個 'eth0' 網(wǎng)絡設備 ifdown eth0 禁用一個 'eth0' 網(wǎng)絡設備 ifconfig eth0 192.168.1.1 netmask 255.255.255.0 控制IP地址 ifconfig eth0 promisc 設置 'eth0' 成混雜模式以嗅探數(shù)據(jù)包 (sniffing) dhclient eth0 以dhcp模式啟用 'eth0' route -n show routing table route add -net 0/0 gw IP_Gateway configura default gateway route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure static route to reach network '192.168.0.0/16' route del 0/0 gw IP_gateway remove static route echo "1" > /proc/sys/net/ipv4/ip_forward activate ip routing hostname show hostname of system host www.example.com lookup hostname to resolve name to ip address and viceversa(1) nslookup www.example.com lookup hostname to resolve name to ip address and viceversa(2) ip link show show link status of all interfaces mii-tool eth0 show link status of 'eth0' ethtool eth0 show statistics of network card 'eth0' netstat -tup show all active network connections and their PID netstat -tupl show all network services listening on the system and their PID tcpdump tcp port 80 show all HTTP traffic iwlist scan show wireless networks iwconfig eth1 show configuration of a wireless network card hostname show hostname host www.example.com lookup hostname to resolve name to ip address and viceversa nslookup www.example.com lookup hostname to resolve name to ip address and viceversa whois www.example.com lookup on Whois database
Linux常用命令總結
最后編輯于 :
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來血久,“玉大人突照,你說我怎么就攤上這事⊙跬拢” “怎么了讹蘑?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長副砍。 經(jīng)常有香客問我衔肢,道長,這世上最難降的妖魔是什么豁翎? 我笑而不...
- 文/花漫 我一把揭開白布蝉揍。 她就那樣靜靜地躺著链峭,像睡著了一般。 火紅的嫁衣襯著肌膚如雪又沾。 梳的紋絲不亂的頭發(fā)上弊仪,一...
- 文/蒼蘭香墨 我猛地睜開眼表窘,長吁一口氣:“原來是場噩夢啊……” “哼典予!你這毒婦竟也來了?” 一聲冷哼從身側響起乐严,我...
- 正文 年R本政府宣布,位于F島的核電站滞磺,受9級特大地震影響升薯,放射性物質發(fā)生泄漏。R本人自食惡果不足惜击困,卻給世界環(huán)境...
- 文/蒙蒙 一涎劈、第九天 我趴在偏房一處隱蔽的房頂上張望广凸。 院中可真熱鬧,春花似錦蛛枚、人聲如沸谅海。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽扭吁。三九已至,卻和暖如春盲镶,著一層夾襖步出監(jiān)牢的瞬間侥袜,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 系統(tǒng)信息 arch 顯示機器的處理器架構(1) uname -m 顯示機器的處理器架構(2) uname -r 顯...