Linux基礎-用戶管理相關操作-week 4

1.復制/etc/skel 目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其他用戶均沒有任何訪問權限
 cp /etc/skel /home/tuser1 -rf
chmod og=  /home/tuser1 -R
2.編輯/etc/group文件添加組hadoop
echo hadoop:x:503 >>/etc/group
3.手動編輯/etc/passwd 文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的ID號,其家目錄為/home/hadoop.
# echo hadoop:x:503:503::/home/hadoop:/bin/bash >>/etc/passwd
# tail -1 /etc/passwd
hadoop:x:503:503::/home/hadoop:/bin/bash
4.復制/etc/ske1目錄為/home/hadoop,要求修改hadoop目錄的屬組和其他用戶沒有任何訪問權限
# cp /etc/skel/ /home/hadoop -rf
# chmod og=  /home/hadoop -R
5.修改/home/hadoop目錄及其內部所有文件的屬主為hadoop,屬組為hadoop
# chown -R hadoop.hadoop /home/hadoop -R
6.顯示/proc/meminfo文件中以大寫或小寫S開頭的行,兩種方式
方式一:
# cat /proc/meminfo |grep -i ^s
SwapCached:         2676 kB
SwapTotal:       2031608 kB
SwapFree:        2018740 kB
Shmem:                 8 kB
Slab:              62448 kB
SReclaimable:       9320 kB
SUnreclaim:        53128 kB
方式二:
# egrep “^(s|S)” /proc/meminfo 
SwapCached:         2676 kB
SwapTotal:       2031608 kB
SwapFree:        2018740 kB
Shmem:                 8 kB
Slab:              62488 kB
SReclaimable:       9364 kB
SUnreclaim:        53124 kB
7.顯示/etc/passwd文件中其默認Shell 為非/sbin/nologin得用戶
# grep -v “/sbin/nologin” /etc/passwd|awk -F “:” ‘{print $1}’
root
sync
shutdown
halt
nginx
user3
tuser1
test2
hadoop
8.顯示/etc/passwd 文件中其默認Shell 為/bin/bash的用戶
# grep “/bin/bash” /etc/passwd|awk -F “:” ‘{print $1}’
root
nginx
user3
tuser1
test2
hadoop
9.找出/etc/passwd 文件中的一位數或者兩位數
grep -E -o “(“[0-9]”|”[0-9][0-9]”)” /etc/passwd
10,顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行;
# grep “^[[:space:]]\+” /boot/grub/grub.conf 
11.顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,而后又有至少一個非空白字符的行;
#grep   “^[#][[:space:]]+.*[^[:space:]]+.*” /etc/rc.d/rc.sysinit
12,打出netstat -tan命令執行結果中以’LISTEN’,后或跟空白字符結尾的行;
# netstat -tan  | grep “LISTEN[[:space:]]*$”
13,添加用戶bash,testbash,basher,nologin(此一個用戶的shell為/sbin/nologin),而后找出當前系統上其用戶名和默認shell相同的用戶的信息
#useradd bash
 # useradd testbash
 # useradd basher
 #useradd nologin -s /sbin/nologin
# tail -4 /etc/passwd
bash:x:504:504::/home/bash:/bin/bash
testbash:x:505:505::/home/testbash:/bin/bash
basher:x:506:506::/home/basher:/bin/bash
nologin:x:507:507::/home/nologin:/sbin/nologin
# 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:504:504::/home/bash:/bin/bash
nologin:x:507:507::/home/nologin:/sbin/nologin
14.顯示/proc/meminfo文件中以大寫或者小寫S開頭的行;三種方式
方式一:
# cat /proc/meminfo |grep -i ^s
SwapCached:         2676 kB
SwapTotal:       2031608 kB
SwapFree:        2018740 kB
Shmem:                 8 kB
Slab:              62448 kB
SReclaimable:       9320 kB
SUnreclaim:        53128 kB
方式二:
# egrep “^(s|S)” /proc/meminfo 
SwapCached:         2676 kB
SwapTotal:       2031608 kB
SwapFree:        2018740 kB
Shmem:                 8 kB
Slab:              62488 kB
SReclaimable:       9364 kB
SUnreclaim:        53124 kB
方式三:
# grep “^[Ss]\+” /proc/meminfo 
SwapCached:         2700 kB
SwapTotal:       2031608 kB
SwapFree:        2018748 kB
Shmem:                12 kB
Slab:             100668 kB
SReclaimable:      45276 kB
SUnreclaim:        55392 kB

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

(0)
N24_liuzN24_liuz
上一篇 2016-11-21 20:15
下一篇 2016-11-21

相關推薦

  • Storm集群安裝詳解

    storm有兩種操作模式: 本地模式和遠程模式。 本地模式:你可以在你的本地機器上開發測試你的topology, 一切都在你的本地機器上模擬出來;  遠端模式:你提交的topology會在一個集群的機器上執行。 本文以Twitter Storm官方Wiki為基礎,詳細描述如何快速搭建一個Storm集群,其中,項目實踐中遇到的問題及經驗總結,在相應章…

    Linux干貨 2015-04-04
  • Linux中正則表達式和grep的使用

    正則表達式在Linux經常配合grep,sed和awk等用于搜尋關鍵字。正則表達式分為正則表達式和擴展正則表達式: 一、正則表達式 1.1 元字符: .:匹配任意字符    []:匹配[]中的任意一個字符 [^]:匹配[]以外的任意字符 [:alpha:]大小寫英文字母 [:digit:]:十進制數字 [:xdigit…

    Linux干貨 2017-04-08
  • linux終端變量設置,文件系統,man使用說明,文件類型

    一、定義終端提示符的變量 export PS1=’\e[32m[\e[33m\u\e[31m@\e[35m\h\e[36m\t\e[34m\#\e[31m\s\e[37m\W\e[32m]\$ ‘  `]# export 是個命令      PS1指終端提示符變量    &n…

    Linux干貨 2013-06-16
  • 用戶、組及權限管理詳解

    用戶類別:Liunx中用戶標識范圍在0-65535之間; 超級用戶(管理員) —— 默認為root,擁有所有權限。UID與GID值為0, 普通用戶 系統用戶 —— CentOS6中UID與GID值為1~499,CentOS7中UID與GID值為1~999。默認不能登錄系統,存在主要是滿足系統進程對文件屬主的需求; 登錄用戶 —— CentOS6中UID與GI…

    2018-03-08
  • Unlocking the Future of Digital Play

    In the rapidly evolving world of digital entertainment, the bc game stands out as a beacon of innovation and excitement. This app has managed to capture the essence of online gamin…

    Linux干貨 1天前

評論列表(1條)

  • luoweiro
    luoweiro 2016-11-30 22:31

    整體完成的不錯,第5題多個-R

欧美性久久久久