如何批量修改自己账户home下的文件所有者和群组?
Tofloor
poster avatar
cxbii
deepin
2012-01-13 06:15
Author
我的管理员账户名字是cxbii
我已经新建了root账户,可以用root账户登陆
需要批量修改文件所有者和群组的目录为 /home/cxbii/ 下所有文件夹和文件
我需要批量把 /home/cxbii/ 下的所有文件和文件夹的所有者改为cxbii,群组也为cxbii
需要用到chown命令
可是具体怎么输入呢?
Reply Favorite View the author
All Replies
bsfmig
deepin
2012-01-13 06:24
#1
http://en.wikipedia.org/wiki/Chown
Usage examples

These examples illustrate typical syntax and use. Because chown modifies permissions, it usually requires root privilege to run.

    Change the owner of /var/run/httpd.pid to 'root' (the standard name for the Superuser).
  1. # chown root /var/run/httpd.pid
Copy the Code

    Change the owner of strace.log to 'rob' and the group identifier to 'developers'.
  1. # chown rob:developers strace.log
Copy the Code

    Change the owner of /tmp and /var/tmp to ‘nobody’ (not a good idea), and change the group of /tmp and /var/tmp to ‘nogroup’
  1. # chown nobody:nogroup /tmp /var/tmp
Copy the Code

    Change the group identifier of /home to 512 (regardless of whether a group name is associated with the identifier 512 or not).
  1. # chown :512 /home
Copy the Code

    Change the ownership of base to the user foouser and make it recursive (-R)
  1. # chown -R foouser base
Copy the Code

    Change the ownership to newuser and group to newgroup for all of the files and directories in current directory, and all subdirectories (recursively).
  1. # chown -R newuser:newgroup .
Copy the Code

http://linux.vbird.org/linux_basic/0210 ... .php#chown
Reply View the author
cxbii
deepin
2012-01-13 06:42
#2
http://en.wikipedia.org/wiki/Chown
[quote]
Usage examples

These examples illustrate typical syntax and use. Because chown modifies permissions, it usually requires root privilege to run.

    Change the owner of /var/run/httpd.pid to 'root' (the standard name for the Superuser).
  1. # chown root /var/run/httpd.pid
Copy the Code

    Change the owner of strace.log to 'rob' and the group identifier to 'developers'.
  1. # chown rob:developers strace.log
Copy the Code

    Change the owner of /tmp and /var/tmp to ‘nobody’ (not a good idea), and change the group of /tmp and /var/tmp to ‘nogroup’
  1. # chown nobody:nogroup /tmp /var/tmp
Copy the Code

    Change the group identifier of /home to 512 (regardless of whether a group name is associated with the identifier 512 or not).
  1. # chown :512 /home
Copy the Code

    Change the ownership of base to the user foouser and make it recursive (-R)
  1. # chown -R foouser base
Copy the Code

    Change the ownership to newuser and group to newgroup for all of the files and directories in current directory, and all subdirectories (recursively).
  1. # chown -R newuser:newgroup .
Copy the Code

http://linux.vbird.org/linux_basic/0210 ... .php#chown[/quote]
批量改变我上面说的目录所有文件所有者和群组是在终端输入
chown cxbii:cxbii /home
应该是我输错了吧?正确的是怎么输呢?
Reply View the author
bsfmig
deepin
2012-01-13 07:27
#3
chown -R cxbii:cxbii /home
Reply View the author
cxbii
deepin
2012-01-13 07:36
#4
chown -R cxbii:cxbii /home
ok!谢谢啦 :
Reply View the author
stephen
deepin
2012-01-13 16:00
#5
chown -R cxbii:cxbii /home

不要直接修改/home这个目录的权限,请修改$HOME这个目录。有些程序(例如ssh),会做强制的安全性检查,要求/home是root:root的。
Reply View the author
s.******[email protected]
deepin
2012-01-14 12:00
#6
chown -R

不过正如Stephen所说,你这样改是不正确的。
Reply View the author
New Thread

Popular Ranking

Change

Popular Events

More
国际排名
WHLUG