Help Center > > Best Practices> Creating a Readable and Writable Subdirectory on the File System for a Common User> Creating a Readable and Writable Subdirectory on the File System for Each User

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

Updated at: Jul 01, 2019 GMT+08:00

Prerequisites

Procedure

  1. Log in to the ECS as user root.
  2. Run the following command to add a common user under the root account. In the following figure, 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. After adding common user Tom successfully, 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 a 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 creation is complete, run the following command 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 figure 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, cn-north-1b 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.cn-north-1b.myhuaweicloud.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

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel