Category: bash
-
Enable core dump in linux
Enable core dump in linux #!/bin/bash ulimit -f unlimited ulimit -u unlimited ulimit -c unlimited
-
Resize images with Imagemagick
How to batch resize images in linux with imagemagick for image in *.jpg; do convert “$image” -resize 250×250 “thumb.$image”; done
-
Get MySQL options with my_print_defaults
my_print_defaults displays the options that are present in option groups of option files my_print_defaults mysqld
-
Show Default Gateway with ip command
Show default gateway in linux with ip command. ip route show | grep default | awk ‘{ print $3}’
-
What version of Apache are we running?
httpd -V
-
Find absolute path of Bash script
You should run this command within a script! abspath=”$(cd “${0%/*}” 2>/dev/null; echo “$PWD”/”${0##*/}”)”
-
Find directories that do not contain a file
Search for directories that don’t contain a file we set in options. In our case are .vmx files. find /vmfs/volumes/v02tstn02a01/ -type d | while read dir; do if [ ! -f $dir/*.vmx ]; then echo $dir; fi; done;
-
MySQL Server Status in plesk
Get information about your mysql server. Uptime, threads, slow queries,… mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` status Uptime: 16203737 Threads: 1 Questions: 101442770 Slow queries: 1359 Opens: 3857138 Flush tables: 1 Open tables: 64 Queries per second avg: 6.260
-
Analyze history for most used commands
With history and a little bit of awk we make the magic. List commands in history by usage. Two examples above, the simple one and the advanced where the arguments to the commands are shown. history | awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head #Advanced version history |…
-
Limit of descriptors per process on the fly
You can set limits for process such as open files making changes in /etc/security/limits.conf. If you want this file to be re-read you have to reboot the system. But with this command you can set limits on the fly. ulimit -n