---
# System prepended metadata

title: Ethical Hacking

---


# Ethical Hacking

## Useful Shortcuts

`Ctrl + Alt + T` - Opens Terminal

`Ctrl & +` - Increases the Font Size

`Ctrl & -` Decreases Font Size

`Windows Key + Arrow Keys` - Move the terminal to the tiles

`Ctrl + L` - Clear the terminal

`Ctrl + C `- Stop a Process currently running

`Ctrl + Z` - Pause a Process currently running

`Arrow UP` - Previous Command

`Tab` - Auto-complete

`Ctrl + Shift + W` - Close Terminal

## File management and File Manipulation

### Listing
`pwd` - "Print Current Directory" - Show the Current Directory

`ls` - List the files and Directorys inside the current Directory

`ls -l` - Display a long listing of the content of current directory

`ls -a` - Display all files and directory in the current directory including hidden files

`ls -al` - Display a long listing of the content  in the current directory including hidden files

`ls -lh` - Display a long listing of the content in the current directory with the files sizes

`ls -lR "Directory"` - Display subdirectories recursively, it display the directory and the subdirectorys inside.

### Move Through Directory

`cd /` - Cahnge to the root of the file system

`cd ~` - change to home directory

`cd` - Change Directory

`cd ..` - Change to previous Directory

### File Manipulation

`whatis "command"` - Shows what a command does

`man "command"`  - Show a manual of how to use the command(very basic and confusing)

`touch` - Create a file

`mkdir` - Create a directory

`echo "text"` - displays text 

`echo "Hello" > text.txt` - Create a file with the text inside

`Cat` - Show the text inside the file

`Cat "etc/passwd" > passwd.txt` - Create a file with the contents of a directory.

`rm` - Remove files 

`rm -R` - Remove Directory

`mv "filename" "Directory"` - Move a file to a directory

`mv "filename" "new filename"` - Rename the file

`nano` - text editor 

`vim` - text editor (cursed)


`./` - execute programs or scripts

## File & Directory Permissions

	ls -alh

	total 12K
	drwxr-xr-x  3 mike mike 4,0K set 29 10:54 .
	drwxr-xr-x 14 mike mike 4,0K set 29 10:20 ..
	-rw-r--r--  1 mike mike    0 set 29 10:54 test.sh
	drwxr-xr-x  2 mike mike 4,0K set 29 10:54 Text

	The d before the read and write permissions means it is a directory.
	It it has - it means its a file

	The first column is the permissions for the owner of the file
	
	The second column is the permissions of the group 
	
	The third columns is the permission for the rest of the users


	R - Read
	W - Write
	X - Execute


	
## 


`chmod` - change the permission of a file

`chmod u=rwx "file"` - give full permissions for user/owner

	u - owner
	g - Group
	o - Other users
	+ - Add permissions
	-   Remove permissions
	= - Set Permissions

"chmod go-wx "file"- take the write and execute permission froom group and other users


`chmod 777 "file"` - full permission for everyone(favorite)

## 
![](https://i.imgur.com/Q0hgxw9.png)
	


`chmod -R` - Set up Permission Recursevely , it sets up permissions on the chosen directory and the subdirectorys inside.

## File & Directory Ownership

`chown` - Change file owner and group

`chgrp` - Change group ownship 

`group -user` - See what group does the user belong to



## grep & Piping

<span style="color:#B22222">**Disclaimer - Some Distros Don't Recognize "-all" - Just Remove It And It Works**</span>


## 

`grep` - prints line in matching a pattern

`grep "dynamic" /etc/proxychains4.conf` - Search for a certain word in a file(Case Sensitive)


`grep -i "dynamic" /etc/proxychains4.conf` - Search for a certain all words in a certain file(non Case sensitive)

`cat /etc/passwd | grep "mike"` - Search for a certain all words in a 
certain file

`ifconfig | grep inet`- Search inet inside the command ifconfig

## Finding Files with Locate

`locate` - find files by name(case sensitive)


`sudo updatedb` - if locate isn't working

`locate passwd` - all passwd named files(messy)

`locate --all "passwd" ` - same thing

`locate /etc --all "passwd" ` - locate all passwd inside etc directory

`locate "passwd" | grep "/etc"` -
Shows all passwd named files inside etc directory but highlights etc 


`locate "passwd" | grep "/etc/passwd"` - Shows all passwd named files inside etc directory but highlights etc/passwd


`locate --all "*.conf" | grep resolv` - Shows all files with the conf extension and highlights the one named resolv 

`locate -c proxychains`- Count how many results 

`locate -i proxychains` - Non Case sensitive

## Enumerating Distributiom & Kernel Information

`whoami` - tells the user 

`hostname` - Os hostname 

`sudo nano /etc/hostname` - change hostname

`lsb_release -a` - system info

	for other distros - `cat /etc/os-release`
	
`lscpu` - CPU information

`uname -s` - Name of System

`uname -r` - version of system


## Find + OverTheWire Bandit 

`find` - search for files in a directory

`sudo find / -type f -name "proxychains.conf"`

	/ - directory can be any directory
	-type 
		- f for file
		- d for directory
	- name and the name of the file your looking for


`sudo find /etc -type d -name "*conf" ` - search .conf extension

`sudo find /etc -name "proxychains.conf" -size +1M ` - search with sizes

`find . -type f | xargs file` - find a file with text inside

`find . -type f -size 1033c ! -executable |xargs file` - find a file with 1033 bytes not executable 

`find / -size 33c -user bandit7 -group bandit6 | xargs file` 


## Shells & Bash Configuration

`echo $SHELL` - what shell i am using

`cat /etc/shells` - valid login shells

`chsh` - Change Shell

`cat /etc/passwd | grep mike`


`history` . history of commands

https://overthewire.org/wargames/bandit/bandit7.html


## Disk Usage

du - estimate file space usage

du -sh * - see how much space the current directory is taking


du -shc *  - total space

df -h - see the amount used/available etc

## File compression & and Archiving with tar

tar - winrar do linux

tar -cf name.tar nameofdirectory

tar -cfv name.tar nameofdirectory

tar -czf name.tar.gz nameofdirectory

tar -xvf - to unpack

## User and Groups & permission with visudo 

adduser - create user

sudo visudo - goes to sudoers

userdel -r "user"

## Networking

ifconfig - old networking comand

ip - new networking ocmmando

ip route show - current ip table

ip addr - current ip 

netstat -t - networking tool used for troubleshooting and configuration


## TOR & Proxychain

