linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组。在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置。普通用户不能将自己的文件改变成其他的属主。其操作权限一般为管理员。

修改文件属主和属组:

[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 wanghan hx      4096 Aug 12 10:32 abe
drwxr-xr-x 2 root    wanghan 4096 Aug 12 10:32 xab
[[email protected]_168_102_centos ~]# chown root:root abe
[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 root root    4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab
[[email protected]_168_102_centos ~]# chown user1:wanghan abe
[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 user1 wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root  wanghan 4096 Aug 12 10:32 xab

仅修改文件属组:

[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 user1 wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root  wanghan 4096 Aug 12 10:32 xab
[[email protected]_168_102_centos ~]# chown :root abe
[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 user1 root    4096 Aug 12 10:32 abe
drwxr-xr-x 2 root  wanghan 4096 Aug 12 10:32 xab

修改文件属主且属组自动修改成其属主对应的属组

[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 user1 root    4096 Aug 12 10:32 abe
drwxr-xr-x 2 root  wanghan 4096 Aug 12 10:32 xab
[[email protected]_168_102_centos ~]# chown wanghan: abe
[[email protected]_168_102_centos ~]# ls -l
total 8
drwxr-xr-x 2 wanghan hx      4096 Aug 12 10:32 abe
drwxr-xr-x 2 root    wanghan 4096 Aug 12 10:32 xab

chown –R:递归处理文件的属主或属组

[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root    root       0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root    root       0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 wanghan wanghan 4096 Aug 11 15:52 ceshi
[[email protected]_168_102_centos tmp]# ls -l ceshi/
total 4
drwxr-xr-x 2 wanghan wanghan 4096 Aug 11 15:52 123
[[email protected]_168_102_centos tmp]# chown -R root:root ceshi/
[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 root root 4096 Aug 11 15:52 ceshi
[[email protected]_168_102_centos tmp]# ls -l ceshi/
total 4
drwxr-xr-x 2 root root 4096 Aug 11 15:52 123

#chgrp命令:修改文件属组

[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 root root 4096 Aug 11 15:52 ceshi
[[email protected]_168_102_centos tmp]# chgrp wanghan ceshi
[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root root       0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root root       0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 root wanghan 4096 Aug 11 15:52 ceshi

chgrp -R:递归处理

[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 root root 4096 Aug 11 15:52 ceshi
[[email protected]_168_102_centos tmp]# ls -l ceshi/
total 4
drwxr-xr-x 2 root root 4096 Aug 11 15:52 123
[[email protected]_168_102_centos tmp]# chgrp -R user1 ceshi/
[[email protected]_168_102_centos tmp]# ls -l
total 4
srwxrwxrwx 1 root root     0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root root     0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 3 root user1 4096 Aug 11 15:52 ceshi
[[email protected]_168_102_centos tmp]# ls -l ceshi/
total 4
drwxr-xr-x 2 root user1 4096 Aug 11 15:52 123

#chmod命令:

linux学习命令总结⑧

时间: 2024-10-29 19:13:26

linux学习命令总结⑧的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑨

#重定向 输出重定向: 1>覆盖输出(1可省略) [[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# ca

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录.文件夹.文件权限),查看目录信息等等 [[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot dev home lib64 media opt root selinux sys usr ls –a:显示所有文件,包含.开头的隐藏文件 [[email prot

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑩②

#fdisk命令:磁盘分区工具 fdisk –l:查看机器所挂硬盘个数及分区情况 [[email protected]_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

linux学习命令总结⑥

#文件名通配 通配符: *:匹配任意长度的任意字符(0到多个) [[email protected]_168_102_centos ~]# ls * 0812080808 2014-05-16: test.log ceshi_1: test: [[email protected]_168_102_centos ~]# ls -ld t* drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test ?:匹配任意单个字符 [[email protected]_1

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8