N26-第四周

1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其他用戶均沒有任何訪問權限。
[root@localhost home]# cp -R /etc/skel/ /home/tuser1 && chmod -R g=,o= /home/tuser1 
[root@localhost home]# ll -d /home/tuser1/
drwx——. 2 root root 59 3月   7 20:30 /home/tuser1/
[root@localhost tuser1]# ll -a
總用量 16
drwx——.  2 root root   59 3月   7 20:30 .
drwxr-xr-x. 15 root root 4096 3月   7 20:30 ..
-rw——-.  1 root root   18 3月   7 20:30 .bash_logout
-rw——-.  1 root root  193 3月   7 20:30 .bash_profile
-rw——-.  1 root root  231 3月   7 20:30 .bashrc

2、編輯/etc/group文件,添加組hadoop。
[root@localhost tuser1]# echo ‘hadoop:x:5005:’ >> /etc/group
[root@localhost tuser1]# tail -2 /etc/group
admins:x:5004:slackware
hadoop:x:5005:

3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的id號,其家目錄為/home/hadoop。
[root@localhost tuser1]# vim /etc/passwd
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016::/home/slackware:/bin/tcsh
hadoop:x:5005:5005::/home/hadoop:/bin/bash
[root@localhost tuser1]# tail -1 /etc/passwd
hadoop:x:5005:5005::/home/hadoop:/bin/bash

4、復制/etc/skel目錄為/home/hadoop,要求修改hadoop目錄的屬組和其他用戶沒有任何訪問權限。
[root@localhost tuser1]# cp -R /etc/skel/ /home/hadoop && chmod g=,o= /home/hadoop
[root@localhost tuser1]# ll -d /home/hadoop/
drwx——. 2 root root 59 3月   7 20:51 /home/hadoop/

5、修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop。
[root@localhost tuser1]# cd ..
[root@localhost home]# chown -R hadoop:hadoop /home/hadoop/
[root@localhost home]# ll -d /home/hadoop/
drwx——. 2 hadoop hadoop 59 3月   7 20:51 /home/hadoop/

6、顯示/proc/meminfo文件中以大寫或小寫S開頭的行,用兩種方式。
[root@localhost home]# grep  ‘^[sS]’ /proc/meminfo   
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              6868 kB
Slab:              56628 kB
SReclaimable:      21584 kB
SUnreclaim:        35044 kB  
[root@localhost home]# grep -v ‘^[^sS]’ /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              6868 kB
Slab:              56644 kB
SReclaimable:      21584 kB
SUnreclaim:        35060 kB
7、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶。
[root@localhost home]# grep -v ‘/sbin/nologin$’ /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
gentoo:x:4001:5002::/var/tmp/gentoo:/bin/bash
fedora:x:4002:4002:Fedora Core:/home/fedora:/bin/tcsh
abc:x:4003:4003::/home/abc:/bin/bash
centos:x:4004:4004::/home/centos:/bin/bash
user1:x:4005:4005::/home/user1:/bin/bash
bash:x:4006:4006::/home/bash:/bin/bash
testbash:x:4007:4007::/home/testbash:/bin/bash
basher:x:4008:4008::/home/basher:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016::/home/slackware:/bin/tcsh
hadoop:x:5005:5005::/home/hadoop:/bin/bash

8、顯示/etc/passwd文件中其默認shell為/bin/bash的用戶。
[root@localhost home]# grep ‘/bin/bash$’ /etc/passwd
root:x:0:0:root:/root:/bin/bash
gentoo:x:4001:5002::/var/tmp/gentoo:/bin/bash
abc:x:4003:4003::/home/abc:/bin/bash
centos:x:4004:4004::/home/centos:/bin/bash
user1:x:4005:4005::/home/user1:/bin/bash
bash:x:4006:4006::/home/bash:/bin/bash
testbash:x:4007:4007::/home/testbash:/bin/bash
basher:x:4008:4008::/home/basher:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
hadoop:x:5005:5005::/home/hadoop:/bin/bash

9、找出/etc/passwd文件中的一位或兩位數。
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
[root@localhost home]# grep ‘\<[[:digit:]]{1,2}\>’ /etc/passwd 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行。
[root@localhost home]# grep ‘^[[:space:]]+’ /boot/grub2/grub.cfg 
 load_env
  set default=”${next_entry}”
  set next_entry=
  save_env next_entry
  set boot_once=true
  set default=”${saved_entry}”

11、顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行。
[root@localhost home]# grep ‘^#[[:space:]]+.*[^[:space:]]+’ /etc/rc.d/rc.local 

THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

It is highly advisable to create own systemd services or udev rules

to run scripts during boot instead of using this file.

In contrast to previous versions due to parallel execution during boot

this script will NOT be run after all other services.

Please note that you must run ‘chmod +x /etc/rc.d/rc.local’ to ensure

that this script will be executed during boot.

12、打出netstat -tan命令執行結果中,以‘LISTEN’,后跟空白字符結尾的行。
[root@localhost home]# netstat -tan | grep ‘LISTEN[[:space:]]\>’ 
tcp        0      0 0.0.0.0:22              0.0.0.0:
              LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN  
   
13、添加用戶bash,testbash,basher,nologin(此一個用戶的shell為/sbin/nologin),而后找出當前系統上其用戶名和默認shell相同的用戶信息。
[root@localhost home]# grep -E ‘(^[^:]+\>).*\1$’ /etc/passwd 
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
bash:x:4006:4006::/home/bash:/bin/bash
nologin:x:4009:4009::/home/nologin:/sbin/nologin

原創文章,作者:徐 琦,如若轉載,請注明出處:http://www.www58058.com/70727

(0)
徐 琦徐 琦
上一篇 2017-03-07 17:00
下一篇 2017-03-08 10:44

相關推薦

  • Python內置數據結構——集合set

    集合 定義 set翻譯為集合 collection翻譯為集合類型,是一個較大的概念 set是一個可變的、無序的、不重復的元素組成的集合 set的元素要求必須可以hash,目前已學的不可hash的類型只有list、set 元素不可以索引 set可以迭代 set的初始化 set_1 =set() #表示定義一個空集合set_1 set_1 =set(iterab…

    Linux干貨 2017-10-03
  • 馬哥Linux第六周作業

    網絡管理 進程查看及管理之ps,top,htop,dstat,vmstat

    2018-01-20
  • 安裝 VMware Workstation

    1.第一步 打開安裝包所在位置 2.第二步 開始安裝 ai      上面的路徑看個人習慣修改,然后點擊下一步 3.安裝完成后,點擊輸入許可證秘鑰  打開Vmware注冊碼生成器  安裝成功

    2017-07-11
  • N_28 正則表達式的一些基本用法

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 ~]# cp -r /etc/skel /home/tuser1 ~]# chmod -R -g— -o— /home/tuser1 2、編輯/etc/group文件,添加組hadoop。 ~]#vi…

    Linux干貨 2017-12-23
  • 8月2日作業

    在/data/testdir里創建的新文件自動屬于g1組,組g2的成員如:alice能對這些新文件有讀寫權限,組g3的成員如:tom只能對新文件有讀權限,其它用戶(不屬于g1,g2,g3)不能訪問這個文件夾。 [root@localhost ~]# groupadd g1 [root@localhost ~]# groupadd g2 [root@local…

    Linux干貨 2016-08-05
  • 處理文本的工具sed,vim 編輯器的使用 Linux版

    處理文本的工具sed Stream EDitor 行編輯器 sed一次處理一行的內容,處理時,將當前處理的行存儲在臨時緩沖區,稱為“模式空間”,接著用sed命令處理緩沖區中的內容,處理完成后,將緩沖區的內容送往屏幕,接著處理下一行不斷重復,直到末尾。            一次處理一行 文件&#82…

    Linux干貨 2016-08-11

評論列表(1條)

  • 馬哥教育
    馬哥教育 2017-03-14 09:11

    功能上基本實現了,能注意下排版會更好點~加油!

欧美性久久久久