N25_第四周作業(補)

1、復制/etc/skel目錄到/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。

[root@EASTED tmp]# cp -r /etc/skel/ /home/tuser1/
[root@EASTED tmp]# cp -r /etc/skel/ /home/tuser1/
[root@EASTED tmp]# ls -al /home/tuser1/
總用量 4
drwx------.  3 root root   17 1月   2 21:31 .
drwxr-xr-x. 10 root root 4096 1月   2 21:29 ..
drwx------.  3 root root   74 1月   2 21:31 skel

2、編輯/etc/group文件,添加組hadoop

hadoop:x:1004:
:wq

[root@EASTED tmp]# echo "hadoop:x:1004:" >> /etc/group
[root@EASTED tmp]# cat /etc/group
hadoop:x:1004:

3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,基本組的id號;其家目錄為/home/hadoop

[root@EASTED tmp]# vi /etc/passwd
hadoop:x:1004:1004::/home/hadoop:/bin/bash
-- INSERT --

4、復制/etc/skel目錄為/home/hadoop,要求修改hadoop目錄的屬組和其它用戶沒有任何訪問權限。

[root@EASTED tmp]# cp -r /etc/skel/ /home/hadoop
[root@EASTED tmp]# chmod 700 /home/hadoop/
[root@EASTED tmp]# ls -al /home/hadoop/
總用量 16
drwx------.  3 root root   74 1月   2 21:59 .
drwxr-xr-x. 11 root root 4096 1月   2 21:59 ..
-rw-r--r--.  1 root root   18 1月   2 21:59 .bash_logout
-rw-r--r--.  1 root root  193 1月   2 21:59 .bash_profile
-rw-r--r--.  1 root root  231 1月   2 21:59 .bashrc
drwxr-xr-x.  4 root root   37 1月   2 21:59 .mozilla
[root@EASTED tmp]#

5、修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop

[root@EASTED tmp]# chown -R hadoop:hadoop /home/hadoop/
[root@EASTED tmp]# ls -al /home/hadoop/
總用量 16
drwx------.  3 hadoop hadoop   74 1月   2 21:59 .
drwxr-xr-x. 11 root   root   4096 1月   2 21:59 ..
-rw-r--r--.  1 hadoop hadoop   18 1月   2 21:59 .bash_logout
-rw-r--r--.  1 hadoop hadoop  193 1月   2 21:59 .bash_profile
-rw-r--r--.  1 hadoop hadoop  231 1月   2 21:59 .bashrc
drwxr-xr-x.  4 hadoop hadoop   37 1月   2 21:59 .mozilla

6、顯示/proc/meminfo文件中以大寫或小寫開頭的行;用兩種方式;

[root@EASTED tmp]# grep ^[sS] /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              9788 kB
Slab:             116176 kB
SReclaimable:      58352 kB
SUnreclaim:        57824 kB
[root@EASTED tmp]# grep -i ^s /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              9788 kB
Slab:             116188 kB
SReclaimable:      58360 kB
SUnreclaim:        57828 kB

7、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶;

[root@EASTED tmp]# 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
lyf:x:1000:1000:LYF:/home/lyf:/bin/bash
LiangYF:x:1001:1001::/home/LiangYF:/bin/bash
slackware:x:1002:1002::/home/slackware:/bin/tcsh
houyuan:x:1003:1003::/home/houyuan:/bin/bash
hadoop:x:1004:1004::/home/hadoop:/bin/bash

8、顯示/etc/passwd文件中其默認shell 為/bin/bash的用戶

[root@EASTED tmp]# grep  "/bin/bash$" /etc/passwd
root:x:0:0:root:/root:/bin/bash
lyf:x:1000:1000:LYF:/home/lyf:/bin/bash
LiangYF:x:1001:1001::/home/LiangYF:/bin/bash
houyuan:x:1003:1003::/home/houyuan:/bin/bash
hadoop:x:1004:1004::/home/hadoop:/bin/bash

9、找出/etc/passwd文件中的一位或者兩位數;

[root@EASTED tmp]# grep  "\<[0-9]\{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
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
saslauth:x:993:76:Saslauthd user:/run/saslauthd:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin

10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行;

[root@EASTED grub]# grep " ^[[:space:]]+"  /boot/grub/grub.conf

11、顯示/etc/rc.d/sysinit 文件中以#開頭,后面跟至少一個空白字符,而后又至少一個非空白字符的行;

[root@EASTED grub]# grep "^#[[:space:]]+[^[:space:]]" /etc/rc.d/rc.sysinit

12、打出netstat -tan命令執行結果中以'LISTEN',后面跟空白字符結尾的行;

[root@EASTED grub]# netstat -tan | grep  "LISTEN[[:space:]]*$"
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:631           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:631                 :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN

13、添加用戶bash,testbash,basher,nologin(此一個用戶的shell為/sbin/nologin),而后找出當前系統上其用戶名默認shell 相同的用戶信息;

[root@EASTED ~]# grep "^\([[:alnum:]]\+[^:]\>\).*\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:1006:1006::/home/bash:/bin/bash
nologin:x:1012:1012::/home/nologin:/sbin/nologin

14、顯示/proc/meminfo文件中以大寫或者小寫s開頭的行;用三種方式;

[root@EASTED tmp]# grep ^[sS] /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              9788 kB
Slab:             116176 kB
SReclaimable:      58352 kB
SUnreclaim:        57824 kB

[root@EASTED tmp]# grep -i ^s /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              9788 kB
Slab:             116188 kB
SReclaimable:      58360 kB
SUnreclaim:        57828 kB

[root@EASTED ~]# grep -E "^(s|S)" /proc/meminfo
SwapCached:            0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Shmem:              9788 kB
Slab:             116384 kB
SReclaimable:      58500 kB
SUnreclaim:        57884 kB

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

(0)
LYFLYF
上一篇 2017-01-02 22:56
下一篇 2017-01-03 00:19

相關推薦

  • AWK實現求和、平均數、最小值、最大值

    1.簡單的按列求和]$ cat test123125126]$ awk ‘{sum += $1}END {print sum}’ test2.對符合某些條件的行,按列求和]$ cat  testaaa 123bbb 125aaa 123aaa 123ccc 126對文件test中 第一列為aaa的行求和]$ awk &#82…

    Linux干貨 2017-04-09
  • 常見RAID級別原理, Linux中軟RAID實現方式詳解

    RAID簡介     RAID(Redundant Arry of Independent Disks)獨立冗余陣列,舊稱(Redundant Arry of Inexpensive Disks)廉價冗余陣列,其主要目的是將多個硬盤組成在一起來達到提高I/O、讀寫、冗余性。 RAID分為硬件RAID和軟件RAID &n…

    Linux干貨 2016-03-09
  • man和history及bashi的快捷鍵

    man:幫助命令     命令格式:man# cmd;使用時可以先使用whatis 查詢所對應的man的章節,然后用對應的man章節來查詢幫助;     info:本地幫助文檔     官方文檔,在線查詢等等,如果是付費版系統的話可以使用S…

    Linux干貨 2016-07-29
  • find命令

          find:實時查找工具,根據我們指定的內容或者條件在系統上進行實時查找,比locate在實際場景中用的多得多的多      具體用法:find   查找路徑      查找條件         &n…

    Linux干貨 2017-04-10
  • Linux文件類型及顏色標識

    文件類型(共7種): – :普通文件 d:目錄文件 (directory) c:字符設備文件 (char) b:塊設備文件 (block) s:本地域套接口 (socket) p:有名管道 (pipeline) l:符號連接 (link) 關于硬鏈接、軟連接、復制之間的區別說明: 上圖中,我為photo.png這個圖片文件建立了一個拷貝(phot…

    Linux干貨 2016-10-16
  • N22期-第五周博客作業

    1、顯示當前系統上root、fedora或user1用戶的默認shell; [root@localhost jimmy]# egrep '^(root|fedora|user1)\>' /etc/passwd | cut -d: -f7 /bin/bas…

    Linux干貨 2016-09-10
欧美性久久久久