Ubuntu Server Utilities

From rbachwiki
Revision as of 14:13, 8 August 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Linux DIG Command Examples for DNS Lookup

dig redhat.com - dns lookup

dig redhat.com  MX - mx records lookup

dig redhat.com NS

View ALL DNS Records Types Using dig -t ANY

dig -t ANY redhat.com

DNS Reverse Look-up Using dig -x

dig -x 209.132.183.81

Use a Specific DNS server Using dig @dnsserver

dig @ns1.redhat.com redhat.com

Extract Images from PDF Files With PDFimages

apt-get install poppler-utils

pdfimages --help for options

eg

pdfimages -j filename.pdf prefixforallfiles

if the image doesn't convert to jpg. then use the mogrify to convert them. mogrify is part of imagemagick

mogrify -format jpg *.pcm // this will convert all *.pcm files to jpg

Imagemagic

convert rose.jpg rose.png

convert rose.jpg -resize 64x64 thumb_rose.jpg

Only shrink larger images

convert rose.jpg -resize 64x64\> rose.jpg

Percentage Resize

convert rose.jpg -resize 50% rose.jpg

Rotate

convert rose.jpg -rotate 90 rose.jpg

Rotate and overite 

mogrify -rotate 90 img.jpg

Batch Convert from one format to another

mogrify -format jpg *.png 

this will convert all png files to jpg

Using Rsync

RSYNC Syntax

rsync options source destination

Rsync Local Dir to Amazon AWS servers
 rsync azvr --delete --progress -e "ssh -i /fordertopemfile/pemfile.pem" localfoldertosync ubuntu@ipaddress:/var/tmp/
Synchronize Two Directories in a Local Server: To sync two directories in a local computer, use the following rsync -zvr command.
$ rsync -azvr /var/opt/installation/inventory/ /root/temp
building file list ... done
sva.xml
svB.xml
.
sent 26385 bytes  received 1098 bytes  54966.00 bytes/sec
total size is 44867  speedup is 1.63
$
In the above rsync example: -a archive mode (which preserves timestamp) -z is to enable compression -v verbose -r indicates recursive
Synchronize Only One File: To copy only one file, specify the file name to rsync command, as shown below
$ rsync -v /var/lib/rpm/Pubkeys /root/temp/
Pubkeys

sent 42 bytes  received 12380 bytes  3549.14 bytes/sec
total size is 12288  speedup is 0.99 

Rsync Over SSH

With rsync, we can use SSH (Secure Shell) for data transfer, using SSH protocol while transferring our data you can be ensured that your data is being transferred in a secured connection with encryption so that nobody can read your data while it is being transferred over the wire on the internet. Also when we use rsync we need to provide the user/root password to accomplish that particular task, so using SSH option will send your logins in an encrypted manner so that your password will be safe.

Copy a File from a Remote Server to a Local Server with SSH

To specify a protocol with rsync you need to give “-e” option with protocol name you want to use. Here in this example, We will be using “ssh” with “-e” option and perform data transfer.

rsync -avzhe ssh root@192.168.0.100:/root/install.log /tmp/

root@192.168.0.100's password: receiving incremental file list install.log sent 30 bytes received 8.12K bytes 1.48K bytes/sec total size is 30.74K speedup is 3.77>/dd>

Copy a File from a Local Server to a Remote Server with SSH

rsync -avzhe ssh backup.tar root@192.168.0.100:/backups/

root@192.168.0.100's password:
sending incremental file list
backup.tar
sent 14.71M bytes  received 31 bytes  1.28M bytes/sec
total size is 16.18M  speedup is 1.10 

Use of –include and –exclude Options

These two options allows us to include and exclude files by specifying parameters with these option helps us to specify those files or directories which you want to include in your sync and exclude files and folders with you don’t want to be transferred. Here in this example, rsync command will include those files and directory only which starts with ‘R’ and exclude all other files and directory.
 rsync -avze ssh --include 'R*' --exclude '*' root@192.168.0.101:/var/lib/rpm/ /root/rpm
root@192.168.0.101's password:
receiving incremental file list
created directory /root/rpm