馬哥教育N22期第四周作業

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

root@xuc-virtual-machine:/home/xuc# cp -r /etc/skel/ /home/tuser1
root@xuc-virtual-machine:/home# chmod 700 /home/tuser1/examples.desktop 
root@xuc-virtual-machine:/home# ll
total 16
drwxr-xr-x  4 root root 4096  9月  2 15:58 ./
drwxr-xr-x 23 root root 4096  9月  2 11:44 ../
drwx------  3 root root 4096  9月  2 15:58 tuser1/
drwxr-xr-x 14 xuc  xuc  4096  9月  2 15:28 xuc/
root@xuc-virtual-machine:/home/tuser1# ll
total 36
drwx------ 3 root root 4096  9月  2 15:58 ./
drwxr-xr-x 4 root root 4096  9月  2 15:58 ../
-rw-r--r-- 1 root root  220  9月  2 15:58 .bash_logout
-rw-r--r-- 1 root root 3771  9月  2 15:58 .bashrc
-rwx------ 1 root root 8980  9月  2 15:58 examples.desktop*
-rw-r--r-- 1 root root  675  9月  2 15:58 .profile
drwxr-xr-x 2 root root 4096  9月  2 15:58 skel/

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

root@xuc-virtual-machine:/etc# vim + /etc/group
鍵盤i進入輸入模式,hadoop組名,x密碼填充位,id號
hadoop:x:1002:

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

vim + /etc/passwd      //光標停留在最后一行
tuser1:x:1001:1001::/home/tuser1:
hadoop:x:1002:1002::/home/hadoop:
:wq

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

root@xuc-virtual-machine:~# cp -r /etc/skel/ /home/hadoop
root@xuc-virtual-machine:~# cd /home/
root@xuc-virtual-machine:/home# ls
hadoop  tuser1  xuc
root@xuc-virtual-machine:/home# cd /hadoop
root@xuc-virtual-machine:/home/hadoop# chmod g-r examples.desktop
root@xuc-virtual-machine:/home/hadoop# chmod o-r examples.desktop 
root@xuc-virtual-machine:/home/hadoop# ll
total 32
drwxr-xr-x 2 root root 4096  9月  2 16:33 ./
drwxr-xr-x 5 root root 4096  9月  2 16:33 ../
-rw-r--r-- 1 root root  220  9月  2 16:33 .bash_logout
-rw-r--r-- 1 root root 3771  9月  2 16:33 .bashrc
-rw------- 1 root root 8980  9月  2 16:33 examples.desktop
-rw-r--r-- 1 root root  675  9月  2 16:33 .profile

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

root@xuc-virtual-machine:/home/hadoop# chown -R hadoop:hadoop /home/hadoop
root@xuc-virtual-machine:/home/hadoop# ll
total 32
drwxr-xr-x 2 hadoop hadoop 4096  9月  2 16:33 ./
drwxr-xr-x 5 root   root   4096  9月  2 16:33 ../
-rw-r--r-- 1 hadoop hadoop  220  9月  2 16:33 .bash_logout
-rw-r--r-- 1 hadoop hadoop 3771  9月  2 16:33 .bashrc
-rw------- 1 hadoop hadoop 8980  9月  2 16:33 examples.desktop
-rw-r--r-- 1 hadoop hadoop  675  9月  2 16:33 .profile
root@xuc-virtual-machine:/home/hadoop# cd ..
root@xuc-virtual-machine:/home# ll
total 20
drwxr-xr-x  5 root   root   4096  9月  2 16:33 ./
drwxr-xr-x 23 root   root   4096  9月  2 11:44 ../
drwxr-xr-x  2 hadoop hadoop 4096  9月  2 16:33 hadoop/
drwx------  3 root   root   4096  9月  2 15:58 tuser1/
drwxr-xr-x 14 xuc    xuc    4096  9月  2 15:28 xuc/

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

root@xuc-virtual-machine:/home# grep -i '^s' /proc/meminfo 
root@xuc-virtual-machine:/home# grep "^[S,s]" /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       1952764 kB
SwapFree:        1952764 kB
Shmem:              9088 kB
Slab:             131924 kB
SReclaimable:      94576 kB
SUnreclaim:        37348 kB

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

root@xuc-virtual-machine:~# grep -v '/sbin/nologin$' /etc/passwd |cut -d: -f1
root
sync
systemd-timesync
systemd-network
systemd-resolve
systemd-bus-proxy
syslog
messagebus
uuidd
avahi
whoopsie
avahi-autoipd
dnsmasq
colord
speech-dispatcher
hplip
kernoops
pulse
rtkit
saned
usbmux
lightdm
xuc
tuser1
hadoop

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

root@xuc-virtual-machine:~# grep '/bin/bash$' /etc/passwd |cut -d: -f1
root
xuc

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

root@xuc-virtual-machine:~# egrep '\<[0-9]{1,2}\>' /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
speech-dispatcher:x:112:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false
hplip:x:113:7:HPLIP system user,,,:/var/run/hplip:/bin/false
usbmux:x:118:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false

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

[root@xuc ~]# egrep '^[[:space:]]+' /boot/grub/grub.conf 
    root (hd0,0)    
    kernel /boot/vmlinuz-2.6.32-431.el6.x86_64 ro root=UUID=a274520f-caee-49d5-8701-25f5ef4be485 
    rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkern    
    el=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet     
    initrd /boot/initramfs-2.6.32-431.el6.x86_64.img

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

[root@xuc ~]# egrep ^#[[:space:]]\+[^[:space:]]\+ /etc/rc.d/rc.sysinit
# /etc/rc.d/rc.sysinit - run once at boot time
# Taken in part from Miquel van Smoorenburg's bcheckrc.
# Check SELinux status
# Print a text banner.
# Only read this once.
# Initialize hardware
# Set default affinity
# Load other user-defined modules
# Load modules (for backward compatibility with VARs)
# Configure kernel parameters
# Set the hostname.
# Sync waiting for storage.
# Device mapper & related initialization
# Start any MD RAID arrays that haven't been started yet
# Remount the root filesystem read-write.
# Clean up SELinux labels
# If relabeling, relabel mount points.
# Mount all other filesystems (except for NFS and /proc, which is already
# mounted). Contrary to standard usage,
# filesystems are NOT unmounted in single user mode.
# The 'no' applies to all listed filesystem types. See mount(8).
# Update quotas if necessary
# Check to see if a full relabel is needed
# Initialize pseudo-random number generator
# Configure machine if necessary.
# Clean out /.
# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might...
# Clean up /var.
# Clean up utmp/wtmp
# Clean up various /tmp bits
# Make ICE directory
# Start up swapping.
# Set up binfmt_misc
# Boot time profiles. Yes, this should be somewhere else.
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
# create the crash indicator flag to warn on crashes, offer fsck with timeout
# Let rhgb know that we're leaving rc.sysinit

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

[root@xuc ~]# netstat -tan |egrep '*LISTEN\>'
tcp        0      0 0.0.0.0:111                 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      
tcp        0      0 0.0.0.0:52795               0.0.0.0:*                   LISTEN      
tcp        0      0 :::111                      :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 ::1:631                     :::*                        LISTEN      
tcp        0      0 ::1:25                      :::*                        LISTEN      
tcp        0      0 :::36483                    :::*                        LISTEN

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

[root@xuc ~]# egrep '(^[[:alpha:]]+\>).*\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:501:501::/home/bash:/bin/bash
nologin:x:504:504::/home/nologin:/sbin/nologin

原創文章,作者:N22_熊寶,如若轉載,請注明出處:http://www.www58058.com/43521

(0)
N22_熊寶N22_熊寶
上一篇 2016-09-06
下一篇 2016-09-06

相關推薦

  • 馬哥教育網絡班21期+第七周博客作業

    1、創建一個10G分區,并格式為ext4文件系統;    (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;    (2) 掛載至datamydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳 [root@ns1 ~]# m…

    Linux干貨 2016-08-24
  • yum命令的用法

    1.列出所有可更新的軟件清單命令:yum check-update 2.安裝所有更新軟件命令:yum update 3.僅安裝指定的軟件命令:yum install <package_name> 4.僅更新指定的軟件命令:yum update <package_name> 5.列出所有可安裝的軟件清單命令:yum list 用YUM安…

    Linux干貨 2017-08-11
  • LAMP

    1、請描述一次完整的http請求處理過程; 一次完整的http請求處理過程: (1) 建立或處理連接:接收請求或拒絕請求; (2) 接收請求:接收來自于網絡上的主機請求報文中對某特定資源的一次請求的過程; (3) 處理請求:對請求報文進行解析,獲取客戶端請求的資源及請求方法等相關信息; (4) 訪問資源:獲取請求報文中請求的資源; (5) 構建響應報文: (…

    Linux干貨 2016-12-14
  • 用戶相關文件簡介

    2016/10/23 總結關于用戶和組相關的配置文件 Linux系統主要有4個文件與用戶和組的配置有關, 主要為/etc/passwd  /etc/shadow   /etc/group  /etc/gshadow 首先來解釋一下什么是用戶,什么是組 用戶:      管理員用戶&nbsp…

    Linux干貨 2016-10-24
  • 8月5日第七節課作業

    一、當天練習 1、找出ifconfig命令結果中本機的所有IPv4地址 2、查出分區空間使用率的最大百分比值 3、查出用戶UID最大值的用戶名、UID及shell類型 4、查出/tmp的權限,以數字方式顯示 5、統計當前連接本機的每個遠程主機IP的連接數,并按從大 到小排序 1、顯示/proc/meminfo文件中以大小s開頭的行;(要求:使 用兩種方式) …

    Linux干貨 2016-08-08
  • Linux之文件管理命令

      Linux文件管理類命令 Linux一切皆文件,所以熟悉文件管理命令對我們來說至關重要 文件查看命令 cat命令:文本文件查看工具 命令用法:         cat [OPTION]… [FILE]… 常用選項:  &nbsp…

    Linux干貨 2016-11-04

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-09-13 23:31

    排版獨有風格~內容也比較貼近真實環境,贊。

欧美性久久久久