Last active
October 2, 2023 22:21
-
-
Save andreacioni/599c9ab9cdf0042d3c1d085a5b24ec7e to your computer and use it in GitHub Desktop.
Linux Command Handbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### FIND #### | |
> Execute a command on every subfolder | |
find -D exec -maxdepth 1 -type d -name "my/directory" -print -exec COMMAND \; | |
####################### SYSTEMD ####################### | |
> Reload service configuration | |
sudo systemctl daemon-reload | |
> Display and follow logs | |
sudo journalctl -u <service> -f | |
####################### DATE/TIME ####################### | |
> Reconfigure Time Zone | |
sudo dpkg-reconfigure tzdata | |
########################## GIT ########################## | |
> Show git tree topology | |
git log --graph --decorate --oneline | |
> Git discard all | |
git checkout -- . | |
> Show commit of a specific user | |
git log --author=<author> | |
########################## DISK ########################## | |
> Backup disk to file | |
GZip | |
(Mac OSX) sudo dd bs=1m if=/dev/disk2 | gzip > Desktop/actionpi-`date +%Y%m%d`.img.gz | |
LZMA | |
(Mac OSX) sudo dd if=/dev/disk2 bs=1m | xz --format=lzma > Desktop/actionpi-`date +%Y%m%d`.img.lzma | |
> Restore file image to disk | |
GZip | |
(Mac OSX) gzip -dc Desktop/actionpi-`date +%Y%m%d`.img.gz | sudo dd bs=1m of=/dev/disk2 | |
LZMA | |
(Mac OSX) xz -F lzma -d -k -c Desktop/actionpi-`date +%Y%m%d`.img.lzma | sudo dd of=/dev/disk2 bs=1M | |
> Found disk information | |
(Mac OSX) sudo diskutil info disk5 | |
(Mac OSX) sudo gpt -r show disk0 | |
######################### NETWORKING ############## | |
socat TCP-LISTEN:65534,fork TCP:192.168.1.112:65534 | |
> Socket Tunnel | |
socat tcp-listen:9060,reuseaddr,fork,bind=10.8.0.1 tcp:192.168.1.105:80 | |
######################### FOLDER NAVIGATION ############## | |
> Execute command in all immediate subdirectory | |
for d in ./*/ ; do (cd "$d" && ls -al); done | |
## | |
iptables -A INPUT -i wlan0 -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT | |
iptables -A INPUT -i wlan0 -p udp --dport 53 -j ACCEPT | |
iptables -A INPUT -i wlan0 -j DROP | |
iptables -L -v -n --line-numbers | more | |
iptables -D INPUT 8 | |
######################## WEB ########################### | |
> Open Chrome without CORS enabled | |
open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment