Kali Linux Comand Example
Kali Linux Comand Example
Rosetta, 2021
In this article, i have explained all the kali linux terminal command in detail with the
example.
Basic Commands
[root@kali ~] pwd
[pwd will show the Present working directory]
[root@kali ~] ls
[ls will show the list of file and directory of present working directory.]
[root@kali ~] ls b*
[ls b* will show the list of file and directory starting with b and end with anything.]
[root@kali ~] ls -l
[Listing of all files and directory along with attributes(i.e. more detailed format like file
permission,file size etc.]
[root@kali ~] ls -a
[Listing of all files and directory along with hidden file or file starting with periods (i.e. file
stating with * like *bashrc]
[root@kali ~] ls -R
[show the listing of file and directory in tree structure.]
[root@kali ~] cd
[To change the directory.]
[root@kali ~] cd com
[go to directory name com .]
[root@kali ~] cd ..
[change the directory one level back.]
[root@kali ~] cd ../..
[change the directory two level back.]
[root@kali ~] cd ~
[change the directory to home directory.]
[root@kali ~] Vi <filename>
[It will create a Blank file.]
[root@kali ~] Vi file1.txt
[root@kali ~] cd -
[root@kali ~] rm Kalirosetta.txt
[rm remove the file Kalirosetta.txt.]
Method 1
chmod <permission> <file or directory name>
Method 2
chmod <permission> <file or directory name>
eg:1 : if user file permission change from rwx to rw only ,group file permission change from
rwx to r only and other file permission change from rwx to r only.
File Permission
VIM
Vim is simply an improved version of Vi. It pretty much has a ton of stuff that Vi doesn‟t.
Within Vim you can see the differences between Vi and Vim by running the following
command :h vi-differences.
[root@kali ~] Vi <filename>
[It will create a Blank file.]
[root@kali ~] Vi file1.txt
[to open file1.txt using Vi]
[press i - to insert text in file1.txt]
[press Shift+: and then type wq to save and quit.
: q to exit without any changes in file
: x to save changes and exit.]
Group Administration
1 : To add new group named projectX command will be
groupadd projectX
eg: To add username kalirosetta in a group name called projectX and project Y
BACKUP
c -- create
v -- verbose means it will show all the error while creating creating backup.
p -- same permission i.e. maintains the same permissions of file which is backed-up
f -- specifies filename
t -- table of content
x -- extract to
z -- zip/gzip
w -- ask for confirmation
To create a backup
Type1: tar --create --verbose --same-permission --file /usr/backup1 /home /etc
Type2: tar -cvpf /usr/backup1 /home /etc
c-create
v-verbose
p-maintains the same permissions of file which is created
f-to create a file
/usr is the directory were backup is saved
backup1 is the name of backup file created
/home & /etc are the directory for which backup is created
list view of files in backup useful for recovering file which name is not known
SYSTEM COMMANDS
uname -a
Display linux system information
uname -r
Display kernel release information
last reboot
Show system reboot history
date
Show current date and time
cal
Show current month calendar4
whoami
Who you are logged in as
finger user
Display information about user
cat /proc/cpuinfo
Show cpu info
cat /proc/meminfo
Show memory information
man command
Show manual for command
du
Check subdirectories
df -h
Shows file size which is user readable
du --max-depth=1 -h
Check subdirectories by one level down
whereis app
Show possible location of app
which app
Show which app will be run by default
free
To check ram & swap partition usuage
free -g
To see usuage in gigabytes
mkswap /swapfile
To setup a linux swap area in a file.
swapon /swapfile
Enable the swap file.
swapoff /swapfile
Disable the swap file.
Determine the size of the new swap file in megabytes and multiply by 1024 to determine the
number of blocks. For example, the block size of a 64 MB swap file is 65536.
ctrl+alt+f1
GUI (Graphical mode) to text mode i.e. CLI(Command Line Interface)
kcontrol &
Configure the kde enviroment
gnome-control-center
Configure the gnome enviroment
switchdesk kde
Set the default startup to kde
switchdesk gnome
Set the default startup to gnome
up2date-config
Configure the red hat for update
sync
Sync the changed or changes take effect
top
Will show the running process list
gnome-system-monitor
Show the graphical mode of running process
uptime
Show how long the system is running from last boot
load average of first no show the the total load in last one minute
load average of second no show the the total load in last five minute
load average of third no show the the total load in last fifteen minute
NETWORK MANGEMENT
ifconfig
Show the ip address eth0
ip addr show
Display all network interfaces and ip address
(a iproute2 command,powerful than ifconfig).
ethtool eth0
Linux tool to show ethernet status
mii-tool eth0
Linux tool to show ethernet status
ping host
Send echo request to test connection
whois domain
Get who is information for domain
dig domain
Get DNS information for domain
dig -x host
Reverse lookup host
host kali.org
Lookup DNS ip address for the name
hostname -i
Lookup local ip address
wget file
Download file
wget -c file
Continue stopped download
wget -r url
recursively download files from url
netstat -tupl
Listing all active listening ports
hostname
Show system host name
SSH-Secure Shell
ssh user@host
Connect to host as user
e.g.: ssh [email protected]
The above command will open ftp session and then type your ftp username & password.
username:ftp username
password:ftp pasword
Installing apache from the source require the –devel package to be installed on your server.
You can find the latest available version of Apache, you can download it here:
http://httpd.apache.org/download.cgi
Once you download the source file move it to the /usr/local/src folder.
[root@kali ~] cd /usr/local/src
>Apache file is archived with .tar.gz so first use gzip command to extract the data from gzip.
>Now use tar command to extract the data from .tar archived file.
>The compilation of Apache within the /usr/local/apache directory with the DSO capability.
The –enable-so option, can load required modules to apache at run time via the DSO
mechanism rather than requiring a recompilation.
NameVirtualHost *:80
<VirtualHost 192.168.0.108:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/kalirosetta.com
ServerName www.kalirosetta.com
</VirtualHost>
<VirtualHost 192.168.0.108:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/kalirosetta1.com
ServerName www.kalirosetta1.com
</VirtualHost>
Now check the configuration file and make sure all “syntax Ok” with below command
[root@kali ~] httpd –t
<VirtualHost 192.168.10.18:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/kalirosetta.com
ServerName www. kalirosetta.com
</VirtualHost>
<VirtualHost 192.168.10.19:80>
ServerAdmin tuts@ kalirosetta.com
DocumentRoot /var/www/html/kalirosetta1.com
ServerName www.kalirosetta1.com
</VirtualHost>
If user want to deploy the php website then mod_php enabled on your server
This file is find in /etc/httpd/conf.d/ directory.
| means pipe and show the details in table views i.e.in more format
grep is like finding the particular word in whole directory here we are looking for
php5_module so command will be grep "php5_module"
SECURITY
Things to be considered before configuring apache server.
ServerSignature Off
If /var/www/ don‟t have the index file then webserver shows the document root directory
This feature could be turn off for a specific directory through “options directive” available in
the Apache configuration file.
<Directory /var/www/html>
Options -Indexes
</Directory>
<Directory/>
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
This will not allow user to access outside the web root directory
The changes that you make to your iptables rules will be scrapped the next time that the
iptables service gets restarted unless you execute a command to save the changes
For Ubuntu:
sudo /sbin/iptables-save
Red Hat/CentOS:
/sbin/service iptables save
Or
/etc/init.d/iptables save