Skip to content

Instantly share code, notes, and snippets.

@ethauvin
Last active September 13, 2024 09:40
Show Gist options
  • Save ethauvin/da52ef47952bcadbc2c4b5d7028407b8 to your computer and use it in GitHub Desktop.
Save ethauvin/da52ef47952bcadbc2c4b5d7028407b8 to your computer and use it in GitHub Desktop.
linux snippets

A collection of Linux snipets.

apachectl configtest
# 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
# 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"
# remove files
find . -type f -name "FILE-TO-FIND" -exec rm -rf {} \;
# open files in vim
vim $(find -name "filename.txt")
# 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
# 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
gpg -c archive.tgz
gpg -d archive.tgz.gpg > archive.tgz
grep -ir --include "*.cpp" "xyz" .
# list
ipset list -n
ipset list setname
# remove set
ipset destroy setname
# list
iptables -nvL
iptables -vL INPUT
iptables -vL OUTPUT
# 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
echo stats | nc localhost 11211
telnet localhost 11211
stats
netstat -tap | grep service_name
nmap -sT -O www.example.com
# Upgrade latest node
nvm install node --reinstall-packages-from=current
# Uninstall old node
nvm uninstall OLD_VERSION
# Install latest npm
nvm install-latest-npm
# first time
mkdir /pCloud
pcloudcc -n -u [email protected] -s -p-d -m /pCloud
# mount
pcloudcc -n -u [email protected] -s -d -m /pCloud
# Release from queue
postsuper -r queue_id
postsuper -r ALL
postqueue -f
# Create hash map
postmap <file>
# 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
tmux new -s session_name
tmux attach -t session_name
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