top of page

Kali Linux Command Line

Kali is an Operationg System dedicatedly made for Ethical Hacking (VAPT). To use Kali Linux one should know how to use tools using Terminal. Terminal allows to control Kali Linux by text based instructions. It is similar to Command Prompt used in Windows OS.


Launching the terminal in Kali gives us root@kali:~#. One can write text based instruction further.


Fig. Kali Linux Terminal



1. List (ls):

To list down the files, direcories in the present directory.

In Kali Linux Terminal:

~# ls



2. Change directory (cd):

'cd' is used to change present working directory. By default present woeking direcory is 'root'. E.g. Suppose one wants to go to Desktop from root. Then,

In Kali Linux Terminal:

~# cd Desktop



3. Manual (man):

It tells about working of any command along with its options and arguments to be passed.

In Kali Linux Terminal:

~# man {command}



4. Adding user (adduser)

It is used to add users to the system. By default Kali Linux has 'root' user with 'toor' as a password.

In Kali Linux Terminal:

~# adduser {new user name}


One can also specify which user can use the 'sudo' command. 'sudo' command is needed to be used for some commands which needs root privileges.

In Kali Linux Terminal:

~# adduser {user name} sudo


Switching between users can be done using 'su'.

In Kali Linux Terminal:

~# su {user name}



5. Creating a new empty file:

In Kali Linux Terminal:

~# touch {new file name}



6. Creating a new directory:

In Kali Linux Terminal:

~# mkdir {new directory name}



7. Copying the contents of a file:

In Kali Linux Terminal:

~# cp {file name or path of original file} {file name or path of copied file}



8. Moving a file:

In Kali Linux Terminal:

~# mv {file name or path of original file} {file name or path of moved file}



9. Removing a file:

In Kali Linux Terminal:

~# rm {file name or path}



10. Seeing contents of file:

In Kali Linux Terminal:

~# cat {file name or path}



11. Adding text to the file:

In Kali Linux Terminal:

~# echo {text to be added} > {file name or path}

This will simply remove the privious contents of file (if any), and adds the new text thus it overwrites the file contents.


Hence to for appending the text to the file one can use,

In Kali Linux Terminal:

~# echo {text to be added} >> {file name or path}



12. Editing a file:

Simplest editor inbuilt in Kali Linux is Leafpad'.

In Kali Linux Terminal:

~# leafpad {file name or path}



13. File permissions:

Every file has Read (r), Write (w) and Execute (x) permissions. To view the file permissions of a file,

In Kali Linux Terminal:

~# ls -l {file name of path}


To change the file permissions one can use 'chmod'.

In Kali Linux Terminal:

~# chmod {744} {file name or path}


Here,

7 = User [Read(4) + Write(2) + Execute(1)]

4 = Group [Read(4) + Write(0) + Execute(0)]

4 = World [Read(4) + Write(0) + Execute(0)]

This means only user can read, write and execute the file. And others can only read the file. Thus we can use 'chmod' as per needed.



14. Networking:

To see current interfaces of the system to access the network,

In Kali Linux Terminal:

~# ifconfig



15. Starting or stopping services:

In Kali Linux Terminal:

~#service {service name} start

or

~#service {service name} stop

or

~#service {service name} restart



bottom of page