馬哥教育網絡20期+第四周課程練習

1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。
~]# cp -r /etc/skel /home/tuser1
~]# chmod -R go-r /home/tuser1
2、編輯/etc/group文件,添加組hadoop。
hadoop:x:2018:
3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的id號;其家目錄為/home/hadoop。
hadoop:x:2018:2018::/home/hadoop:/bin/bash
4、復制/etc/skel目錄為/home/hadoop,要求修改hadoop目錄的屬組和其它用戶沒有任何訪問權限。
~]# cp -r /etc/skel /home/hadoop
~]# chmod -R go= /home/hadoop
5、修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop。
~]# chown -R hadoop:hadoop /home/hadoop
6、顯示/proc/meminfo文件中以大寫或小寫S開頭的行;用兩種方式;
[root@localhost ~]# grep "^[Ss]" /proc/meminfo
SwapCached:            0 kB
SwapTotal:       2031608 kB
SwapFree:        2031608 kB
Shmem:               320 kB
Slab:              68752 kB
SReclaimable:      13524 kB
SUnreclaim:        55228 kB

[root@localhost ~]# grep "^s" -i /proc/meminfo
SwapCached:            0 kB
SwapTotal:       2031608 kB
SwapFree:        2031608 kB
Shmem:               320 kB
Slab:              68772 kB
SReclaimable:      13528 kB
SUnreclaim:        55244 kB
7、顯示/etc/passwd文件中其默認shell為非/sbin/nologin的用戶;
[root@localhost ~]# 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
ricky:x:500:500:ricky:/home/ricky:/bin/bash
tom:x:501:501::/home/tom:/bin/bash
som:x:502:502::/home/som:/bin/bash
user1:x:504:506::/home/user1:/bin/bash
root1:x:505:507::/home/root1:/bin/bash
bash:x:506:508::/home/bash:/bin/bash
testbash:x:507:509::/home/testbash:/bin/bash
basher:x:508:510::/home/basher:/bin/bash
gentoo:x:510:512:i'm ricky:/home/gentoo:/bin/csh
gentoo3:x:511:513::/home/gentoo3:/bin/bash
ftp_ricky:x:512:50::/home/wwwroot:/bin/bash
archlinux:x:513:514::/users/archlinux:/bin/bash
mandriva:x:1005:1005::/home/mandriva:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016::/home/slackware:/bin/bash
hadoop:x:2018:2018::/home/hadoop:/bin/bash
8、顯示/etc/passwd文件中其默認shell為/bin/bash的用戶;
[root@localhost ~]# grep "/bin/bash$" /etc/passwd
root:x:0:0:root:/root:/bin/bash
ricky:x:500:500:ricky:/home/ricky:/bin/bash
tom:x:501:501::/home/tom:/bin/bash
som:x:502:502::/home/som:/bin/bash
user1:x:504:506::/home/user1:/bin/bash
root1:x:505:507::/home/root1:/bin/bash
bash:x:506:508::/home/bash:/bin/bash
testbash:x:507:509::/home/testbash:/bin/bash
basher:x:508:510::/home/basher:/bin/bash
gentoo3:x:511:513::/home/gentoo3:/bin/bash
ftp_ricky:x:512:50::/home/wwwroot:/bin/bash
archlinux:x:513:514::/users/archlinux:/bin/bash
mandriva:x:1005:1005::/home/mandriva:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016::/home/slackware:/bin/bash
hadoop:x:2018:2018::/home/hadoop:/bin/bash
9、找出/etc/passwd文件中的一位數或兩位數;
[root@localhost ~]# grep "\<[0-9]\{1,2\}\>" /etc/passwd
   blob.png 
10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行;
[root@localhost ~]# grep "^[[:space:]]\+" /etc/grub.conf
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=a8c981b4-f953-430e-b4b4-769f98f89f40 rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img
11、顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行;
[root@localhost ~]# grep "^#[[: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.
12、打出netstat -tan命令執行結果中以‘LISTEN’,后或跟空白字符結尾的行;
[root@localhost ~]# netstat -tan|grep "LISTEN[[:space:]]\+"

 blob.png

13、添加用戶bash, testbash, basher, nologin (此一個用戶的shell為/sbin/nologin),而后找出當前系統上其用戶名和默認shell相同的用戶的信息;
useradd bash
useradd testbash
useradd basher
useradd nologin -s /sbin/nologin
[root@localhost ~]# 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:506:508::/home/bash:/bin/bash
nologin:x:509:511::/home/nologin:/sbin/nologin

馬哥教育網絡20期+第四周課程練習

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

(0)
song0156song0156
上一篇 2016-07-04 11:34
下一篇 2016-07-04 11:35

相關推薦

  • 磁盤管理和高級文件系統管理-習題

    高級文件系統管理-習題 1、 創建一個可用空間為40G 的RAID1 設備,要求其chunk大小為128k ,文件系統為ext4 ,有一個空閑盤,開機可自動掛載至/backup目錄 [root@centos7 ~]# mdadm -C /dev/md0 -c 128 -a yes -l 1 -n 2 -x 1 /dev/sdb /dev/sdc /dev/s…

    Linux干貨 2016-09-01
  • N28-第三周博客作業

    1、列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可。
    2、取出最后登錄到當前系統的用戶的相關信息。
    3、取出當前系統上被用戶當作其默認shell的最多的那個shell。
    4、將/etc/passwd中的第三個字段數值最大的后10個用戶的信息全部改為大寫后保存至/tmp/maxusers.txt文件中。
    5、取出當前主機的IP地址,提示:對ifconfig命令的結果進行切分。
    6、列出/etc目錄下所有以.conf結尾的文件的文件名,并將其名字轉換為大寫后保存至/tmp/etc.conf文件中。
    7、顯示/var目錄下一級子目錄或文件的總個數。
    8、取出/etc/group文件中第三個字段數值最小的10個組的名字。
    9、將/etc/fstab和/etc/issue文件的內容合并為同一個內容后保存至/tmp/etc.test文件中。
    10、請總結描述用戶和組管理類命令的使用方法并完成以下練習:
    (1)、創建組distro,其GID為2016;
    (2)、創建用戶mandriva, 其ID號為1005;基本組為distro;
    (3)、創建用戶mageia,其ID號為1100,家目錄為/home/linux;
    (4)、給用戶mageia添加密碼,密碼為mageedu;
    (5)、刪除mandriva,但保留其家目錄;
    (6)、創建用戶slackware,其ID號為2002,基本組為distro,附加組peguin;
    (7)、修改slackware的默認shell為/bin/tcsh;
    (8)、為用戶slackware新增附加組admins;

    Linux干貨 2017-12-19
  • Linux ssh安全遠程登錄

                   Linux ssh安全遠程登錄 本章內容:     構建SSH遠程登錄系統     SSH(secure shell)是標準的網絡協議,主要用于實現字符界面的遠程登錄管理…

    Linux干貨 2016-10-10
  • 系統排錯——如何修復和保護你的系統

    作業 1、破解root口令,并為grub設置保護功能 開機啟動時按e進入grub菜單,然后按a 編輯當前菜單的kernel選項,在后面追加1,s,S,single中的任意一個,然后回車,輸入b鍵啟動 進入了單用戶模式,可以直接修改root密碼 如何為grub設置保護功能: (1)、首先生成grub的md5密碼 (2)、修改grub.conf文件 (3)、重啟…

    Linux干貨 2016-09-12
  • HAproxy對wordpress的代理

    一,實驗環境 網絡拓撲結構 Web2,master是centos7.3 Web1,backup是centos6.8 客服端的window主機首win7 所有的主機通過switch相連,處于172.18.0.0/16的網段中 二,安裝的軟件 使用wordpress版本4.3.1 Web1安裝httpd,php,php-mysql Web2安裝nfs-utils…

    Linux干貨 2017-05-17
  • 文件查找命令find詳解

    文件的查找命令 find 用法 功能:實時查找工具,通過遍歷指定路徑完成文件查找 工作特點: ?  查找速度略慢?  精確查找?  實時查找?  可能只搜索用戶具備讀取和執行權限的目錄 語法:   find [OPTION]… [查找路徑] [查找條件] [處理動作] 查找路徑:指定具體目標路徑;默認為當前目錄查找條件…

    Linux干貨 2016-11-07

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-09-27 09:20

    寫的很好,看的出來很用心的測試過,希望繼續保持,加油

欧美性久久久久