Last active
August 17, 2018 10:17
-
-
Save oxidizeddreams/2f202ad1d31989e63527dbe4fdfcfd6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 specific emails from the postqueue | |
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } | |
# $7=sender, $8=recipient1, $9=recipient2 | |
{ if ($8 == "[email protected]" && $9 == "") | |
print $1 } | |
' | tr -d '*!' | postsuper -d - | |
# ssh-keygen options | |
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N "" < /dev/null | |
ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key -N "" < /dev/null | |
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N "" < /dev/urandom | |
ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key -N "" < /dev/urandom | |
ssh-keygen -t ed25519 -a 100 -f ssh_host_ed25519_key | |
ssh-keygen -t rsa -a 100 -b 2048 -f ssh_host_rsa_key | |
# convert ssh keys | |
# from SSH2 to OpenSSH | |
ssh-keygen -i -f nameofpubkey.pub > newnameofpubkey.pub | |
# from OpenSSH to SSH2 (rfc4716 format) | |
ssh-keygen -e -f nameofpubkey.pub > newnameofpubkey.pub | |
# print human-readable process name | |
ps rf -opid,cmd -C <process-name> | awk ‘$2 !~ /^[|\\]/ { print $1 }’ | |
# drop this in your .bash_profile to use a default SSH key with the agent | |
if [ -z "$SSH_AUTH_SOCK" ] ; then | |
eval `ssh-agent -s` | |
ssh-add | |
fi | |
# expanding a linux LVM disk live (no reboot) | |
tldr; expand disk, fdisk /dev/disk, delete partition 1, create new part, expand till max, w - and then q in fdisk, partx /dev/disk (150gb), xfs_growfs /dev/part1, partx -u | |
1. expand the disk (through AWS) or attach a new volume (which will become the /root or /disk) | |
# before moving ahead, for god sakes, make sure the new disk/partition settings match the original disk (or else risk corruption) | |
2. fdisk -l /dev/disk # take a screenshot, or remember the DISK TYPE | |
2a. fdisk /dev/disk #format disk command prompts inc | |
2b. > m [enter] # FFS read this before proceeding | |
2c. > d [enter] # will DELETE 'partition 1', assuming that's the one you want to delete | |
2d. > n [enter] # will create new partition, expand until max, write changes to disk | |
2e. >> p OR [enter] # will be used as the PRIMARY partition type, or hit ENTER for default | |
2f. >> 1 OR [enter] # will be used as the partition number to designate, or hit ENTER for default | |
2g. >> 666 OR [enter] # will be used as the FIRST SECTOR, or hit ENTER for default | |
2h. >> 9000 OR [enter] # will be used as the LAST SECTOR, or hit ENTER for default | |
>> `Created a new partition 1 of type 'Linux' and of size 30 GiB. # an example of what the output _should look like_` | |
2i. > w [enter] # will WRITE CHANGES to the disk | |
# the output should look akin to: | |
>> `The partition table has been altered.` | |
>> `Calling ioctl() to re-read partition table.` | |
>> `Re-reading the partition table failed.: Device or resource busy` | |
>> `The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).` | |
2j. > q [enter] # exit from fdisk | |
2f. fdisk -l /dev/disk # VERIFY new partition layout | |
# we touched the disk layout, now to actually expand the disk and update the kernel | |
3a. partprobe # on centos it will likely fail, so we use partx (which does no real checking) | |
3b. partx -v /dev/disk # tell the Linux kernel about the presence and numbering of on-disk partitions | |
3c. xfs_growfs /dev/xvda1 # grow the filesystem | |
3d. partx -u /dev/xvda # the true magic that people don't document, update the kernel with new layout | |
# spinning progress bar | |
# /usr/bin/scp [email protected]:file somewhere 2>/dev/null & | |
pid=$! # Process Id of the previous running command | |
spin[0]="-" | |
spin[1]="\\" | |
spin[2]="|" | |
spin[3]="/" | |
echo -n "[copying] ${spin[0]}" | |
while [ kill -0 $pid ] | |
do | |
for i in "${spin[@]}" | |
do | |
echo -ne "\b$i" | |
sleep 0.1 | |
done | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment