1、  复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。

 

此题,先执行拷贝操作,然后执行更改目录及内部文件的权限操作。

1.执行拷贝操作

[root@centos ~]#cp -r /etc/skel/ /home/tuser1

2.查看拷贝操作完成情况

[root@centos ~]#ll -a /home/tuser1

总用量 16

drwxr-xr-x.  3 root root  74 8  26 00:11 .

drwxr-xr-x. 11root root 4096 8  26 00:11 ..

-rw-r--r--.  1 root root  18 8  26 00:11 .bash_logout

-rw-r--r--.  1 root root 193 8  26 00:11 .bash_profile

-rw-r--r--.  1 root root 231 8  26 00:11 .bashrc

drwxr-xr-x.  4 root root  37 8  26 00:11 .mozilla

3.执行更改目录及其内部文件权限操作

[root@centos ~]#chmod -R g=,o= /home/tuser1/

[root@centos ~]#ll -a /home/tuser1

总用量 16

drwx------.  3 root root  74 8  26 00:11 .

drwxr-xr-x. 11root root 4096 8  26 00:11 ..

-rw-------.  1 root root  18 8  26 00:11 .bash_logout

-rw-------.  1 root root 193 8  26 00:11 .bash_profile

-rw-------.  1 root root 231 8  26 00:11 .bashrc

drwx------.  4 root root  37 8  26 00:11 .mozilla

完成

 

2、  编辑/etc/group文件,添加组hadoop

1.vim 打开此文件

[root@centos ~]#vim /etc/group                

2.在编辑模式下按I,进入输入模式

3.在文件的最后输入

hadoop:x:3005:

4.在输入模式按ESC键退回到编辑模式,再按”:” 进入末行模式,

5.输入wq,保存并退出。

3、  手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组IDhadoop组的id号;其家目录为/home/hadoop

 

1.vim 打开此文件

[root@centos ~]# vim /etc/passwd

2.在编辑模式下按I,进入输入模式

3.在文件的最后输入

hadoop:x:3005:3005::/home/hadoop:/bin/bash

4.在输入模式按ESC键退回到编辑模式,再按”:进入末行模式,

5.输入wq,保存并退出。

 

4、  复制/etc/skel目录为/home/hadoop,要求修改hadoop目录的属组和其它用户没有任何访问权限。

 

 此题,先执行拷贝操作,然后执行更改此目录的权限操作。

1.执行拷贝操作

[root@centos ~]#cp -r /etc/skel/ /home/hadoop

2.查看拷贝操作完成情况

[root@centos ~]#ll -a /home/hadoop

总用量 16

drwxr-xr-x.  3 root root  74 8  26 00:11 .

drwxr-xr-x. 11root root 4096 8  26 00:11 ..

-rw-r--r--.  1 root root  18 8  26 00:11 .bash_logout

-rw-r--r--.  1 root root 193 8  26 00:11 .bash_profile

-rw-r--r--.  1 root root 231 8  26 00:11 .bashrc

drwxr-xr-x.  4 root root  37 8  26 00:11 .mozilla

3.执行更改目录权限操作。

[root@centos ~]#chmod  g=,o= /home/hadoop/

[root@centos ~]#ll -a /home/hadoop/

总用量 16

drwx------.  3 root root  74 8  26 00:44 .

drwxr-xr-x. 12root root 4096 8  26 00:44 ..

-rw-r--r--.  1 root root  18 8  26 00:44 .bash_logout

-rw-r--r--.  1 root root 193 8  26 00:44 .bash_profile

-rw-r--r--.  1 root root 231 8  26 00:44 .bashrc

drwxr-xr-x.  4 root root  37 8  26 00:44 .mozilla

完成

 

5、  修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop

 

[root@centos ~]#chown -R hadoop:hadoop /home/hadoop/

[root@centos ~]#ll -a /home/hadoop/

总用量 16

drwx------.  3 hadoop hadoop    74 8  26 00:44 .

drwxr-xr-x. 12root root 4096 8  26 00:44 ..

-rw-r--r--.  1 hadoop hadoop    18 8  26 00:44 .bash_logout

-rw-r--r--.  1 hadoop hadoop   193 8  26 00:44 .bash_profile

-rw-r--r--.  1 hadoop hadoop   231 8  26 00:44 .bashrc

drwxr-xr-x.  4 hadoop hadoop    37 8  26 00:44 .mozilla

 

6、  显示/proc/meminfo文件中以大写或小写S开头的行;用两种方式;

方式1

[root@centos ~]#grep ^[S,s] /proc/meminfo

SwapCached:            0 kB

SwapTotal:       4194300 kB

SwapFree:        4194300 kB

Shmem:              9248 kB

Slab:              77920 kB

SReclaimable:      30100 kB

SUnreclaim:        47820 kB

  方式2

[root@centsOS ~]#grep -i "^s" /proc/meminfo

SwapCached:            0 kB

SwapTotal:       4194300 kB

SwapFree:        4194300 kB

Shmem:              9248 kB

Slab:              77920 kB

SReclaimable:      30100 kB

SUnreclaim:        47820 kB

 

7、  显示/etc/passwd文件中其默认shell为非/sbin/nologin的用户;

 

Linux基础(4)_用户

8、  显示/etc/passwd文件中其默认shell/bin/bash的用户;

 

Linux基础(4)_Linux_02

 

 

9、  找出/etc/passwd文件中的一位数或两位数;


Linux基础(4)_用户_03

 

 

 

10、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;


Linux基础(4)_Linux_04

 

11、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;

 

[root@CentsOS ~]#grep "^#[[:space:]]\+[^[:space:]]" /etc/rc.d/rc.sysinit

#/etc/rc.d/rc.sysinit - run once at boot time

# Taken in partfrom Miquel van Smoorenburg's bcheckrc.

# Check SELinuxstatus

# Print a textbanner.

# Only read thisonce.

# Initializehardware

# Set defaultaffinity

# Load otheruser-defined modules

# Load modules(for backward compatibility with VARs)

# Configurekernel parameters

# Set thehostname.

# Sync waitingfor storage.

# Device mapper& related initialization

# Start any MDRAID arrays that haven't been started yet

# Remount theroot filesystem read-write.

# Clean upSELinux labels

# If relabeling,relabel mount points.

# Mount all otherfilesystems (except for NFS and /proc, which is already

# mounted).Contrary to standard usage,

# filesystems areNOT unmounted in single user mode.

# Update quotasif necessary

# Check to see ifa full relabel is needed

# Initializepseudo-random number generator

# Configuremachine if necessary.

# Clean out /.

# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin m

# Clean up /var.

# Clean uputmp/wtmp

# Clean upvarious /tmp bits

# Make ICEdirectory

# Start upswapping.

# Set upbinfmt_misc

# Boot timeprofiles. Yes, this should be somewhere else.

# Now that wehave all of our basic modules loaded and the kernel going,

# let's dump thesyslog ring somewhere so we can find it later

# create thecrash indicator flag to warn on crashes, offer fsck with timeout

# Let rhgb knowthat we're leaving rc.sysinit

 

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

 

Linux基础(4)_Linux_05

 

13、添加用户bash,testbash, basher, nologin (此一个用户的shell/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;

 

1、  添加用户

[root@CentsOS ~]# useradd bash

[root@CentsOS ~]# useradd testbash

[root@CentsOS ~]# useradd basher

[root@CentsOS ~]# useradd nologin –s /sbin/noligin

2、查看添加用户情况。

[root@CentsOS ~]# cat /etc/passwd

bash:x:501:501::/home/bash:/bin/bash

testbash:x:502:502::/home/testbash:/bin/bash

basher:x:503:503::/home/basher:/bin/bash

nologin:x:504:504::/home/nologin:/sbin/nologin

3、过滤出其用户名与默认SHELL相同的用户的信息。

[root@CentsOS ~]# 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:501:501::/home/bash:/bin/bash

nologin:x:504:504::/home/nologin:/sbin/nologin