Linux Commands
This operating system is essential if you want to learn cybersecurity.
Among the preferred distributions for hacking, two stand out above the rest.
Now let’s look at the main commands used in Linux.
SUDO
This is the quintessential command in Linux to execute commands as an administrator.
sudo [command]
Packages
Linux uses packages which would be the equivalent of applications / programs in Windows. When we want to install a program we have to install it using its package name.
- To install packages
sudo apt install [package]
- To remove the package
sudo apt remove [package]
- To remove residual files
sudo apt autoremove [package]
Files
It is VERY IMPORTANT to learn how to deal with files and directories (folders) in Linux.
- To create a file
touch [file]
- To write text directly to a file
echo 'Write text' > [file] ```bash touch [file]
- To delete a file
sudo rm [file]
- To delete a directory and the files inside it
sudo rm -r [directory]
- To locate a file *gets the directory where it is located
locate [file]
Ports
The most important and most used are:
Port | Service | Description |
---|---|---|
21 | FTP | Upload files to the computer |
22 | SSH | Remote access via another computer |
80 | HTTP | Web Service (NOT secure) |
443 | HTTPS | Web Service (MOST secure) |
| SSH
ssh -22 user@telefonica.com
ssh user@192.168.0.0
Networking
- Displays a list of all active network connections and the ports and ports that are connected to the network.
netstat -tuln
- Displays the computers connected to the network
ifconfig
KALI
Screenshot in Kali Linux
-
Ctrl + ImprPant
*whole -
Shift + Ctrl + ImprPant
*part
nmap
Recognition of open ports. Dumps to the file
sudo nmap -p- -sVC -sC --open -sS -vvv -n -Pn [IP] -oN scan.txt
Text editors
Among some of the prominent ones are VIM and Nano
VIM
Text editor for Linux
Command to open a file
vi test.txt
Commands
-
Insert: “I
**Move:** **I
Move: **I` Move: **Move -
Move: **Left
-
Left
H
-
Down
J
-
Up
L
-
Right
K
-
-
Delete line:** press
D
twice -
Save:**
:w
Save::w
-
Save and exit:**
:wq
Save and exit::wq
-
Save and rename:
:w name.txt
Exit and NO Save::w name.txt
Exit and NO Save: `:w name.txt -
Exit and NOT Save:**
:q!