馬哥教育網絡21期+第四周作業博客

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

[root@localhost ~]# cp -r /etc/skel /home/ && mv /home/skel /home/tuser1[root@localhost ~]# chmod -R g-rwx,o-rwx  /home/tuser1[root@localhost tuser1]# ll -a總用量 12drwx------. 3 root root  74 7月  30 13:31 .
drwx--x--x. 3 root root  43 7月  30 13:31 ..
-rw-------. 1 root root  18 7月  30 13:31 .bash_logout
-rw-------. 1 root root 193 7月  30 13:31 .bash_profile
-rw-------. 1 root root 231 7月  30 13:31 .bashrc
drwx------. 4 root root  37 7月  30 13:31 .mozilla

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

[root@localhost /]# echo "hadoop:x:1000:" >> /etc/group
[root@localhost /]# tail -1 /etc/grouphadoop:x:1000:

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

[root@localhost /]# echo "hadoop:x:1000:1000:hadoop:/home/hadoop:/bin/bash" >> /etc/passwd[root@localhost /]# tail -1 /etc/passwdhadoop:x:1000:1000::/home/hadoop:/bin/bash

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

[root@localhost /]# cp -r /etc/skel/ /home && mv /home/skel /home/hadoop
[root@localhost /]# chmod g-rwx,o-rwx /home/hadoop/[root@localhost /]# ll -a /home | grep hadoop
drwx------.  4 root root    85 7月  30 13:42 hadoop

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

[root@localhost /]# chown -R hadoop:hadoop /home/hadoop[root@localhost /]# ll /home | grep hadoopdrwx------. 3 hadoop hadoop 74 7月  30 13:45 hadoop
[root@localhost /]# ll -a /home/hadoop總用量 12drwx------. 4 hadoop hadoop  85 7月  30 13:42 .
drwx--x--x. 4 root   root    56 7月  30 13:42 ..
-rw-r--r--. 1 hadoop hadoop  18 7月  30 13:42 .bash_logout
-rw-r--r--. 1 hadoop hadoop 193 7月  30 13:42 .bash_profile
-rw-r--r--. 1 hadoop hadoop 231 7月  30 13:42 .bashrc
drwxr-xr-x. 4 hadoop hadoop  37 7月  30 13:42 .mozilla

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

[root@localhost /]# cat /proc/meminfo | grep ^[s,S] 
Sfile:            0 kBSwapFile:       148 kBShmem:        9721438 kBSHanghaiFile:              80 kBSlab:              6132 kB

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

[root@localhost /]# cat /etc/passwd | grep -v /sbin/nologin | awk -F: '{ print $1 }' root
sync
shutdown
halt
hadoop

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

[root@localhost /]# cat /etc/passwd | grep  /bin/bash | awk -F: '{ print $1 }'                root
hadoop

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

[root@localhost /]# grep -o "[0-9]\{1,2\}" /etc/passwd  0中間略...00

10、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行 備注:系統為CentOS 7,以/boot/grub2/grub.cfg代替

[root@localhost grub2]# grep "^[[:space:]]\+" grub.cfg 
  load_env   set default="${next_entry}"中間略... 
        initrd16 /initramfs-0-rescue-37e800fd7ca2447eade3a5cb36080c40.img  source ${config_directory}/custom.cfg  source $prefix/custom.cfg;

顯示/etc/rc.d/rc.sysinit文件 中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行 備注:系統為CentOS 7,以/boot/grub2/grub.cfg代替

[root@localhost /]# cat /boot/grub2/grub.cfg  | grep "^#[[:space:]]\{1,\}[^[:space:]]"# DO NOT EDIT THIS FILE
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
# Fallback normal timeout code in case the timeout_style feature is# unavailable.
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change# the 'exec tail' line above.

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

[root@localhost /]# 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: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 /]# useradd bash && useradd testbash && useradd basher && useradd -s /sbin/nologin nologin[root@localhost /]# grep -E '^(\<.+\>).*\1$' /etc/passwd            sync:x:5:0:sync:/sbin:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/sbin:/sbin/haltbash:x:1001:1001::/home/bash:/bin/bashnologin:x:1004:1004::/home/nologin:/sbin/nologin

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

(0)
Net21_XUNet21_XU
上一篇 2016-09-05 08:50
下一篇 2016-09-05 08:52

相關推薦

  • MySQL復制

    目錄: 1.備份與恢復 2.主從復制 3.主主復制 4.半同步復制 5.MHA 6.centos7搭建mariadb Galera集群 1.備份和恢復 備份工具:mysqldump+復制binlog xtrabackup (1) mysqldump+復制binlog 備份: mysqldump -E -R –triggers –master-data=2 –…

    2017-11-21
  • LNMP編譯安裝-week16

    1、源碼編譯安裝LNMP架構環境; 系統: CentOS 7.2IP: 172.16.0.11版本: nginx-1.10.3 php-5.6.30 mysql-5.6.30 一.安裝開發包組 ~]# yum -y groupinstall “Development Tools” “Server Platform Development” 二.編譯安裝ngi…

    2017-05-11
  • 馬哥教育網絡班22期-第九周課程作業

    1、寫一個腳本,判斷當前系統上所有用戶的shell是否為可登錄shell(即用戶的shell不是/sbin/nologin);分別這兩類用戶的個數;通過字符串比較來實現; #!/bin/bash # declare -i count=0 declare -i bash_num=0 declare -i&nbs…

    Linux干貨 2016-11-21
  • Linux運維學習歷程-第十天-文件查找工具

    概述:本篇主要講解locate命令和find命令,來幫助我們在linux中完成文件查找,方便我們快速定位文件。 一、文件查找    即在文件系統上查找符合條件的文件,常用工具有locate和find  1、locate命令    locate命令其實是find -name的另一種寫法,但是要比后者快得多,原因…

    Linux干貨 2016-08-21
  • grep,egrep及相應的正則表達式用法詳解

    目錄 1、grep簡介     1.1、grep是什么     1.2、grep使用格式     1.3、grep常用選項 2、正則表達式與grep     2.1、正則表達式簡介  &nb…

    系統運維 2016-08-22
  • httpd——事務

    http協議: http/0.9 ,http/1.0 ,http/1.1 ,http/2.0 http協議:stateless          服務器無法持續追蹤訪問者來源          &nb…

    Linux干貨 2016-10-12

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-09-07 18:45

    完成的非常好,答案的排版需要注意一下,有些地方需要添加換行符哈,加油!

欧美性久久久久