Monday, December 16, 2013

Editing your DNS in Linux/CentOS


There are a few ways to change your DNS Servers and this is specifically created with CentOS but can basically be applied to any Linux distro as they all use the /etc/resolv.conf file. To configure your DNS manually you will need to modify the /etc/resolv.conf file, if you are using DHCP this will reset when you reboot the system so you will need to do one of the below methods.

Option 1: Edit your /etc/resolv.conf (Static IP)

You will replace the DNS in the /etc/resolv.conf file. After replacing the IP your resolve.conf file should look similar to the one below.

[root@hostname]# cat /etc/resolv.conf
search dynamichosting.biz
nameserver 123.123.123.1
nameserver 123.123.123.2
Note: You do not need to restart the network as the changes are instant.
If you are using CentOS you can also change this from a text-gui while ssh’d into the server by typing system-config-network as root.
system-config-network
You will enter “Edit DNS configuration”
system-config-network
You will see something similar to the above photo.
system-config-network
These are the correct DNS Servers you should have now and you should be able to hit the tab button down to the OK button.
system-config-network
tab down to save and quit and that is it.

Option 2: Configure dhclient.conf

The /etc/dhclient.conf or /etc/dhcp/dhclient.conf file contains configuration information for dhclient. You can turn on or off DNS update and other options for specific interfaces or all interfaces using this file. You should add this to the file to prevent DHCP from resetting the DNS after reboot:
option domain-name-servers 123.123.123.1, 123.123.123.2
Save the file and restart your network and this should take effect.

Sunday, December 15, 2013

Linux Set or Change User Password

Task: Set or Change User Password

Type passwd command as follows to change your own password:
$ passwd
Output:
Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
The user is first prompted for his/her old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed.
A new password is tested for complexity. As a general guideline, passwords should consist of 6 to 8 characters including one or more from each of following sets:
  1. Lower case alphabetics
  2. Upper case alphabetics
  3. Digits 0 thru 9
  4. Punctuation marks

Task: Change Password For Other User Account

You must login as root user, type the following command to change password for user vivek:
# passwd vivek
Output:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Where,
  • vivek - is username or account name.

Task: Change Group Password

When the -g option is used, the password for the named group is changed. In this example, change password for group sales:
# passwd -g sales
The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

Tuesday, December 10, 2013

Install Crontab in CentOS 6.4

Install the package and dependencies
#yum install vixie-cron

Enable the package on boot and start
# /sbin/chkconfig crond on

# /etc/init.d/crond start