作业一:
1) 新建用户natasha,uid为1000,gid为555,备注信息为“master”
groupadd -g 555 natasha
useradd -u 1000 -g 555 -c master natasha
id natasha 2) 修改natasha用户的家目录为/Natasha
cd /home
usermod -md /Natasha natasha 3) 查看用户信息配置文件的最后一行
tail -1 /etc/passwdtai 4) 为natasha用户设置密码“123”
echo '' | passwd --stdin natasha 5) 查看用户密码配置文件的最后一行
tail -1 /etc/shadow 6) 将natasha用户账户锁定
usermod -L natasha 7) 将natasha用户账户解锁
usermod -U natasha 8) 新建组police,gid为1999
groupadd -g 1999 police 9) 查看组配置文件的最后一行
tail -1 /etc/group 10) 将natasha用户加入police组
usermod natasha -a -G police 11) 修改police组的组名为jingcha
groupmod -n jingcha police 12) 删除natasha用户,连家目录和邮箱一起删除
userdel -r natasha 13) 删除jingcha组
groudel jingcha 作业二:
1) 在用户的主目录下创建目录test,进入test创建空文件file1
mkdir /test/
cd /test
touch file1 2) 以长格式形式显示文件信息,注意文件的权限和所属用户和组
ls -l file1 3) 为文件file1设置权限,使其他用户可以对此文件进行写操作。
chmod o=r file1 4) 查看设置结果
ls -l file1 5) 取消同组用户对文件file1的读取权限,并查看设置结果。
chmod g-r file1
ls -l file1 6) 用数字表示法为文件file设置权限,所有者可读、可写、可执行,所属组用户和其他用户只具有读和执行的权限。设置完成后查看设置结果。
chmod 755 file1
ls -l filel 7) 用数字形式更改文件file1的权限,使所有者只能读取此文件。其他任何用户都没有权限。查看设置结果。
chmod 400 file1
ls -l filel 8) 回到上层目录,查看test的权限
cd ..
ll -d /test 9) 为其他用户添加对此目录的写权限
chmod -R 0+w /test 作业三:
以操作文件的方式,新建一个用户alex
[root@localhost /]# vim /etc/passwd 添加内容:#alex:x:2001:1001:alex:/home/alex:/bin/bash
[root@localhost /]# vim /etc/shadow 添加内容:#alex:$6$5p8WDDqDOhrEhzbSNe.enZJpJZR387pc0::0:99999:7:::
[root@localhost /]# vim /etc/group 添加内容:#alex:x:1001:alex
[root@localhost /]# vim /etc/gshadow 添加内容:#alex:!!::alex
[root@localhost /]# mkdir /home/alex
[root@localhost /]# cp -r /etc/skel/.[!.]* /home/alex
[root@localhost /]# chown -R alex:alex /home/alex/
[root@localhost /]# touch /var/spool/mail/alex
[root@localhost /]# chown alex:mail /var/spool/mail/alex
[root@localhost /]# id alex
uid=2001(alex) gid=1001(alex) 组=1001(alex)
[root@localhost /]# 作业四:
1) 新建目录/test/dir,属主为tom,数组为group1,/test目录的权限为777
useradd tom
echo '' | passwd --stdin tom
groupadd group1
mkdir -p /test/dir
chown tom:group1 /test/dir
chmod 777 /test/ 2) 新建用户jack,切换到jack用户下,验证jack用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的others权限)
useradd jack
echo '' | passwd --stdin jack
su - jack
ll -d /test/dir
验证: 修改权限:
ll -d /test/dir chmod 0=- /test/dir
touch /test/dir/yanzheng.txt
cd /test/dir 3)将jack加入group1组,验证jack用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的group权限)
usermod jack -a -G group1
验证: 修改权限:
ll -d /test/dir chmod g+w /test/dir
rm /test/dir/yanzheng.txt
cd /test/dir 4)切换到tom用户,验证tom用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的user权限)
su - tom
验证:
ls /test/dir
touch /test/dir/yanzheng.txt
cd /test/dir 5)在dir目录内新建文件tom.txt,属主为tom,属组为group1,/test目录的权限为777
touch /test/dir/tom.txt
chown tom:group1 /test/dir/tom.txt
chmod 777 /test 6)新建用户rose,切换到rose用户下,验证rose用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的others权限来配合验证过程)
useradd rose
echo '' | passwd --stdin rose
su - rose
验证:
cat /test/dir/tom.txt
echo ''>> /test/dir/tom.txt
./test/dir/tom.txt
7)将rose加入group1组,在rose用户下,验证rose用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的group1权限来配合验证过程)
usermod rose -a -G group1
su - rose
验证:
cat /test/dir/tom.txt
echo ''>> /test/dir/tom.txt
./test/dir/tom.txt 8)切换到tom用户,验证tom用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的user权限来配合验证过程)
su - tom
验证:
cat /test/dir/tom.txt
echo ''>> /test/dir/tom.txt
./test/dir/tom.txt

Linux基础系列:常用命令(2)的更多相关文章

  1. Linux基础之常用命令整理(一)

    Linux 操作系统的安装 如今比较流线的linux操作系统 Centos Redhat  Fedora Ubuntu, 安装操作系统的提前是要有操作系统的镜像文件(.iso文件)并且必须为系统指定一 ...

  2. Linux基础、常用命令

    Linux作为IT程序员必知必会知识,将自己学习到的和最近工作常用的一些命令进行总结,作为我结束过去生活和开始类程序员的序吧! 如果你想系统性学习的话,还是建议看书(鸟哥的Linux私房菜)或网上视频 ...

  3. Linux基础之常用命令篇

    一.命令的基本格式 [root@localhost~] root为用户名 -表示当前所在位置 localhost主机名 ‘#’超级用户 '$" 普通用户 命令的基本格式: 命令 [选项] [ ...

  4. Linux基础之常用命令(1)

    一 linux命令的格式 1.命令  [选项]  [参数] ls  list    显示目录下内容 ①  命令名称:ls 命令英文原意:list 命令所在路径:/bin/ls 执行权限:所有用户 功能 ...

  5. Linux 压缩系列常用命令

    tar 命令: http://man.linuxde.net/tar zip 命令: http://man.linuxde.net/zip unzip 命令: http://man.linuxde.n ...

  6. Linux基础之常用命令整理(二)

    Linux系统启动流程 bios(找到启动介质) --> mbr(找到boot loader  512B 446引导信息 64分区信息 2 标志位 ) -->grub(选择操作系统或者内核 ...

  7. Linux基础和常用命令

    经常使用的命令: #查看端口被占用情况 netstat -tunlp|grep #查看java进程 ps -ef|grep java #压缩前端工程 rar a -ep1 ./update/win32 ...

  8. 【原创】Linux基础之常用命令

    1 磁盘.cpu.内存相关 查看全部设备信息 # lspci 查看整体磁盘空间占用情况 # df -h 查看整体磁盘inode占用情况 # df -i 查看文件详细信息 # ls -l $path 查 ...

  9. linux基础知识-常用命令

    ifconfig :查看当前ip hostname:查看主机名 vim /etc/hosts:修改地址映射 service iptables status : 查看防火墙状态 chkconfig ip ...

  10. 《Linux基础知识及命令》系列分享专栏

    <Linux基础知识及命令>系列分享专栏 本专题详细为大家讲解了Linux入门基础知识,思路清晰,简单易懂.本专题非常适合刚刚学习Linux的小白来学习,通过学习该专题会让你由入门达到中级 ...

随机推荐

  1. C++语言基础(4)-构造函数和析构函数

    一.构造函数 类似于java,C++中也有构造函数的概念,相关用法如下: 1.1 构造函数的定义 #include <iostream> using namespace std; clas ...

  2. 小程序swiper配置参数使用

    不管什么项目,一个轮播是基本少不了的,现在就来踩下微信小程序的swiper吧! 首先打开文档,可以看到下面这些参数:(https://mp.weixin.qq.com/debug/wxadoc/dev ...

  3. 如何获取wifi名称(SSID)

    @import SystemConfiguration.CaptiveNetwork; /** Returns first non-empty SSID network info dictionary ...

  4. socket心跳检测

    一.什么是心跳检测 判断对方(设备,进程或其它网元)是否正常动行,一般采用定时发送简单的通讯包,如果在指定时间段内未收到对方响应,则判断对方已经当掉.用于检测TCP的异常断开. 基本原因是服务器端不能 ...

  5. iOS开发之删除过期Provisioning Profiles方法

    1.在finder下打开go -> go to folder输入: ~/Library/MobileDevice/Provisioning Profiles 2.查看上面的列表,依照时间顺序删除 ...

  6. zeppelin部署

    1.下载解压2.修改conf/zeppelin-env.sh,添加如下两行 export ZEPPELIN_PORT= export MASTER=spark://master:7077 3.启动 b ...

  7. 【转】锤子CTO钱晨:福利好是一种堕落的公司文化

    “这是拉勾网对锤子科技CTO钱晨的访谈,作为中国手机界三大产品经理之一,他带领着一众硬件工程师在手机红海中厮杀.钱晨喜欢焦虑的工程师,佩服有方向感的人. 本文作者:西岳 拉勾网原创出品,转载请注明作者 ...

  8. JSP接口浅析

    一.tree型关系 JSP页面继承了org.apache.jasper.runtime.HttpJspBase抽象类并实现了org.apache.jasper.runtime.JspSourceDep ...

  9. MySQL的语法高级之SELECT

    1.语法:select 字段列表 from  子句 [where 子句][group by 子句][ order by 子句][having 子句][limit 子句]; 注解: 1.where子句对 ...

  10. scrapy 简介

    Scrapy是用纯Python实现一个为了爬取网站数据.提取结构性数据而编写的应用框架. Scrapy架构图(绿线是数据流向): Scrapy Engine(引擎): 负责Spider.ItemPip ...