When Backspace key does not work

Select and delete or retype. I have been doing that on my 2012 Acer Aspire One 725, including while typing this.


How to do a batch forward and reserve lookup using dig and host

For this example, I have a list of FQDNs and IPs in two files namely hostnames and ips. We will look at how to do a bulk query using dig and host in 6 examples.

1. Forward lookup using dig in batchmode and return only IPs

dig -f hostnames +short

2. Forward lookup using dig in batchmode and return A records

dig -f hostnames +noall +answer
rtfmp107.example.com. 479  IN      A
rtfmp109.example.com. 5    IN      A
rtfmp111.example.com. 900  IN      A
rtfmp113.example.com. 804  IN      A
rtfmp115.example.com. 804  IN      A
rtfmp117.example.com. 186  IN      A
rtfmp119.example.com. 5    IN      A
rtfmp139.example.com. 900  IN      A
rtfmp141.example.com. 4    IN      A
rtfmp143.example.com. 1    IN      A
rtfmp145.example.com. 1    IN      A

3. Bulk reverse lookup with dig and xargs

cat ips | xargs -Ih dig +noall +answer -x  h 900 IN      PTR     rtfmp107.example.com. 900 IN      PTR     rtfmp109.example.com. 900 IN      PTR     rtfmp111.example.com. 900 IN      PTR     rtfmp113.example.com. 900 IN      PTR     rtfmp115.example.com. 900 IN      PTR     rtfmp117.example.com. 900 IN      PTR     rtfmp119.example.com. 900 IN      PTR     rtfmp139.example.com. 900 IN      PTR     rtfmp141.example.com. 900 IN      PTR     rtfmp143.example.com. 352 IN      PTR     rtfmp145.example.com.

4. To extract just the names

cat ips  | xargs -Ih dig +noall +answer -x  h | awk '{print $5}' | sed 's/com./com/g'

5. Forward lookup with host and xargs for a list of hostnames

cat hostnames | xargs -Ih host h
rtfmp107.example.com has address
rtfmp109.example.com has address
rtfmp111.example.com has address
rtfmp113.example.com has address
rtfmp115.example.com has address
rtfmp117.example.com has address
rtfmp119.example.com has address
rtfmp139.example.com has address
rtfmp141.example.com has address
rtfmp143.example.com has address
rtfmp145.example.com has address

6. Reserve lookup with host and xargs for a list of hostnames

cat ips | xargs -Ih host h domain name pointer rtfmp107.example.com. domain name pointer rtfmp109.example.com. domain name pointer rtfmp111.example.com. domain name pointer rtfmp113.example.com. domain name pointer rtfmp115.example.com. domain name pointer rtfmp117.example.com. domain name pointer rtfmp119.example.com. domain name pointer rtfmp139.example.com. domain name pointer rtfmp141.example.com. domain name pointer rtfmp143.example.com. domain name pointer rtfmp145.example.com.

Find all ESXi hosts in a subnet

I have got a task to clear subnets off non-VMware hosts so we can turn on dhcp, PXE for Auto Deploy. I have identified inactive IPs and our DNS admin reclaimed them. I need a way to verify the active IPs are VMware ESXi.

My first method is to ssh to the IPs and run vmware -v in a for loop.

for i in `cat list`
    ssh -q -o "BatchMode yes" root@$i vmware -v

We have ssh keys setup but for every subnet there are a bunch of hosts where I cannot ssh with keys. I do not have the time to fix them all.
Continue reading

Verify you can ssh to a list of hosts using keys

for i in `cat list` 
    ssh -o "BatchMode yes" root@$i hostname

ssh to a list of hosts and run the hostname command to verify you can ssh to the hosts password-lessly. If password-less login is not working, it will not prompt for passphrase or password and will skip it.

man ssh_config

If set to “yes”, passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present to supply the password. The argument must be “yes” or “no”. The default is “no”.

Access a shell prompt and issue commands with correct syntax

While preparing for RHCE RHEL 6 (available upto March 31, 2016), I came across this website which does an easy to follow cheat sheet of sort for each topics under the RHCE/RHCSA Exam objectives. I was hugely impressed and wanted to do something similar. This is my attempt at creating a cheat sheet for RHCE/RHCSA RHEL 7.

Now to the topic. Anyone attempting RHCE should already know how to launch a terminal to access the shell and run commands. If you are really that fresh to Linux, among the many many resources available online I recommend Daniel Robin’s Linux Fundamental series and Introduction to Linux by the Linux Foundation at EdX.
Continue reading