Skip to content

Instantly share code, notes, and snippets.

@blokhin
Last active April 24, 2024 18:40
Show Gist options
  • Save blokhin/49eaaf050e77a9b0cadb44b087d827d9 to your computer and use it in GitHub Desktop.
Save blokhin/49eaaf050e77a9b0cadb44b087d827d9 to your computer and use it in GitHub Desktop.
ssh-copy-id -i ~/.ssh/mykey user@host
export HISTCONTROL=ignorespace
split -l 10000 myfile segment
ssh -nNT -L 9001:host01:22 user@host02
ssh -nNT -L 7777:localhost:8888 user@host02
tar cf - DATA_DIR | gzip --to-stdout --fast | ssh root@host "cd /data; tar xzf -"
tar zc DATA_DIR | ssh root@host "tar zx -C DEST_DIR"
python -m smtpd -n -c DebuggingServer localhost:1025
netstat -nlpt
htpasswd -c ~/.htpasswd user1
less go to line 125: 125g
vi go to line 125: :125
vi go to end of file: G
vi go to n-th symbol: n|
htop
netstat -an | grep :443 | grep -v TIME_WAIT | wc -l
netstat -tuc
echo -n > /dev/tcp/95.213.252.55/80
diff /data/cstar/conf/cassandra.yaml <(ssh root@10.9.4.33 'cat /data/cstar/conf/cassandra.yaml')
diff <(ssh root@10.9.6.1 'cat /data/cstar/conf/cassandra.yaml') <(ssh root@10.9.4.33 'cat /data/cstar/conf/cassandra.yaml')
"netstat -an | grep :5432 | wc -l"
gzip -cd public_profiles_API2.0_2017_10_json.tar.gz | dd ibs=1024 count=20
libreoffice --headless --convert-to pdf 123.odt
# fix keys
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys MISSINGKEY
# simple shmsetup script
page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`
shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`
echo kernel.shmmax = $shmmax
echo kernel.shmall = $shmall
# Perms keys
chmod g-w /root
chmod 0700 /root/.ssh
chmod 0600 /root/.ssh/authorized_keys
nohup tar cf - /DataShare/shares | gzip --to-stdout --fast | ssh -i ~/id_rsa root@192.168.0.52 "cd /DataShare/; tar xzf -" &
nohup tar cf - animations | ssh root@51.15.87.212 "cd /data2; tar xf -"
# Check any DOI meta via Crossref:
curl -D - -L -H "Accept: text/turtle" "http://dx.doi.org/..."
# nohup other file
nohup myprogram > myprogram.out 2>&1
# how long process running
ps -o etime= -p $$
# remove all tags
C:\YandexDisk\apps\exiftool.exe -all= C:\Users\Evgeny\Desktop\2018.jpeg
# find dups
find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD
find . -size +100G -print0 | xargs -0 ls -sd
find . -name *.out -print -exec grep SMEAR {} \;
find . -name "*.pyc" -print0 | xargs -0 rm
find where/ -mindepth 2 -maxdepth 2 -type d
# find non-latin filenames
LC_ALL=C find . -name '*[! -~]*'
# find newer than a year
find . -mtime -365
# postpone cmd
at now + 2 hours
>nohup python /root/mpds-ml-labs/train_regressor.py m > /root/mpds-ml-labs/m_ordered.out 2>&1 &
> ^D
# number of CPUs
grep -c ^processor /proc/cpuinfo
# free mem
echo 3 > /proc/sys/vm/drop_caches
# convert 4 tg
ffmpeg -ss 00:42:00 -i any_fmt_input.avi -c:v libx264 -profile:v baseline -c:a aac -ar 44100 -ac 2 -b:a 128k -vf format=yuv420p result.mp4
# N conns
netstat -ant | grep :5432 | awk '{print $6}' | sort | uniq -c | sort -n
# IP-address
ip=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
# CURE PIP IF NOT FOUND MAIN
hash -d pip && pip -V
systemctl list-units --all
# Memory Error fighting in sysctl.conf
vm.overcommit_memory=2
# Autoload
update-rc.d cassandra defaults
update-rc.d cassandra enable
# Mount volumes
lsblk
mkfs -t ext4 /dev/LABEL
mkdir /data2
mount /dev/LABEL /data2
echo '/dev/LABEL /data2 ext4 defaults 0 0' >> /etc/fstab
# Copy the entire postgres DB to another host
pg_dump -C dbname | bzip2 | ssh user@host "bunzip2 | psql dbname"
# Remote copy preserving symlinks
rsync -az -e ssh root@src:/folder /dest
# Replace in-file
sed -i 's/AllowAllAuthenticator/PasswordAuthenticator/' /data/...
# Tune-up ssh at GCloud: add at least one SSH key to the machine, the run:
sudo vi /etc/ssh/sshd_config # PermitRootLogin
sudo vi /root/.ssh/authorized_keys
sudo systemctl restart sshd
# identify the current init system
ps --no-headers -o comm 1
# how much time job
ps -o etime= -p "$$"
# random contents
dd if=/dev/zero of=TEST.DAT bs=24M count=1
# mass rename and convert files (e.g. PNG -> WEBP)
for x in *.webp ; do mv "$x" `cat /proc/sys/kernel/random/uuid`.webp ; done
for x in *.png ; do mv "$x" `cat /proc/sys/kernel/random/uuid`.png ; done
cwebp xxx.png -o xxx.webp
# mp3 tags and bitrate
ffmpeg -i file.mp3
ffmpeg -i file.wav -b:a 256k file.mp3
eyeD3 -a "Artist" -t "Title" -Y 2024 spring.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment