Computer Programming

Kali Linux Commands

Kali linux is a operating system. It is widely used by hackers and penetration testers. It is maintained and funded by offensive security, though it runs on some basic linux commands which are followed as:

1. Arch Command:

You can use the arch command to know computer architecture. Arch command prints things such as “i386, i486, i586, alpha, arm, m68k, mips, sparc, x86_64, etc.

You can use the following Syntax to check your system architecture:

#arch

2. Arp Command:

ARP stands for Address Resolution Protocol, which is used to find the address of a network neighbor for a given IPv4 address.

arp command is used to show the arp table of your Kali Linux system. You can use this command on other Linux systems as well as Windows operating systems.

arp without any option will print the current content of the ARP (MAC/CAM) table.

#arp

3. arping Command

arping command is similar to ping command but it is working on an Ethernet layer. arping command gives the result of reachability and round-trip time on an IP address in a local network.

#arping -I eth0 -c 5 IPADDRESS

4. Aspell Command:

aspell is a spell checker command in Kali Linux, you can give file name or anything from standard input to check for misspellings.

Syntax: aspell check [options] filename

#aspell -c filename.txt

5. awk command

awk command is used to manipulate data and generate a report in the scripting language. It allows the user to use a variable, functions both numeric and functions and logical operators.

You can write tiny and effective programs in the form of a statement by using awk utility in Kali Linux.

What can you do with awk?

  1. AWK Operations:
    (a) Scans a file line by line
    (b) Splits each input line into fields
    (c) Compares input line/fields to pattern
    (d) Performs action(s) on matched lines
    awk is Useful For:
    (a) Transform data files
    (b) Produce formatted reports
  2. Programming Constructs:
    (a) Format output lines
    (b) Arithmetic and string operations
    (c) Conditionals and loops

Syntax:

awk options ‘selection _criteria {action }’ input-file > output-file

6. bg command

bg command is used to control shell jobs. It resumes execution of a stoped or suspended process and bg command used to restart a stopped background process

Example
I used ping command followed by technicalustad.com then pressed CTRL +z to stop the service.

Next, I used jobs commands to see available jobs.

Again I used bg command to restart the stoped command “ping technicalustad.com”

7. basename command

You can use basename command to remove base directory information and suffixes from the file names. You can print any file name with any leading directory components removed

Syntax:

#basename NAME [SUFFIX]
or
#basename OPTION NAME

8. Bzip2

Bzip2 is a basic utility for compress and decompress files. It is pre-installed in kali Linux as other commands.

Syntax:

#bzip2 [Options] [filename]

An example:

I used cat command to create a new file name with the filename.txt

Later I used bzip2 command followed by -z (option for compress file) and file name.

Next option -d, I used for decompressing “filename.txt.bz2”

When you use bzip2 command to compress file, The new file will be created with .bz2 extension. You will decompress any file with .bz2 extension by using bzip2 command.

9. cal command:

Cal command is used to display calendar

$cal

root@kali:~#cal
    October 2019      
Su Mo Tu We Th Fr Sa  
       1  2  3  4  5  
 6  7  8  9 10 11 12  
13 14 15 16 17 18 19  
20 21 22 23 24 25 26  
27 28 29 30 31 
root@kali:~#

10. cat command

This tutorial for hackers, So if you will get access to any computer of the drive then you will 100% find some files. so cat command is used to see, edit matter inside the file. You can create a file and add content inside the file.

How is it possible?

Simple use

$cat > ‘New File’ [Create a new file or overwrite data on the desired file] 

$cat “file name” [See matter inside file]

$ cat >> “filename” [add some data into file] 

11. cksum command

cksum command stands for checksum is used to calculates a CRC (cyclic redundancy check) and byte count for each input file, and writes it to standard output.

In a simple way, this command is used to check file’s data for being corrupted when transferred one location to another.

Command syntax is simple and straight forward

#cksum filename

12. Clear command

Clear command is used to clear the terminal screen when you are running multiple commands in terminal the terminal screen getting full.

So use the clear command and enjoy a clean screen again.3

#clear

13. cmp Command:

the cmp command is used to compare two files byte by byte. If a difference is found, it reports the byte and line number where the first difference is found.

If no differences are found, by default, cmp returns no output.

Basic syntax of cmp command

#cmp file1.txt file2.txt

14. comm Command

you can use comm command to compare two sorted files line by line. The basic syntax to use this command:

#comm file1.txt file2.txt

15. cp command:

Cp command is used to copy one or more files from one location to another location.

#cp /source/location/path /destination/location/path

If you are copying file from the current working directory then give a file name and source address.

#cp filename /destination/location/path

Use the cp command carefully because it will overwrite files without asking. It means if the destination file name already exists, its data will be erased. you can use -i option to prompt for confirmation.

16. Crontab Command:

In kali Linux operating systems, The crontab command is used to view or edit the table of commands to be run by cron. The cron table is the list of tasks scheduled to run at regular time intervals on the Linux system.

The daemon which reads the crontab and executes the commands at the right time is called cron.

Crontab command examples

#crontab -e
Edit your crontab.

#crontab -l
Display (“list”) the jobs of your crontab.

#crontab -r
Remove your crontab.

#crontab -u technicalustad -e
Edit crontab for user technicalustad.

17. cut Command:

cut command is used to cut parts of lines from specified files or piped data and print the result to standard output. It can be used to cut parts of a line by delimiter, byte position, and character

The basic syntax for the cut command is as follows:

cut OPTION… [FILE]…

You can use cut command followed and specified with filed

for the example:

#cut -f 1,3 file.txt

18. Date Command:

date command is used for checking the current date and time.

root@kali:~#date
Fri jun  12 09:55:34 IST 2020
root@kali:~#

the date can be changed by running the following code

$ date –set=’20 September 2019 13:09′

but the normal user can’t change system time, Then you are thinking about “how to change system time” Of-course I will teach you in this article, dont worry about it.

Some examples of date command:

$ date -d now
$ date -d today
$ date -d yesterday
$ date -d tomorrow
$ date -d sunday
$ date -d last-sunday

19. dc command:

The desk calculator works with postfix notation; rather like many HP Calculators. Basic arithmetic uses the standard + – / * symbols but entered after the digits.

Syntax

dc [-V] [–version] [-h] [–help] [-e scriptexpression]
[–expression=scriptexpression] [-f scriptfile] [–file=scriptfile]

20. Dd command

dd stands for data duplicator, which is mainly used to copy and convert data. but this tool can be used for:

  • Backing up and restoring an entire hard drive or a partition.
  • Creating virtual filesystem and backup images of CD or DVDs called ISO files
  • Copy regions of raw device files like backing up MBR (master boot record).
  • Converting data formats like ASCII to EBCDIC.
  • Converting lowercase to uppercase and vice versa.
  • Converting data formats like ASCII to EBCDIC.
  • Converting lowercase to uppercase and vice versa.

dd command is not basic command so you must be superuser to execute it.

Syntax of dd command is not basic command so you must be superuser to execute it.

Syntax of dd command is

dd if= of= [Options]

21. df command 

The df command stands for Disk Free is used to reports file system disk space usage. It displays the amount of disk space available on the file system of Kali Linux. The df command reports how much free disk space we have in our system.

simple syntax:

#df

22. diff command

Diff command is used to display the differences between two files.

Basic Syntax:

#diff file1.txt file2.txt

23. diff3 command

Diff3 command is used to show differences among the three files.

Basic Syntax

#diff3 file1.txt file2.txt file3.txt

24. dig command

dig command is a powerful command in kali Linux used to for DNS lookup. Simple use and simple syntax

#dig www.domainname.com

You will get all the information related DNS of the website.

25. dir Command

dir command is used to print the content list of a directory. Most of Linux user use ls command instead of dir command. but you can use it.
Basic Syntax:

#dir [OPTION] [FILE]

Example:

#dir /etc

26. echo command:

Display message on the screen

The echo command is one of the most basic commands in Linux used to display a message on the screen. The arguments passed to echo are printed to the standard output.

echo is commonly used in shell scripts to display a message or output the results of other commands.

Example:

#echo Hello world!

27. Egrep Command

The egrep command is used to search files for lines that match a text pattern. It performs the match by using extended regular expressions. Running egrep is equivalent to running grep with the -E option.
Basic Example:

#egrep “support|help|windows” myfile.txt

Search for patterns of support help and windows in the file myfile.txt.

28. Eject Command

Eject command is used to remove a removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) under software control. You can eject DVD by pressing a button, but you can remove it without touching button just type the following command:

#eject

Use the following command, in the case above command, is not working:

#eject /dev/cdrom

#eject /dev/cdrw

#eject /dev/dvd

#eject /dev/dvdrom

#eject /dev/dvdrw

29. ethtool Command

ethtool is a networking utility used to configure ethernet devices on Kali Linux.

#ethtool [ethernet card]

If you want to display network usage statistics with ethtool by using the following command

#eththoo -S eth0

where eth0 is a card name

30. whoami command:

it is looking something difference command but it is used to tell about you. For example if you forget “which user is logged in?This command will tell you who are you current.

$whoami

31. pwd command:

pwd command is used for print working directory. It means “On what location you are“. here location meaning is directory and sub-directory.

The parent directory is “/” called root directory.

Don’t be confused with /root directory, this root directory “/root” is home directory for root user.

root@kali:~#pwd
/root
root@kali:~#

32. ls command:

ls command is used to see files and directory inside a directory. using ‘ls’ without any location will list the files and folders inside the current directory.

If you want to look up inside another directory, you will have to specify location.

$ls

$ls /var

$ls /home/username

oot@kali:~# ls
Desktop Downloads Pictures Templates virtualbox_6.1.10-dfsg-4kali1.dsc hello.txt
Documents Music Public Videos virtualbox_6.1.10-dfsg.orig.tar.xz
root@kali:~# ls /var/
backups lib lock mail run tmp www
cache local log opt spool unicornscan
root@kali:~#

33cd command:

the cd command is a very useful command and plays a very important role for Linux user. This command is used for changing directory. And the basic syntax will be as below:

cd /desired/location

If you use blank ‘cd’ without location then you will move in the user’s home directory. so see the power of cd commands and enjoy!

$cd

$cd ..

$cd /desired/location ($cd /home/hemant)

34. mkdir command:

Do you know about the directory? It is a term used for the folder. You can say windows folder is a directory in Linux It is very easy to create a folder in Windows” but not in Linux. T

The graphical interface is really awesome, but the command interface is not less. The command-line interface is the fastest way to operate a Linux based Operating System. Linux users love it.

mkdir command is used to create a directory. if want to create a directory within the current directory, just use mkdir ‘directory name’.

if you want to create a directory in the desired location then

$mkdir /desired/location/directory name.

$mkdir lab

root@kali:~#mkdir lab
root@kali:~#mkdir lab/lab1
root@kali:~#

$mkdir /home/hemant/lab1

35. mv command:

If you don’t like files and folders on the current location and want to move to another location, then mv command is useful for you. mv command work as a cut and paste in windows.

$mv /Source_location /destination/location

mv source location if the file or directory does not exist in current location if the file/folders within current location then us mv file/folder name [space] destination location {destination location = where you want to move}

mv command is also used for rename the file and folder

$mv ‘old filename’ ‘new filename’

36. rm command:

rm command is used to remove files and folders. In other words this command for deleting files and folders.

$rm <file name>

System Basic Kali Linux commands 

37. uname command:

Do you want to know the name of your Linux? if yes then use uname command 
The “uname” stands for (Unix Name), displays detailed information about the machine name, Operating System and Kernel.

$uname

$uname -a

root@kali:~#uname -a
Linux kali 5.2.0-kali2-amd64 #1 SMP Debian 5.2.9-2kali1 (2019-08-22) x86_64 GNU/Linux
root@kali:~#

38. uptime command:

this command is used to check how long your system is running. uptime for your system, this command can be used for forensics also.

root@kali:~#uptime 
 10:29:28 up 36 min,  1 user,  load average: 0.08, 0.08, 0.08
root@kali:~#

39. users command:

users command is used to check current logged in user, On my Kali Linux system I have logged in with root user and later I switched to vijay user.

root@kali:~#users 
root
root@kali:~#

40. Less Command

less command is used for quickly view file on terminal. user can page up and down. Press ‘q‘ to quit from less window.

$less /etc/passwd

root@kali:~#less /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
/etc/passwd

41. More Command

more command is used for quickly view file and shows details in percentage. Press up and down arrow for page up and down. Press ‘q‘ to quit out from more window.

$more /etc/passwd

root@kali:~#more /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologi
n
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbi
n/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/n
ologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
--More--(37%)

42. Sort command

You can sort lines of text files in ascending order. with -r options will sort in descending order.

$sort filename.txt [ascending order]

$sort -r filename.txt [descending order]

43. VI Command

Vi is a most popular text editor used for most of the UNIX-like OS.

#vi <filename>

44. Free command

The free command shows free, total and swap memory information in bytes.
Free with -t options shows total memory used and available to use in bytes.

$free

$free -t

45. history command

The history command is used to check recent running commands. Oh really it is useful because Forgetting is the nature of human. IF you forget previous running command, you can use history command.

$history

System Advanced Kali Linux commands

46. find command

The find command is used for search files in Linux. Searching any files and folders in Windows is easy but in Linux.

To find a file by name, size, type, etc in the graphical interface is quite easy, And it is not really so easy in CLI (Command Line Interface)

Find is a command-line utility that allows you to search for files and directories in a directory hierarchy based on user-given expression and applies user-specified action on each matched file

Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path…] [expression]

root@kali:~#find -L /etc -name passwd
/etc/pam.d/passwd
/etc/passwd
root@kali:~#

47. apt-get command

apt-get is a package manager used to install, remove, purge, and update packages.

the apt-get command is a most popular command for Debian based operating systems including Kali Linux.

All the available options are below with apt-get command.

48. dpkg command

dpkg command is used to Install deb File in Kali Linux. You can remove packages by using dpkg command as well.

Kali Linux is a Debian based operating system so you can install .deb files only.

For example: you can install Nessus on Kali Linux by using dpkg because the Nessus files do not exist in the repository.

You can run the following command to install packages on Kali Linux by using dpkg command

#dpkg -i package_name

dpkg –i /{Download_Location}/Nessus-{Version}.deb

49. Du Command

The du command is used to display the amount of disk space used by files and directories.

If you run command du without specified path then it will give the result behalf of the current working directory.

If you run du command followed by a specific path, it will summarize disk usage of each file and subdirectories in that directory.

I used the du command without any argument and path. I got a shocking result. You run the command now, check the result and tell me our experience in the comment box.

root@kali:~#du
4	./Pictures
4	./.mozilla/extensions
36	./.mozilla/firefox/l6ruxl24.default/saved-telemetry-pings
12	./.mozilla/firefox/l6ruxl24.default/sessionstore-backups
4	./.mozilla/firefox/l6ruxl24.default/minidumps
56	./.mozilla/firefox/l6ruxl24.default/datareporting/archived/2019-08
40	./.mozilla/firefox/l6ruxl24.default/datareporting/archived/2019-09
100	./.mozilla/firefox/l6ruxl24.default/datareporting/archived
112	./.mozilla/firefox/l6ruxl24.default/datareporting
8	./.mozilla/firefox/l6ruxl24.default/bookmarkbackups
4	./.mozilla/firefox/l6ruxl24.default/storage/permanent/chrome/idb/1657114595AmcateirvtiSty.files
4	./.mozilla/firefox/l6ruxl24.default/storage/permanent/chrome/idb/3561288849sdhlie.files

More: Du Command to get Size of Directory in Linux

50. Curl command

Curl is a command-line utility to transfer data from or to a server. You can say it is used to download and upload files and data by using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more.

Use the following command to know more about #curl

#curl –help

51. Adduser command

Adduser command is used to add a new user. You can create multiple users by using adduser command.

#adduser username

root@kali:~#adduser hemant
Adding user `hemant' ...
Adding new group `hemant' (1000) ...
Adding new user `hemant' (1000) with group `hemant' ...
Creating home directory `/home/hemant' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for hemant
Enter the new value, or press ENTER for the default
	Full Name []: hemant kumar
	Room Number []: 22
	Work Phone []: 9999888889
	Home Phone []: same
	Other []: Ethical hacking learner
Is the information correct? [Y/n] y
root@kali:~#

52. passwd command To change password

Username and password are the basic security of the Kali Linux operating system. You are working on cybersecurity / ethical hacking.

You must keep in mind all security points, and managing password is one of them.

passwd command is used to change the password of a normal user / sudo user/ root user.

Basic example: You are login with root user and want to change current user password then simple syntax as follows:

#passwd

root@kali:~#passwd
New password: 
Retype new password: 
passwd: password updated successfully
root@kali:~#

As you hit enter, you get the screen to enter a new password twice. You will not see anything on the screen at the time of entering a password. Don’t worry at all.

Give a new password and hit enter, again enter the same password and hit enter. Your password for the current user will be updated.

53. usermod command

usermod command is used to modify a user in a group.

By default, Kali Linux is operated by the root user, but it is a loophole of security. So You must use kali Linux with normal user.

But the problem starts from here, lots of tools are required administrative permission. Normal user can not run these tools.

You can run these tools by the root user or sudo user. usermod command will help to promote normal user to sudo user by running following command

root@kali:~#usermod -aG sudo hemant
root@kali:~#

54. lsb_release command to check the version of Kali Linux

lsb_relase command is used to check the version of Kali Linux. There are multiple switches are used with this command.

#lsb_release -a

root@kali:~#sb_release -a
No LSB modules are available.
Distributor ID:	Kali
Description:	Kali GNU/Linux Rolling
Release:	2019.3
Codename:	kali-rolling
root@kali:~#

55. SCP command

scp command is used to copy files from one device to another device securely. There are multiple ways to transfer files from one system to another.

But scp copy files over ssh protocol. One system should have an ssh server running.

Hacker used this command when the compromised system and transfer files. Basic syntax as bellow.

$scp [OPTION] [user@]SRC_HOST:]file1_Path [user@]DEST_HOST:]file2

56. unzip command

Now you are a Kali Linux user, and you are using Kali Linux. You will download many files from different -2 sources.

You will find most of the files in zip format, you can’t use them. You have the challenge to extract files. unzip command will help you get extracted files.

The basic syntax of unzip command

#unzip filename.zip

57. Locate command

Locate command is basically used to find the path to the file you are searching for

$ locate <filename>

58. Rmdir command

rmdir command is basically used to remove or erase a directory

basic syntax:

$rmdir <directory name>

59. ifconfig command

ifconfig command is used to review your ip address of your personnel device

$ifconfig

There are some alternative commands to find ip address

$ ip addr

$ ip a

Thank you for reading this article,

Team BloggerBoy

7 Comments

  1. Together with every thing which seems to be building within this subject material, your points of view tend to be somewhat refreshing. Nevertheless, I am sorry, but I can not give credence to your whole strategy, all be it exhilarating none the less. It appears to everyone that your opinions are not completely justified and in reality you are generally your self not even totally certain of your argument. In any case I did enjoy reading it.

  2. Excellent information was provided. I truly liked reading this piece, and I’m grateful to the author for providing it. Thank you for sharing this blog post. Once again, thanks. Nice.

  3. You could never find the words to describe how much I loved you. No matter how beautiful the picture is or how polished your writing is, you read it quickly. To be honest, I think you should give it another chance soon. I will probably try to go on this hike again and again if you make sure it is safe.

Leave a Reply to Hemant Kumar Cancel reply