首页 > 编程知识 正文

linux文件夹权限修改,linux查看文件权限

时间:2023-05-05 14:59:26 阅读:172514 作者:2522

linux-命令权限

1 )新用户natasha、uid1000、GID555,备注信息为“master”

2 )将natasha用户的主目录更改为/Natasha

3 )显示用户信息配置文件的最后一行

4 )设置natasha用户的密码“123”

5 )显示用户密码配置文件的最后一行

6 )锁定natasha用户帐户

解除锁定natasha用户帐户

7 )新组police,gid为999

显示组配置文件的最后一行

8 )让natasha用户加入police组

9 )将police组的组名更改为jingcha

10 )删除natasha用户,并按主目录和邮箱删除

userdelr natasha

11 )删除京查组

1 )在用户的主目录下创建目录test,进入test创建空文件file1

[root@bogon ~]# mkdir test

[root@ bogon ~]# cd test/

[root@ bogon test]# touch file1

2 )以长格式显示文件信息,注意文件权限及所属用户和组

[root@ bogon test]# ls -l

总0

-rw-r----r----1路由0mar1516336024file1

3 )将权限设置为文件file1,以便其他用户可以写入此文件。

[root@ bogon test]# chmod 666 file1

4 )查看安装结果

[root@ bogon test]# ls -l

-rw-rw-rw-1根0 mar 1516336024文件1

5 )取消同一组的用户对文件file1的读取权限,确认设定结果。

[root@ bogon test]# chmod g-w file1

[root@ bogon test]# ls -l

-rw-r--rw-1根0 mar 1516336024文件1

6 )用数字格式对文件file设置权限,所有者可以读写,所属组用户和其他用户只有读写权限。 设定完成后,确认设定结果。

[root@ bogon test]# chmod 755 file1

[root@ bogon test]# ls -l

-rwxr-xr-x1根0 mar 1516336024文件1

7 )用数字更改文件file1的权限,使所有者只能读取该文件。 其他用户没有权限。 查看设置结果。

[root@ bogon test]# chmod 400 file1

[root@ bogon test]# ls -l

----1根根根0 mar 1516336024文件1

8 )返回上级目录,查看test权限

[root@ bogon test]# cd光盘.

[root@ bogon ~]# ls -ld test

rwxr-xr-x2 root root 4096 mar 1516336024 test

9 )向其他用户添加对该目录的写入权限

[root@ bogon ~]# chmod -R g w test

[root@ bogon ~]# ls -ld test

rwxrwxr-x2 root root 4096 mar 1516336024 test

1 )以操作文件的方式,新建用户的现实丝袜

tail -1 /etc/passwd

现实连裤袜: x :101033601010336033603360/home /现实连裤袜:/bin/bash

tail -1 /etc/shadow

现实中的长筒袜:17240:0:99999:7:

tail -1 /etc/group

现实中的长筒袜:x:1010:

tail -1 /etc/gshadow

现实中的长筒袜:

mkdir /home/现实的丝袜

cp -r /etc/skel/.[!.]* /home/现实的丝袜/

chown -R 现实的丝袜.现实的丝袜 /home/现实的丝袜/

touch /var/spool/mail/现实的丝袜

chown -R 现实的丝袜.mail /var/spool/mail/现实的丝袜

1) 新建目录/test/dir,属主为tom,数组为group1,/test目录的权限为777

mkdir -p /test/dir

useradd tom

groupadd group1

chown tom.group1 /test/dir

chmod 777 /test/

2) 新建用户jack,切换到jack用户下,验证jack用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的others权限)

useradd jack

[root@bogon test]#chmod o=rw /test/dir

[root@bogon test]# ls –ld /test/dir

Drwxr-xrw-. 2 tom group1 6 3月   15  18:06 /test/dir

su - jack

3)将jack加入group1组,验证jack用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的group权限

4)切换到tom用户,验证tom用户对dir目录的rwx权限(开启另外一个终端,依次修改dir目录的user权限)

5)在dir目录内新建文件tom.txt,属主为tom,属组为group1,/test目录的权限为777

[root@bogon dir]# chown tom.group1 tom.txt

[root@bogo dir]# chmod 777 tom.txt

[root@bogo dir]# ls -l tom.txt

-rwxrwxrwx 1 tom group1 11 Mar 15 17:27 tom.txt

6)新建用户rose,切换到rose用户下,验证rose用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的others权限来配合验证过程)

(1)rwx权限

[rose@bogo dir]$ ls -l tom.txt

-rwxrwxrwx 1 tom group1 11 Mar 15 17:27 tom.txt

[rose@bogo dir]$ cat tom.txt

echo "tom"

[rose@bogo dir]$ vim tom.txt

(2)rw权限

[root@bogo dir]# chmod 776 tom.txt

[root@bogo dir]# ls -l tom.txt

-rwxrwxrw- 1 tom group1 12 Mar 15 17:31 tom.txt

7)将rose加入group1组,在rose用户下,验证rose用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的group1权限来配合验证过程)

8)切换到tom用户,验证tom用户对tom.txt的rwx权限(开启另外一个终端,依次修改tom.txt的user权限来配合验证过程)

9。linux 下查看当前用户

使用who命令可以查看当前登录用户,使用w命令可以看到所有登录用户信息。

1、命令who

显示当前登录用户,登录时间和登录IP地址。参考下图

2、命令w

按照标题显示:当前时间、机器运行时间、登录用户数量、系统负载信息。

10.分派IP地址:

[root@bogon /]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet

BOOTPROTO=static

DEVICE=eth0

IPADDR=

192.168.2.4 

NETMASK=

255.255.255.0 

GATEWAY=

192.168.2.10 

ONBOOT=yes

11.Centos修改root密码

[root@localhost ~]# passwd

Changing password for user root.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

11.直接把包拉到虚拟机(yum install  lrzsz)

12.

#Linux:

#建文件:

# touch /tep/a.txt

#动态监测文件变化:

#tail -f /tep/a.txt

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。