# Linux Command Intro

Catatan ini ditujukan untuk mempermudah pencarian perintah-perintah dasar Linux untuk keperluan Pentesting/VA.Cheatsheet ini disadur dari akun Github rekan saya[ Satrya Mahardhika](https://github.com/mahaardhiika/VAPT-Training/).

## whoami

Print active User ID

```bash
whoami
```

## pwd

Print Working directory

```bash
pwd
```

## mkdir

Make Directory

```bash
mkdir pentest/
```

## cd

Change directory

```bash
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

```bash
ls
ls -la // Print out all files including hidden files
```

## which

Locate executable file full path

```bash
which nmap // Locate the full path of nmap  
```

## man

Manual Page of a Command

```bash
man which // Manual page of which Command
man -K "change password" // Search for command to change password
```

## locate

Find / Search for files

```bash
locate -i passwd // Find for passwd files with case-Insensitive
```

## wget

Download a file

```bash
wget http://<IP>:<Port>/access_log.txt
```

## cat

Concatenate / print contents of a files

```bash
cat access_log.txt
```

## head

Cat only first 10 lines of a file

```bash
head access_log.txt
```

## tail

Cat only last 10 lines of a file

```bash
less access_log.txt
```

## cp

Copy file

```bash
cp access_log.txt access_log.txt.backup
```

## mv

Rename or cut a file

```bash
mv access_log.txt exercise.txt
```

## grep

Search for specific word in a file

```bash
grep admin exercise.txt
```

## wc

Count lines, words, bytes, of a files

```bash
wc exercise.txt
```

## sort

Sort files

```bash
sort -u exercise.txt // Sort unique lines on exercise.txt
```

## tab completion

Automatically fill the command/files names we write

```bash
cat ex<TAB> // will show exercise.txt
```

## history

Check history of command we input

```bash
history
```

## sudo

Super User do!

```bash
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

```bash
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.

```bash
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

```bash
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
```

## cut

Cutting out some section of a file

```bash
cat user.txt | cut -d ":" -f 1 //Menampilkan hanya colomn 1
```

## awk

More powerful than Cut

```bash
cat user.txt | awk -F ":" '{print $1 $2}'
cut user.txt | awk -F ":" '{print "Terdapat user bernama " $1}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.anggipradana.com/tutorial/linux-command-intro.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
