Linux基本操作【作业】
1.如何使用命令立即重啟linux操作系統(tǒng)?
sudo reboot
2.如何查看/etc下的所有文件,并以列表格式顯示,并且顯示隱藏文件
cd /etc | ls -la
3.一次性創(chuàng)建 text/1/2/3/4
cd tmp
mkdir -p text/1/2/3/4
(1)在子目錄4下創(chuàng)建一個新文件1.txt,1.txt內(nèi)容是/etc目錄下文件的列表
touch text/1/2/3/4/1.txt
ls /etc >text/1/2/3/4/1.txt
(2) 在子目錄3下創(chuàng)建一個文件2.txt,文件的內(nèi)容是/etc/passwd文件內(nèi)容的第一列sudo /etc/passwd
cat /etc/passwd | awk -F ':' '{print $1}' > text/1/2/3/2.txt
(3) 將1.txt和2.txt內(nèi)容合并到新文件3.txt,3.txt在目錄2下cat text/1/2/3/2.txt >>text/1/2/3/4/1.txt >text/1/2/3.txt
(4) 刪除目錄3及其子目錄。rm -r text/1/2/3
(5) 將3.txt改名為4.txtmv text/1/2/3.txt text/1/2/4.txt
4.查找/etc下所有t開頭的普通文件,并且大小大于1m,小于100m,將結(jié)果保存到家目錄下d1.txt中
sudo find /etc -name 't*' -size +10k -size -100k >~/d1.txt
5.在家目錄及其子目錄下查找文件內(nèi)容包含hello的文件,只顯示找到的文件名
grep -r -l -w 'hello'
6.如何查看passwd文件中前三行和后三行
head -3 /etc/passwd
tail -3 /etc/passwd
7.統(tǒng)計當(dāng)前系統(tǒng)中一共有多少賬戶
who | wc -l
8.設(shè)置/test/a.txt屬主有讀寫執(zhí)行權(quán)限,屬組,有讀寫,其他賬戶無權(quán)限,用三種方式實現(xiàn)。
chmod u=rwx,g=rw-,o=--- /text/a.txt 修改的方式
chmod 760 /text/a.txt
chmod u+rwx,g+rw,o-rwx /text/a.txt 修改的方式
9.把/tmp/etc/man.conf移動到/tmp下并改名為test.conf設(shè)置所有人都有讀寫執(zhí)行權(quán)限
chmod 777 /tmp/etc/man.conf | mv /tmp/etc/man.conf ./text.conf
10.添加賬戶u2,為其指定id號為1000
sudo useradd -u 1000 u2
11.如何查看u2的uid gid
id u2
12.在/temp目錄下建立test目錄,把/etc下所有已t開頭的文件和目錄考本到test目錄下
find /etc -name 't*' -exec cp {} \;>/temp/test
?
13.新建用戶python,并讓python具有登錄權(quán)限,設(shè)置其用戶家目錄為/home/test, 并將其加入sudo附屬組;設(shè)置其登錄密碼為123
sudo useradd -md /home/test -a -G sudo python
sudo passwd python
123
14.在/home目錄下創(chuàng)建文件newfile2 ,移動文件newfile2到/home/perm目錄下同時改名為file01 ;改變/home/perm/file01文件的所有者為系統(tǒng)用戶adm ,改變其所屬組為系統(tǒng)用戶組games ;改變/home/perm/file01文件權(quán)限為“rwxrw-r—”;在/home/perm目錄下,分別給file01生成一個軟鏈接文件file01.soft和一個硬鏈接文件file01.hard ;刪除/perm目錄.
sudo touch /home/newfile2 |mv /home/newfile2 /home/perm/file01
sudo chown adm :games /home/perm/file01
sudo chmod u=rwx,g=rw-,o=r-- /home/perm/file01
cd /home/perm
ln -s fileo1 file01.soft
ln fileo1 file01.hard
sudo rm -r /perm
15.統(tǒng)計當(dāng)前目錄/home/zheng下普通文件的數(shù)目
ls /home/zheng |grep -c -E '^-'
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的Linux基本操作【作业】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5y计算机应用2010综合测评答案,计算
- 下一篇: python中自动化办公 【笔记】