Commands
curl cheat.sh/find | curl https://cheat.sh/find | bash alias: function ct { curl cheat.sh\/"$1"; } | on github |
Cheat sheets: muo Vim | vim | tldr simpler man pages | find | awk | awk quickref | htg awk | sed | sed, htg | 13 CLI cmds | dig | netstat cmds | html |
ls -Al | tr -s ' ' | cut -f9- -d' ' (list just file and folder names; -R for dir recursion)
comm -12 <(sort file1.txt) <(sort file2.txt) find common lines in two files
cat papers_to_read.htm | sort | cut -c 1-50 | uniq -d (find duplicate lines)
gpg --output outfile.gpg --symmetric --cipher-algo AES256 file.ext | gpg -o original_file.txt -d file.txt.gpg |
history -c
chmod --reference=reference_file file | chown --reference=reference_file file |
sudo systemctl -a | sudo systemctl --state active |
sudo cp -p pedit.html blogview.html cp -rp doc | sudo chmod/chown --reference=f f1 [f2 f3] |
grep -Eri '(Redirect|RewriteRule)' /etc/apache2/
host ipaddr|domain (Cloud Shell: get ip addr for domain or domain for ip addr, etc)
find /tmp -type f -name ".htaccess" -exec grep -EHi '(Redirect|RewriteRule)' {} \;
find . -maxdepth 1 -type f -name "*.md" -exec ls -al {} \; |
whatis | free | find . -type f -perm 777 -exec chmod 644 {} \; |
sudo apache2ctl -M (show all loaded modules)
sudo apache2ctl -D DUMP_RUN_CFG | sudo apache2ctl -D DUMP_VHOSTS
sudo apache2ctl -S (show parsed VHost settings) | sudo apachectl -t (apache config test)
journalctl -u ssh.service | journalctl -u network.service | journalctl article |
faillog
netstat -tulpn | netstat -npl
tar -cvzf archive-name.tar.gz directory-name | tar -C /diff-folder -xvf yourfile.tar to extract to a different directory |
curl http://ipv4.icanhazip.com or curl http://icanhazip.com` or curl http://ip.fossdaily.xyz | curl --ssl | curl --insecure | curl -I http://domain.com (headers info) |
wget --no-check-certificate
zgrep -E "^(Remove:|Purge)" /var/log/apt/history.log*
sudo iptables -L -nv --line-numbers | sudo iptables-restore < /etc/iptables/rules.v4 |
lastlog | last
install pkgs “kept back”: sudo apt-get dist-upgrade | sudo apt-get --with-new-pkgs upgrade |
apt list --installed | grep " installed" /var/log/dpkg.log (also log.1) | apt show <pkg> |
sudo -u www-data php occ app:list
sudo systemctl list-unit-files | sudo systemctl list-unit-files | grep -i docker |
sudo systemctl | grep running (list running services)
sudo systemctl list-unit-files | grep enabled (list enabled services)
apt-cache search php7.3
dpkg-query -L <package name> (list files in package)
zip -d gallery.zip "picture_43_9.jpg" (delete file from zip, note zip goes first, followed by file)
netstat -plane | grep :80 | awk '{print $5}' | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'| sort | uniq -c | sort -n conn port 80
perl -pi -e 's,RoseHosting,BestManagedVPS' file.php Replace all string instances w/o opening file w text editor
find /home -type d -perm -o+w -exec ls -ld {} \; find world-writable directories in /home
sed -e "s/\r//g" file > newfile remove newline chars from file
sed -i 's/search/repace/g' *.php replace string in all specified files
sudo sshd -T | sudo systemctl reload ssh.service | /etc/ssh/sshd_config | ssh security hardening |
sudo lshw
df -h | df -T
systemctl list-unit-files --type=service
systemctl list-dependencies graphical.target
apt list --installed
apt purge <unneeded package>
sudo apt autoremove | sudo apt autoclean
id <username>
timedatectl | Bash date to/from unix epoch time: date +%s | date -d @<unix epoch time> |
hostnamectl status
lsb_release -a | cat /proc/version |
gcloud info | gcloud version |
Windows: netstat | findstr ESTABLISHED
Replace string recursively with find and sed Remove all dpkg rc residual packages
delete every line until PATTERN, that line included: cat index.html | sed '1,/body onload/d'
print (p) from the first line matching PATTERN to the end ($): cat index.html | sed -n '/body onload/,$p'
Which Linux distro is running: cat /etc/*-release
dpkg queries:
-l, --list package-name-pattern...
List packages matching given pattern.
-s, --status package-name...
Report status of specified package.
-L, --listfiles package-name...
List files installed to your system from package-name.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
-p, --print-avail package-name...
On debian/ubuntu, use instead: apt-cache show package-name
Display details about package-name, as found in /var/lib/dpkg/available.