INTE2625 Week 3 Lab Manual
INTE2625 Week 3 Lab Manual
Objectives
In this Lab, you are going to learn some of the basics of Kali Linux user, directory, and file
management. You will find step-by-step instructions to perform several basic operations.
At the end of the Lab, we will learn the followings:
Giving sudo privilege to a user that has already been created.
Managing directories
Managing text files
Task-1: Giving sudo privilege to a user that has already been created.
In Week 2 lab, you have already learned how to create a user (say, alice). The user alice is not
allowed to do everything in the system by default. However, the user alice may need to do some
tasks (such as installing a new application, rebooting the system, updating the operating system
or an application, and many more which you will figure out later) as the user is created with
restricted privileges. To ensure that a new user can operate with improved efficiency, have
better user management, and get access to different tools, the user should be added to the
sudo group.
In Kali Linux and other Linux distributions, the sudo group is a collection of users who are
authorized to execute commands with elevated privileges, also known as root privileges. These
privileges allow users to perform actions that normally require being logged in as the root user,
the most powerful user on the system.
In this task, you will learn how to add a user into the sudo group.
Given that you have already created a user alice in the week 2 lab, check the user exists or not in
your system using the id username command as follows:
If the user exists, you should the see the user’s uid, gid, groups information as below:
You should not see any output if a user doesn’t exist. (Try for any random user name, say bob).
1
Now, we will add the user alice into the sudo group use the usermod command with the “-aG”
flag:
Here:
The permission is denied as adding a user to the sudo group is very risky. Only root user should
do it. Therefore, use sudo su command as follows to switch to the root user from kali:
Provide the password for kali user and you should see that the user mode has been changed to
root:
Type the usermod -aG sudo alice command again and press Enter:
Note: You may also do the above task from the user ‘kali’ by using the ‘sudo’ command as
follows:
2
Task-1.3: Check if the user has been added to ‘sudo’ group
Now, check if the user alice has been added to the sudo group with the command id alice:
The red rectangle highlights that the user alice is also a part of the sudo group. You may also
check the group of alice using the command groups alice:
In this task, you will learn how to create a text file in Kali linux. Although it seems simple, it will
give you an idea to create files in Kali linux. Moreover, you will need to create text files several
times in the future.
In this task, you will create a text file named ‘my_text_file.txt’ using the touch command. For
this task, we will assume that /home/kali as the present working directory. Hence, switch to
user kali from the current user:
It shows the list of current directories within the present working directory.
Now, touch command to create the file with name ‘my_text_file.txt’ as follows:
3
This command creates a new file named ‘my_text_file.txt’ in your current directory, if it doesn't
already exist. Check with the ls command again:
Now, run the following command to verify or see the contents of the file “my_text_file.txt”:
Alternatively, you may use any text editor (such as gedit, nano, or vim). You should explore
them by yourself.
In this task, you will learn how to create, rename, copy, move, and delete a directory in Kali
Linux.
In this task, we will create a directory named “Directory1” in the home directory
(/home/kali )of the user Kali. Check the current working directory as follows:
4
Check the current list of directories and files in the home directory using ls command:
Now, use mkdir directory_name to create a new directory. Replace the ‘directory_name’ with
Directory1:
Check the current list of directories and files in the home directory using ls command again:
Now, change the directory name from Directory1 to MyDirectory1 using mv command:
Here, the first parameter after mv is the old directory name and the second parameter is the new
directory name.
Use the ls command to check if the directory name has been changed or not:
Let’s say, we want to move the newly created directory MyDirectory1 from /home/kali to
/home/kali/Desktop. Use mv current_location new_location command as follows:
5
Check the current listing of the /home/kali using ls command:
MyDirectory1 is not in the current directory. Now, check the current listing of the
/home/kali/Desktop using ls command without changing the current location:
You have successfully moved the file. Here, you can replace ‘/home/kali’ with ‘~’ symbol as
both denote the path of the home directory. Try yourself!
Please note that the other directory names should be different in your system.
Here, the flag ‘-r’ indicates recursive copying. That is, cp command with copy the directory and
all its files and directories inside the directory MyDirectory1.
To delete a directory, you need to use the rmdir (remove directory) command as follows:
6
Check the listing with ls command:
Note: The above command removes an ‘empty’ directory only. To remove a ‘non-empty'
directory use ‘rm -r directory_name’ command.
Please explore this yourself. To do that, create a new directory and create a text file in the
directory. Now, deleting the new directory.