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