This topic describes how to create a regular user and grant sudo privileges to the user.
If you are an individual user, you can deploy the cluster as the root user and skip this step. If you are an enterprise user, we recommend that you create a regular user on the machine to ensure security. You can create your commonly used account as needed.
Note
You must perform this operation on each machine.
Follow these steps to create a user. The following example creates a user named admin.
Run the following command to create the admin account.
[root@test001 ~]# useradd -U admin -d /home/admin -s /bin/bash [root@test001 ~]# chown -R admin:admin /home/adminRun the following command to set a password for the admin account.
[root@test001 ~]# passwd admin(Optional) Grant sudo privileges to the admin account.
Run the following command to open the
/etc/sudoersfile:[root@test001 ~]# vim /etc/sudoersAdd the following line at the end of the
/etc/sudoersfile:## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL admin ALL=(ALL) NOPASSWD: ALLRun the following command to check the permissions of the cluster-related file directories.
This example uses the
datadirectory:[root@test001 data]# ls -alThe expected output is as follows:
drwxr-xr-x 2 admin admin 4096 Feb 9 18:43 . drwxr-xr-x 2 admin admin 4096 Feb 9 18:43 log1If the
adminuser does not have the required permissions for the related files after checking the directory permissions, you can run the following command to change the file owner:[root@test001 ~]# chown -R admin:admin /data [root@test001 ~]# chown -R admin:admin /redoHere,
/dataand/redoare example mount directories. You need to replace them with your actual mount directories.
