Answer for KodeKloud Question - Create a user with a specific ID

 For security reasons the xFusionCorp Industries security team has decided to use custom Apache users for each web application hosted, rather than its default user. This will be theApache user, so it shouldn't use the default home directory. Create the user as per requirements given below:

a. Create a user named yousuf on the App server 2 in Stratos Datacenter.
b. Set UID to 1701 and its home directory to /var/www/yousuf.


Answer:

ssh <user>@<server>

#swithc to root user
    sudo su 

#create a new user named username with UID of 1701 you would type:
    useradd -u 1701 yousuf

#after above user creation when we checked in /etc/passwd the default user home as 
/home/yousuf but as per the question we need to change its home directory to/var/www/yousuf
    
cat /etc/passwd | grep yousuf 


# Set home directory to /var/www/yousuf.
        usermod -d /var/www/yousuf -m yousuf

# To check 

    cat /etc/passwd | grep yousuf 


Note: Commands are correct but based on your question the server and user name, other details might differ so please do check.

No comments:

Post a Comment

Featured Post

Answer for Kodekloud DEVOPS Questions - Init container in Kubernetes

Question: 1. Create a Deployment named as ic-deploy-devops. 2. Configure spec as replicas should be 1 , labels app should be ic-devops , ...