1、軟硬鏈接區別
硬鏈接:1.硬鏈接指定是一個節點所指定的文件數量,因此,多個文件可以使用一個節點,但不能使用多個節點。
2.硬鏈接在刪除的時候必須刪除硬鏈接爲0、並且原有的節點號被其他文件佔有並覆蓋之後才能算徹底刪除文件。
軟鏈接:1.軟鏈接可以擁有多個節點來指向一個文件,
2.軟鏈接在刪除的時候不用關心硬鏈接數是否爲0 ,只要軟鏈接所指向的實際文件不存在,當前的軟鏈接即失效。
軟硬鏈接詳解:http://xxlii.blog.51cto.com/10277731/1832094
全部練習詳解:http://xxlii.blog.51cto.com/
2、file1文件的內容爲:”1 2 3 4 5 6 7 8 9 10” 計算出所有數字的總和
答案:
1.[root@localhost /]# echo "1+2+3+4+5+6+7+8+9+10" > file1 | cat file1 | bc 55 2.[root@localhost l1]# echo '1 2 3 4 5 6 7 8 9 10' | tee file1 | tr ' ' '+' | bc 55
3、處理字符串“xt.,l 1 jr#!$mn2 c*/fe3 uz4”,只保留其中的數字和空格
[root@localhost /]# echo 'xt.,l 1 jr#!$mn2 c*/fe3 uz4' | tr -d '[[:alpha:]]' | tr -d '[[: punct:]]' 1 2 3 4
4、將PATH變量每個目錄顯示在獨立的一行
[root@localhost /]# echo $PATH | tr ':' '\n' /usr/lib64/qt-3.3/bin /usr/local/sbin /usr/local/bin /sbin /bin /usr/sbin /usr/bin /root/bin
5、刪除指定文件的空行
[root@localhost /]# echo "a b c d e f g h j k l m " > file2.txt | cat file2.txt | tr -d ' '
abcdefghjklm
6、將文件中每個單詞(字母)顯示在獨立的一行,並無空行
[root@localhost /]# echo "aa bb cat default echo finger group hello jack k l" > file2.txt | tr ' ' '\n' < file2.txt
aa
bb
cat
default
echo
finger
group
hello
jack
k
l
7、創建用戶gentoo,附加組爲bin和root,默認shell爲/bin/csh,註釋信息爲"Gentoo Distribution"
[root@localhost /]# useradd -G bin,root -s /bin/csh -c "Gentoo Distribution"
8、創建下面的用戶、組和組成員關係
名字爲admins 的組
用戶natasha,使用admins 作爲附屬組
用戶harry,也使用admins 作爲附屬組
用戶sarah,不可交互登錄系統,且不是admins 的成員,natasha,harry,sarah密碼都是centos
groupadd admins;useradd -G admins natasha;echo "centos" | passwd --stdin natasha;useradd -G admins harry;echo "centos" | passwd --stdin natasha;useradd -s /bin/nologin sarah;echo "centos" | passwd --stdin sarah