0% found this document useful (0 votes)
6 views

basic linux commands

Uploaded by

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

basic linux commands

Uploaded by

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

• ip a – to find the IP address of your Kali machine

• pwd – to know the directory you are in


• ls – to know what files are in your current directory
• cd – to move from your current directory
• mkdir – to create a directory
• rmdir – to remove a directory
• rm – to delete files and directories
• touch – to create a file (e.g. touch myFirstFile.txt)
• cp – to copy files
• mv – to move the files (know the di?erence between cp and mv commands)
• locate – to locate a file in Kali
• cat – to display the contents of a file
• man – to know about a particular command and how to use it (e.g. man cd)

The below is the list of some Linux commands along with a brief purpose of each. Run
the following commands in the Kali Linux terminal (pressing enter after each):
• Update the Linux Environment
o apt-get is the command-line tool used to install, remove, and manage
software package. To obtain further information about the command-line
options that can be used with apt-get use the terminal command apt-get
--help
o apt-get update is the command used to retrieve new lists of packages
from a server on the internet. It does not install packages but only
retrieves a list of all available packages that can be installed.
o apt-get upgrade is the command used to perform an upgrade of the
current packages installed on the system. In e?ect, it upgrades software
to the most recently released version.
o apt-get install <package name> is the command used to install a
specific package (replace with the name of the package you are trying to
install). If the package is already installed on the system, then it will
upgrade it to the most recent version.

• sudo (super user do)


o The sudo command allows the current user to run a command as a user
with a higher privilege. In most cases, this will be the root user who by
default, can run any command on the system. In terms of computer
security, it is critical only to allow administrator users the ability to run
commands that could compromise the security of the overall system, e.g.
installing software that could be, in fact, malware.
o The sudo command will ask the user for a password – enter the
password kali.
o Run the following command sudo apt-get upgrade. When prompted,
enter ‘Y’ to complete the upgrade. Please note this may take up to 10
minutes to complete.

• Install a New Package


o We will install a new package call tree. This package will list the directory
structure in a visual tree format:
§ enter the command sudo apt-get install tree
§ Enter the command tree to view the siblings of the current
directory
§ Now enter the command cd / to move to the root directory. Run
the tree command again and note the results. This lists the entire
directory structure of Kali Linux. This may take a few minutes. To
exit enter the hotkey CTRL/Z. To move back to the default directory
of the user kali enter the command cd /home/kali.

• Become the root User


o On occasion, you may need to action a series of commands that can only
be completed as the root user. This can be achieved using the terminal
command sudo -s and entering the password for the username kali.
Enter the command exit to move back to the non-privileged user
account kali.
o Please note: It is good practice not to leave the root user logged in. If the
system is compromised and a malicious actor is able to obtain access as
a root user, then there is no command that cannot be actioned.

• Installing and Using 7-Zip for Linux


o Use the command sudo apt-get install p7zip-full p7zip-rar to install 7-
Zip.
o Enter the command cd /home/kali/Documents/ . Then use the
command mkdir Files to create a directory called Files. Use tree to view
the directory structure. Navigate to the new directory using the
command cd Files
o Create a file using the command nano file1. This will open up a text editor
that can be populated with text, scripts etc. Enter some text as per the
image below. To save the file complete the following CTRL/X to exit,
followed by ‘y’ to save, followed by the filename (file1).
o Enter the command ls to view the newly created file within the directory.
o Now repeat this process and create two more files entitled file2 and file3.
o Enter the command ls view the contents of the current directory.
o To compress these files, i.e. add file1, file2, and file3 to an archive then we
use the command 7z a files.7z * where a stands for archive/add
and files.7z is the designated filename to add the files to.
o Next, we are going to move files.7z to the Desktop using the command mv
files.7z /home/kali/Desktop. You should see the file appear on your
Desktop. Now navigate to the Desktop directory using the command cd
/home/kali/Desktop.
o Finally, we will extract the newly created 7z file using the command 7z e
files.7z where e stands for extract.
o The files should now extract to the Desktop. Enter ls to view the contents
of the directory to show the files.

You might also like