#!/bin/bash
#
# author: twily 2017-2023
# place in /usr/bin/help` or ~/.local/bin/help to replace $ help command
CLEAR="\033[0m"
GREEN="\033[0;32m"
RED="\033[0;91m"
PINK="\033[0;95m"
YELLOW="\033[0;33m"
BLUE="\033[0;94m"
CYAN="\033[1;96m"
GREY="\033[0;90m"
BLOCKYELLOW="\033[3;93m"
BLOCKGREEN="\033[3;92m"
BLOCKRED="\033[3;91m"
BLOCKPINK="\033[3;95m"
BLOCKCYAN="\033[3;36m"
echo -e "Read a file"
echo -e "$"$CLEAR" "$GREEN"less/more "$RED"file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"cat "$RED"file"$CLEAR""
echo -e ""
echo -e "Create files or folders"
echo -e "$"$CLEAR" "$GREEN"touch "$RED"filename"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"echo "$RED"\"your string to empty file\" "$CLEAR"> "$RED"filename"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"mkdir "$CLEAR"-p "$RED"folder/subfolder"$CLEAR""
echo -e ""
echo -e "$"$CLEAR" File handling"
echo -e "$"$CLEAR" "$GREEN"mv "$RED"path/to/source path/to/dest"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"cp "$RED"path/to/folder/* path/to/dest "$CLEAR"-Rv "$CLEAR""
echo -e "$"$CLEAR" "$GREEN"rm "$RED"file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"rm "$CLEAR"-f "$RED"file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"rm "$CLEAR"-r "$RED"folder"$CLEAR""
echo -e ""
echo -e "Edit files"
echo -e "$"$CLEAR" "$GREEN"nano "$RED"filename"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"vim "$RED"filename"$CLEAR""
echo -e ""$GREY"(In vim, press "i" to insert, "esc" to enter control mode)"$CLEAR""
echo -e ""$GREY"(To write/exit do "esc" then ":wq"<enter> :w write :q quit)"$CLEAR""
echo -e ""$GREY"(To search in vim press esc then "/search this", "n" for next)"$CLEAR""
echo -e ""$GREY"(Replace all with esc ":%s/old/new/g")"$CLEAR""
echo -e ""
echo -e "Search a file for word (pipe grep word)"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"cat "$RED"file "$CLEAR"| "$GREEN"grep "$RED"word"$CLEAR""
echo -e ""
echo -e "Find a file or folder"
echo -e "$"$CLEAR" "$GREEN"find "$CLEAR"/ -iname "$RED"\"something*\""$CLEAR""
echo -e ""
echo -e "Find files containing word in current folder"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"find "$CLEAR". -type f -exec grep -Hi "$RED"\"word\""$CLEAR" {} \;"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"find "$CLEAR". -type f -exec sed -i "$RED"'s/replace this string in all files/with this/g'"$CLEAR" {} \;"$CLEAR""
echo -e ""
echo -e "Change into another user, with or without users environment"
echo -e "$"$CLEAR" "$GREEN"su "$CLEAR"- username"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"su "$CLEAR"username"$CLEAR""
echo -e ""
echo -e "List all running processes"
echo -e "$"$CLEAR" "$GREEN"ps "$CLEAR"aux"$CLEAR" | "$GREEN"grep "$RED"name"$CLEAR""
echo -e ""
echo -e "Terminate a process"
echo -e "$"$CLEAR" "$GREEN"kill "$CLEAR"<PID>"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"kill "$CLEAR"-9 <PID>"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"pkill "$CLEAR"<NAME>"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"killall "$CLEAR"<NAME>"$CLEAR""
echo -e ""
echo -e "List all ports in use"
echo -e "$"$CLEAR" "$GREEN"lsof "$CLEAR"-i -P -n | "$GREEN"grep "$CLEAR"LISTEN"$CLEAR""
echo -e ""
echo -e "Find what program a process is"
echo -e "$"$CLEAR" "$GREEN"pwdx "$CLEAR"<PID>"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"lsof "$CLEAR"-p <PID> | "$GREEN"grep "$CLEAR"cwd"$CLEAR""
echo -e ""
echo -e "Port forwarding"
echo -e "$"$CLEAR" "$GREEN"iptables "$CLEAR"-A \e[95mTCP "$CLEAR"-p \e[95mtcp "$CLEAR"--match multiport --dports "$RED"1000:2000 "$CLEAR"-j \e[95mACCEPT"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"iptables "$CLEAR"-A \e[95mUDP "$CLEAR"-p \e[95mudp "$CLEAR"--match multiport --dports "$RED"1000:2000 "$CLEAR"-j \e[95mACCEPT"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo ufw "$CLEAR"allow "$PINK"80"$CLEAR""
echo -e ""$PINK"* use latest method below - edit mytable.rules and run command restore (auto loads on reboot)"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo bash "$CLEAR"-c "$RED"'iptables-restore < /etc/ufw/mytable.rules'"$CLEAR""
echo -e ""
echo -e "Permission handling (number 640 = user:group:everyone)"
echo -e "$"$CLEAR" "$GREEN"chown "$CLEAR"user:group "$RED"filename"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chown "$CLEAR"user:group "$RED"folder -Rv"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chmod "$CLEAR"+x "$RED"executable_file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chmod "$CLEAR"-x "$RED"not_executable_file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chmod "$CLEAR"644 "$RED"file"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chmod "$CLEAR"755 "$RED"folder"$CLEAR""
echo -e ""$GREY"4=Read | 2=Write | 1=Executable"$CLEAR""
echo -e ""$GREY"4+2+1=7 = full access, 4+2=6 = read/write, 4 = read only, 0 = denied"$CLEAR""
echo -e ""
echo -e "Uncathegorized"
echo -e "$"$CLEAR" "$GREEN"acme.sh "$CLEAR"--issue -d "$RED"domain.com "$CLEAR"-w "$RED"/var/www/html/domain.com"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"nmap "$CLEAR"-sP "$RED"192.168.2.1/24"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo useradd "$CLEAR"-s "$RED"/usr/bin/zsh "$CLEAR"-g users -G wheel,developers -m username"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo passwd "$RED"username"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo userdel "$CLEAR"-f "$RED"username"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"chsh "$CLEAR"-s "$RED"/usr/bin/zsh"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"usermod "$CLEAR"-a -G group1,group2,group3 exampleusername"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"usermod "$CLEAR"-g groupname username"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sudo groupadd "$CLEAR"mynewgroup"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sc "$CLEAR"name"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sl"$CLEAR""
echo -e "$"$CLEAR" "$GREEN"sr "$CLEAR"name"$CLEAR""
Top