Tag: command
-
Get MAC address of a host in your lan
With arp command you can find out what mac address any host in your lan has. > arp 192.168.0.12 Address HWtype HWaddress Flags Mask Iface 192.168.0.12 ether 00:0F:AE:34:03:07 C eth0
-
Reconfigure timezone on Debian
Use dpkg-reconfigure to change time zone on Debian dpkg-reconfigure tzdata
-
MySQL dump tables matching a pattern
Quick command to dump all tables matching a like pattern. In the example drop tables option is added with xargs. mysql $DB -u$USERNAME -p$PASSWORD -e ‘show tables like “$LIKE%”‘ | grep -v Tables_in | xargs mysqldump –add-drop-table $DB -u$USERNAME -p$PASSWORD
-
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
-
Show Default Gateway with ip command
Show default gateway in linux with ip command. ip route show | grep default | awk ‘{ print $3}’
-
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;
-
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
-
How to generate a tar gz file from a file list
Easy example of tar use. We provide a list of files to archive them in one tar file. tar zcvf myFile.tar.gz file1.txt file2.txt file3.txt file4.txt
-
List large files in Linux
Command to find and list all files above a defined size. Works for debian based distros and Centos. If the output its wrong in other systems, you can play with awk params. find . -type f -size +50000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’