Linux Basic Commands
Notes on rights
400 read by owner 040 read by group 004 read by anybody 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybody
Search for text in files recursively
The following grep will return each filename containing the given text :
grep -Ril "text"
-RRead all files under each directory, recursively.-icase-insensitive search-lPrint the file name for each match. This is the default when there is more than one file to search.
Search for Email Adresses Recursively
The following grep will match all email adresses @gmail.com :
grep -RIHEo "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" . | grep gmail.com
-RRead all files under each directory, recursively.-IProcess a binary file as if it did not contain matching data.-HPrint the file name for each match. This is the default when there is more than one file to search.-EInterpret PATTERN as an extended regular expression.-oPrint only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
To generate list file from addresses found :
grep -RhIEo "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" . | grep gmail.com | sort -u > mails.txt
-hdisables filename printingsort -uremoves duplicates
List Open Files For Process
lsof -p PID
PID = Process ID
Display files and folders sorted by size
Ascending
du -hs ~/web/* | sort -h
Descending
du -hs ~/web/* | sort -hr
Network setup
Disable NetworkManager
systemctl disable NeworkManagerSet static IP with NetworkManagercomputer :: Documents/projects/PentestFTW »
Set IP
nmcli con mod My\ Connection ipv4.addresses 10.1.1.250/24Set Gateway
nmcli con mod My\ Connection ipv4.gateway 10.1.1.1Set DNS
nmcli con mod My\ Connection ipv4.dns 8.8.8.8 Set connection up
nmcli con up My\ ConnectionConnect to wifi with wpa_supplicant
Scan available ESSID
sudo iwlist wlo1 scan | grep ESSID | sort -uGenerate config for ESSID
wpa_passphrase mySSID myPass | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.confConnect to wifi
sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlo1 -BObtain IP address via DHCP
sudo dhclient -v wlo1Set static IP
Assign IP address to interface
sudo ip addr add 192.168.112.45/24 dev myNetworkInterfaceAdd default route
sudo ip route add default via myGateway dev myNetworkInterfaceExtract IP adresses from file
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"Last updated
Was this helpful?