Ask: permission can’t cross user directory limitation, even with sudo
# List all users
getent passwd
# or
cat /etc/passwd
# Search for a specific user
getent passwd | grep <username>
# List user belonging group
groups username
id -Gn username
# List all groups
getent group # or cat /etc/group
# List the group users
getent group <group_name>
id -u # This will display the current user's UID
id -g # This will display the current user's primary GID
id -u username # This will display the specified user's UID
id -g username # This will display the specified user's primary GID
Create A New User
sudo adduser <username>
sudo passwd <username>
Give The User sudo Privilege
# Use `visudo` command to open `Sudoers` file (/etc/sudoers), the command will open a vi editor.
sudo visudo
# After the `root ALL=(ALL:ALL) ALL` line, add the following line
<username> ALL=(ALL:ALL) ALL
Switch To The User
su - <username>
[apiuser@allma-expo ~]$ ls -al
total 28
drwx------ 3 apiuser apiuser 4096 May 16 17:33 .
drwxr-xr-x. 3 root root 4096 May 16 16:39 ..
-rw------- 1 apiuser apiuser 489 May 16 17:58 .bash_history
-rw-r--r-- 1 apiuser apiuser 18 Aug 3 2022 .bash_logout
-rw-r--r-- 1 apiuser apiuser 141 Aug 3 2022 .bash_profile
-rw-r--r-- 1 apiuser apiuser 376 Aug 3 2022 .bashrc
drwx------ 2 apiuser apiuser 4096 May 16 17:29 .ssh