Step by step approach of Linux task on creating a user by the KodeKloud Engineer Program:
Task:
a. Create a user named anita
on the App server 3 in Stratos Datacenter.
b. Set its UID to 1273 and home directory to /var/www/anita
.
Checkout this task's video here: https://youtu.be/y1h5dfqMU5Q
Step 1: Connect to App Server 3
SSH into App Server 3: Replace
username
with your user name on App Server 3 andapp_server_3_ip
with the server's IP address or hostname.sudo ssh username@app_server_3_ip
Enter your password to proceed.
Step 2: Switch to Root User
Root access is required for elevated privileges to execute sensitive commands.
sudo su -
(Enter your password )
Step 3: Create the User with a Specific UID
Create a new user with the specified UID (1550):
useradd -u 1273 anita
- This command creates a new user named 'anita' with the User ID (UID) of 1273.
Step 4: Create the Home Directory
Create the home directory for the user:
mkdir -p /var/www/anita
- The
-p
flag ensures that themkdir
command creates the necessary parent directories/var/www
if they don't already exist.
- The
Step 5: Assign the Home Directory to the User
Assign the newly created directory as the user's home directory:
usermod -d /var/www/anita anita
- This command modifies the user 'anita' to have a home directory at
/var/www/anita
.
- This command modifies the user 'anita' to have a home directory at
Step 6: Verify the User Creation
Check the details of the newly created user account:
id anita
- This command will display the user information including UID and groups.