bash_oneliners
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash_oneliners [2015/10/08 13:28] – admin | bash_oneliners [2025/08/06 12:07] (current) – 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 +7 -print0 | du -hc --files0-from - | tail -n 1 | ||
| + | </ | ||
| + | * To find the largest file in all sub-directories: | ||
| + | < | ||
| + | find . -type f -exec ls -s {} \; | sort -nr | awk 'NR==1 { $1=""; | ||
| + | </ | ||
| + | * grep for valid IP Addresses. | ||
| + | < | ||
| + | grep -E -o " | ||
| + | </ | ||
| + | * show used inode count for subdirectories. | ||
| + | < | ||
| + | find */ | sed ' | ||
| + | </ | ||
| + | * free all caches | ||
| + | < | ||
| + | free && sync && echo 3 > / | ||
| + | </ | ||
| + | * rescan all SCSI buses | ||
| + | < | ||
| + | for i in / | ||
| + | </ | ||
| + | * enlarge LVM | ||
| + | < | ||
| + | fdisk /dev/sdk | ||
| + | #set partition type to Linux LVM (type 8e) | ||
| + | pvcreate /dev/sdk1 | ||
| + | vgextend VolGroupDB /dev/sdk1 | ||
| + | lvextend -l +100%FREE / | ||
| + | resize2fs -p / | ||
| + | #for xfs use xfs_growfs / | ||
| + | parted -a optimal /dev/sdc mklabel gpt | ||
| + | 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 / | ||
| + | </ | ||
| + | * Enlarge LVM 2 | ||
| + | < | ||
| + | echo ' | ||
| + | yum install cloud-utils-growpart | ||
| + | growpart | ||
| + | pvresize /dev/sdd1 | ||
| + | lvextend -l +100%FREE / | ||
| + | xfs_growfs / | ||
| + | </ | ||
| - | Basic operations | + | * polkit logging for debugging |
| + | < | ||
| - | $ echo $((1+1)) | + | cat /etc/polkit-1/rules.d/ |
| - | 2 | + | |
| - | $ echo $((3-1)) | + | |
| - | 2 | + | |
| - | $ echo $((4/2)) | + | |
| - | 2 | + | |
| - | $ echo $((1*2)) | + | |
| - | 2 | + | |
| - | Basic ops using expr | + | polkit.addRule(function(action, |
| + | polkit.log(" | ||
| + | polkit.log(" | ||
| - | $ expr 60 / 5 | + | if (action.id.startsWith(" |
| - | 12 | + | |
| + | action.id == " | ||
| + | action.id == " | ||
| + | action.id == " | ||
| + | action.id == " | ||
| + | polkit.log(" | ||
| + | return polkit.Result.YES; | ||
| + | } | ||
| - | Floating point calculations | + | polkit.log("Authorization denied for action: |
| - | + | }); | |
| - | $ echo "2*2.2/2.2" | bc | + | |
| - | 2 | + | |
| - | + | ||
| - | $ echo " | + | |
| - | -10.48 | + | |
| - | + | ||
| - | using here-doc | + | |
| - | + | ||
| - | $ bc <<< | + | |
| - | -10.48 | + | |
| - | + | ||
| - | a bash funtion, for your .bashrc | + | |
| - | + | ||
| - | calc () { | + | |
| - | bc -l <<< | + | |
| - | } | + | |
| - | + | ||
| - | usage: | + | |
| - | + | ||
| - | $ calc 65320*670 | + | |
| - | 43764400 | + | |
| </ | </ | ||
| - | |||
bash_oneliners.1444310890.txt.gz · Last modified: (external edit)
