设为首页 收藏本站
查看: 3057|回复: 0

[经验分享] Linux基础(4)

[复制链接]

尚未签到

发表于 2018-5-19 12:58:21 | 显示全部楼层 |阅读模式
  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的用户;

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


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

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

DSC0003.png

  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’,后或跟空白字符结尾的行;
  
DSC0004.png
  
  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
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-462011-1-1.html 上篇帖子: Linux作业5 下篇帖子: LINUX作业( 四)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表