当前位置: 首页 > article >正文

Linux练习_2账户管理

题目描述1

建立用户组

[root@localhost ~]# groupadd -g 2000 shengchan
[root@localhost ~]# groupadd -g 2001 caiwu
[root@localhost ~]# groupadd -g 2002 jishu
[root@localhost ~]# tail -3 /etc/group
shengchan:x:2000:
caiwu:x:2001:
jishu:x:2002:
[root@localhost ~]# 

建立用户

[root@localhost ~]# useradd -g shengchan -G jishu,caiwu -u 2000 lee
[root@localhost ~]# useradd -r linux
[root@localhost ~]# useradd -G caiwu westos
[root@localhost ~]# useradd tabadmin
[root@localhost ~]# tail -4 /etc/passwd
lee:x:2000:2000::/home/lee:/bin/bash
linux:x:980:979::/home/linux:/bin/bash
westos:x:2001:2003::/home/westos:/bin/bash
tabadmin:x:2002:2004::/home/tabadmin:/bin/bash
[root@localhost ~]# 
[root@localhost ~]# id lee
uid=2000(lee) gid=2000(shengchan) groups=2000(shengchan),2001(caiwu),2002(jishu)
[root@localhost ~]# id westos
uid=2001(westos) gid=2003(westos) groups=2003(westos),2001(caiwu)
[root@localhost ~]# 

赋予tabadmin用户权限

[root@localhost ~]# visudo
visudo: /etc/sudoers.tmp unchanged
[root@localhost ~]# 

修改密码

[root@localhost ~]# echo westos | passwd --stdin lee
Changing password for user lee.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd -e lee
Expiring password for user lee.
passwd: Success
[root@localhost ~]# passwd -x 30 lee
Adjusting aging data for user lee.
passwd: Success
[root@localhost ~]# 
[root@localhost ~]# echo westos | passwd --stdin linux
Changing password for user linux.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd -e linux
Expiring password for user linux.
passwd: Success
[root@localhost ~]# passwd -x 30 linux
Adjusting aging data for user linux.
passwd: Success
[root@localhost ~]# 
[root@localhost ~]# echo westos | passwd --stdin westos
Changing password for user westos.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd -e westos
Expiring password for user westos.
passwd: Success
[root@localhost ~]# passwd -x 30 westos
Adjusting aging data for user westos.
passwd: Success
[root@localhost ~]# 
[root@localhost ~]# echo westos | passwd --stdin tabadmin
Changing password for user tabadmin.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd -e tabadmin
Expiring password for user tabadmin.
passwd: Success
[root@localhost ~]# passwd -x 30 tabadmin
Adjusting aging data for user tabadmin.
passwd: Success
[root@localhost ~]# 
[root@localhost ~]# tail -4 /etc/shadow
lee:$6$OEIx66YxRiFjEkmj$uQfZtCM16GPemUVyOYSpvn7MkV9aPeEGa9DRQU8kkfKwohhqTtjowDHlMXJDQ6nRWA8T9hYk7f1lNEeMfZuPX1:0:0:30:7:::
linux:$6$vT8vw6l9p3RnZquv$dzQ30aPzNmsG9u.wYtNPuCfUuqKBj62nzBdBluPWn35AJh6uNIp849SJkoeosJZNndr2gAlSCPAnnF0IbfWoT1:0::30::::
westos:$6$rvrvZor0jV.la/8e$WoL9tEdrKcNnxrcbYnDrxBJWXj6HAhRkywS.yDiQqByu0F66pdlS7mCdnTLwmfFinpJkbhoZFWgiBop3sAb7Z0:0:0:30:7:::
tabadmin:$6$2RHz.B657WFI5U5E$D0xBdt9heZqiTaTJMa.GLlS/InaZCZnKm1Y/w7pVhmBaESscE4aV5I2AoLvcoSMd1sZn.i73WolswP.ekfNpW.:0:0:30:7:::
[root@localhost ~]# 

题目描述2

建立目录

[root@localhost ~]# mkdir /sc
[root@localhost ~]# chown -R root:shengchan /sc/
[root@localhost ~]# chmod 2770 /sc
[root@localhost ~]# ls -ld /sc
drwxrws---. 2 root shengchan 6 Oct 27 18:06 /sc
[root@localhost ~]# 
[root@localhost ~]# mkdir /cw
[root@localhost ~]# chown -R root:caiwu /cw
[root@localhost ~]# chmod 2770 /cw
[root@localhost ~]# ls -ld /cw
drwxrws---. 2 root caiwu 6 Oct 27 18:09 /cw
[root@localhost ~]# 
[root@localhost ~]# mkdir /js
[root@localhost ~]# chown -R root:jishu /js
[root@localhost ~]# chmod 2770 /js
[root@localhost ~]# ls -ld /js
drwxrws---. 2 root jishu 6 Oct 27 18:10 /js
[root@localhost ~]# 
[root@localhost ~]# mkdir /pub
[root@localhost ~]# chmod 777 /pub
[root@localhost ~]# ls -ld /pub
drwxrwxrwx. 2 root root 6 Oct 27 18:12 /pub
[root@localhost ~]# 

 赋予tabadmin用户权限

[root@localhost ~]# visudo
visudo: /etc/sudoers.tmp unchanged
[root@localhost ~]# 


http://www.kler.cn/news/367741.html

相关文章:

  • 鸿蒙是必经之路
  • 【go】仅设想,能不能通过pure go编写页面。
  • Linux: Shell编程中的应用之基于sh脚本生成网页
  • 推荐15个 Vue 常用自定义指令,含实现原理与使用方式
  • 【AI换装整合及教程】CatVTON:时尚与科技的完美融合
  • Mybatis-03.入门-配置SQL提示
  • IPV6扩展头部
  • Verilog:参数(parameter)的使用
  • 嵌入式——STM32外设应用
  • 抖音列表页采集-爬虫部分(2)
  • B/S架构的诊所药店云his管理系统源码,云门诊管理系统,自主知识产权,支持二次开发
  • iOS Swift逆向——deMangle过程中的偏移计算
  • 算法|牛客网华为机试10-20C++
  • 学点高数-数学上的集合①-集合的基本概念
  • 学成在线实战
  • 机器学习 - 树结构1 - 随机森林
  • Spring Cloud --- Sentinel 规则持久化
  • YOLO11改进 | 卷积模块 | 卷积模块替换为选择性内核SKConv【附完整代码一键运行】
  • 设计模式概览
  • 手机拍证件照,换正装有领衣服及底色的方法
  • jenkins配置邮件通知
  • Flutter控制台提示setState() or markNeedsBuild() called during build错误
  • Linux中DNS搭建
  • GenAI 生态系统现状:不止大语言模型和向量数据库
  • Day 8 UE5c++
  • React实现购物车功能