2. Basic usage of Kali Linux 2

1. Introduction and installation of Kali Linux 2

1. Introduction to Kali Linux 2

Kali Linux 2 is an operating system for professional penetration testing and security auditing, which was developed from the previously well-known Back Track system. Back Track was once the best penetration test operating system in the world and achieved great success. Offensive Security then upgraded Back Track and launched Kali Linux 1.0 in March 2013, providing more updated tools than Back Track. After that, Offensive Security updates Kali every once in a while, launching the more powerful Kali Linux 2 in 2016. The latest version is the Kali Linux 2020 series, launched in 2020. This version contains a variety of programs in 13 categories, covering almost all the best penetration testing tools in the world today. If you haven't used Kali Linux 2 before, you'll be absolutely thrilled by the sheer number of tools in it.

Metasploit5 is built in.

2. Installation of Kali Linux 2

Kali Linux 2 is an operating system that can be installed on almost any smart device. Computers, tablets, mobile phones, virtual machines, U-disks, and disc playback devices can all be carriers of Kali Linux 2, plus the now popular Raspberry Pi (RPi) can also install Kali Linux 2. Even Amazon's cloud computing service platform AWS provides a virtual host with Kali Linux 2.

Use Kali Linux 2 installed in the VMware virtual machine environment.

2. File System in Kali Linux 2

1. File System in Kali Linux 2

Beginning with version 2020.1, the default user in Kali Linux 2 is no longer the previous root but has changed to kali. When this user tries to complete some root access and operations, he or she needs to use sudo and verify his or her password. sudo indicates that he or she temporarily switches to superuser mode to perform superuser privileges. When prompted for a password, the password is the current user's password. Instead of the password for the super account. To frequently execute certain privileges that only super users can execute, instead of typing the password each time, you can use the command "sudo-i".

2. Safe cattle

file        A collection of logically complete information.

Catalog        Amount to Windows Folder below to hold related files. Because a directory can contain subdirectories, it can be layered                
            Layers are nested and thus form file paths.

Catalog Items      In a file path, each part of the path is referred to as a directory item, such as a path/etc/apache2/apache2.conf 
            Medium, directory/,etc,apache2 And files apache2.conf Is a directory item.

3. Some important directories in Kali Linux 2

4. Safe cattle

Kali Linux 2 is a Linux system itself, so command line operations are unavoidable when using it. Before learning commands, we need to know three nouns -- Shell, Bash, and Terminal.

In Kali Linux 2, we execute commands using a shell, an application that provides an interface through which users can access operating system kernel services. There are a number of Shells available, and the Bash Shell (see figure) we use in Kali Linux 2 is also the more popular one. A terminal is a program that interacts with a shell.

3. Common commands in Kali Linux 2

1,    File directory related commands

2,    File View Command

3,    Network related commands

4,    Process Control Command

5,    Kali Service management in

6,    Kali In shell Script

1. File directory

PWD The command is Print Working Directory(Print working directory) is an abbreviation for the current working directory.

cd yes Change Directory(The abbreviation of Change Directory), which functions to change the active directory to a specified path.

ls The command displays the contents of the specified working directory (lists the files and subdirectories contained in the current working directory)). 

locate The command is used to find files that meet the criteria.

whereis Commands are also used to find files.

which Command will be in environment variable $PATH Find qualified files in the directory you set up. 

mkdir yes make directory(Abbreviation for Create Directory) used to create a new directory.

cp: Copy a file or directory with the syntax " cp Source File Target File"

rmdir To delete an empty directory, rm Command to delete non-empty directories.

2. File Viewing

cat The command displays the contents of the file in the syntax " cat Catalog items, cat Commands can display files on the screen, merge files, and create text files.

in addition head,tail,nl,more and less Commands can also be used to browse files.

grep Command is used to find qualified strings in a file.

more Commands are similar cat ,However, it will be displayed page by page, making it easier for users to read page by page, and users can press the space bar when reading. space)To display the next page, press b Key to return ( back)One page shows.

less and more Similar, but using less You can browse through the files as you like. Here's how to use less After the parameters display the contents of the file, some actions can be taken by the user.

3. Network-related

Kali Linux 2 supports both net-tools and iproute2, so you can use both commands to configure and view your network. If you want to view the device's network connection information, you can use "ip addr" and "sudo ifconifg"

Common methods used in ip commands are:

ip addr show: Display network information;

ip route show: Show routes;

ip neigh show: display arp Table (equivalent to arp Command).

4. Process Control

A process is an instance of a program that is running. Commands for process control are provided in Kali Linux 2. The ps command has many parameters for displaying the state of ps of the current process. Here, only a few commonly used parameters are listed and their meanings are explained.

-A List all processes

-w Show wider to show more information

-au Show more detailed information

-aux Show all processes including other users

5. Service Management

In Linux terminology, services refer to applications running in the background waiting to be used. Service commands are used to manage system services, such as start, stop, restart, status, and so on. Many services are pre-installed in Kali linux2. Some services on Kali Linux can be stopped and started through the GUI, just like in Windows or Mac. However, there are also services that require command line management.

Here we describe the syntax for managing basic services:

service servicename start|stop|restart

6. Shell scripts

Shell scripts are similar to batch processing under Windows/Dos, that is, they are pre-loaded into a file with various commands to facilitate one-time execution of a program file, mainly for setup or management purposes. Shell scripts are written in the same way as JavaScript and php, as long as there is a text editor that can write code and a script interpreter that can interpret execution.

Then open an editor and type the following.
#! /bin/bash
echo "Hello, Kali!"
Save this file as HelloKali,No suffix name is required.
We are currently unable to execute this script because of its permissions. You can use it here ls -l Command to view permissions for this file. Currently this file only has w and r Permission, is not executable, here you need to add an executable permission for it.
chmod  755  HelloKali
 Reuse ls -l Look, you can see that it has executable permissions.
kali > ./HelloKali
 There./ You can think of it as looking for files in the current directory.
Press Enter to see the output on the screen:
Hello, Kali!
This indicates that the current program has been successfully executed.

Four Orders

1. Text file editing commands

2. File Directory Management Commands

3. Packaging Compression and Search Commands

4. Document Management Permission Commands

1. Text file editing commands

cat The command is used to view plain text files (less content) in the format " cat [option] [file]"

more The command is used to view plain text files (more content) in the format " cat [option] File"

head The command is used to view the front of a plain text document N Line, formatted as " head [option] [file]"

wc The command counts the number of lines, words, and bytes of the specified text in the format " wc [parameter] Text"

stat The command is used to view the specific storage information and time of the file in the format " stat File Name"

2. File directory management commands

touch The command creates a blank file in the format " touch [option] [file]"

mkdir The command creates a blank directory in the format " mkdir [option] Directory"

cp The command copies a file or directory in the format " cp [option] Source File Target File"

mv The command is used to move or rename a file in the format " mv [option] source file [Target Path|Target File Name]"

file The command is used to view the type of file in the format " file Filename"

3. Packaging Compression and Search Commands

tar The command packages, compresses, or decompresses a file in the format " tar [option] [file]"

find The command is used to find files under specified conditions in the format " find [Find Path] Find Conditional Operations"

4. File Management Rights Command

Use chmod command to modify file permissions

chmod [Options] <Mode, Mode...> < Filename...>

Files and directories have different permissions in linux

Permissions for files:

r Readable files have a value of 4

w Writable file value is 2

x Executable file value is 1

Permissions for directories:

x r Readable ( cp)And view ( ls)The contents of the directory (files and directories), along with executable permissions

Execution rights:

x w You can create files in the directory ( touch)And directories ( mkdir)And delete files ( rm)And directories ( rmdir),Executable privileges are also required

x x You can enter the directory ( cd)And execute the file practice process

Keywords: Cyber Security penetration test Kali Linux

Added by kula on Sat, 12 Feb 2022 20:42:21 +0200