0% found this document useful (0 votes)
22 views7 pages

INTE2625 Week 3 Lab Manual

Uploaded by

SaidurRahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views7 pages

INTE2625 Week 3 Lab Manual

Uploaded by

SaidurRahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

INTE2625 Introduction to Cyber Security

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.

Task-1.1: Check if the user exists

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).

Task-1.2: Add the user into ‘sudo’ group

1
Now, we will add the user alice into the sudo group use the usermod command with the “-aG”
flag:

Here:

usermod: This command modifies existing user accounts.


-aG: ‘a’ denotes ‘add’ and ‘G’ denotes ‘group’. This flag tells usermod to add the user to an
existing group.
sudo: This is the name of the sudo group in Kali Linux.
alice: usename of the user to be added to sudo group.

You should see the following:

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:

The user alice has been added to the sudo group.

Task-2: Managing text files

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.

Task 2.1: create a ‘TEXT’ file

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:

Now, type pwd command to check the present working directory:

Check the current contents of the current directory using ls command:

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:

The file ‘my_text_file.txt’ is shown in the present working directory /home/kali.

Task 2.2: Writing to a ‘TEXT’ file

Use the following command to write text directly to the file:

Now, run the following command to verify or see the contents of the file “my_text_file.txt”:

You will see the following output:

Alternatively, you may use any text editor (such as gedit, nano, or vim). You should explore
them by yourself.

Task-3: Managing Directories

In this task, you will learn how to create, rename, copy, move, and delete a directory in Kali
Linux.

Task 3.1: Creating a directory

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:

Task 3.2: Renaming a directory

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:

Task 3.3: Moving a directory from one location to another

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.

Task 3.4: Copying a directory from one location to another

Let’s say, we want to copy the directory MyDirectory1 from /home/kali/Desktop to


/home/kali. Use cp -r source_directory destination_directory_Path command as follows:

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.

Check the listing of /home/kali again:

You have successfully copied the directory.

Task 3.5: Deleting a directory

To delete a directory, you need to use the rmdir (remove directory) command as follows:

Here, MyDirectory1 is the directory to be deleted.

6
Check the listing with ls command:

You can see the directory has been deleted.

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.

You might also like