bash_oneliners
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
bash_oneliners [2015/10/08 13:28] – admin | bash_oneliners [2023/07/27 13:28] – admin | ||
---|---|---|---|
Line 2: | Line 2: | ||
- | * Remove offending key from known_hosts file with one command | + | * Whats my WAN IP? |
< | < | ||
- | $ sed -i 18d .ssh/ | + | dig +short myip.opendns.com @resolver1.opendns.com |
</ | </ | ||
- | * Whats my WAN IP? | + | * Find large files, print 10 largest files in dir |
< | < | ||
- | $ dig +short myip.opendns.com @resolver1.opendns.com | + | find . -printf '%s %p\n' |
</ | </ | ||
- | * Math on the cli | + | * size of all files older than mtime |
< | < | ||
- | + | find . -mtime | |
- | Basic operations | + | </ |
- | + | * To find the largest file in all sub-directories: | |
- | $ echo $((1+1)) | + | < |
- | 2 | + | find . -type f -exec ls -s {} \; | sort -nr | awk 'NR==1 { $1=""; |
- | $ echo $((3-1)) | + | </ |
- | 2 | + | * grep for valid IP Addresses. |
- | $ echo $((4/2)) | + | < |
- | 2 | + | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]? |
- | $ echo $((1*2)) | + | </ |
- | 2 | + | * show used inode count for subdirectories. |
- | + | < | |
- | Basic ops using expr | + | find */ | sed ' |
- | + | </ | |
- | $ expr 60 / 5 | + | * free all caches |
- | 12 | + | <code> |
- | + | free && sync && echo 3 > / | |
- | Floating point calculations | + | </code> |
- | + | * rescan all SCSI buses | |
- | $ echo "2*2.2/2.2" | + | <code> |
- | 2 | + | for i in /sys/ |
- | + | </ | |
- | $ echo "4.4+7/8-(4.74*3.14)" | + | * enlarge LVM |
- | -10.48 | + | < |
- | + | fdisk /dev/sdk | |
- | using here-doc | + | #set partition type to Linux LVM (type 8e) |
- | + | pvcreate /dev/sdk1 | |
- | $ bc <<< | + | vgextend VolGroupDB /dev/sdk1 |
- | -10.48 | + | lvextend |
- | + | resize2fs -p / | |
- | a bash funtion, for your .bashrc | + | #for xfs use xfs_growfs / |
- | + | parted -a optimal /dev/sdc mklabel gpt | |
- | calc () { | + | parted -a optimal /dev/sdc mkpart p 0% 100% |
- | | + | parted -a optimal /dev/sdc set 1 lvm on |
- | } | + | vgextend VGEXL /dev/sdf1 |
- | + | lvresize -l +100%free / | |
- | usage: | + | |
- | + | ||
- | $ calc 65320*670 | + | |
- | 43764400 | + | |
</ | </ | ||
+ | * Enlarge LVM 2 | ||
+ | < | ||
+ | echo ' | ||
+ | yum install cloud-utils-growpart | ||
+ | growpart | ||
+ | pvresize /dev/sdd1 | ||
+ | lvextend -l +100%FREE / | ||
+ | xfs_growfs / | ||
+ | </ |
bash_oneliners.txt · Last modified: 2023/07/27 13:28 by admin