1.用vmware添加一塊10G的硬碟,且永久掛載到/data01中,寫出詳細的步驟 2.用自己語言描述raid0和raid1的區別 RAID 0: 將兩個或以上相同信號,容量的硬碟組合,磁碟陣列的總容量是多個硬碟的總和,數據依次寫 入物理磁碟,理想狀態下,硬碟讀寫性能會翻倍。但只要壞一塊磁碟,所有 ...
1.用vmware添加一塊10G的硬碟,且永久掛載到/data01中,寫出詳細的步驟
2.用自己語言描述raid0和raid1的區別
RAID 0:
將兩個或以上相同信號,容量的硬碟組合,磁碟陣列的總容量是多個硬碟的總和,數據依次寫
入物理磁碟,理想狀態下,硬碟讀寫性能會翻倍。但只要壞一塊磁碟,所有數據都會損壞
優點:速度快
缺點:冗餘差
RAID 1:
RAID 1 技術,是將兩塊以上硬碟綁定,數據寫入時,同時寫入多個硬碟,因此即使有硬碟故障,也有數據備份。
優點:冗餘性好
缺點:浪費資源
3.sed刪除文件的空白和註釋行
[root@vm-main luffty]# cat test.txt
I am oldboy teacher
I teach linux.
\#I like python.
My qq is 877348180.
My name is chaoge.
\#My website is http://pythonav.cn
[root@vm-main luffty]# cat test.txt | sed '/^$/d' | sed '/^#/d'
I am oldboy teacher
I teach linux.
My qq is 877348180.
My name is chaoge.
[root@vm-main luffty]# sed -e '/^$/d' -e '/^#/d' test.txt
I am oldboy teacher
I teach linux.
My qq is 877348180.
My name is chaoge.
4.使用awk刪除文件chaoge.txt空白行
[root@vm-main luffty]# cat test.txt | awk '!/^$/{print $0}'
I am oldboy teacher
I teach linux.
\#I like python.
My qq is 877348180.
My name is chaoge.
\#My website is http://pythonav.cn
5.把命令echo "I am oldboy" 的結果寫入"黑洞文件中",且命令的標準錯誤輸出,也當做標準輸出處理
echo "I am oldboy" > /dev/null 2>&1
6.利用{}符號備份/etc/hosts文件
[root@vm-main luffty]# cp /etc/hosts{,.bak}
[root@vm-main luffty]# ll /etc/ | grep hosts
-rw-r--r--. 1 root root 158 Jun 7 2013 hosts
-rw-r--r--. 1 root root 370 Jun 7 2013 hosts.allow
-rw-r--r-- 1 root root 158 Sep 28 04:26 hosts.bak
-rw-r--r--. 1 root root 460 Jun 7 2013 hosts.deny
[root@vm-main luffty]#
7.過濾掉文件chaoge.txt的註釋和空白行
[root@vm-main luffty]# cat test.txt | grep -Ev '(^$|^#)'
I am oldboy teacher
I teach linux.
My qq is 877348180.
My name is chaoge.
[root@vm-main luffty]# cat test.txt | grep -v '^$' | grep -v '^#'
I am oldboy teacher
I teach linux.
My qq is 877348180.
My name is chaoge.
8. 找出除了小寫字母以外的字元,文本如下chaoge.txt
I am oldboy teacher
I teach linux.
I like python.
My qq is 877348180.
My name is chaoge.
My website is http://pythonav.cn
[root@huahua-centos7-aliyun luffy]# cat a.txt | sed 's/[a-z]//g'
I
I .
I .
M 877348180.
M .
M ://.
[root@huahua-centos7-aliyun luffy]# cat a.txt | grep -Eo '[^a-z]'
9.使用sed輸出文件chaoge.txt的2-5行內容
[root@vm-main luffty]# cat -n chaoge.txt | sed -n '2,5p'
2 I teach linux.
3 I like python.
4 My qq is 877348180.
5 My name is chaoge.
10.使用sed刪除含有game字元的行,chaoge.txt
[root@vm-main luffty]# cat chaoge.txt
I am oldboy teacher
I teach linux.
I like python.
My qq is 877348180.
My name is chaoge.
My website is http://pythonav.cn
I like play game
[root@vm-main luffty]# cat chaoge.txt | sed '/game/d'
I am oldboy teacher
I teach linux.
I like python.
My qq is 877348180.
My name is chaoge.
My website is http://pythonav.cn
11.使用sed替換文件chaoge.txt中,替換所有My為His,同時換掉QQ號為8888888
My name is chaoge.
I teach linux.
I like play computer game.
My qq is 877348180.
My website is http://pythonav.cn.
[root@vm-main luffty]# cat chaoge.txt2 | sed -e 's/My/His/g' -e 's/877348180/8888888/'
His name is chaoge.
I teach linux.
I like play computer game.
His qq is 8888888.
His website is http://pythonav.cn.
[root@vm-main luffty]#
12.用sed取出ip地址
[root@vm-main luffty]# ifconfig ens33 | sed -n '2p' | sed -n 's/^.*inet//p' | sed -n 's/netmask.*$//p'
192.168.58.130
13.用awk顯示/etc/passwd文件的第一列,倒數第二列,以冒號分割。
[root@vm-main luffty]# cat /etc/passwd | awk -F ":" '{print $1":"$(NF-1)}'
root:/root
bin:/bin
daemon:/sbin
adm:/var/adm
lp:/var/spool/lpd
sync:/sbin
shutdown:/sbin
halt:/sbin
mail:/var/spool/mail
operator:/root
games:/usr/games
ftp:/var/ftp
nobody:/
systemd-network:/
dbus:/
polkitd:/
postfix:/var/spool/postfix
sshd:/var/empty/sshd
test:/home/test
abrt:/etc/abrt
saslauth:/run/saslauthd
pcp:/var/lib/pcp
mailnull:/var/spool/mqueue
smmsp:/var/spool/mqueue
apache:/usr/share/httpd
tss:/dev/null
mailman:/usr/lib/mailman
[root@vm-main luffty]# cat /etc/passwd | awk -v OFS=":" -F ":" '{print $1,$(NF-1)}'
root:/root
bin:/bin
daemon:/sbin
adm:/var/adm
lp:/var/spool/lpd
sync:/sbin
shutdown:/sbin
halt:/sbin
mail:/var/spool/mail
operator:/root
games:/usr/games
ftp:/var/ftp
nobody:/
systemd-network:/
dbus:/
polkitd:/
postfix:/var/spool/postfix
sshd:/var/empty/sshd
test:/home/test
abrt:/etc/abrt
saslauth:/run/saslauthd
pcp:/var/lib/pcp
mailnull:/var/spool/mqueue
smmsp:/var/spool/mqueue
apache:/usr/share/httpd
tss:/dev/null
mailman:/usr/lib/mailman
14.用awk取出ip地址
[root@vm-main luffty]# ifconfig ens33 | awk 'NR==2 {print $2}'
192.168.58.130
15.用awk找出/etc/passwd文件中禁止登錄的用戶
[root@vm-main luffty]# cat /etc/passwd | awk -F ":" '$NF=="/sbin/nologin"{print $1}'
bin
daemon
adm
lp
mail
operator
games
ftp
nobody
systemd-network
dbus
polkitd
postfix
sshd
abrt
saslauth
pcp
mailnull
smmsp
apache
tss
mailman