Creating a Readable and Writable Subdirectory on the File System for Each User
- A file system has been created and can be mounted to the ECS by the root user. For details, see Creating a Local Directory for a File System.
- You have obtained the shared path of the file system.
- Log in to the ECS as user root.
- 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.
- 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.
- 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
The preceding figure indicates that user Tom has obtained the read and write permissions on subdirectory Tom.
- 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
Run the following command to check whether the subdirectory has been mounted to the home directory of Tom. See Figure 3.