1] Create a user with your name and set uid as 1234, comment as student, primary group as
apache, secondary group as BCA. Set the password as [email protected] Check the result.
Solution: -
$ su
Password:
# groupadd apache
# grep apache /etc/group
apache:x:1004:
# useradd -u 1234 -c student test_user
# grep test_user /etc/passwd
test_user:x:1234:1234:student:/home/test_user:/bin/bash
# groupadd BCA
# grep BCA /etc/group
BCA:x:1235:
# gpasswd -M test_user apache
# gpasswd -M test_user BCA
# grep BCA /etc/group
BCA:x:1235:test_user
# passwd test_user
Changing password for user test_user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2. Create three files with single command. Create one directory as /data move all these files to
this directory.
Solution: -
# touch file1 file2 file3
# mkdir /data
# mv file1 file2 file3 /data
---------------------------------------------------------------Cut-------------------------------------------------------
1] Create user with your name with uid as 3000, primary group as apache, secondary group as
MCA and comment as user. Set the password as [email protected].
Solution: -
$ su
Password:
# groupadd apache
# grep apache /etc/group
apache:x:1004:
# useradd -u 3000 -c user test_user
# grep test_user /etc/passwd
test_user:x:3000:3000:student:/home/test_user:/bin/bash
# groupadd MCA
# grep MCA /etc/group
MCA:x:1235:
# gpasswd -M test_user apache
# gpasswd -M test_user MCA
# grep MCA /etc/group
MCA:x:1235:test_user
# passwd test_user
Changing password for user test_user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2. Take the backup of /boot directory using tar command in a file boot.tar.gz. Use appropriate
options of tar command.
Solution: -
# tar cvzf boot.tar.gz /boot
# ls -ld boot.tar.gz
-rw-r--r--. 1 root root 143554337 Jan 1 19:05 boot.tar.gz
---------------------------------------------------------------Cut-------------------------------------------------------
1. View the IP address of your machine. Set the new IP address as 10.10.1.100 to it and show
the result.
Solution: -
# ifconfig
Assuming eth0 is the interface name
Save old IP information
# ifconfig eth0 > Old_IP_Address
Assign new IP
# ifconfig eth0 add 128.10.10.10 netmask 255.255.255.255
Verify results
#ping 128.10.10.10
2. Create user with your name set uid as 6000, comment as Manager and shell as /bin/nologin. Set
the password as [email protected]
Solution: -
# useradd -u 6000 -c Manager DemoUser
# grep DemoUser /etc/passwd
DemoUser:x:6000:6000:Manager:/home/DemoUser:/bin/bash
# usermod DemoUser -s /sbin/nologin
# grep DemoUser /etc/passwd
DemoUser:x:6000:6000:Manager:/home/DemoUser: /sbin/nologin
# passwd DemoUser
Changing password for user DemoUser
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
---------------------------------------------------------------Cut-------------------------------------------------------
1. Create associated directory structure as /data/data1/data2/data3 with single command. Change
the group ownership of these directories to apache group and show the result.
Solution: -
#mkdir -p data/data1/data2/data3
# tree data
data
└── data1
└── data2
└── data3
#groupadd apache
# grep apache /etc/group
apache:x:1004:test_user
# chgrp -c apache data
changed group of ‘data’ from root to apache
# ls -ld data
drwxr-xr-x. 3 root apache 19 Jan 1 21:26 data
# cd data
# chgrp -c apache data1
changed group of ‘data1’ from root to apache
# cd data1
# chgrp -c apache data2
changed group of ‘data2’ from root to apache
# cd data2
# chgrp -c apache data3
changed group of ‘data3’ from root to apache
2. Create three files with single command. Create any three directories. Copy each file in each of
these directories.
Solution: -
:/mnt/c/Users/Admin$ touch file1 file2 file3
:/mnt/c/Users/Admin$ mkdir -p storage/storage1/storage2
:/mnt/c/Users/Admin$ tree storage
storage
└── storage1
└── storage2
2 directories, 0 files
:/mnt/c/Users/Admin$ cp file1 file2 file3 storage
:/mnt/c/Users/Admin$ cd storage
:/mnt/c/Users/Admin/storage$ ls
file1 file2 file3 storage1
:/mnt/c/Users/Admin/storage$ cp file1 file2 file3 storage1
:/mnt/c/Users/Admin/storage$ cd storage1
:/mnt/c/Users/Admin/storage/storage1$ ls
file1 file2 file3 storage2
:/mnt/c/Users/Admin/storage/storage1$ cp file1 file2 file3 storage2
:/mnt/c/Users/Admin/storage/storage1$cd storage2
:/mnt/c/Users/Admin/storage/storage1/storage2$ ls
file1 file2 file3
---------------------------------------------------------------Cut-------------------------------------------------------
1. Create a directory as /BCADATA. Copy files from /boot directory to it. Take the backup of
/BCADATA into bcadatabackup.tar.bz2 using tar command. Use appropriate options of tar.
Solution: -
# mkdir /BCADATA
# cp -a /boot /BCADATA
# tar cvzf bcadatabackup.tar.gz /BCADATA
2. Create a group as TMV1000. Create one user with your name, set password. Add this user as
a member of group TMV1000.
Solution: -
# groupadd TMV1000
# grep TMV1000 /etc/group
TMV1000:x:6001:
# useradd user1
# passwd user1
Changing password for user user1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# gpasswd -M user1 TMV1000
# grep TMV1000 /etc/group
TMV1000:x:6001:user1
---------------------------------------------------------------Cut-------------------------------------------------------
1. Create a user with your name with uid as 5000, comment as Manager. Set a blank password to
it and test the user login.
Solution: -
# useradd -u 5000 -c “Manager” user2
# grep user2 /etc/passwd
user2:x:5000:5000:“Manager”:/home/user2:/bin/bash
# passwd -f -u user2
Unlocking password for user user2.
passwd: Success
# su user2
$
2. Take the backup of /etc folder into etc.tar.gz file using tar command. Use proper options of
tar.
Solution: -
# tar cvzf etc.tar.gz /etc
# ls -ld etc.tar.gz
-rw-r--r--. 1 root root 13496991 Jan 1 22:09 etc.tar.gz
*****************************************************************************