For the love of technology

Hacking

CentOS-RedHat, rejister hostname with DHCP and DNS

So I have quite a few machines on my home network and even a few machines that are running as virtual machines. Almost all of the machines would resister their hostname with the router slash DHCP, DNS server. The only problem was that none of the CentOS machines would rejister their hostname with the router. I tried to make all sorts of changes to /etc/hosts and /etc/sysconfig/network but none of those changes made any diffrence.

simple ping test script

Here is a simple ping script. You privide the server-file and the program will output all the server thta do not respond to the ping request #!/bin/bash for i in $(cat server-file); do ping -c 1 $i > /dev/null 2>&1 if [ $? = 1 ]; then echo $i did not ping fi done

awk remove paragraph with matching string and script

Sed is a stream editor, you give it a file and it outputs it, redirecting the output helps if you want to save it to a file. I had a couple thousand print queues entries in a file with the name of the queue some information about it and then a carriage return that separates them from each other. A simple grep would not work because grep -v would only remove the name of the queue while I needed to remove the name of the queue and the information that was associated with it.

Automate user permission setup

I had a bunch of home directories that I just created. So now I wanted to set the permissions for each home directory quickly and easily, so it only made sense to automate the process. The echo commands are not necessary but very helpful when debugging a issue. This example assumes that you the server is connected to a NIS directory server. Please note that you can not use UID or GIUD as variables because they are reserved variables.

using bash shell to create mulitipule directories at the same time

There are a few other way to make multiple directory’s quickly and easily, but this is my favorite. mkdir {direcotyone,directorytwo,directorythree,directoryfour} $ ls -l drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 direcotyone drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directoryfour drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directorythree drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directorytwo