We will be discussing some of the basic commands which are required to get started in Kali Linux.
This command is used to change directory in the terminal. This is used with the path of the directory, for example,
Changing current directory to the desktop directory, we would use
$ cd Desktop/
For going one directory back, use the command
$ cd ..
This command is used to print working directory where the terminal is running. You just need to type in pwd and press enter.
By default, when we open terminal using the terminal icon, it is opened in “/home/kali” directory. So, writing pwd outputs “/home/kali”.
Try changing the directory to “Desktop/” and print the working directory.
This command is to list the folders and files inside the current working directory. This command can be used standalone. Type in “ls” and press enter, it would output the folders and files inside the directory, your terminal is running in.
As, we are currently running terminal in the directory “/home/kali/”, which contains Desktop, Documents & other folders.
Try going to other directories using the “cd” command and printing the working directory.
You can also type in
$ cd /
This will change the active directory to the main directory where system files are located.
There are multiple ways of doing this,
You can have a look at the output. There are multiple folders such as bin, dev, home, etc.
The “home” folder contains the crucial user folder which is “kali”
You can go back to the kali directory by typing in “cd /home/kali/”. This will change the working directory to the default directory which opens up when you start terminal.
If you want to know about each of the folder that the “/” folder is containing, have a look at this https://www.linux.com/training-tutorials/linux-filesystem-explained/ .
This is a simple command which clears out everything that is displaying on the terminal. There might be clutter around inside the terminal which could require you to close and re-open the terminal, but typing the clear command will simply clears out text stuff.
This is the most crucial command in Kali terminal. This command provides you the root privilege or we can say that you are acquired with super user access. You might have heard about the super user (SU box), if you ever tried to root (jailbreak) your android device (not recommended though).
There are certain tools in the kali which require the root privilege to work, else they will output “bash, command not found” or “run this command with root access”. To provide such tools, root privilege we have to append them with “sudo”. You also have to enter the password “kali” after that, same as we have done before in installing virtual box guest addition tools.
We will be discussing more about sudo in the next command.
This command is used to display the active network adapters which are running inside your Kali. Try entering the following command and press enter.
You might receive an error saying “bash, command not found”. This is because, the “ifconfig” command requires the root privilege at least once.
Try entering the command
$ sudo ifconfig
This will display some IP addresses and MAC addresses. These IP and MAC addresses are very crucial in the wireless attacks and performing remote execution attacks such as MSF venom, beef, etc. If you want to perform the wireless attacks or want to crack the wireless router password, you may read our ultimate guide to wireless attacks in Kali.
As we are now having the root access, but do we need to enter the sudo each time we enter any command which require sudo or root access.
Well, the answer is NO!
You can turn to the root mode and type as many root commands as you want without writing sudo before each command. This can be achieved by typing the command
$ sudo su
This will enter you into the root privileged directory which is root directory.
Now, you can run any number of root commands with typing in sudo each time. For exiting the root mode, type
and press enter. It will return back to normal user mode.
This command is used to create a file in the active directory.
Let’s create a file named “newfile”. For this enter the command
$ cd Desktop/
(Changing active directory to Desktop)
$ touch newfile
This will create an empty file name newfile on the Desktop.
Double click on the file and see whether it is empty or not. It would definitely be empty currently.
This command is used to edit a file using a terminal editor. This is not as same as text editor but it is a handy command when editing root level files which couldn’t be edited using the normal text editor.
Enter the command
$ nano newfile
This will open a terminal editor. Type in “Hello World” text there.
After typing this, press “Ctrl O” with keyboard, then press “Enter” key. And finally press “Ctrl X”. These key combinations will take you out of the terminal editor by saving whatever you have typed in.
“nano” command can be used directly to create a file also without the need to use “touch” command.
To create a file with nano command, enter
$ nano anotherfile
This will create a new file with name “anotherfile”, but you have to enter something and then save that file for the file to be appear on the active directory.
Type in “Hello There” and press “Ctrl O” then “Enter Key” then “Ctrl X”. This will save the file and the file will appear in the active directory.
This command is used to enter any text or code into the specified file. This works same as nano terminal editor works.
Let’s create a new file name “file1” and insert the text “Have a Great Day” into the “file1” using the “echo” command.
This will create a file named “file1” and insert “Have a Great Day” into it.
This command is used to display the content of a file into the terminal.
We have created 3 files till yet.
Let’s display the content of each of them with this command.
To do so, type the following commands and press enter after each command.
$ cat newfile
$ cat anotherfile
$ cat file1
Here, each of them is showing the content that we have typed in them before.
These are some of the basic commands which are very useful for beginners. Checkout other commands in the Kali Linux for Beginners Handbook Available on Google Play.
If you want to become a successful Ethical Hacker, Check out the complete e-book to become an Ethical Hacker for Complete Beginners Available on Google Play & Amazon (Select Your Specific Country Code)
For Printed Version of “Practical Ethical Hacking for Complete Beginners”, Check Out Links Below to Order.
For People Residing in India, Check out this link available for FREE Shipping