新聞中心
在LINUX系統(tǒng)中,分區(qū)與格式化硬盤(pán)的命令是什么?
Linux下常用的分區(qū)工具:
創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括太康網(wǎng)站建設(shè)、太康網(wǎng)站制作、太康網(wǎng)頁(yè)制作以及太康網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃等。多年來(lái),我們專(zhuān)注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,太康網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶(hù)以成都為中心已經(jīng)輻射到太康省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶(hù)的支持與信任!
fdisk/sfdisk:命令行工具,各種版本和環(huán)境都能使用,包含在軟件包util-linux中
diskdruid:圖形化分區(qū)工具,只能在安裝REDHAT系統(tǒng)時(shí)使用。
第一步:fdisk
[root@novice ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
[root@novice ~]# fdisk /dev/sdb
Command (m for help): #在輸入上面的命令后會(huì)出現(xiàn)左邊的提示,輸入m就會(huì)得到一個(gè)幫助菜單,如下:
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
#help雖然是英文的,可都很簡(jiǎn)單,在這里不再解釋。
#現(xiàn)在,我們正式開(kāi)始分區(qū)的操作:
Command (m for help): n #新建分區(qū)
Command action
e extended
p primary partition (1-4)
#e/p分別對(duì)應(yīng)擴(kuò)展分區(qū) /主分區(qū);我們先分四個(gè)主分區(qū),每個(gè)50M;然后再來(lái)增加主分區(qū)或擴(kuò)展分區(qū),看會(huì)出現(xiàn)怎樣的狀況,嘿嘿。
p #分區(qū)類(lèi)型為主分區(qū)
Partition number (1-4, default 1): 1 #分區(qū)號(hào),在這里我們依次選擇1、2、3、4
First sector (2048-496127, default 2048): #指定分區(qū)的起始扇區(qū),一般默認(rèn),按enter鍵即可。
Last sector, +sectors or +size{K,M,G} (2048-496127, default 496127): +50M #指定分區(qū)的終止扇區(qū),根據(jù)前面的提示我們可以做出相應(yīng)的選擇+sectors 或 +size{K,M,G}
Command (m for help): p #用p打印出已建好的分區(qū)列表
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
#剩下的三個(gè)分區(qū)的建立操作同上
#分好四個(gè)主分區(qū)后的情況如下
Command (m for help): p
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 309298 25+ 83 Linux
#已經(jīng)建好四個(gè)主分區(qū)啦,現(xiàn)在我們來(lái)看看如果再建主分區(qū)或是擴(kuò)展分區(qū)的話會(huì)出現(xiàn)怎樣的情況:
Command (m for help): n
You must delete some partition and add an extended partition first
??吹搅税?,不能再建分區(qū)啦!要再建分區(qū)的話必須刪除some分區(qū),再新建一個(gè)擴(kuò)展分區(qū)才行。
#現(xiàn)在,我們刪掉一個(gè)主分區(qū),來(lái)新建擴(kuò)展分區(qū)
Command (m for help): d #刪除分區(qū)
Partition number (1-4): 4 #選擇要?jiǎng)h除分區(qū)的分區(qū)號(hào),我們選第四個(gè)
Command (m for help): p #打印,如下,四個(gè)分區(qū)變成了三個(gè)!
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
#新建一個(gè)擴(kuò)展分區(qū)
#如果在沒(méi)有建滿(mǎn)三個(gè)主分的區(qū)的情況下建立擴(kuò)展分區(qū),相關(guān)選項(xiàng)會(huì)有些不同。
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First sector (309248-496127, default 309248): #enter,默認(rèn)
Using default value 309248
Last sector, +sectors or +size{K,M,G} (309248-496127, default 496127): #enter,默認(rèn),使用剩余空間
Using default value 496127
Command (m for help): p
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
#接下來(lái),我們?cè)谛陆ǖ臄U(kuò)展分區(qū)里再新建兩個(gè)邏輯分區(qū),因?yàn)橐呀?jīng)有了三個(gè)主分區(qū),這里不會(huì)再顯示是建立邏輯分區(qū)還是主分區(qū)的提示!
Command (m for help): n
First sector (311296-496127, default 311296): #enter
Using default value 311296
Last sector, +sectors or +size{K,M,G} (311296-496127, default 496127): +50M
Command (m for help): n
First sector (415744-496127, default 415744): #enter
Using default value 415744
Last sector, +sectors or +size{K,M,G} (415744-496127, default 496127): #enter
Using default value 496127
Command (m for help): p
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#上面的列表,就是我們今天分區(qū)的成果啦!接下來(lái)保存退出,重啟計(jì)算機(jī),就可以進(jìn)行下一步的mkfs操作啦!如果忘記了相關(guān)的操作命令,記得按m!!!
Command (m for help): w #保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
另:在建好分區(qū)后,我們還可以更改相關(guān)分區(qū)的文件系統(tǒng)類(lèi)型
#如,我們要把第二個(gè)主分區(qū)改成Linux下的交換分區(qū),操作如下
Command (m for help): t #更改文件系統(tǒng)類(lèi)型
Partition number (1-6): 2 #選擇第二個(gè)分區(qū)
Hex code (type L to list codes): L #選擇要更改的文件系統(tǒng)編碼,可以按L來(lái)查看相關(guān)編碼信息。
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
............
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 82 #查找到linux swap的編碼為82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p
..............
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 82 Linux swap / Solaris
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#最后別忘了保存!如果你須要的話!
#擴(kuò)展分區(qū)不能直接使用,邏輯分區(qū)只能建立在擴(kuò)展分區(qū)上!
第二步:mkfs(mkfs時(shí)分區(qū)的格式最好與fdisk設(shè)定的分區(qū)格式一致,不然.......)
mkfs支持ext2 ext3 vfa msdos jfs reiserfs等文件系統(tǒng)。
用法1:mkfs -t
例: mkfs -t ext3 /dev/sdb2
用法2:mkfs.
例:mkfs,vfat /dev/sdb3
mke2fs支持ext2/ext3文件系統(tǒng)
用法:mke2fs [-j]
例:mke2fs -j /dev/sdb5
# 更多更具體的用法請(qǐng)參照相關(guān)命令的man手冊(cè)
下面,接著實(shí)驗(yàn):
例一
[root@novice ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
12824 inodes, 51200 blocks
2560 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=52428800
7 block groups
8192 blocks per group, 8192 fragments per group
1832 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
第三部:掛載
掛載:mount
例:mount /dev/sdb1 /mnt /sdb1
卸載:umonut
例:umount /dev/sdb1
在linux系統(tǒng)中下面哪個(gè)命令可用來(lái)建立分區(qū)
Linux下常用的分區(qū)工具:
fdisk/sfdisk:命令行工具,各種版本和環(huán)境都能使用,包含在軟件包util-linux中
diskdruid:圖形化分區(qū)工具,只能在安裝REDHAT系統(tǒng)時(shí)使用。
第一步:fdisk
[root@novice ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
[root@novice ~]# fdisk /dev/sdb
Command (m for help): #在輸入上面的命令后會(huì)出現(xiàn)左邊的提示,輸入m就會(huì)得到一個(gè)幫助菜單,如下:
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
#help雖然是英文的,可都很簡(jiǎn)單,在這里不再解釋。
#現(xiàn)在,我們正式開(kāi)始分區(qū)的操作:
Command (m for help): n #新建分區(qū)
Command action
e extended
p primary partition (1-4)
#e/p分別對(duì)應(yīng)擴(kuò)展分區(qū) /主分區(qū);我們先分四個(gè)主分區(qū),每個(gè)50M;然后再來(lái)增加主分區(qū)或擴(kuò)展分區(qū),看會(huì)出現(xiàn)怎樣的狀況,嘿嘿。
p #分區(qū)類(lèi)型為主分區(qū)
Partition number (1-4, default 1): 1 #分區(qū)號(hào),在這里我們依次選擇1、2、3、4
First sector (2048-496127, default 2048): #指定分區(qū)的起始扇區(qū),一般默認(rèn),按enter鍵即可。
Last sector, +sectors or +size{K,M,G} (2048-496127, default 496127): +50M #指定分區(qū)的終止扇區(qū),根據(jù)前面的提示我們可以做出相應(yīng)的選擇+sectors 或 +size{K,M,G}
Command (m for help): p #用p打印出已建好的分區(qū)列表
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
#剩下的三個(gè)分區(qū)的建立操作同上
#分好四個(gè)主分區(qū)后的情況如下
Command (m for help): p
linux硬盤(pán)分區(qū)命令
1.返回到Linux系統(tǒng)的命令終端,再次輸入 fdisk -l 命令,就可以看到新添...
2.輸入fdisk /dev/sdb 開(kāi)始對(duì)新添加的硬盤(pán)進(jìn)行分區(qū)操作。
3.輸入n 按回車(chē)鍵,然后再輸入 p ,按回車(chē)鍵。 n 表示新建一個(gè)分區(qū),p ...
4.輸入Partition number(即:分區(qū)號(hào)),按回車(chē)鍵。如果在 /dev/sdb ...
5.等待分區(qū)創(chuàng)建完成,輸入 w 保存磁盤(pán)分區(qū),并退出磁盤(pán)分區(qū)命令。
Linux安裝基本命令
Linux安裝基本命令大全
Linux常用命令,你還能記得多少呢?下文是我為大家準(zhǔn)備的Linux常用命令,一起來(lái)看看吧!
安裝升級(jí)
查看軟件xxx安裝內(nèi)容
dpkg -L xxx
查找軟件庫(kù)中的軟件
apt-cache search 正則表達(dá)式
或
aptitude search 軟件包
顯示系統(tǒng)安裝包的統(tǒng)計(jì)信息
apt-cache stats
顯示系統(tǒng)全部可用包的名稱(chēng)
apt-cache pkgnames
顯示包的信息
apt-cache show k3b
查找文件屬于哪個(gè)包
dpkg -S filename
apt-file search filename
查看已經(jīng)安裝了哪些包
dpkg -l
也可用
dpkg -l | less
翻頁(yè)查看
查詢(xún)軟件xxx依賴(lài)哪些包
apt-cache depends xxx
查詢(xún)軟件xxx被哪些包依賴(lài)
apt-cache rdepends xxx
增加一個(gè)光盤(pán)源
sudo apt-cdrom add
系統(tǒng)更新
sudo apt-get update (這一步更新包列表)
sudo apt-get dist-upgrade (這一步安裝所有可用更新)
或者
sudo apt-get upgrade (這一步安裝應(yīng)用程序更新,不安裝新內(nèi)核等)
清除所有已刪除包的殘馀配置文件
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
如果報(bào)如下錯(cuò)誤,證明你的系統(tǒng)中沒(méi)有殘留配置文件了,無(wú)須擔(dān)心。
----------------------------------------------------------
dpkg: --purge needs at least one package name argument
Type dpkg --help for help about installing and deinstalling packages [*];
Use `dselect' or `aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Type dpkg --license for copyright license and lack of warranty (GNU GPL) [*].
Options marked [*] produce a lot of output - pipe it through `less' or `more' !
----------------------------------------------------------
編譯時(shí)缺少h文件的自動(dòng)處理
sudo auto-apt run ./configure
查看安裝軟件時(shí)下載包的臨時(shí)存放目錄
ls /var/cache/apt/archives
備份當(dāng)前系統(tǒng)安裝的所有包的列表
dpkg --get-selections | grep -v deinstall ~/somefile
從上面?zhèn)浞莸陌惭b包的列表文件恢復(fù)所有包
dpkg --set-selections ~/somefile
sudo dselect
清理舊版本的軟件緩存
sudo apt-get autoclean
清理所有軟件緩存
sudo apt-get clean
刪除系統(tǒng)不再使用的孤立軟件
sudo apt-get autoremove
如果使用
sudo apt-get autoremove --purge
的話會(huì)把這些孤立軟件的殘留配置文件也一并移除
查看包在服務(wù)器上面的地址
apt-get -qq --print-uris download 軟件包名稱(chēng) | cut -d\' -f2
徹底刪除Gnome
sudo apt-get --purge remove liborbit2
徹底刪除KDE
sudo apt-get --purge remove libqt3-mt libqtcore4
一鍵安裝 LAMP 服務(wù)
sudo tasksel install lamp-server
刪除舊內(nèi)核
sudo aptitude purge ~ilinux-image-.*\(\!\(`uname -r`\|generic-.*\)\)
導(dǎo)入ppa源的'key值
#W: GPG簽名驗(yàn)證錯(cuò)誤: jaunty Release: 由于沒(méi)有公鑰,下列簽名無(wú)法進(jìn)行驗(yàn)證: NO_PUBKEY 5126890CDCC7AFE0
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 5126890CDCC7AFE0 #5126890CDCC7AFE0替換為你需要導(dǎo)入的Key值
增加 add-apt-repository 命令
sudo apt-get install software-properties-common
增加一個(gè)ppa源
sudo add-apt-repository ppa:user/ppa-name
#使用 ppa 的地址替換 ppa:user/ppa-name
添加163鏡像源
sudo add-apt-repository "deb `lsb_release -cs` main restricted universe multiverse"
sudo add-apt-repository "deb `lsb_release -cs`-updates main restricted universe multiverse"
sudo add-apt-repository "deb `lsb_release -cs`-security main restricted universe multiverse"
系統(tǒng)升級(jí)
1 這里指的是版本間的升級(jí),例如 9.04=10.04。
2 使用該升級(jí)方式通常需要使用 backports 源。
sudo apt-get update
sudo apt-get install update-manager-core
sudo do-release-upgrade
系統(tǒng)
查看內(nèi)核
uname -a
查看系統(tǒng)是32位還是64位
#查看long的位數(shù),返回32或64
getconf LONG_BIT
#查看文件信息,包含32-bit就是32位,包含64-bit就是64位
file /sbin/init
或者使用
uname -m
查看Ubuntu版本
lsb_release -a
或 cat /etc/lsb-release
查看內(nèi)核加載的模塊
lsmod
查看PCI設(shè)備
lspci
查看USB設(shè)備
lsusb
#加參數(shù) -v 可以顯示USB設(shè)備的描述表(descriptors)
lsusb -v
查看網(wǎng)卡狀態(tài)
sudo apt-get install ethtool
sudo ethtool eth0
激活網(wǎng)卡的 Wake-on-LAN
sudo apt-get install wakeonlan
或 sudo ethtool -s eth0 wol g
查看CPU信息
cat /proc/cpuinfo
顯示當(dāng)前硬件信息
sudo lshw
查看內(nèi)存型號(hào)
sudo dmidecode -t memory
獲取CPU序列號(hào)或者主板序列號(hào)
#CPU ID
sudo dmidecode -t 4 | grep ID
#Serial Number
sudo dmidecode | grep Serial
#CPU
sudo dmidecode -t 4
#BIOS
sudo dmidecode -t 0
#主板:
sudo dmidecode -t 2
#OEM:
sudo dmidecode -t 11
顯示當(dāng)前內(nèi)存大小
free -m |grep "Mem" | awk '{print $2}'
查看硬盤(pán)溫度
sudo apt-get install hddtemp
sudo hddtemp /dev/sda
顯示系統(tǒng)運(yùn)行時(shí)間
uptime
查看系統(tǒng)限制
ulimit -a
查看內(nèi)核限制
ipcs -l
查看當(dāng)前屏幕分辨率
xrandr
硬盤(pán)
查看塊設(shè)備
lsblk
查看硬盤(pán)的分區(qū)
sudo fdisk -l
硬盤(pán)分區(qū)
#危險(xiǎn)!小心操作。
sudo fdisk /dev/sda
硬盤(pán)格式化
#危險(xiǎn)!將第一個(gè)分區(qū)格式化為 ext3 分區(qū), mkfs.reiserfs mkfs.xfs mkfs.vfat
sudo mkfs.ext3 /dev/sda1
硬盤(pán)檢查
#危險(xiǎn)!檢查第一個(gè)分區(qū),請(qǐng)不要檢查已經(jīng)掛載的分區(qū),否則容易丟失和損壞數(shù)據(jù)
sudo fsck /dev/sda1
硬盤(pán)壞道檢測(cè)
sudo badblocks -s -v -c 32 /dev/sdb
#得到壞的塊后,使用分區(qū)工具隔離壞道。
分區(qū)掛載
sudo mount -t 文件系統(tǒng)類(lèi)型 設(shè)備路經(jīng) 訪問(wèn)路經(jīng)
#常用文件類(lèi)型如下: iso9660 光驅(qū)文件系統(tǒng), vfat fat/fat32分區(qū), ntfs ntfs分區(qū), smbfs windows網(wǎng)絡(luò)共享目錄, reiserfs、ext3、xfs Linux分區(qū)
#如果中文名無(wú)法顯示嘗試在最後增加 -o nls=utf8 或 -o iocharset=utf8
#如果需要掛載後,普通用戶(hù)也可以使用,在 -o 的參數(shù)後面增加 ,umask=022 如:-o nls=utf8,umask=022
分區(qū)卸載
sudo umount 目錄名或設(shè)備名
只讀掛載ntfs分區(qū)
sudo mount -t ntfs -o nls=utf8,umask=0 /dev/sdb1 /mnt/c
可寫(xiě)掛載ntfs分區(qū)
sudo mount -t ntfs-3g -o locale=zh_CN.utf8,umask=0 /dev/sdb1 /mnt/c
掛載fat32分區(qū)
sudo mount -t vfat -o iocharset=utf8,umask=0 /dev/sda1 /mnt/c
掛載共享文件
sudo mount -t smbfs -o username=xxx,password=xxx,iocharset=utf8 //192.168.1.1/share /mnt/share
掛載ISO文件
sudo mount -t iso9660 -o loop,utf8 xxx.iso /mnt/iso
查看IDE硬盤(pán)信息
sudo hdparm -i /dev/sda
查看軟raid陣列信息
cat /proc/mdstat
參看硬raid陣列信息
dmesg |grep -i raid
cat /proc/scsi/scsi
查看SATA硬盤(pán)信息
sudo hdparm -I /dev/sda
或
sudo apt-get install blktool
sudo blktool /dev/sda id
查看硬盤(pán)剩余空間
df
df --help 顯示幫助
查看目錄占用空間
du -hs 目錄名
閃盤(pán)沒(méi)法卸載
sync
fuser -km /media/閃盤(pán)卷標(biāo)
使用文件來(lái)增加交換空間
#創(chuàng)建一個(gè)512M的交換文件 /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=512
sudo mkswap /swapfile
sudo swapon /swapfile
#sudo vim /etc/fstab #加到fstab文件中讓系統(tǒng)引導(dǎo)時(shí)自動(dòng)啟動(dòng)
/swapfile swap swap defaults 0 0
查看硬盤(pán)當(dāng)前讀寫(xiě)情況
# 首先安裝 sysstat 包
sudo apt-get install sysstat
#每2秒刷新一次
sudo iostat -x 2
測(cè)試硬盤(pán)的實(shí)際寫(xiě)入速度
dd if=/dev/zero of=test bs=64k count=512 oflag=dsync
進(jìn)程
查看當(dāng)前的內(nèi)存使用情況
free
連續(xù)監(jiān)視內(nèi)存使用情況
watch -d free
# 使用 Ctrl + c 退出
動(dòng)態(tài)顯示進(jìn)程執(zhí)行情況
top
top指令運(yùn)行時(shí)輸入H或?打開(kāi)幫助窗口,輸入Q退出指令。
查看當(dāng)前有哪些進(jìn)程
ps -AFL
查看進(jìn)程的啟動(dòng)時(shí)間
ps -A -opid,stime,etime,args
查看目前登入用戶(hù)運(yùn)行的程序
w
查看當(dāng)前用戶(hù)程序?qū)嶋H內(nèi)存占用,并排序
ps -u $USER -o pid,rss,cmd --sort -rss
統(tǒng)計(jì)程序的內(nèi)存耗用
ps -eo fname,rss|awk '{arr[$1]+=$2} END {for (i in arr) {print i,arr[i]}}'|sort -k2 -nr
按內(nèi)存從大到小排列進(jìn)程
ps -eo "%C : %p : %z : %a"|sort -k5 -nr
列出前十個(gè)最耗內(nèi)存的進(jìn)程
ps aux | sort -nk +4 | tail
按cpu利用率從大到小排列進(jìn)程
ps -eo "%C : %p : %z : %a"|sort -nr
ps aux --sort -pcpu |head -n 20
查看當(dāng)前進(jìn)程樹(shù)
pstree
中止一個(gè)進(jìn)程
kill 進(jìn)程號(hào)(就是ps -A中的第一列的數(shù)字)
或者 killall 進(jìn)程名
強(qiáng)制中止一個(gè)進(jìn)程(在上面進(jìn)程中止不成功的時(shí)候使用)
kill -9 進(jìn)程號(hào)
或者 killall -9 進(jìn)程名
圖形方式中止一個(gè)程序
xkill 出現(xiàn)骷髏標(biāo)志的鼠標(biāo),點(diǎn)擊需要中止的程序即可
查看進(jìn)程打開(kāi)的文件
lsof -p 進(jìn)程的pid
顯示開(kāi)啟文件abc.txt的進(jìn)程
lsof abc.txt
顯示22端口現(xiàn)在運(yùn)行什么程序
lsof -i :22
顯示nsd進(jìn)程現(xiàn)在打開(kāi)的文件
lsof -c nsd
在後臺(tái)運(yùn)行程序,退出登錄後,并不結(jié)束程序
nohup 程序
#查看中間運(yùn)行情況 tail nohup
在后臺(tái)運(yùn)行交互式程序,退出登錄后,并不結(jié)束程序
sudo apt-get install screen
screen vim a.txt
#直接退出后使用
screen -ls # 2208pxs-0.ubuntu (Detached)
screen -r 1656 #恢復(fù)
#熱鍵,同時(shí)按下Ctrl和a鍵結(jié)束后,再按下功能鍵
C-a ? #顯示所有鍵綁定信息
C-a w #顯示所有窗口列表
C-a C-a #切換到之前顯示的窗口
C-a c #創(chuàng)建一個(gè)新的運(yùn)行shell的窗口并切換到該窗口
C-a n #切換到下一個(gè)窗口
C-a p #切換到前一個(gè)窗口(與C-a n相對(duì))
C-a 0..9 #切換到窗口0..9
C-a a #發(fā)送 C-a到當(dāng)前窗口
C-a d #暫時(shí)斷開(kāi)screen會(huì)話
C-a k #殺掉當(dāng)前窗口
在后臺(tái)運(yùn)行交互式程序,退出登錄后,并不結(jié)束程序
tmux 進(jìn)入后再運(yùn)行其它命令
tmux attach #恢復(fù)
#熱鍵,同時(shí)按下Ctrl和b鍵結(jié)束后,再按下功能鍵
C-b c #創(chuàng)建一個(gè)新的運(yùn)行shell的窗口并切換到該窗口
C-b n #切換到下一個(gè)窗口
C-b p #切換到前一個(gè)窗口(與C-a n相對(duì))
C-b 0..9 #切換到窗口0..9
C-b d #暫時(shí)斷開(kāi)會(huì)話
C-b #殺掉當(dāng)前窗口
詳細(xì)顯示程序的運(yùn)行信息
strace -f -F -o outfile
增加系統(tǒng)最大打開(kāi)文件個(gè)數(shù)
#ulimit -SHn
sudo vim /etc/security/limits.conf
文件尾追加
* hard nofile 4096
* soft nofile 4096
sudo vim /etc/pam.d/su
將 pam_limits.so 這一行注釋去掉
重起系統(tǒng)
清除僵尸進(jìn)程
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | xargs sudo kill -9
將大于120M內(nèi)存的php-cgi都?xì)⒌?/p>
ps -eo pid,fname,rss|grep php-cgi|grep -v grep|awk '{if($3=120000) print $1}' | xargs sudo kill -9
Linux系統(tǒng)中如何限制用戶(hù)進(jìn)程CPU占用率
renice +10 `ps aux | awk '{ if ($3 0.8 id -u $1 500) print $2}'`
#或直接編輯/etc/security/limits.conf文件。 ;
linux磁盤(pán)分區(qū)命令是什么
Linux磁盤(pán)分區(qū)命令中有專(zhuān)門(mén)的分區(qū)命令fdisk和parted。其中fdisk命令較為常用,但不支持大于2TB的分區(qū);如果需要支持大于2TB的分區(qū),則需要使用parted命令,當(dāng)然parted命令也能分配較小的分區(qū)。
分享文章:linux安裝分區(qū)命令 linux安裝分區(qū)詳解
文章網(wǎng)址:http://www.dlmjj.cn/article/hpejch.html