N32-第四周-小羅

1、復(fù)制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內(nèi)部文件的屬組和其它用戶(hù)均沒(méi)有任何訪(fǎng)問(wèn)權(quán)限努咐。

[root@host ~]# cp -r /etc/skel /home/tuser1
 --------------------------------------------------------
 [root@host ~]# ll /home/
total 60
drwx------ 2 bash      bash     4096 Jul  6 04:29 bash
drwx------ 2 basher    basher   4096 Jul  6 04:29 basher
drwx------ 2 centos    centos   4096 Jul 11 03:39 centos
drwx------ 2 centos10  centos10 4096 Jul 22 04:56 centos10
drwx------ 2 centos2   centos2  4096 Jul  4 04:29 centos2
drwx------ 2 centos3   centos3  4096 Jul  3 21:59 centos3
drwx------ 2 fedora    fedora   4096 Jul 11 02:51 fedora
drwx------ 2 hadoop    hadoop   4096 Jul  9 07:54 hadoop
drwx------ 2 mageia    mageia   4096 Jul  4 23:23 linux
drwx------ 2 distro   4096 Jul  4 23:01 mandriva
drwx------ 2 mygrp     mygrp    4096 Jul  9 08:29 mygrp
drwx------ 2 nologin   nologin  4096 Jul  6 04:30 nologin
drwx------ 2 slackware distro   4096 Sep  2 03:56 slackware
drwx------ 2 testbash  testbash 4096 Jul  6 04:29 testbash
drwxr-xr-x 2 root      root     4096 Sep  6 01:12 tuser1
--------------------------------------------------------
[root@host home]# chmod -R 700 tuser1/
[root@host home]# ll
drwx------ 2 root      root     4096 Sep  6 01:12 tuser1

2、編輯/etc/group文件殴胧,添加組hadoop渗稍。

[root@host home]# vim /etc/group  
按o鍵進(jìn)入編輯模式,輸入 :hadoop:x:2019
按esc鍵進(jìn)入命令模式,按shift+:進(jìn)入末行模式輸入
:wq 回車(chē)鍵保存退出
--------------------------------------------------------
[root@host home]# grep hadoop /etc/group
hadoop:x:2019

3、手動(dòng)編輯/etc/passwd文件新增一行溃肪,添加用戶(hù)hadoop免胃,其基本組ID為hadoop組的id號(hào);其家目錄為/home/hadoop惫撰。

[root@host home]# vim /etc/passwd
按o鍵進(jìn)入編輯模式,輸入hadoop:x:2019:2019::/home/hadoop:/bin/bash
按esc鍵進(jìn)入命令模式,按shift+:進(jìn)入末行模式輸入
:wq 回車(chē)鍵保存退出
--------------------------------------------------------
[root@host home]# grep hadoop /etc/passwd
hadoop:x:2019:2019::/home/hadoop:/bin/bash

4羔沙、復(fù)制/etc/skel目錄為/home/hadoop,要求修改hadoop目錄的屬組和其它用戶(hù)沒(méi)有任何訪(fǎng)問(wèn)權(quán)限厨钻。

[root@host ~]# cp -rv /etc/skel /home/hadoop
`/etc/skel' -> `/home/hadoop'
`/etc/skel/.bash_logout' -> `/home/hadoop/.bash_logout'
`/etc/skel/.bashrc' -> `/home/hadoop/.bashrc'
`/etc/skel/.bash_profile' -> `/home/hadoop/.bash_profile'
--------------------------------------------------------
[root@host ~]# chmod -R 700 /home/hadoop
--------------------------------------------------------
[root@host ~]# ll -d /home/hadoop
drwx------ 2 root root 4096 Sep  6 02:33 /home/hadoop

5扼雏、修改/home/hadoop目錄及其內(nèi)部所有文件的屬主為hadoop,屬組為hadoop夯膀。

[root@host ~]# chown -R hadoop:hadoop /home/hadoop
--------------------------------------------------------
[root@host ~]# ll -d /home/hadoop
drwx------ 2 hadoop hadoop 4096 Sep  6 02:33 /home/hadoop

6诗充、顯示/proc/meminfo文件中以大寫(xiě)或小寫(xiě)S開(kāi)頭的行;用兩種方式诱建;

[root@host ~]# cat /proc/meminfo | grep -i "^s"
SwapCached:          284 kB
SwapTotal:        135164 kB
SwapFree:         131708 kB
Shmem:                12 kB
Slab:              77836 kB
SReclaimable:      64888 kB
SUnreclaim:        12948 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
--------------------------------------------------------
[root@host ~]# cat /proc/meminfo | grep  "^\(s\|S\)"
SwapCached:          284 kB
SwapTotal:        135164 kB
SwapFree:         131708 kB
Shmem:                12 kB
Slab:              77836 kB
SReclaimable:      64888 kB
SUnreclaim:        12948 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB

7蝴蜓、顯示/etc/passwd文件中其默認(rèn)shell為非/sbin/nologin的用戶(hù);

[root@host ~]# cat /etc/passwd | grep -v "/sbin/nologin$" | cut -d: -f1
root
sync
shutdown
halt
centos2
centos3
mageia
slackware
bash
testbash
basher
centos
mygrp
fedora
centos10
archlinux
hadoop

8俺猿、顯示/etc/passwd文件中其默認(rèn)shell為/bin/bash的用戶(hù)茎匠;

[root@host ~]# cat /etc/passwd | grep "/bin/bash$"
root:x:0:0:root:/root:/bin/bash
centos2:x:501:501::/home/centos2:/bin/bash
centos3:x:502:502::/home/centos3:/bin/bash
mageia:x:1100:1100::/home/linux:/bin/bash
slackware:x:2002:2016:/bin/tcsh:/home/slackware:/bin/bash
bash:x:2004:2004::/home/bash:/bin/bash
testbash:x:2005:2005::/home/testbash:/bin/bash
basher:x:2006:2006::/home/basher:/bin/bash
centos:x:2008:2008::/home/centos:/bin/bash
mygrp:x:2009:2009::/home/mygrp:/bin/bash
fedora:x:2010:2010::/home/fedora:/bin/bash
centos10:x:2011:2011::/home/centos10:/bin/bash
archlinux:x:2012:2012::/users/archlinux:/bin/bash
hadoop:x:2019:2019::/home/hadoop:/bin/bash

9、找出/etc/passwd文件中的一位數(shù)或兩位數(shù)押袍;

[root@host ~]# cat /etc/passwd | grep "[[:digit:]]\{0,1\}"
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
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
saslauth:x:499:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin

10诵冒、顯示/boot/grub/grub.conf中以至少一個(gè)空白字符開(kāi)頭的行;

[root@host ~]# cat /boot/grub/grub.conf | grep "^[[:space:]]\+"

11谊惭、顯示/etc/rc.d/rc.sysinit文件中以#開(kāi)頭汽馋,后面跟至少一個(gè)空白字符侮东,而后又有至少一個(gè)非空白字符的行;

[root@host ~]# cat /etc/rc.d/rc.sysinit | grep "^#[[:space:]]\+[^[:space:]]\+"
# /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).
# Check to see if a full relabel is needed
# Update quotas if necessary
# 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命令執(zhí)行結(jié)果中以‘LISTEN’悄雅,后或跟空白字符結(jié)尾的行;

[root@host ~]# netstat -tan | grep "LISTEN[[:space:]]\+$"
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:26605               0.0.0.0:*                   LISTEN      
tcp        0      0 ::1:25                      :::*                        LISTEN      
tcp        0      0 :::443                      :::*                        LISTEN      
tcp        0      0 :::26605                    :::*                        LISTEN      

13告组、添加用戶(hù)bash, testbash, basher, nologin (此一個(gè)用戶(hù)的shell為/sbin/nologin)煤伟,而后找出當(dāng)前系統(tǒng)上其用戶(hù)名和默認(rèn)shell相同的用戶(hù)的信息;

[root@host ~]# useradd bash
[root@host ~]# useradd testbash
[root@host ~]# useradd basher
[root@host ~]# useradd -s /sbin/nologin nologin
 --------------------------------------------------------
[root@host ~]# cat /etc/passwd | grep "^\([[:alnum:]]\+\).*\1$"
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
nobody:x:99:99:Nobody:/:/sbin/nologin
hadoop:x:2019:2019::/home/hadoop:/bin/bash
bash:x:2020:2020::/home/bash:/bin/bash
basher:x:2022:2022::/home/basher:/bin/bash
nologin:x:2023:2023::/home/nologin:/sbin/nologin
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末木缝,一起剝皮案震驚了整個(gè)濱河市便锨,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌我碟,老刑警劉巖放案,帶你破解...
    沈念sama閱讀 212,029評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異矫俺,居然都是意外死亡吱殉,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,395評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)厘托,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)友雳,“玉大人,你說(shuō)我怎么就攤上這事铅匹⊙荷蓿” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,570評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵包斑,是天一觀(guān)的道長(zhǎng)流礁。 經(jīng)常有香客問(wèn)我,道長(zhǎng)罗丰,這世上最難降的妖魔是什么神帅? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,535評(píng)論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮萌抵,結(jié)果婚禮上找御,老公的妹妹穿的比我還像新娘。我一直安慰自己绍填,他們只是感情好萎坷,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,650評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著沐兰,像睡著了一般。 火紅的嫁衣襯著肌膚如雪蔽挠。 梳的紋絲不亂的頭發(fā)上住闯,一...
    開(kāi)封第一講書(shū)人閱讀 49,850評(píng)論 1 290
  • 那天瓜浸,我揣著相機(jī)與錄音,去河邊找鬼比原。 笑死插佛,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的量窘。 我是一名探鬼主播雇寇,決...
    沈念sama閱讀 39,006評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼蚌铜!你這毒婦竟也來(lái)了锨侯?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 37,747評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤冬殃,失蹤者是張志新(化名)和其女友劉穎囚痴,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體审葬,經(jīng)...
    沈念sama閱讀 44,207評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡深滚,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,536評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了涣觉。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片痴荐。...
    茶點(diǎn)故事閱讀 38,683評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖官册,靈堂內(nèi)的尸體忽然破棺而出生兆,到底是詐尸還是另有隱情,我是刑警寧澤攀隔,帶...
    沈念sama閱讀 34,342評(píng)論 4 330
  • 正文 年R本政府宣布皂贩,位于F島的核電站,受9級(jí)特大地震影響昆汹,放射性物質(zhì)發(fā)生泄漏明刷。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,964評(píng)論 3 315
  • 文/蒙蒙 一满粗、第九天 我趴在偏房一處隱蔽的房頂上張望辈末。 院中可真熱鬧,春花似錦映皆、人聲如沸挤聘。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,772評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)组去。三九已至,卻和暖如春步淹,著一層夾襖步出監(jiān)牢的瞬間从隆,已是汗流浹背诚撵。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,004評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留键闺,地道東北人寿烟。 一個(gè)月前我還...
    沈念sama閱讀 46,401評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像辛燥,于是被迫代替她去往敵國(guó)和親筛武。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,566評(píng)論 2 349

推薦閱讀更多精彩內(nèi)容