A collection of Linux snipets.
Last active
September 13, 2024 09:40
-
-
Save ethauvin/da52ef47952bcadbc2c4b5d7028407b8 to your computer and use it in GitHub Desktop.
linux snippets
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
apachectl configtest |
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
# Run commands in sequence | |
(cd some/directory && cmd) | |
# Create backup file | |
cp file.txt{,.bak} | |
# Diff original and backup file | |
diff file.txt{.bak,} | |
# Loop thru files | |
for f in * ; do echo $f ; done; | |
# List only dirs | |
ls -d */ | |
# Repeat previous command | |
!! | |
sudo !! | |
# Print previous command | |
!!:p | |
[up arrow] # to execute | |
# Search and print command from history | |
!?foo?:p | |
# Find borken symlinks | |
find -L . -type l | |
# Empty file | |
> file | |
# Change directory to previous location | |
cd - | |
# Open previous command in editor | |
fc | |
# Previous command arguments | |
cd !* | |
alt+. | |
# Previous command first argument | |
cd !^ | |
# Previous command first agrument | |
cd !$ | |
# Search History / Reverse search | |
ctrl+r | |
# Replace/Fix previous command | |
ehco foo | |
^ehco^echo |
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
# list alerts | |
cscli alerts list --since 1h --all | |
# unban ip | |
cscli decisions delete -i <ip address> | |
# ban ip | |
cscli decisions add --ip <ip address> --duration 24h --reason "web brutforce" |
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
# remove files | |
find . -type f -name "FILE-TO-FIND" -exec rm -rf {} \; | |
# open files in vim | |
vim $(find -name "filename.txt") |
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
# add service | |
firewall-cmd --permanent --zone=public --add-service=ms-wbt | |
firewall-cmd --permanent --zone=public --add-port=2525/tcp | |
firewall-cmd --reload | |
# remove service | |
firewall-cmd --permanent --zone=public --remove-service=ms-wbt | |
firewall-cmd --reload |
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
# setup | |
set -U fish_greeting "" | |
fish_config theme choose "ayu Dark" | |
fish_config theme save | |
fish_update_completions | |
# fisher | |
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher | |
# mvn | |
fisher install jorgebucaran/nvm.fish | |
set --universal nvm_default_version 22.8.0 | |
# fzf | |
fisher install PatrickF1/fzf.fish |
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
gpg -c archive.tgz | |
gpg -d archive.tgz.gpg > archive.tgz |
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
grep -ir --include "*.cpp" "xyz" . |
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
# list | |
ipset list -n | |
ipset list setname | |
# remove set | |
ipset destroy setname |
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
# list | |
iptables -nvL | |
iptables -vL INPUT | |
iptables -vL OUTPUT |
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
# like tail -f | |
journalctl -f -n <unit_name> | |
# only X entries | |
journalctl -n X | |
# last boot log | |
journalctl -b | |
# last since | |
journalctl -n <unit_name> --since 9:00 | |
journalctl -n <unit_name> --since today | |
# by process id | |
id -u <name> | |
journalctl _UID=<id> --since today | |
# by patch | |
journalctl /foo/bar/app | |
# only errors since boot | |
journalctl -p err -b |
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
echo stats | nc localhost 11211 | |
telnet localhost 11211 | |
stats |
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
netstat -tap | grep service_name |
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
nmap -sT -O www.example.com |
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
# Upgrade latest node | |
nvm install node --reinstall-packages-from=current | |
# Uninstall old node | |
nvm uninstall OLD_VERSION | |
# Install latest npm | |
nvm install-latest-npm |
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
# first time | |
mkdir /pCloud | |
pcloudcc -n -u [email protected] -s -p-d -m /pCloud | |
# mount | |
pcloudcc -n -u [email protected] -s -d -m /pCloud |
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
# Release from queue | |
postsuper -r queue_id | |
postsuper -r ALL | |
postqueue -f | |
# Create hash map | |
postmap <file> |
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
# continous stat | |
redis-cli --stat | |
# info | |
redis-cli ping | |
redis-cli info | |
redis-cli info server | |
redis-cli monitor | |
# latency | |
redis-cli --latency | |
redis-cli --latency-history | |
redis-cli --latency-dist | |
# list all keys | |
redis-cli keys * | |
redis-cli scan | |
redis-cli --bigkeys | |
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
tmux new -s session_name | |
tmux attach -t session_name |
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
xargs -a args.txt cmd | |
find . -name "*.txt" | xargs -o vim | |
xargs rm < 1.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment