Before providing with you resolution of above error, remember this case is for providing sudo access to new user which actually can be security risk if you are working in production enviornment. Do consult with you infosecurity team if new user really need sudo access.
I am assuming here that you are already aware of how to create new user and set password for it.
Solution
Linux assign permission to different users or groups to run read-only or admin commands via sudoers file. You may find this file on path /etc/sudoers. Content of this file are only accesible for root user, and you may not be able to view or change it unless you are having admin rights yourself.
To resolve issue, you may either add permission to your new user in this file or check existing groups which have sudo rights, and simply add your user part of that group.
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
Standard IAM policy rule, irrespective of end system, follow latter, i.e. making your new user part of admin or sudo group in this case, instead of changing rule for each new user.
Analyzing above file, I found there is a group “wheel” present, which allow users part of it to run all commands. So I will simply add my new user in this group.
usermod -aG wheel dev #dev --> username
Now I am able to run sudo commands using new user.
[dev@terraform ~]$ sudo su
[sudo] password for dev:
[root@terraform dev]#