Kali Commands
Kali Commands
Kali Commands
After opening the command line in linux OS, we saw a default message.
SHORTCUTS:
Alias - Sometimes typing commands can get really repetitive, or if you need to type a long
command many times, it’s best to have an alias you can use for that.
Usage: alias minoj=’sudo apt install’
Keep in mind that this command won't save your alias after reboot, so you'll need to add a
permanent alias in: ~/.bashrc
Auto-Complete
Cursor Movement
[CTRL] + U - Erase everything from the current position of the cursor to the beginning of the
line.
[Ctrl] + K - Erase everything from the current position of the cursor to the end of the line.
Ends Task
End-of-File (EOF)
Clear Terminal
[CTRL] + L - Clears the terminal. An alternative to this shortcut is the clear command you
can type to clear our terminal.
Background a Process
[CTRL] + Z - Suspend the current process and run in the background.
[CTRL] + R - Search through command history for commands we typed previously that
match our search patterns.
Zoom
GETTING HELP:
Man - manual of any tool, full documentation of tool
Usage: man curl
Help - it is also like a man command but it gives a list of arguments connected with the tool.
Usage: curl –h (or) curl -h (or) curl –help
SYSTEM INFORMATION:
Whoami - it displays the username ( tells the username who is working )
usage: whoami
Hostname - it displays the hostname ( tells the hostname )
usage: hostname
Uname - prints basic info about the operating system and hardware
usage: uname
Pwd - present working directory, it tells the path you are in!
usage: pwd
Ifconfig - interface configuration, displays the status of the currently active network
interfaces and network related information
usage: ifconfig
Netstat - shows network status, Print network connections, routing tables, interface
statistics. netstat displays a list of open sockets.
usage: netstat
usage: ss
Who - Displays who is logged in. ( username with date and time )
usage: who
Ssh - secure shell, to configure and maintain a computer through remote access.
usage: ssh username@ipaddress and password
NETWORK CONFIGURATION:
ping - used to test connectivity between two devices. It sends packets to a remote host and
measures the time to return them.
Usage: ping <ip address>
traceroute - This will display the IP addresses of the devices that the packets pass through
to reach the website server. It sends packets to a remote host and displays the IP addresses
of the devices that the packets pass through.
Usage: traceroute <www.tryhackme.com>
NAVIGATION:
In windows, for navigating to any location, we use a mouse or touchpad. In linux, we can use
the command line.
Ls - it lists the files and folders in the current directory. Hidden file names start with . (.bash)
usage: ls
Cd - change directory/path.
usage: cd Desktop (or) cd /Desktop/downloads/path
Touch - create a new text file. Only for creating, not editing. For creating and editing, use the
NANO command.
usage: touch test.txt
Mv - move and rename files. The mv command is able to move multiple files, as long as the
final argument provided to the command is the destination.
usage: mv test.txt testing.txt ( for renaming file ) and mv test.txt Downloads/ ( for moving
test file to downloads folder )
Cp - copy files
usage: cp Storage/readme.txt Storage/local/
EDITING FILES:
Touch command is used for just creating a file and mkdir is used to create a folder. For
editing, have a look.
> - to add text to newly created files/replace the existed text in that file
usage: echo “i like food” > food.txt
Which - it searches for the file and give its path also.
Usage: which <filename,foldername>
Find - it is also used for searching, it results the all related files.
Usage: find <filename>
Locate - it offers us a quicker way to search through the system. It is an effective search.
Usage: locate <filename>
FILTER CONTENTS:
Grep - The grep command is a text filter that will search input and return lines which contain
a match to a given pattern.
Usage: grep <search term> <filename> eg., grep Monkey alpha.txt
REGULAR EXPRESSIONS:
PERMISSION MANAGEMENT:
R - read
W - write
X - execute
U - owner
G - group
O - others
A - all users
Permission codes:
777 - anyone can do anything (read, write, or execute)
755 - you can do anything; others can only read and execute ( drwx-r-xr-x )
711 - you can do anything; others can only execute
644 - you can read and write; others can only read
USER MANAGEMENT:
Sudo - execute as root, execute command as a different user.
Usage: sudo <command>
PACKAGE MANAGEMENT:
Package files are commonly installed by downloading them directly from repositories located
on Internet servers. The Debian repositories contain more than 65,000 different packages of
software. Before installing a package, it is good practice to refresh the list of available
packages using the apt-get update command.
A package is an archive file. Packages are archives that contain binaries of software,
configuration files, information about dependencies and keep track of updates and upgrades.
When installing a program from a standalone ".deb" file, we may run into dependency issues
and need to download and install one or multiple additional packages.
Apt - Advanced Package Manager, Apt provides a high-level command-line interface for the
package management system.
Usage: sudo apt install <package name>
Updating all packages of the system should be done in two steps. First, update the cache of
all packages available with apt-get update. Second, execute the apt-get upgrade
command and all packages and dependencies will be updated.
An administrator can execute the apt-get remove command to remove a package or the
apt-get purge command to purge a package completely from the system.
Gem - Gem is the front-end to RubyGems, the standard package manager for Ruby.
Usage:
Pip - Pip is a Python package installer recommended for installing Python packages that are
not available in the Debian archive. It can work with version control repositories (currently
only Git, Mercurial, and Bazaar repositories), logs output extensively, and prevents partial
installs by downloading all requirements before starting installation.
Usage: pip install
Git - we have git installed, we can use it to download useful tools from Github.
Usage: git clone <repository address>
Semicolon (;)
Double ampersand characters (&&)
Pipes (|)
The difference between them lies in the previous processes' treatment and depends on
whether the previous process was completed successfully or with errors.
semicolon(;) - The semicolon (;) is a command separator and executes the commands by
ignoring previous commands' results and errors.
Usage: echo 1; ls; cat test.txt
AND characters (&&) - to run the commands one after the other. If there is an error in one
of the commands, the following ones will not be executed anymore, and the whole process
will be stopped.
Usage: touch test.txt && vim
Pipes (|) - depend not only on the correct and error-free operation of the previous processes
but also on the previous processes' results.
Usage: touch test.txt | vim
WEB SERVERS:
We need one local web server for receiving http responses and installing web pages locally
for running PHISHING pages.
A separate function is considered as a server. We regularly saw some of these:
APACHE2
PYTHON
SSH
VPN
Ssh - for operating systems remotely. We can connect to another system remotely.
Usage: ssh username@ip address
Apache2 - running web server locally
Usage: systemctl start apache2
cURL - for downloading and viewing pages and files from web server
Usage: curl http://localhost
CONTAINERS:
Containerization is a process of packaging and running applications in isolated
environments, such as a container, virtual machine, or serverless environment. Technologies
like Docker, Docker Compose, and Linux Containers make this process possible in Linux
systems.
For example, we might need to test a web application requiring a specific database or web
server version. Rather than setting up these components on our machine, which can be
time-consuming and error-prone, we can create a container that contains the exact
configuration we need.
Su - switch user(superuser)
Ssh - to connect two computers ( ssh username@ipaddress )
Ifconfig - to check network connections, ipaddress
Cd - change directory (change from one path to another)
Cd .. - to get back from directory
Cd - to go to home ( there is a space after cd )
Pwd - print working directory ( it tells your current path)
Ls - list out all file in current directory
Ls -al - to check hidden files (-al is a switch, check all switches at -help)
Help - to get help ( enter command name and then enter –help , eg: cp –help )
Man - to get manual of any command (man su)
Apropos - Each manual page has a short description available within it. This tool searches
the descriptions for instances of a given keyword.
—---------------------------------------------------------------------------------------------------------------
—------------------------------------------------------------------------------------------------------------------------