Mastering Linux
< Previous Solution - Home - Next Solution >
student@vm01:~$ for name in marketing finance apps production; do sudo groupadd ${name}; done
Create the users below with the given characteristics:
student@vm01:~$ sudo useradd -c "Anna" -d /home/anna -m -s /bin/bash -g marketing anna
student@vm01:~$ sudo useradd -c "Mary" -d /home/mary -m -s /bin/bash -g finance mary
student@vm01:~$ sudo useradd -c "Peter" -d /home/peter -m -s /bin/bash -g apps peter
student@vm01:~$ sudo useradd -c "Rick" -d /home/rick -m -s /bin/bash -g production rick
Another way to create:
student@vm01:~$ for usr in anna:marketing mary:finance peter:apps rick:prouction; do
login=$(echo $usr | cut -d: -f1)
group=$(echo $usr | cut -d: -f2)
sudo useradd -c "$login" -d /home/$login -m -s /bin/bash -g $group $login
done
Create passwords for all users
student@vm01:~$ sudo passwd anna
student@vm01:~$ sudo passwd mary
student@vm01:~$ sudo passwd peter
student@vm01:~$ sudo passwd rick