linux

1.以TEST用戶登錄到系統(tǒng)中, 顯示當(dāng)前系統(tǒng)時(shí)間,并將系統(tǒng)時(shí)間修改為 2017年11月11日零點(diǎn)。

  • date
  • date -s 2017/11/11
  • date -s 00:00:00
    2.使用cat命令在用戶主目錄下創(chuàng)建一個(gè)名為file1的文本文件,內(nèi)容為:
    Hello,how are you?
    I’m fine,thank you ,and you?
    Me too.
  • cat > file1.txt

Hello,how are you?
I’m fine,thank you ,and you?
Me too.

ctrl+z保存

  • wc < file1.txt >counter.txtx
    3.使用cat命令在用戶主目錄下創(chuàng)建一個(gè)名為hello.txt的文本文件,內(nèi)容為:
    Hello,my name is WANG Lin
    What’s you name?
    并將文件的內(nèi)容顯示到屏幕上。
  • cat > hello.txt

Hello,my name is WANG Lin
What’s you name?
cat <hello.txt

  1. 利用touch命令,在當(dāng)前目錄下創(chuàng)建一個(gè)新的空文件newfile. 然后給newfile文件輸入內(nèi)容,內(nèi)容為自己的“班級(jí)+學(xué)號(hào)+姓名”。
  • touch newfile

班級(jí)+學(xué)號(hào)+姓名

5.顯示當(dāng)前的工作目錄,在當(dāng)前目錄下創(chuàng)建文件test1,使用輸入重定向,把/etc/profile文件的內(nèi)容發(fā)送到test1中。

  • touch test1
  • cat /etc/profile > test1

6.首先顯示/bin/目錄中所有以a為首字母,文件名只有2個(gè)字符的文件和目錄。然后在顯示“/bin/”目錄中所有首字母為c或s或h的文件和目錄。

  • cd /bin/
  • ls | grep -E "^a.{1}"
  • ls |grep -E "c|s|^h"

7.首先顯示/bin/目錄中所有名字以a為首字母的文件和目錄。然后在顯示“/bin/”目錄中所有首字母為s或h的文件和目錄。

  • ls /bin/ |grep -E "^a"
  • ls /bin/ |grep -E "s|h"
  1. 復(fù)制文件系統(tǒng)/etc/profile到當(dāng)前目錄下,并顯示profile文件前6行信息。
    • cp /etc/profile ~
    • more -6 profile
      9.當(dāng)前用戶目錄下創(chuàng)建test目錄,將/etc/profile文件復(fù)制到test目錄中,用grpe命令在profile文件中對(duì)關(guān)鍵字then 進(jìn)行查詢。
  • mkdir test
  • cp /etc/profile test/
  • grep then profile

10.當(dāng)前目錄下建立目錄CC,并復(fù)制文件系統(tǒng)/etc/profile文件到CC目錄中,并顯示profile文件后6行信息。

  • mkdir CC
  • cp /etc/profile CC/
    -tail -6 profile

11.顯示當(dāng)前的工作目錄,并將當(dāng)前工作目錄切換到CC,用grpe命令在profile文件中對(duì)關(guān)鍵字if進(jìn)行查詢。

  • pwd
  • cd test/CC
  • grep if profile

12.當(dāng)前目錄下建立目錄BB,將test1文件復(fù)制到BB目錄中,并在BB中建立test1的副本文件名為test1.bak并分屏顯示test1.bak文件的內(nèi)容

  • cp test1 /test/CC/BB
  • cd /test/CC/BB
  • cp test1 test1.bak
  • more test1.bak

13.在test目錄下創(chuàng)建空文件file1,對(duì)文件file1設(shè)置權(quán)限,使其他用戶可以對(duì)此文件進(jìn)行讀寫操作,并查看設(shè)置效果。

  • touch file1
  • chmod o+rw file1
  • ls -al

14.在BB目錄下創(chuàng)建空文件newfile1,,用數(shù)字形式更改文件newfile1的權(quán)限,使所有者只能讀取此文件,其他任何用戶都沒(méi)有使用權(quán)限。

  • touch newfile1
  • chmod 400 file1

15.在CC目錄下創(chuàng)建空文件newfile1,對(duì)文件newfile1設(shè)置權(quán)限,使文件主具有可讀、可寫和執(zhí)行權(quán)限,其它用戶具有讀寫權(quán)限,并查看設(shè)置效果。

  • touch newfile1
  • chmod 706 newfile1
    -ls -al

16.把目錄test進(jìn)行打包壓縮,打包后文件名為test.tar.gz。

  • tar -czvf test.tar.gz test

17.新建用戶user1,UID為510,指定其所屬私有組為mlx組(mlx的標(biāo)識(shí)符為505),用戶的主目錄為/home/user1,用戶的shell為/bin/bash,賬戶永不過(guò)期。

  • su
  • groupadd -g 505 mlx
  • useradd -u 510 -g mlx -d /home/user1 -s /bin/bash -f 0 user1
  1. 新建一個(gè)名為student的用戶,創(chuàng)建一個(gè)名為ftpusers的用戶組,然后將student用戶添加到ftpusers用戶組中。
  • su
  • useradd student
  • gpasswd ftpusers
  • gpasswd -a student ftpusers

19.新建用戶newuser,UID為620,用戶的主目錄為/home/newuser,用戶的shell為/bin/bash,賬戶永不過(guò)期,設(shè)置密碼為123456。

  • useradd -u 620 -d /home/newuser -s /bin/bash -f 0 -p 123456 newuser

20.新建用戶user1,設(shè)置user1用戶的最短口令存活期為6天,最長(zhǎng)口令存活期為60天,口令到期前3天提醒用戶修改口令,設(shè)置完成后查看各屬性值。

  • useradd user1
  • chage -m 6 -M 60 -W 3 user1

21.創(chuàng)建組group1和group2,將user1的附屬組設(shè)置為group1和group2。

  • groupadd group1
  • groupadd group2
  • gpasswd -a user1 group1
  • gpasswd -a user1 group2

22.新建一個(gè)名為newgroup的用戶組,然后將newuser用戶添加到newgroup用戶組中。

  • groupadd newgroup
  • gpasswd -a newuser newgroup

23.顯示文件test1所占用的磁盤空間,并顯示當(dāng)前內(nèi)存的使用情況。

  • du -h test1
  • free -m
  1. 以人類習(xí)慣的方式顯示目錄/root、目錄/home和目錄/boot總的使用量。
  • df -h /root /home /boot

25.顯示目錄/root和目錄/boot總的使用量。

  • df /root /boot

26.顯示磁盤分區(qū)信息和CPU信息。

  • dmesg |grep -i cpu
  • dmesg |grep -i sda

27.顯示當(dāng)前計(jì)算機(jī)和操作系統(tǒng)的詳細(xì)信息,并獲取當(dāng)前主機(jī)的運(yùn)行時(shí)間和操作系統(tǒng)的負(fù)載信息。

  • uname -a
  • uptime
  1. 設(shè)置at調(diào)度,要求在當(dāng)前時(shí)間后的10分鐘后,將信息 “hello world” 追加到/home/test/newfile 文件中。
  • at now+10 minutes

echo "hello world" > /home/test/newfile

  1. 設(shè)置crontab文件,名為test.sh
    文件要求如下:
     (1)每個(gè)整點(diǎn)都輸出信息“runs at the top of every hour”
    (2)每天早上1點(diǎn),2點(diǎn)整時(shí)輸出信息“runs at the 1am and 2am”
    (3) 每月的1號(hào)早上2:15輸出信息“runs at 2:15 am on the 1st of the month”
    設(shè)置at調(diào)度,要求在2017年的6月20日的17:00向系統(tǒng)上所有的用戶發(fā)送”happy day !”信息。
  • crontab -e
  • */1 * * * echo "runs at the top of every hour"


at 17:00 2017-6-20

wall "hello world"

  1. 設(shè)置crontab文件,名為crontab1.sh
    文件要求如下:
     (1)每周星期1-5的下午5:15分輸出信息“happy every day”
    (2)新年到來(lái)時(shí)輸出“happy new year”
    (3)雙號(hào)早晨6點(diǎn)鐘輸出信息“runs at 6am on even-numbered days”答:
    設(shè)置at調(diào)度,在當(dāng)前時(shí)間之后五分鐘,使使系統(tǒng)自動(dòng)關(guān)閉

at now+5 minutes
shutdown -h

31.有一普通用戶想在每周日凌晨零點(diǎn)零分定期備份/user/backup到/tmp目錄下,該用戶應(yīng)如何做?

  • 采用計(jì)劃任務(wù)來(lái)做
  • crontab -e

0 12 7 * * tar -cvf /tmp/temp /user/backup

32.啟動(dòng)samba服務(wù),如果啟動(dòng)不了,安裝samba-3.5.10-125.el6.x86_64

  • yum install samba-3.5.10-125.el6.x86_64
  • 需要配置相關(guān)的選項(xiàng)的

33.查詢當(dāng)前系統(tǒng)是否安裝telnet-server服務(wù)器軟件包,若未安裝,則進(jìn)行安裝,然后測(cè)試telnet-server軟件包是否安裝成功。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容