Devops Real Time Problem

 






1. Suppose you are going for the interview and interviewer ask you to write a shell script to add the users. At this point of time below example will help you.


Ans: adduser is a linux command which is used to add the user in the linux server.



Script:


#!/bin/bash


echo " Step 1:We will take the users from the file"

echo " Step 2:Create a txt file and add all the user name which you want to create"

echo " Step 3:Add user one by one using for loop"

for i in $(cat users.txt); do

echo "Adding user"

echo $i

sudo adduser $i

done


Output:


$ ./1.sh

Step 1:We will take the users from the file

Step 2:Create a txt file and add all the user name which you want to create

Step 3:Add user one by one using for loop

Adding user

a

Adding user

b

Adding user

c

For Python and Shell Scripting Tutorial
https://payhip.com/b/247HD
Free Demo Videos : https://www.youtube.com/channel/UCt2T23g4bLe0_NcuXqFdpkQ




Comments

Popular posts from this blog

Python & Shell Scripting Real Time Course Book & Videos

Top Five Devops Technical Interview QA Books

Linux-Command Hands-On (DF)