User Tools

Site Tools


bash_oneliners

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
bash_oneliners [2015/10/08 13:28] adminbash_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?
 <code> <code>
-$ sed -i 18d .ssh/known_hosts+dig +short myip.opendns.com @resolver1.opendns.com
 </code> </code>
-  * Whats my WAN IP?+  * Find large files, print 10 largest files in dir
 <code> <code>
-$ dig +short myip.opendns.com @resolver1.opendns.com+find -printf '%s %p\n'|sort -nr|head
 </code> </code>
-  * Math on the cli+  * size of all files older than mtime
 <code> <code>
- +find . -mtime +7 -print0 | du -hc --files0-from - | tail -n 
-Basic operations +</code> 
- +  * To find the largest file in all sub-directories: 
-$ echo $((1+1)) +<code> 
-2 +find . -type f -exec ls -s {} \; | sort -nr | awk 'NR==1 { $1=""; sub(/^ /, ""); print }' 
-$ echo $((3-1)) +</code> 
-2 +  grep for valid IP Addresses. 
-echo $((4/2)+<code> 
-2 +grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt 
-$ echo $((1*2)) +</code> 
-+  * show used inode count for subdirectories
- +<code> 
-Basic ops using expr +find */ | sed 's!/.*!!' | uniq -c 
- +</code> 
-$ expr 60 / 5 +  * free all caches 
-12 +<code> 
- +free && sync && echo 3 > /proc/sys/vm/drop_caches && free 
-Floating point calculations +</code> 
- +  * rescan all SCSI buses 
-$ echo "2*2.2/2.2" bc +<code> 
-2 +for i in /sys/class/scsi_host/host{0..32}/scan; do echo "- -" > $i; done 
- +</code> 
-$ echo "4.4+7/8-(4.74*3.14)" | bc +  * enlarge LVM 
--10.48 +<code> 
- +fdisk /dev/sdk 
-using here-doc +#set partition type to Linux LVM (type 8e
- +pvcreate /dev/sdk1 
-$ bc <<< "4.4+7/8-(4.74*3.14)" +vgextend VolGroupDB /dev/sdk1 
--10.48 +lvextend -l +100%FREE /dev/mapper/VolGroupDB-data 
- +resize2fs -p /dev/mapper/VolGroupDB-data 
-a bash funtion, for your .bashrc +#for xfs use xfs_growfs /dev/mapper/VolGroupDB-data 
- +parted -a optimal /dev/sdc mklabel gpt 
-calc () { +parted -a optimal /dev/sdc mkpart p 0% 100% 
-    bc -l <<< "$@" +parted -a optimal /dev/sdc set 1 lvm on 
-} +vgextend VGEXL /dev/sdf1 
- +lvresize -l +100%free /dev/mapper/VGEXL-exllv
-usage: +
- +
-$ calc 65320*670 +
-43764400+
 </code> </code>
  
 +* Enlarge LVM 2
 +<code>
 +echo '1' > /sys/class/scsi_disk/0\:0\:3\:0/device/rescan
 +yum install cloud-utils-growpart
 +growpart  /dev/sdd 1
 +pvresize /dev/sdd1
 +lvextend -l +100%FREE /dev/mapper/VGKUB-lv_kub
 +xfs_growfs /dev/mapper/VGKUB-lv_kub
 +</cdoe>
bash_oneliners.txt · Last modified: 2023/07/27 13:28 by admin