Updated on 2022-12-09 GMT+08:00

Creating a Readable and Writable Subdirectory on the File System for Each User

Prerequisites

Procedure

  1. Log in to the ECS as user root.
  2. Run the following commands to add a common user under the root account. User Tom is added as an example.

    adduser Tom
    passwd Tom

    Change the password of common user Tom as prompted. After the user is created, the home directory /home/Tom is automatically created.

  3. Run the following command in the local directory of the root user to create a subdirectory.

    According to 4 in Creating a Local Directory for a File System, the local directory of the root user is root001. Run the following command to create subdirectory Tom for common user Tom. Replace root001 with the actual local directory.

    mkdir /root/root001/Tom

  4. Run the following command to assign the read and write permissions of subdirectory Tom to common user Tom. Replace root001 with the actual local directory.

    chown Tom:Tom /root/root001/Tom

    After the subdirectory is created, run the following commands to check whether common user Tom has the read and write permissions on subdirectory Tom. See Figure 1.

    cd /home
    cd /root/root001
    ll
    Figure 1 Checking the permissions

    The preceding command output indicates that user Tom has obtained the read and write permissions on subdirectory Tom.

  5. Run the mount command to mount subdirectory root001/Tom to the home directory of Tom, /home/Tom. In the following command, xx-xxxxx-xx needs to be replaced with the region where the file system is located, and share-xxxx needs to be replaced with the actual file system. The first Tom needs to be replaced with the actual subdirectory name. See Figure 2.

    mount -t nfs sfs-nas1.xx-xxxxx-xx.xxxxxxxxxx.com:/share-xxxx/Tom /home/Tom
    Figure 2 Mounting the subdirectory

    Run the following command to check whether the subdirectory has been mounted to the home directory of Tom. See Figure 3.

    df -h
    Figure 3 Checking the mounting result