红联Linux门户
Linux帮助

在挂载的目录下 如何使 文件或目录的属主 变成 创建者的

发布时间:2011-01-12 15:26:41来源:红联作者:fujiefujie
谁知道啊
文章评论

共有 6 条评论

  1. fujiefujie 于 2011-01-13 01:48:36发表:

    3Q

  2. fujiefujie 于 2011-01-13 01:48:03发表:

    谢了 还有就是
    挂载目录下的属主 也可以是多个人吧
    要是同时 在挂载目录 下建立 多个用户的文件夹 再用 -o 分别挂载的话 只要指定不同的文件夹就行了吧

  3. fujiefujie 于 2011-01-13 01:41:30发表:

    发现 root挂载目录 的属主始终是 root(尽管用-o 修改属主)
    当新用户建立该挂载目录 下的 一个 新的文件夹或文件时 属主 就改成 指定的了 用户了

  4. fujiefujie 于 2011-01-13 01:35:28发表:

    以下是我的实验过程:
    [root@localhost /]# useradd ggg
    [root@localhost /]# passwd ggg
    Changing password for user ggg.
    New UNIX password:
    BAD PASSWORD: it is WAY too short
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
    [root@localhost /]# tail -1 /etc/passwd
    ggg:x:502:502::/home/ggg:/bin/bash
    [root@localhost /]# mkdir ggg
    [root@localhost /]# ls ./
    bin etc lib misc net root srv tmp var
    boot ggg lost+found mmm opt sbin sys ttt
    dev home media mnt proc selinux tftpboot usr
    [root@localhost /]# chmod 777 ggg
    [root@localhost /]# ls -ld /ggg
    drwxrwxrwx 2 root root 4096 01-13 01:28 /ggg
    [root@localhost /]# mount -o uid=501,gid=501 /dev/web/web_v1 /ggg
    [root@localhost /]# cd ggg
    [root@localhost ggg]# ls -ld ./
    drwxrwxrwx 4 root root 4096 01-13 01:25 ./
    [root@localhost ggg]# su sunyu
    [sunyu@localhost ggg]$ ls -ld ./
    drwxrwxrwx 4 root root 4096 01-13 01:25 ./
    [sunyu@localhost ggg]$ cd /
    [sunyu@localhost /]$ ls -ld /ggg
    drwxrwxrwx 4 root root 4096 01-13 01:25 /ggg
    [sunyu@localhost /]$ cd ggg
    [sunyu@localhost ggg]$ mkdir ggg
    [sunyu@localhost ggg]$ ls -ld ggg
    drwxrwxr-x 2 sunyu sunyu 4096 01-13 01:32 ggg
    [sunyu@localhost ggg]$ cd ggg
    [sunyu@localhost ggg]$ touch ggg
    [sunyu@localhost ggg]$ ls
    ggg
    [sunyu@localhost ggg]$ ls -l ggg
    -rw-rw-r-- 1 sunyu sunyu 0 01-13 01:32 ggg
    [sunyu@localhost ggg]$

  5. fujiefujie 于 2011-01-13 01:26:37发表:

    重新把这个问题整理一下 可能没阐述明白
    就是 怎么样 能使 任意用户 创建的文件或目录 的属主和属组 为 创建者
    当然 前提是 不是通过修改用户权限

    上楼说的mount 参数 -o 指定 gid 和 uid




    uid=value and gid=value
    Set the owner and group of the files in the file system
    (default: uid=gid=0).
    是这个命令吧
    好像 就这么招 就行了

  6. 相思爱文 于 2011-01-12 20:50:47发表:

    没看明白什么意思

    挂载目录,可指明uid和gid。如mount -o uid=1000,gid=1000
    可以用root把父目录用chown改变属主