How to Install JAVA 8 (JDK 8u45) on CentOS 6 / CentOS 7

The JDK is a development tool for building applications, applets, and components using the Java programming language . It includes a useful tool for developing and testing programs written in the Java programming language and runs on the Java platform. You can go through this document to know more about new enhancement of Java JDK 8. This post describe how to install JAVA 8 (JDK 8u45) on CentOS 6 and CentOS 7 from rpm package.

1. Download Oracle Java 8 rpm from official website (64 bit):

# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm"

2. Install Oracle Java 8 :

# rpm -ivh jdk-8u45-linux-x64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_45-2000:1.8.0_45-fcs    ################################# [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        jfxrt.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...

3. Verify the Oracle Java version :

# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

How to Grant a New User to Root Privileges on CentOS 6 / CentOS 7

One recommended way to manage virtual private server (VPS) or a dedicated linux server is not using the root account as the main access for SSH login. This is because usually the hackers will try to brute force your root password and potentially get access to your server. Instead of using the default root account, you can create a new account and assign root privileges to it and issue the sudo command line to root from it. Please make sure that the normal user account given root privileges accounts work properly before you disable the default root login access. The following command has been tested works on CentOS 6, CentOS 7, RHEL 6 and RHEL 7 VPS.

1. Create new account named skytech and set the password :

[root@vps ~]# useradd skytech
[root@vps ~]# passwd skytech
Changing password for user skytech.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2. Grant a New User to Root Privileges

[root@vps ~]# visudo

Add the following code at the bottom of the file and save the file with the command :wq :

## Allow skytech user to run any commands anywhere
skytech    ALL=(ALL)       ALL

This will grant a root privileges to the normal user skytech.

linux-banner

How to Add Linux Swap Space on CentOS 6 VPS

Linux swapI have a virtual private server (VPS) and plans to run a WordPress blog in it. A limited amount of RAM and swap size will be an issue because some software applications like MySQL, Apache, NGINX, PHP, HHVM and Varnish requires more memory to operate.

From my past experience in Ubiquity Hosting and Linode, the pre-allocated swap sizes of 2GB and 1GB VPS are 1GB and 512MB only. After switched to 2GB plan for RamNode VPS, linux swap also provided in the size of 1GB.

Why we need Linux Swap Space ?

To make your server more responsive and prevent crash when it runs out of memory, giving additional linux swap space will help. Linux swap is an area on the storage or hard disk where the operating system can temporarily store data that it no longer can hold in memory. Without the Linux swap, the VPS that runs out of memory can crash or start kill some applications to free up memory. This can cause lose for unsaved data or experience downtime.

However, swapping does have drawbacks. Reading from and writing to swap is slower than using memory. But swapping should take advantages on the SSD server. In the hard disk drive, If VPS started using linux swap space, the VPS performance can slow down significantly.

As a reference for webmasters and system administrators, here are the steps on how to increase the size of the linux swap on CentOS 6 VPS. This steps may also works and tested on CentOS 7 / RHEL 7 and oracle linux 7.

1. Check and verify the allocated disk partition for swap using “fdisl -l” command :

[root@vps ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00059ca1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018        3099     1048576   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3            3099      104023    50865920   83  Linux
Partition 3 does not end on cylinder boundary.

2. From the operating system, verify the swap size from command line utility “swapon -s” and “free -m“. The current swap size is 1GB :

[root@vps ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/vda2                               partition       1048568 0       -1
[root@vps ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1877       1624        253          0        210        503
-/+ buffers/cache:        909        967
Swap:         1023          0       1023

3. Start Create the Swap file by determine the size of the new swap file and assign the swap file name. At a shell prompt as root, type the following dd command with count being equal to the desired block size. As an example i will add 2048MB as additional space size and assigned swap file name is /swapfile-ext.

[root@vps ~]# dd if=/dev/zero of=/swapfile-ext bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 4.05978 s, 529 MB/s

4. Creating a linux swap area with mkswap command :

[root@vps ~]# mkswap /swapfile-ext
mkswap: /swapfile-ext: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=cc49d098-52e3-4fdf-8157-c40b23e00eef

5. Assign the correct permission to prevent swap space from world-readable :

[root@vps ~]# chmod 600 /swapfile-ext

6. Activatethe swap file immediately :

[root@vps ~]# swapon /swapfile-ext

7. Verify by viewing the output using “free -m” utility. 1GB plus 2GB equal to 3GB new swap size :

[root@vps ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1877       1801         76          0        137        765
-/+ buffers/cache:        897        979
Swap:         3071          0       3071

Verify by viewing the output using “swapon -s” utility

[root@vps ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/vda2                               partition       1048568 556     -1
/swapfile-ext                           file            2097144 0       -2

8. To enable it at boot time, edit /etc/fstab to include the following entry:

/swapfile-ext          swap            swap    defaults        0 0

How to Remove/Uninstall Nginx Installed from Source on CentOS 6/RHEL 6

On this day, Nginx web server is reported to be a most popular and fastest in the internet if installed properly. But it should always be updated from time to time in order to maintain stability and high security so that is not exposed to hackers. For system administrators and web masters, it is routine to constantly update the software Nginx if the latest version is launched on their official website, nginx.org. In this tutorial , I will explain how to remove the Nginx that was installed from source on CentOS 6/RHEL 6.

1. Stop Nginx software :

[root@centos66 ~]# service nginx stop

2. Remove autostart for Nginx :

[root@centos66 ~]# chkconfig nginx off

3. Remove the Nginx sofware :

[root@centos66 ~]# rm -rf /usr/sbin/nginx
[root@centos66 ~]# rm -rf /etc/nginx
[root@centos66 ~]# rm -rf /etc/init.d/nginx

New Naming Scheme for the Network Interface on RHEL 7/CentOS 7

Red Hat Enterprise Linux 7 (RHEL 7) and CentOS 7 come with the new naming scheme for the network devices.

These features change the name of network interfaces on a system in order to make the network interfaces fully predictable, fully automatic, easier to differentiate and that broken hardware can be replaced seamlessly.

This affects both network adapters embedded on the motherboard (Lan-on-Motherboard, or additional adapters such as PCI network card and etc.

Traditionally, network interfaces in Linux used eth[0123…]. In RHEL7/CentOS7, the default network interface name is based on firmware, topology, and location information.

The following different naming schemes for network interfaces are now supported by udev natively:

  • Names incorporating Firmware or BIOS provided index numbers for on-board devices (example: eno1)
  • Names incorporating Firmware or BIOS provided PCI Express hotplug slot index numbers (example: ens1)
  • Names incorporating physical location of the connector of the hardware (example: enp2s0)
  • Names incorporating the interface’s MAC address (example: enx78e7d1ea46da)
  • The traditional unpredictable kernel-native ethX naming (example: eth0)

The names have two character prefixes based on the type of interface:

  • en for Ethernet,
  • wl for wireless LAN (WLAN),
  • ww for wireless wide area network (WWAN).
FormatDescription
o<index>on-board device index number
s<slot>[f<function>][d<dev_id>]hotplug slot index number
x<MAC>MAC address
p<bus>s<slot>[f<function>][d<dev_id>]PCI geographical location
p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]USB port number chain

ifconfig utility is not installed by default in minimal installation. You can use “ip link show“, “ip addr” or “ip address” to display the auto assigned devices name :

[root@centos7 ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:ba:3e:fe brd ff:ff:ff:ff:ff:ff
[root@centos7 ~]# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:ba:3e:fe brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.18/24 brd 192.168.0.255 scope global dynamic ens160
       valid_lft 604707sec preferred_lft 604707sec
    inet6 fe80::20c:29ff:feba:3efe/64 scope link
       valid_lft forever preferred_lft forever

Ldapsearch Examples for 389 Directory

This post will show you the list of ldapsearch examples for 389 Directory. This ldapsearch examples assumes the following:

a)This ldapsearch is search for uid in the directory.
b)The 389 directory is configured to not support anonymous access, then the user “Directory Manager” and the password is required
c)This ldapsearch command has been run on the 389 server itself, so “localhost” for host is enough.
d)The server uses port number 389. Since this is the default port, the port number does not have to be sent in the search request.

-D binddn  bind DN
-b basedn  base dn for search
-h host    LDAP server
-w passwd  bind password (for simple authentication)
-W         prompt for bind password (Recommended to use this to hide password)
ldapsearch -h localhost -D "cn=Directory Manager" -W -b dc=ehowstuff,dc=local uid=user1

Example :

[root@ldapmaster-11 ~]# ldapsearch -h localhost -D "cn=Directory Manager" -W -b dc=ehowstuff,dc=local uid=user1
Enter LDAP Password:
# extended LDIF
#
# LDAPv3
# base  with scope subtree
# filter: uid=user1
# requesting: ALL
#

# user1, ehowstuff.local
dn: uid=user1,dc=ehowstuff,dc=local
uid: user1
givenName: user1
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
sn: test
cn: user1 test
userPassword:: e1NTSEF9eTdNQTcyNUxnNjNPRXUxNUVkYk84TEJlTmp3M2d3Z3VoVEIreHc9PQ=
 =

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

How to Change Timezone Linux on RHEL 6/7 and CentOS 6/7

change timezone linux

This post assumed that we will change the System Timezone from the command line without using redhat-config-date.

There are several files and directories that are used for time zones. In RHEL 6 and RHEL 6, there is one directory that very useful to select the appropriate time zone which is /usr/share/zoneinfo directory.

Sometimes we forget to set the correct time zone for the new linux system. This quick steps show how to change timezone on RHEL 6/7 and CentOS 6/7.

/usr/share/zoneinfo – this directory contains the System Timezone files that were compiled by zic. These are binary files and cannot be viewed with a text viewer. The files contain information such as rules about DST. They allow the kernel to convert UTC UNIX time into appropriate local dates and times.

In order to change the System Timezone of your system you will need to access the file or configuration using root.

How to Change Timezone Linux on RHEL / CentOS

1) How to list all available time zone on RHEL 6 / CentOS 6:

#ls /usr/share/zoneinfo

2) How to list all available time zone on RHEL 7 / CentOS 7:

# timedatectl list-timezones | grep Asia
Asia/Aden
Asia/Almaty
Asia/Amman
..
..
Asia/Kuala_Lumpur

3) How to check timezone in linux RHEL 6 / CentOS 6 :

# cat /etc/sysconfig/clock

4) How to check timezone in linux RHEL 7 / CentOS 7 :

# timedatectl status
      Local time: Thu 2017-01-05 20:00:22 MYT
  Universal time: Thu 2017-01-05 12:00:22 UTC
        RTC time: n/a
       Time zone: Asia/Kuala_Lumpur (MYT, +0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

5) How to Change Timezone Linux RHEL 6 / CentOS 6 :

Edit ZONE= to the following:

# cat /etc/sysconfig/clock
ZONE="Asia/Kuala_Lumpur"

Create a new soft link to your time zone :

# mv /etc/localtime /root/localtime.old
# ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

6) How to Change Timezone Linux RHEL 7 / CentOS 7 :

timedatectl set-timezone Asia/Kuala_Lumpur

7) How to Display current date and time and timezone :

# date
Thu Jan  5 19:54:38 MYT 2017

Reference :

How to Mount CDROM Media on CentOS 5/CentOS 6/CentOS 7

Question :
How to mount CDROM/DVDROM media on linux CentOS server ?

Solution :
In certain situations, system administrators will need to mount cdrom containing the installer or data on linux CentOS or RHEL. Once cdrom mounted, they can access the data in the media discs directly. For reference, here is the easy way to do it through the command line on Linux CentOS 5 or CentOS 6 or CentOS 7 :

Note : This example will mount the device /dev/cdrom to /mnt.

[root@centos6 ~]# mount /dev/cdrom /mnt

Examples :

[root@centos6 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only

How to Install tcpdump on CentOS 5/CentOS 6/RHEL 5/RHEL 6

Tcpdump is a packet sniffer that able to capture traffic that passes through a machine. It operates on a packet level, meaning that it captures the actual packets that fly in and out of your computer. It can save the packets into a file. In this post, i will show how to install tcpdump on CentOS 5/CentOS 6/ CentOS 7/RHEL 5/RHEL 6/ RHEL 7 server. You can proceed to read the example usage of tcpdump in this article.

Install tcpdump on CentOS

How to Install tcpdump on CentOS / RHEL

1. Run any tcpdump command to check whether tcpdump installed or not :

[root@centos62 ~]# tcpdump -D
-bash: tcpdump: command not found

2. To install tcpdump, simply run the following command :

[root@centos62 ~]# yum install tcpdump -y

3. Show available interface that can be monitor :

# tcpdump -D
1.eth0
2.usbmon1 (USB bus number 1)
3.usbmon2 (USB bus number 2)
4.any (Pseudo-device that captures on all interfaces)
5.lo

4. Check tcpdump version in CentOS 6.7

# tcpdump --version
tcpdump version 4.1-PRE-CVS_2015_07_23
libpcap version 1.4.0
Usage: tcpdump [-aAdDefhIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
                [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
                [ -i interface ] [ -j tstamptype ] [ -M secret ]
                [ -P in|out|inout ]
                [ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
                [ -W filecount ] [ -y datalinktype ] [ -z command ]
                [ -Z user ] [ expression ]

5. Check tcpdump version in CentOS 7.1

# tcpdump --version
tcpdump: invalid option -- '-'
tcpdump version 4.5.1
libpcap version 1.5.3
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
                [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
                [ -i interface ] [ -j tstamptype ] [ -M secret ]
                [ -P in|out|inout ]
                [ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]
                [ -W filecount ] [ -y datalinktype ] [ -z command ]
                [ -Z user ] [ expression ]

I hope this article gives you some ideas and essential guidance on how to install tcpdump on CentOS 5/CentOS 6/ CentOS 7/RHEL 5/RHEL 6/ RHEL 7.

 

Why “portmap unrecognized service” on RHEL 6/CentOS 6

Question :

During the deployment of Samba and NFS services on one of the RHEL 6 server, I’m hit by this message when trying to start, stop and restart service portmap :

[root@rhel6 ~]# service portmap start
portmap: unrecognized service

 

Answer :
Portmap is replaced by rpcbind on some linux distributions such as Fedora 8,RHEL 6 and CentOS 6. Portmap is now started and stopped as part of the rpcbind service. You may not able to find the portmap service, but you can see rpcbind instead.
http://www.archlinux.org

Command line below provides the required dependency packages. It can also be used to track a package containing a specific executable :

[root@rhel6 ~]# yum whatprovides portmap
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
rpcbind-0.2.0-8.el6.i686 : Universal Addresses to RPC Program Number Mapper
Repo        : DVD-RHEL6-Repository
Matched from:
Other       : portmap

rpcbind-0.2.0-8.el6.i686 : Universal Addresses to RPC Program Number Mapper
Repo        : installed
Matched from:
Other       : Provides-match: portmap

When you try to install portmap on RHEL 6, it will install rpcbind instead :

[root@rhel6 ~]# yum install portmap -y
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Package rpcbind-0.2.0-8.el6.i686 already installed and latest version
Nothing to do

What is Portmap :
Portmap is a server that converts RPC (Remote Procedure Call) program numbers into DARPA protocol port numbers. It must be running in order to make RPC calls. Server services that use RPC include NFS, NIS and Samba. When an RPC server is started, it will tell portmap what port number it is listening to, and what RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it will first contact portmap on the server machine to determine the port number where RPC packets should be sent. Therefore, portmap must be started before any RPC servers are invoked. This because RPC-based services rely on portmap to make all connections with incoming client requests.

What is rpcbind :
rpcbind is a server that converts RPC program numbers into universal addresses. It must be running on the host to be able to make RPC calls on a server on that machine. When an RPC service is started, it tells rpcbind the address at which it is listening, and the RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it first contacts rpcbind on the server machine to determine the address where RPC requests should be sent. rpcbind should be started before any other RPC service. Normally, standard RPC servers are started by port monitors, so rpcbind must be started before port monitors are invoked.

Server service that use RPC :
1. NFS
NFS uses Remote Procedure Calls (RPC) to route requests between clients and servers, meaning that the portmap service must be enabled and active at the proper runlevels for NFS communication to occur.

2. Samba
Samba is an Open Source software that based on the common client/server protocol of Server Message Block (SMB) and Common Internet File System (CIFS). It’s allows end users to access and use files, printers and sharing the company resources.

Example portmap instance
The rpcinfo command shows each RPC-based service with its port number, RPC program number, version, and IP protocol type (TCP or UDP). This is to make sure the proper NFS RPC-based services and portmapper are enabled for portmap.

[root@rhel6 ~]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  56670  status
    100024    1   tcp  54564  status

How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on RHEL 6

In this article, I will share about how to update and install RPM packages from the image CD-ROM/DVD-ROM in Red Hat Enterprise Linux 6 (RHEL 6). This step can also be used on CentOS 6 or older versions such as CentOS 5. It would be very useful if the server you have a slow internet connection, or no internet connection. Instead of using internet connection directly to RHEL repositories registered, it is possible to use the Local CD/DVD- ROM as your yum repository. There are two methods to install and configure local yum repository RHEL 6. Both methods have been tested and works well on Linux RHEL 6 server. You can choose whichever method you choose :

Method 1:
1. Insert DVD/ISO into DVD-Drive.
2. Mount the ISO from the DVD-ROM into /mnt directory :

    [root@rhel6 ~]# mount /dev/cdrom /mnt
    mount: block device /dev/sr0 is write-protected, mounting read-only
    

3. Check the existing partition on your RHEL 6 server :

    [root@rhel6 ~]# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           9845280   1328824   8016336  15% /
    tmpfs                   515660         0    515660   0% /dev/shm
    /dev/sda1               495844     28689    441555   7% /boot
    /dev/sr0               2862360   2862360         0 100% /mnt
    

4. Go to /mnt and check current directory :

    [root@rhel6 ~]# cd /mnt
    [root@rhel6 mnt]# pwd
    /mnt
    

5. List out what is in DVD.

    [root@rhel6 mnt]# ls
    EULA                      RELEASE-NOTES-es-ES.html  RELEASE-NOTES-ru-RU.html
    GPL                       RELEASE-NOTES-fr-FR.html  RELEASE-NOTES-si-LK.html
    HighAvailability          RELEASE-NOTES-gu-IN.html  RELEASE-NOTES-ta-IN.html
    images                    RELEASE-NOTES-hi-IN.html  RELEASE-NOTES-te-IN.html
    isolinux                  RELEASE-NOTES-it-IT.html  RELEASE-NOTES-zh-CN.html
    LoadBalancer              RELEASE-NOTES-ja-JP.html  RELEASE-NOTES-zh-TW.html
    media.repo                RELEASE-NOTES-kn-IN.html  repodata
    Packages                  RELEASE-NOTES-ko-KR.html  ResilientStorage
    README                    RELEASE-NOTES-ml-IN.html  RPM-GPG-KEY-redhat-beta
    RELEASE-NOTES-as-IN.html  RELEASE-NOTES-mr-IN.html  RPM-GPG-KEY-redhat-release
    RELEASE-NOTES-bn-IN.html  RELEASE-NOTES-or-IN.html  Server
    RELEASE-NOTES-de-DE.html  RELEASE-NOTES-pa-IN.html  TRANS.TBL
    RELEASE-NOTES-en-US.html  RELEASE-NOTES-pt-BR.html
    

6. Read what is in media.repo. Take note on the mediaid :

    [root@rhel6 mnt]# cat media.repo
    
    [InstallMedia]
    name=Red Hat Enterprise Linux 6.0
    mediaid=1235481171.125642
    metadata_expire=-1
    gpgcheck=0
    cost=500
    

7. Create dvdrhel.repo text file in /etc/yum.repos.d/ with the following content. Please create something as follow:

    [root@rhel6 ~]# vi /etc/yum.repos.d/dvdrhel.repo
    
    [DVD-RHEL6-Repository]
    mediaid=1235481171.125642
    name=DVD-RHEL6 repository
    baseurl=file:///mnt/Server
    enabled=1
    gpgcheck=0
    

8. Finish. You can start install, remove and update using yum command :

Method 2 :
1. Check the existing partition on your RHEL 6 server :

    [root@rhel6 ~]# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           9845280   1221632   8123528  14% /
    tmpfs                   515660         0    515660   0% /dev/shm
    /dev/sda1               495844     28689    441555   7% /boot
    

2. Create repo directory in /media :

    [root@rhel6 ~]# mkdir /media/repo
    

3. Create 1 2 3 directory in /media/repo :

    [root@rhel6 ~]# mkdir -p /media/repo/{1,2,3}
    

4. Mount the ISO from the DVDROM into /media/repo/1 directory :

    [root@rhel6 ~]# mount -o loop /dev/cdrom /media/repo/1
    
    [root@rhel6 ~]# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           9845280   1221644   8123516  14% /
    tmpfs                   515660         0    515660   0% /dev/shm
    /dev/sda1               495844     28689    441555   7% /boot
    /dev/loop0             2862360   2862360         0 100% /media/repo/1
    

5. Create temporary repo folder under /tmp to put required rpm’s packages for createrepo installation :

    [root@rhel6 ~]# mkdir /tmp/repo 
    

6. Copy the require packages to install create repo :

    [root@rhel6 ~]# cp /media/repo/1/Packages/createrepo* /tmp/repo
    [root@rhel6 ~]# cp /media/repo/1/Packages/deltarpm* /tmp/repo
    [root@rhel6 ~]# cp /media/repo/1/Packages/python-deltarpm* /tmp/repo
    

7. Install the rpm packages using below command :

    [root@rhel6 ~]# rpm -ivh /tmp/repo/*
    warning: /tmp/repo/createrepo-0.9.8-4.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
    Preparing...                ########################################### [100%]
       1:deltarpm               ########################################### [ 33%]
       2:python-deltarpm        ########################################### [ 67%]
       3:createrepo             ########################################### [100%]
    

8. Go to /media/repo directory :

    [root@rhel6 ~]# cd /media/repo/
    [root@rhel6 repo]# pwd
    /media/repo
    

9. Run createrepo command :

    [root@rhel6 repo]# createrepo .
     2358/13395 - 1/HighAvailability/Packages/system-config-keyboard-1.3.1-3.el6.i68
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
     5037/13395 - 1/LoadBalancer/Packages/system-config-keyboard-1.3.1-3.el6.i686.rp
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
     7716/13395 - 1/Packages/system-config-keyboard-1.3.1-3.el6.i686.rpm
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
    10395/13395 - 1/ResilientStorage/Packages/system-config-keyboard-1.3.1-3.el6.i68
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
    13074/13395 - 1/Server/Packages/system-config-keyboard-1.3.1-3.el6.i686.rpm
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
    13395/13395 - 1/Server/Packages/zsh-4.3.10-4.1.el6.i686.rpm
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    

10. Clean up the repo :

    [root@rhel6 ~]# yum clean all
    Loaded plugins: rhnplugin
    Cleaning up Everything
    

11. Create a repo config file in /etc/yum.repos.d/ directory :

    [root@rhel6 ~]# vi /etc/yum.repos.d/rhel.repo
    
    [RHEL6-Repository]
    name=RHEL6 repository
    baseurl=file:///media/repo
    enabled=1
    gpgcheck=0
    

12. Start install using yum command as below :

    [root@rhel6 ~]# yum install httpd
    Loaded plugins: rhnplugin
    This system is not registered with RHN.
    RHN support will be disabled.
    RHEL6-Repository                                                             | 1.3 kB     00:00 ...
    RHEL6-Repository/primary                                                     | 5.4 MB     00:00 ...
    RHEL6-Repository                                                                        13395/13395
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.i686 0:2.2.15-5.el6 set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================
     Package            Arch              Version                   Repository                     Size
    ====================================================================================================
    Installing:
     httpd              i686              2.2.15-5.el6              RHEL6-Repository              813 k
    
    Transaction Summary
    ====================================================================================================
    Install       1 Package(s)
    Upgrade       0 Package(s)
    
    Total download size: 813 k
    Installed size: 2.8 M
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : httpd-2.2.15-5.el6.i686                                                      1/1
    
    Installed:
      httpd.i686 0:2.2.15-5.el6
    
    Complete!
    

How to Add User to root Group on CentOS 5/CentOS 6

useradd is a low-level utility to create new users to the system. When used without the -D option, useradd command will create a new user account using the command line plus the default values ??of the system. Depending on the command line option, useradd command will update system files and also can create new user’s home directory. In this article, I will explain to you how to create a user then add it to the particular group in CentOS 5 and CentOS 6. Prior to that , this article assumes that the server CentOS 5 or CentOS 6 has been fully installed.

1. Add a new user. In this example, the username will be ‘myroot‘.

[root@CentOS57 ~]# useradd myroot
[root@CentOS57 ~]# passwd myroot
Changing password for user myroot.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

2. Check current groups for ‘root‘ user.

[root@CentOS57 ~]# groups
root bin daemon sys adm disk wheel

3. Add ‘myroot‘ into root group as below:
useradd -G {group-name} username

[root@CentOS57 ~]# usermod -G root myroot

Above is example, we are adding a user ‘myroot‘ into group ‘root‘.

4. Switch to ‘myroot‘ user. Then Check current group for ‘myroot‘. root group will be the second group for ‘myroot’.

[root@CentOS57 ~]# su - myroot
[myroot@CentOS57 ~]$ groups
myroot root

5. Grep the ‘myroot’ user’s group.

[root@CentOS57 ~]# grep myroot /etc/group
root:x:0:root,myroot
myroot:x:502:

6. Check the file permission for /etc/passwd

[root@CentOS57 ~]# ls -al /etc/passwd
-rw-r--r-- 1 root root 1026 Jan 21 05:32 /etc/passwd

Explanation : Only the owner which is ‘root’ user can edit the /etc/passwd file, not in the root’s group.