Linux Command Intro
Cheatsheet perintah-perintah dasar Linux
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
whoamipwd
Print Working directory
pwdmkdir
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 Upls
List files in working Directory
ls
ls -la // Print out all files including hidden fileswhich
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 passwordlocate
Find / Search for files
locate -i passwd // Find for passwd files with case-Insensitivewget
Download a file
wget http://<IP>:<Port>/access_log.txtcat
Concatenate / print contents of a files
cat access_log.txthead
Cat only first 10 lines of a file
head access_log.txttail
Cat only last 10 lines of a file
less access_log.txtcp
Copy file
cp access_log.txt access_log.txt.backupmv
Rename or cut a file
mv access_log.txt exercise.txtgrep
Search for specific word in a file
grep admin exercise.txtwc
Count lines, words, bytes, of a files
wc exercise.txtsort
Sort files
sort -u exercise.txt // Sort unique lines on exercise.txttab completion
Automatically fill the command/files names we write
cat ex<TAB> // will show exercise.txthistory
Check history of command we input
historysudo
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 commandsu
switch user
su kali // Switch to kali
sudo su // Switch to rootPiping & 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 outputRedirection 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.txtcut
Cutting out some section of a file
cat user.txt | cut -d ":" -f 1 //Menampilkan hanya colomn 1awk
More powerful than Cut
cat user.txt | awk -F ":" '{print $1 $2}'
cut user.txt | awk -F ":" '{print "Terdapat user bernama " $1}'Last updated
Was this helpful?