MODULE 2: INTRODUCTION TO
KALI LINUX
1/
MODULE OBJECTIVE
This Module gives you hands-on experience to the Kali Linux
environment specifically on how to use the Command Line
Interface (CLI) to carry out basic task. On completing this
module you should know:
- File Structures in Kali Linux.
- How to use the terminal for different computer
operations.
2/
MODULE 2: INTRODUCTION TO
KALILINUX
Topics:
✔
Introduction To Kali Linux.
✔
Linux File System.
✔
Linux Permissions
✔
The Terminal
✔
Important And Common Linux Commands.
3/
INTRODUCTION TO KALI LINUX
Requirements:
●
Oracle VirtualBox
Download Link:
https://download.virtualbox.org/virtualbox/6.1.14/VirtualBox-6.1.14-140239
-Win.exe
●
Kali Linux (.ova)
Download Link:
https://images.kali.org/virtual-images/kali-linux-2020.3-vbox-amd64.ova
4/
INTRODUCTION TO KALI LINUX
In order to become a good ethical hacker or penetration
tester, you need to be conversant with Linux, which is by far
one of the most powerful operating systems. Linux is really
good for ethical hacking and penetration testing because it is
compatible with a wide variety of related tools and software,
whereas other operating systems such as Mac and Windows
support fewer of these software and tools.
5/
INTRODUCTION TO KALI LINUX
Major Linux Operating Systems
Before talking about Kali Linux, let’s take a look at some of the Linux-based distros
that you will encounter very often:
●
Red hat Linux—Used mostly for administration purpose.
●
Debian Linux—Designed for using only in open source software.
●
Ubuntu Linux—Designed mostly for personal use.
●
Mac OS X—Used in all Apple computers.
●
Solaris—Used in many commercial environments.
●
Back Track Linux—Used mostly for penetration testing.
6/
LINUX FILE STRUCTURE
7/
INTRODUCTION TO KALI LINUX
File Structure inside of Linux:
8/
INTRODUCTION TO KALI LINUX
Subdirectories of the root directory:
9/
INTRODUCTION TO KALI LINUX
10 /
INTRODUCTION TO KALI LINUX
/opt: Typically contains extra and third-party software.
/etc: contains configuration files.
/proc: A virtual file system containing information about system resources. More
information about the meaning of the files in proc is obtained by entering the
command man proc in a terminal window. The file proc.txt discusses the virtual file
system in detail.
/sbin: Programs for use by the system and the system administrator.
11 /
INTRODUCTION TO KALI LINUX
/tmp: Temporary space for use by the system, cleaned upon reboot, so don’t use this
for saving any work!
/usr: Programs, libraries, documentation, etc., for all user-related programs.
/dev: This directory only contains special files, including those relating to the devices.
These are virtual files, not physically on the disk.
/var: Storage for all variable files and temporary files created by users, such as log
files, the mail queue, the print spooler area, space for temporary storage of files
downloaded from the Internet, or to keep an image of a CD before burning it.
12 /
THE TERMINAL
13 /
INTRODUCTION TO KALI LINUX
The Terminal:
A terminal emulator is a program that allows the use of the terminal in a graphical
environment. As most people use an OS with a graphical user interface (GUI) for their
day-to-day computer needs, the use of a terminal emulator is a necessity for most
Linux server users.
Here are some free, commonly-used terminal emulators by operating system:
Mac OS X: Terminal (default), iTerm 2
Windows: PuTTY
Linux: Terminal, KDE Konsole, XTerm
14 /
INTRODUCTION TO KALI LINUX
15 /
LET’S GO TO LAB
IMPORTANT AND COMMON LINUX
COMMANDS
16 /
1) SUDO
17 /
INTRODUCTION TO KALI LINUX
Most Common and Important Commands:
1) sudo: allows you to run programs with the security privileges of another user (by default, as the
superuser).
Syntax:
sudo [option]
Command to run a program with privilege rights:
sudo apt update
sudo apt install nmap
Command to login into the shell with privilege rights:
sudo -i
18 /
2) ADDUSER
19 /
INTRODUCTION TO KALI LINUX
2) adduser: adds a new common user to the system.
Syntax:
adduser [options] username
Command to create a new user:
adduser john
20 /
3) USERMOD
21 /
INTRODUCTION TO KALI LINUX
3) usermod: adds a new common user to the sudoers list.
Syntax:
usermod [options] username
Command to create a new user:
sudo usermod -aG sudo john
22 /
4) PWD – PRINT WORKING
DIRECTORY
23 /
INTRODUCTION TO KALI LINUX
Most Common and Important Commands:
4) pwd: print name of current/working directory.
Syntax:
pwd [option]
Command to print current working directory:
pwd
24 /
5) CD – CHANGE DIRECTORY
25 /
INTRODUCTION TO KALI LINUX
5) cd: change directories.
Syntax:
cd directory_name
Commands to change directory to Desktop, Downloads, Documents respectively:
cd Desktop
cd Downloads
cd Documents
cd .. (go one step down)
cd -- (go down to the home directory)
26 /
6) LS
27 /
INTRODUCTION TO KALI LINUX
6) ls: list directory contents..
Syntax:
ls [options]
Command to list all files in CEH directory using absolute path:
ls /home/kali/Desktop/CEH/
ls -al /home/kali/Desktop/CEH/ (with -al it will list both hidden and unhidden files and directories with
their permission attribute)
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
ls or ls -al
28 /
7) MKDIR
29 /
INTRODUCTION TO KALI LINUX
7) mkdir: create directories.
Syntax:
mkdir directory_name
Command to create a directory named CEH on Desktop Directory using absolute
path:
mkdir /home/kali/Desktop/CEH
Equally it can be done this way (one at a time):
cd Desktop
mkdir CEH
30 /
8) TOUCH
31 /
INTRODUCTION TO KALI LINUX
8) touch: create a file.
Syntax:
touch file_name
Command to create a file with filename print.py in the CEH directory using absolute path:
touch /home/kali/Desktop/CEH/print.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
touch print.py
NB: I created a file with a .py extension, an extension for python programming. You can choose to create with a
.txt, .lst, etc
32 /
9) NANO
33 /
INTRODUCTION TO KALI LINUX
9) nano: Command Line Interface (CLI) file editor for reading
andwriting into files.
Syntax: Add this line of code into print.py file:
nano file_name
#!/usr/bin/python3
Command to read and write into a file using absolute path:
nano /home/kali/Desktop/CEH/print.py
print (“This is introduction to Linux class”)
Equally it can be done this way (one at a time): #NB: This is a python script to Display “This is
introduction to Linux class” on screen to user when
cd Desktop
executed. Also, the first line begins with the #!
cd CEH character
combination, which is commonly called hash bang or
nano print.py shebang, this line indicates what program must be used
to run the file.
use CTRL + O to save.
use CTRL + X to exit the editor.
34 /
10) CAT
35 /
INTRODUCTION TO KALI LINUX
10) Cat: reads data from the file and gives their content as output.
Syntax:
cat [option] file_name
Command to print the content of a file:
cat /home/kali/Desktop/CEH/print.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
cat print.py
36 /
11) ./
37 /
INTRODUCTION TO KALI LINUX
Running/Executing our print.py file using absolute path:
python3 /home/kali/Desktop/CEH/print.py
/home/kali/Desktop/CEH/./print.py (guessed you noticed ./)
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
python3 print.py or ./print.py
38 /
12) CHMOD
39 /
INTRODUCTION TO KALI LINUX
Group Permission:
Owner—The Owner permissions apply only the owner of the file or directory; they
will not impact the actions of other users.
Group—The Group permissions apply only to the group that has been assigned to the
file or directory; they will not affect the actions of other users.
All User/Other—The All Users permissions apply to all other users on the system;
this is the permission group that you want to watch the most.
40 /
INTRODUCTION TO KALI LINUX
Each file or directory has three basic permission types:
Read—The Read permission refers to a user’s capability to read the contents of the
file.
Write—The Write permissions refer to a user’s capability to write or modify a file or
directory.
Execute—The Execute permission affects a user’s capability to execute a file or view
the contents of a directory.
41 /
INTRODUCTION TO KALI LINUX
12) Chmod: change file mode bits, from read to write and vice versa
Syntax:
chmod [option] [mode] file_name
Command to give read, write or execute rights to a user for a file using absolute path:
chmod u+r /home/kali/Desktop/CEH/print.py
chmod u+w /home/kali/Desktop/CEH/print.py
chmod u+x /home/kali/Desktop/CEH/print.py
Command to give read, write or execute rights to a group for a file using absolute path:
chmod g+r /home/kali/Desktop/CEH/print.py
chmod g+w /home/kali/Desktop/CEH/print.py
chmod g+x /home/kali/Desktop/CEH/print.py
42 /
INTRODUCTION TO KALI LINUX
Command to give read, write or execute rights to others for a file using
absolute path:
chmod o+r /home/kali/Desktop/CEH/print.py
chmod o+w /home/kali/Desktop/CEH/print.py
chmod o+x /home/kali/Desktop/CEH/print.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
chmod u+x print.py
43 /
13) CHOWN
44 /
INTRODUCTION TO KALI LINUX
13) Chown: change ownership of a file.
Syntax:
chmod [option] [owner]:[group] file_name
Command change ownership of a file using absolute path:
chown isidore:isidore /home/kali/Desktop/CEH/print.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
chown isidore:isidore print.py
45 /
14) CP
46 /
INTRODUCTION TO KALI LINUX
14) cp: copy file/directory or rename a file or directory.
Syntax:
cp [source] [destination]
Command to copy print.py to Documents directory using absolute path:
cp /home/kali/Desktop/CEH/print.py /home/kali/Documents/
cp /home/kali/Desktop/CEH/print.py ../../Documents/
Command to copy print.py to Documents directory with a new name obinna.py using absolute path:
cp /home/kali/Desktop/CEH/print.py /home/kali/Documents/obinna.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
cp print.py /home/kali/Documents/
47 /
INTRODUCTION TO KALI LINUX
Command to copy CEH directory/folder with its content to Documents directory using
absolute path:
cp -R /home/kali/Desktop/CEH /home/kali/Documents/
cp -R /home/kali/Desktop/CEH ../../Documents/
Command to copy CEH directory/folder with its content to Documents directory with a
new directory name CEH2 using absolute path:
cp -R /home/kali/Desktop/CEH /home/kali/Documents/CEH2
Equally it can be done this way (one at a time):
cd Desktop
cp -R CEH /home/kali/Documents/
48 /
15) RM
49 /
INTRODUCTION TO KALI LINUX
15) rm: remove file/directory.
Syntax:
rm file_name
Command to remove print.py using absolute path:
rm /home/kali/Desktop/CEH/print.py
Command to remove CEH directory and its contents using absolute path:
rm -R /home/kali/Desktop/CEH
rmdir /home/kali/Desktop/CEH (rmdir can be used to remove directories)
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
rm print.py
50 /
16) MV
51 /
INTRODUCTION TO KALI LINUX
16) mv: move file/directory or rename a file or directory.
Syntax:
mv [source] [destination]
Command to copy print.py to Documents directory using absolute path:
mv /home/kali/Desktop/CEH/print.py /home/kali/Documents/
mv /home/kali/Desktop/CEH/print.py ../../Documents/
Command to copy print.py to Documents directory with a new name obinna.py using absolute path:
mv /home/kali/Desktop/CEH/print.py /home/kali/Documents/isidore.py
Equally it can be done this way (one at a time):
cd Desktop
cd CEH
mv print.py /home/kali/Documents/
52 /
INTRODUCTION TO KALI LINUX
Command to move CEH directory/folder with its content to Documents directory using
absolute path:
mv -R /home/kali/Desktop/CEH /home/kali/Documents/
mv -R /home/kali/Desktop/CEH ../../Documents/
Command to copy CEH directory/folder with its content to Documents directory with a
new directory name CEH2 using absolute path:
mv -R /home/kali/Desktop/CEH /home/kali/Documents/CEH2
Equally it can be done this way (one at a time):
cd Desktop
mv -R CEH /home/kali/Documents/
53 /
17) IFCONFIG
54 /
INTRODUCTION TO KALI LINUX
17) ifconfig: show network interface details
Syntax:
ifconfig [option]
Command to display network details:
ifconfig
ifconfig -a
55 /
18) NETSTAT
56 /
INTRODUCTION TO KALI LINUX
18) netstat: show local or remote established connection.
Syntax:
netstat [option]
Command to Display of all open ports and active connections (numeric and
process ID included) :
netstat -ano
57 /
19) TOP
58 /
INTRODUCTION TO KALI LINUX
19) top: show system task manager.
Syntax:
top [option]
Command To view a list of all currently running processes:
top
To kill/End a process:
press k then select the PID number you want to kill.
59 /
20) W, WHOAMI AND ID
60 /
INTRODUCTION TO KALI LINUX
20) w, whoami and id: Show who is logged in.
Syntax:
w [option]
whoami [option]
id [option] [user]
Commands:
w
whoami
id
61 /
21) MAN
62 /
INTRODUCTION TO KALI LINUX
21) Man: manual/help
Syntax:
man utility_name
Command to show a manual page for netstat utility:
man netstat
Equally it can be done with (--help):
netstat --help
63 /
SUMMARY
64 /
SUMMARY
Linux commands are virtually identical from one Linux
distribution (a.k.a. version, distro) to another. So, when you
learn a command in one Linux distribution, it works the
same in all Linux distributions.
Linux commands may be trickier to learn than using a
"point-and-click" GUI utility, but once you learn them you
will be able to work much faster and you will be in demand.
65 /