Linux基础系列:常用命令(2)
作业一:
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)的更多相关文章
- Linux基础之常用命令整理(一)
Linux 操作系统的安装 如今比较流线的linux操作系统 Centos Redhat Fedora Ubuntu, 安装操作系统的提前是要有操作系统的镜像文件(.iso文件)并且必须为系统指定一 ...
- Linux基础、常用命令
Linux作为IT程序员必知必会知识,将自己学习到的和最近工作常用的一些命令进行总结,作为我结束过去生活和开始类程序员的序吧! 如果你想系统性学习的话,还是建议看书(鸟哥的Linux私房菜)或网上视频 ...
- Linux基础之常用命令篇
一.命令的基本格式 [root@localhost~] root为用户名 -表示当前所在位置 localhost主机名 ‘#’超级用户 '$" 普通用户 命令的基本格式: 命令 [选项] [ ...
- Linux基础之常用命令(1)
一 linux命令的格式 1.命令 [选项] [参数] ls list 显示目录下内容 ① 命令名称:ls 命令英文原意:list 命令所在路径:/bin/ls 执行权限:所有用户 功能 ...
- Linux 压缩系列常用命令
tar 命令: http://man.linuxde.net/tar zip 命令: http://man.linuxde.net/zip unzip 命令: http://man.linuxde.n ...
- Linux基础之常用命令整理(二)
Linux系统启动流程 bios(找到启动介质) --> mbr(找到boot loader 512B 446引导信息 64分区信息 2 标志位 ) -->grub(选择操作系统或者内核 ...
- Linux基础和常用命令
经常使用的命令: #查看端口被占用情况 netstat -tunlp|grep #查看java进程 ps -ef|grep java #压缩前端工程 rar a -ep1 ./update/win32 ...
- 【原创】Linux基础之常用命令
1 磁盘.cpu.内存相关 查看全部设备信息 # lspci 查看整体磁盘空间占用情况 # df -h 查看整体磁盘inode占用情况 # df -i 查看文件详细信息 # ls -l $path 查 ...
- linux基础知识-常用命令
ifconfig :查看当前ip hostname:查看主机名 vim /etc/hosts:修改地址映射 service iptables status : 查看防火墙状态 chkconfig ip ...
- 《Linux基础知识及命令》系列分享专栏
<Linux基础知识及命令>系列分享专栏 本专题详细为大家讲解了Linux入门基础知识,思路清晰,简单易懂.本专题非常适合刚刚学习Linux的小白来学习,通过学习该专题会让你由入门达到中级 ...
随机推荐
- Mat::operator =
Provides matrix assignment operators. C++: Mat& Mat::operator=(const Mat& m) C++: Mat& M ...
- SQL数据库 CRUD
1.删除表 drop table +表名 2.修改表 alter table+表名+ add(添加)+列名+ int(类型) alter table+表名+ drop(删除)+column(列) ...
- “Missing artifact....."的解决办法
在使用Maven开发时,总会碰到一些问题,例如"Missing artifact org.apache.commons:commons-csv:jar:1.0-SNAPSHOT", ...
- hibernate的helloworld实现
首先要新建一个 web project,然后新建一个lib的文件夹并导入相应的jar包 hibernate开发步骤: 1.创建hibernate配置文件 2.创建持久化类 3.创建对象关系映射文件 如 ...
- staticmethod classmethod修饰符
一.staticmethod(function) Return a static method for function.A static method does not receive an imp ...
- jQuery + Cookie引导客户操作
网址:http://www.sucaihuo.com/js/707.html 示例:http://www.sucaihuo.com/jquery/7/707/demo/
- android中TabHost和RadioGroup
android底部菜单应用 博客分类: android--UI示例 TabHostMenuRadioGroupButton 在android中实现菜单功能有多种方法. Options Menu:用户 ...
- 用MathType可以编辑n元乘积吗
在学习数学过程中很多的用户朋友会发现需要接触到各种数学符号.但是在编辑文档的时候很多的文档自带的符号往往不够全面,这个时候就需要专业的数学公式编辑器来解决这个问题.MathType就是在这种情况下诞生 ...
- IOS开发UI篇之──自定义加载等待框(MBProgressHUD)
本文转载至 http://blog.csdn.net/xunyn/article/details/8064984 原文地址http://www.189works.com/article-89289 ...
- jmGraph:一个基于html5的简单画图组件
jmGraph:一个基于html5的简单画图组件 特性: 代码书写简单易理解 面向对象的代码结构 对图形控件化 样式抽离 模块化:入seajs实现模块化开发 兼容性:暂只推荐支持html5的浏览器:i ...