Catatan ini ditujukan untuk mempermudah pencarian perintah-perintah dasar Linux untuk keperluan Pentesting/VA.Cheatsheet ini disadur dari akun Github rekan saya Satrya Mahardhika.
whoami
Print active User ID
whoami
pwd
Print Working directory
pwd
mkdir
Make Directory
mkdir pentest/
cd
Change directory
cd pentest // Change directory to pentest (Inside Working Directory)
cd /var // change directory to var (Outside Working Directory)
cd //Back to home Directory
cd .. // Directory Up
ls
List files in working Directory
ls
ls -la // Print out all files including hidden files
which
Locate executable file full path
which nmap // Locate the full path of nmap
man
Manual Page of a Command
man which // Manual page of which Command
man -K "change password" // Search for command to change password
locate
Find / Search for files
locate -i passwd // Find for passwd files with case-Insensitive
wget
Download a file
wget http://<IP>:<Port>/access_log.txt
cat
Concatenate / print contents of a files
cat access_log.txt
head
Cat only first 10 lines of a file
head access_log.txt
tail
Cat only last 10 lines of a file
less access_log.txt
cp
Copy file
cp access_log.txt access_log.txt.backup
mv
Rename or cut a file
mv access_log.txt exercise.txt
grep
Search for specific word in a file
grep admin exercise.txt
wc
Count lines, words, bytes, of a files
wc exercise.txt
sort
Sort files
sort -u exercise.txt // Sort unique lines on exercise.txt
tab completion
Automatically fill the command/files names we write
cat ex<TAB> // will show exercise.txt
history
Check history of command we input
history
sudo
Super User do!
cat /etc/shadow // It will prompt Access Denied
ls -la /etc/shadow // Check permission of /etc/shadow file
whoami
sudo -l // Check our sudo privilege
sudo /etc/shadow
cat /etc/shadow
sudo !! // Sudo above command
su
switch user
su kali // Switch to kali
sudo su // Switch to root
Piping & Redirection
Piping ( | ) is a command that let you use two or more commands such that output of one command serves as input to the next command.
cat exercise.txt // Will show all lines of exercises.txt
cat exercise.txt | grep admin // will only show line contain admin
cat exercise.txt | grep admin | wc -c // Count bytes of above output
Redirection is change the output of command to a files
cat exercise.txt | grep admin > admin_exercise.txt
echo "This will overwrite" > admin_exercise.txt | Overwrite exercise.txt with "This will overwrite", or make exercise.txt file if it is not exists
echo "This will not overwrite" >> admin_exercise.txt | write "This will not overwrite" to the last line of exercise.txt