How to Reset Forgotten Root Password on Linux RHEL 7/CentOS 7

Reset Forgotten Root Password

This article will explain the steps to reset a lost root password or to reset forgotten root password on Linux RHEL 7 or CentOS 7.

Basically, the steps will adding a “rd.break” to the end of the line with kernel parameters in Grub to stops the start up process before the regular root filesystem is mounted, hence the necessity to chroot into sysroot. Continue reading “How to Reset Forgotten Root Password on Linux RHEL 7/CentOS 7”

How to a Add and Remove User Account on RHEL 6/7, CentOS 6/7, Oracle Linux 6/7

This article will explain and share how to add and remove user account with useradd(add) and userdel (remove) from the command-line on linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7 server.

1. Adding a New User to an Linux System.

a) Get the useradd manual :

# man useradd
useradd - create a new user or update default new user information

b) To creates the new account and the /home/john home directory :

# useradd --home /home/ehowstuff ehowstuff

c) useraddd command does not set any valid password by default, and user cannot log in until a password is set.To set the password user the following command :

# passwd ehowstuff
Changing password for user ehowstuff.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

d) Verify the values in /etc/password :

# cat /etc/passwd | grep ehowstuff

e) Verify the values in /etc/group :

# cat /etc/group | grep ehowstuff

f) Verify email user created for id ehowstuff :

# ls /var/spool/mail | grep ehowstuff

More useradd options :

-c, –comment COMMENT
Add a value, such as a full name, to the GECOS field.

-g, –gid GROUP
Specify the primary group for the user account.

-G, –groups GROUPS
Specify a list if supplementary groups for the user account.

-a, –append
Used with the -G option to append the user to the supplemental groups mentioned without removing the user from other groups.

-d, –home HOME_DIR
Specify a new home directory to a new location. Must be used with the -d option.

-m, –move-home
Move a user home directory to a new location. Must be used with the -d option.

-s, –shell SHELL
Specify a new login shell for the user account.

-L, –lock
Lock a user account.

-U, –unlock
Unlock a user account.

2. Deleting a User from an Linux System.

a) Get userdel manual :

# man userdel
userdel - delete a user account and related files

b) userdel username removes the user from /etc/passwd, but leaves the home directory intact by default. Proper command to remove the user’s account, user’s home directory and mail spool as part of the deletion process :

# userdel --remove ehowstuff


# userdel -r ehowstuff

Warning :
When a user is removed with userdel without the -r option specified, the system will have files that are owned by an unassigned user ID number. This can also happen when files created by a deleted user exist outside their home directory. This situation can lead to information leakage and other security issues.


How to Install EPEL Yum Repository on Linux CentOS 7 / RHEL 7

Epel yum repository is an open source centos yum repository or rpm repository for developers and system administrators to perform the installation of RPM packages via yum on their virtual private server (VPS) or dedicated server.

EPEL yum repository is redhat yum repository for CentOS and additional yum repository for the existing CentOS repository.

It provides 100 % high quality software packages for Linux distributions, including RHEL (Red Hat Enterprise Linux), CentOS and Debian, and all packages maintained by Fedora repo team.

1. Prepare EPEL repository for RHEL 7/CentOS 7 64 bit (epel centos 7/epel rhel 7) :

# sudo rpm --import
# # sudo rpm -Uvh

Example :

# sudo rpm --import
# sudo rpm -Uvh
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-9                 ################################# [100%]

In CentOS 7, an alternative way to install the EPEL repo is by using the command yum :

# sudo yum install epel-release -y

2. Command to verify that the EPEL repository is enabled.

# sudo yum repolist

Sample output :

# sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
repo id                                                       repo name                                                                                 status
base/7/x86_64                                                 CentOS-7 - Base                                                                            9,363
epel/x86_64                                                   Extra Packages for Enterprise Linux 7 - x86_64                                            11,046
extras/7/x86_64                                               CentOS-7 - Extras                                                                            200
nginx/x86_64                                                  nginx repo                                                                                    41
updates/7/x86_64                                              CentOS-7 - Updates                                                                           438
varnish-4.1/x86_64                                            Varnish Cache 4.1 for Enterprise Linux                                                        31
repolist: 21,119

3. Install httpd package using epel repo option –enablerepo=epel :

# sudo yum --enablerepo=epel install httpd

EPEL Yum Repository

How to Remove / Uninstall Nginx on CentOS 7 / RHEL 7 / Oracle Linux 7

Nginx web server is alternative web server to Apache and Lighttpd. Nginx popularity now growing because it focuses on high concurrency, high performance while maintaining low memory usage. However, due to certain reasons webmaster or system administrator can not use Nginx on their server and decide to uninstall Nginx. Most of the webmaster, administrator and programmer still prefer to user Apache over Nginx as a web server because of the following reasons :

  • Not many webmaster, administrator and programmer comfortable with Nginx configuration
  • Apache has built-in support for a wide range of web programming languages, including Perl, PHP and Python
  • Apache languages are easy to learn and can be used to create powerful online applications
  • Apache is still the most popular web server on the Internet
  • Apache is the oldest web server, you won’t have any trouble finding people skilled in configuring it.

For the linux server platform that running on CentOS 7, RHEL 7 and Oracle linux 7, the removal step for Nginx is quite different from older version. Therefore, this article will explain the steps to remove or uninstall Nginx that was installed from source on CentOS 7, RHEL 7 and Oracle Linux 7.

Note : These steps to Remove / Uninstall Nginx has been tested on CentOS, RHEL and Oracle Linux platform and was running under root privilege.

1. Stop Nginx service and remove Nginx auto start script :

[root@rhel7 ~]# sudo systemctl stop nginx.service
[root@rhel7 ~]# sudo systemctl disable nginx.service

2. Remove Nginx user and it related directory :

[root@rhel7 ~]# sudo userdel -r nginx

3. Delete and related Nginx installation directory :

[root@rhel7 ~]# sudo rm -rf /etc/nginx
[root@rhel7 ~]# sudo rm -rf /var/log/nginx
[root@rhel7 ~]# sudo rm -rf /var/cache/nginx/

4. Remove the created nginx.service script under systemd :

[root@rhel7 ~]# sudo rm -rf /usr/lib/systemd/system/nginx.service

Uninstall Nginx

How to Install Nginx on CentOS 7 / RHEL 7

NGINX is a web server that focuses to high performance and high concurrency and at the same time very low memory usage. It is a flexible web server and lightly if compare to the Apache HTTP Web Server. Since the advent of RHEL 7 and CentOS 7, many webmasters or system administrators and the owner of Virtual Private Server (VPS) or dedicated server start to find a best way to update and install Nginx on CentOS 7 and RHEL 7. The article below discusses how to install Nginx with two method option and the steps are tested on CentOS 7 and RHEL 7 operating system.

OPTION A. Install Nginx – Source Installation :

1. Install Nginx software prerequisites :

# yum install pcre pcre-devel openssl-devel perl gcc make -y

2. Create Nginx user :

# useradd nginx
# usermod -s /sbin/nologin nginx

3. Create the following directory to keep all the installation files and logs :

# mkdir -p /etc/nginx
# mkdir -p /var/log/nginx
# mkdir -p /var/cache/nginx

4. Download Nginx from official website and extract it :

# wget
# tar xzvf nginx-1.6.2.tar.gz

5. Go to the extracted directory and start Compiling and install Nginx :

# cd nginx-1.6.2
# ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

If your Nginx software compiling is successful, you will received below configuration summary :

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using system zlib library

  nginx path prefix: "/etc/nginx"
  nginx binary file: "/usr/sbin/nginx"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/var/run/"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/cache/nginx/client_temp"
  nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"
  nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"
  nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"
  nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"

6. Still in the current, nginx-1.x.x directory, issue the installation command as below :

# make && make install

7. Register Nginx service into systemd as a service by create the file named nginx.service :

# vi /usr/lib/systemd/system/nginx.service

Add the following :

Description=nginx - high performance web server

ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID


8. Start Nginx service and make it start at boot :

# sudo systemctl start nginx.service
# sudo systemctl enable nginx.service

9. Stop and disable Firewalld service :

# sudo systemctl stop firewalld.service
# sudo systemctl disable firewalld.service

OPTION B. Install Nginx – Installation via yum repository :

1. To enable automatic updates of Linux packages set up the yum repository for the RHEL/CentOS distributions, you can added manually without installing the nginx-release package. Create the file named /etc/yum.repos.d/nginx.repo with the following contents:

# vi /etc/yum.repos.d/nginx.repo
name=nginx repo

Note : Please replace “OS” with “rhel” or “centos“, depending on the distribution used, and “OSRELEASE” with CentOS or RHEL version such as “5”, “6”, or “7”, for 5.x, 6.x, or 7.x versions, respectively.

As an example for RHEL 7 :

name=nginx repo

2. Alternatively you can install the prepare yum repository using nginx-release package followed by the OS version.

a) RHEL 7 :

# rpm -Uvh

b) CentOS 7 :

# rpm -Uvh

3. Start install Nginx with yum command :

# yum install nginx -y

How to verify the both installation method are successful or not ?

Visit http://Nginx-ipaddres

install nginx

How to Prepare Local Yum Repository from CD-ROM/DVD-ROM image on RHEL 7

If you have installed Red Hat Enterprise Linux 7 (RHEL 7) but do not have access to the redhat official repo, you will encounter problems installing and updating software. To solve the above problems, I have prepared a short step to update and install the RPM package from the CD-ROM/DVD-ROM image for RHEL 7. This step can also be used in RHEL 6 or older versions such as RHEL 5. For linux servers that do not have access to the internet or no access to the RHEL official repository, the steps below will help.

1. Mount the ISO from the DVD-ROM into /mnt directory :

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

2. Take note the media ID :

[root@rhel7 ~]# cat /mnt/media.repo
name=RHEL-7.0 Server.x86_64

3. Create rhel7.repo text file in /etc/yum.repos.d/ with the following content. Make sure you include the correct media ID as above. Save the file :

[root@rhel7 ~]# vi /etc/yum.repos.d/rhel7.repo
name=DVD-RHEL7 repository

4. Install, remove and update using yum command.

[root@rhel7 ~]# yum install perl -y

Example :

[root@rhel7 ~]# yum install perl -y
 Package                    Arch       Version                 Repository                      Size
 perl                       x86_64     4:5.16.3-283.el7        Local-DVD-RHEL7-Repository     8.0 M
Installing for dependencies:
 perl-Carp                  noarch     1.26-244.el7            Local-DVD-RHEL7-Repository      19 k
 perl-Encode                x86_64     2.51-7.el7              Local-DVD-RHEL7-Repository     1.5 M
 perl-Exporter              noarch     5.68-3.el7              Local-DVD-RHEL7-Repository      28 k
 perl-File-Path             noarch     2.09-2.el7              Local-DVD-RHEL7-Repository      27 k
 perl-File-Temp             noarch     0.23.01-3.el7           Local-DVD-RHEL7-Repository      56 k
 perl-Filter                x86_64     1.49-3.el7              Local-DVD-RHEL7-Repository      76 k
 perl-Getopt-Long           noarch     2.40-2.el7              Local-DVD-RHEL7-Repository      56 k
 perl-HTTP-Tiny             noarch     0.033-3.el7             Local-DVD-RHEL7-Repository      38 k
 perl-PathTools             x86_64     3.40-5.el7              Local-DVD-RHEL7-Repository      83 k
 perl-Pod-Escapes           noarch     1:1.04-283.el7          Local-DVD-RHEL7-Repository      50 k
 perl-Pod-Perldoc           noarch     3.20-4.el7              Local-DVD-RHEL7-Repository      87 k
 perl-Pod-Simple            noarch     1:3.28-4.el7            Local-DVD-RHEL7-Repository     216 k
 perl-Pod-Usage             noarch     1.63-3.el7              Local-DVD-RHEL7-Repository      27 k
 perl-Scalar-List-Utils     x86_64     1.27-248.el7            Local-DVD-RHEL7-Repository      36 k
 perl-Socket                x86_64     2.010-3.el7             Local-DVD-RHEL7-Repository      49 k
 perl-Storable              x86_64     2.45-3.el7              Local-DVD-RHEL7-Repository      77 k
 perl-Text-ParseWords       noarch     3.29-4.el7              Local-DVD-RHEL7-Repository      14 k
 perl-Time-Local            noarch     1.2300-2.el7            Local-DVD-RHEL7-Repository      24 k
 perl-constant              noarch     1.27-2.el7              Local-DVD-RHEL7-Repository      19 k
 perl-libs                  x86_64     4:5.16.3-283.el7        Local-DVD-RHEL7-Repository     686 k
 perl-macros                x86_64     4:5.16.3-283.el7        Local-DVD-RHEL7-Repository      42 k
 perl-parent                noarch     1:0.225-244.el7         Local-DVD-RHEL7-Repository      12 k
 perl-podlators             noarch     2.5.1-3.el7             Local-DVD-RHEL7-Repository     112 k
 perl-threads               x86_64     1.87-4.el7              Local-DVD-RHEL7-Repository      49 k
 perl-threads-shared        x86_64     1.43-6.el7              Local-DVD-RHEL7-Repository      39 k


How to Create LVM in Linux CentOS 7 / RHEL 7 / Oracle Linux 7

Storage technology plays a important role in improving the availability, performance, and ability to manage Linux servers.

One of the most useful and helpful technology to linux system administrator is Linux Logical Volume Manager(LVM), version 2 (or LVM 2).

LVM is a widely-used technique and extremely flexible disk management scheme for deploying logical rather than physical storage. With LVM, system administrator can easily resize and extend the logical drive when it is required.

Create Lvm

The following steps will describe how to create LVM in Linux CentOS 7 or RHEL 7 or Oracle Linux 7.

How to Create Lvm in Linux Step by Step

1. Add the new 20GB vdisk from the ESXi or vCenter :

Create Lvm

2. create a new Partiton using fdisk tool and select partition type LVM :

[root@centos7 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xfd3bf27d.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xfd3bf27d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xfd3bf27d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496   8e  Linux LVM

3. Initializes the partition /dev/sdb1 as an LVM physical volume :

[root@centos7 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

4. Scanning for Block Devices

[root@centos7 ~]# lvmdiskscan
  /dev/centos/swap [       2.00 GiB]
  /dev/sda1        [     500.00 MiB]
  /dev/centos/root [      27.51 GiB]
  /dev/sda2        [      29.51 GiB] LVM physical volume
  /dev/sdb1        [      20.00 GiB] LVM physical volume
  2 disks
  1 partition
  0 LVM physical volume whole disks
  2 LVM physical volumes

5. Displaying Physical Volumes :

There are three commands you can use to display properties of LVM physical volumes: pvs,
pvdisplay, and pvscan.

The pvdisplay command provides a verbose multi-line output for each physical volume. It displays
physical properties (size, extents, volume group, etc.) in a fixed format.

[root@centos7 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               29.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              7554
  Free PE               0
  Allocated PE          7554
  PV UUID               JvDOto-KDiF-gtca-TveX-ne9M-frsB-qsP1aJ

  "/dev/sdb1" is a new physical volume of "20.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               20.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               rJ8wl7-xzIN-2qqV-ov7Z-lHKe-ELge-aAV29V

The pvscan command scans all supported LVM block devices in the system for physical volumes

[root@centos7 ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [29.51 GiB / 0    free]
  PV /dev/sdb1                      lvm2 [20.00 GiB]
  Total: 2 [49.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 1 [20.00 GiB]

6. Create volume group name vg_newlvm and add /dev/sdb1 partition into the group.

[root@centos7 ~]# vgcreate vg_newlvm /dev/sdb1
  Volume group "vg_newlvm" successfully created

If you have more than one partition, you can add multiple partition in single command. This command creates a local volume named vg_newlvm that contains physical volumes /dev/sdb1 and /dev/sdc1 :

[root@centos7 ~]# vgcreate vg_newlvm /dev/sdb1 /dev/sdc1

7. Creates a logical volume called centos7_newvol that uses all of the unallocated space in the volume group vg_newlvm :

[root@centos7 ~]# lvcreate --name centos7_newvol -l 100%FREE vg_newlvm
  Logical volume "centos7_newvol" created

You can see more example of lvcreate command in article “4 lvcreate Command Examples on Linux

8. Display the created logical volumes :

[root@centos7 ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_newlvm/centos7_newvol
  LV Name                centos7_newvol
  VG Name                vg_newlvm
  LV UUID                szlkNP-0lwe-f59Z-PJVU-X7pG-unBL-qN10D4
  LV Write Access        read/write
  LV Creation host, time centos7.ehowstuff.local, 2015-01-25 15:15:48 +0800
  LV Status              available
  # open                 0
  LV Size                20.00 GiB
  Current LE             5119
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

9. Use the mkfs command to format a newly created LVM :

[root@centos7 ~]# mkfs.ext4 /dev/vg_newlvm/centos7_newvol
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241856 blocks
262092 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

10. Create the mount point and mount the new LVM :

[root@centos7 ~]# mkdir -p /data
[root@centos7 ~]# mount /dev/vg_newlvm/centos7_newvol /data

11. Verify thew new disk layout :

[root@centos7 ~]# df
Filesystem                           1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root               28260132 9191032  17610516  35% /
devtmpfs                               1935888       0   1935888   0% /dev
tmpfs                                  1941892       0   1941892   0% /dev/shm
tmpfs                                  1941892    8728   1933164   1% /run
tmpfs                                  1941892       0   1941892   0% /sys/fs/cgroup
/dev/sda1                               487634   73191    384747  16% /boot
tmpfs                                  1941892    8728   1933164   1% /var/named/chroot/run/named
/dev/mapper/vg_newlvm-centos7_newvol  20507216   45080  19397384   1% /data

Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

Rescan SCSI bus

When you need to add a hard disk or network interface cards on the new VMware virtual machine on the production server, but you are not allowed to shutdown the server or you have several related issues as below. The following quick article shows how to rescan SCSI Bus to add or remove a SCSI Devices on Linux.

This steps may work on CentOS 5/6/7 and RHEL 5/6/7.

Other related Issues

  • Is it possible to add or remove a SCSI device without rebooting a running system?
  • Can you scan a SCSI bus for new or missing SCSI devices without rebooting?
  • How can I make newly connected SCSI storage devices available without rebooting?
  • What is the Linux equivalent to the Solaris command devfsadm to add or remove storage devices?
  • I am trying to add a LUN to a live system but it is not recognized
  • I am trying to add a tape drive to a live system but it is not recognized
  • I am trying to add a disk drive to a live system but it is not recognized
  • How can I force a rescan of my SAN to find newly associated LUNs?
  • What to do if a newly allocated LUN on my SAN is not available?
  • Unable to probe for a newly allocated LUN
  • Some nodes can’t see my new storage device, how can I make it available?
  • After SAN maintenance activity, not all devices returned – devices in multipath missing or remain in failed state.
  • After SAN failover testing completed, not all devices returned to running state as expected – devices in multipath missing or remain in failed state.
  • What is the best way to remove a SCSI disk from the system

After Red Hat Enterprise Linux 5.0 (RHEL 5) and above (RHEL 6 and RHEL 7), it is possible to make changes to the SCSI I/O subsystem without rebooting.

How to Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

1. Identify host bus number :

# ls /sys/class/scsi_host/
host0  host1  host2

2. Rescan the SCSI Bus to Add a SCSI Devices :

# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
# echo "- - -" > /sys/class/scsi_host/host2/scan

Reference :

What are the Differences Between the Open-VM-Tools package and VMware Tools package

Many of the system administrator asked whether they need to install Open-VM-Tools package or VMware Tools package that ships with ESX/ESXi VMware products.

VMware Tools is a suite of utilities that enhances the performance of the virtual machine’s guest operating system and improves management of the virtual machine.

How to Install Vmware-tools for windows
How to Install Vmware-tools for Linux

The Open Virtual Machine Tools (open-vm-tools) are the open source implementation of VMware Tools. They consists of a suite of virtualization utilities that improves the functionality, administration, and management of virtual machines within a VMware environment. As virtualization technology rapidly becomes mainstream, each virtualization solution provider implements their own set of tools and utilities to supplement the guest virtual machine. The primary purpose for open-vm-tools is to enable operating system vendors and/or communities and virtual appliance vendors to bundle VMware Tools into their product releases.

open-vm-tools is available with these operating systems:

  • Fedora 19 and later releases
  • Debian 7.x and later releases
  • openSUSE 11.x and later releases
  • Recent Ubuntu releases (12.04 LTS, 13.10 and later)
  • Red Hat Enterprise Linux 7.0 and later releases
  • SUSE Linux Enterprise 12 – available Q4 2014
  • CentOS 7
  • Oracle Linux 7

Note : If your OS is not listed above, i would suggest you to install VMware Tools package that ships with ESX/ESXi VMware products.

VMware support policy

  • VMware recommends using open-vm-tools redistributed by operating system vendors.
  • VMware fully supports virtual machines that include open-vm-tools redistributed by operating system vendors, which is done in collaboration with the OS vendor and OS communities. However, the operating system release must be published as certified by the specific VMware product in the online VMware Compatibility Guide.
  • VMware provides assistance to operating system vendors and communities with the integration of open-vm-tools with OS releases.
  • VMware fully supports virtual appliances that include open-vm-tools, which is done in collaboration with the virtual appliance vendor.
  • VMware does not recommend removing open-vm-tools redistributed by operating system vendors.

References :

3 Command to Change the Linux Date and Time in CentOS 7/RHEL 7

Red Hat Enterprise Linux 7 or CentOS 7 come with three default utilities or command line that help to configure and display the information about the system date and time:

3 Command to Change the Linux Date and Time in CentOS 7/RHEL 7

1.The timedatectl utility, which is new in Red Hat Enterprise Linux 7 and is part of systemd;
2.The traditional date command;
3.The hwclock utility for accessing the hardware clock.

1. timedatectl Utility

The timedatectl utility is a part of the systemd system and service manager that allows you to change the current date and time of the linux system.

1.1. How to check time server linux using timedatectl ?

Run the timedatectl command with no additional command line options:

[root@centos7 ~]# timedatectl
      Local time: Mon 2014-11-03 22:44:24 MYT
  Universal time: Mon 2014-11-03 14:44:24 UTC
        RTC time: Mon 2014-11-03 14:44:24
        Timezone: Asia/Kuala_Lumpur (MYT, +0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

1.2. How to set date on centos sing timedatectl ?

timedatectl set-time YYYY-MM-DD

Example of change the current date :

[root@centos7 ~]# timedatectl set-time 2014-11-04

1.3. How to change server time centos using timedatectl ?

timedatectl set-time HH:MM:SS

Example of change the current time :

[root@centos7 ~]# timedatectl set-time 00:50:00

1.4. How to change the Time Zone using timedatectl ?

Use the following command to list all available time zones in Asia :

[root@centos7 ~]# timedatectl list-timezones | grep Asia

In order to change the time zone to Asia/Kuala_Lumpur, type the following command as a root user :

[root@centos7 ~]# timedatectl set-timezone Asia/Kuala_Lumpur

2. date Utility

The date utility is available on all Linux systems. date allows you to display and change the current date and time and it is frequently used in scripts to display the system clock.

2.1. How to display the current Date and Time using date ?

To display the current date and time, run the date command with no additional command line options:

[root@centos7 ~]# date
Tue Nov  4 01:12:39 MYT 2014

This displays the day of the week followed by the current date, local time, abbreviated time zone, and year.

2.2. How to display the current Date and Time in customized the format ?

You can also customize the format of the displayed information by providing the +”format” option on the command line:

date +"format"

Example :

[root@centos7 ~]# date +"%Y-%m-%d %H:%M"
2014-11-04 01:20

2.3. How to change the current time using date ?

In order to change the current date and time, type the date command with the –set or -s option as a root user :

To change the current time, run the date command with the –set or -s option as root:

date +%T -s HH:MM:SS

Replace HH with an hour, MM with a minute, and SS with a second, all typed in a two-digit form.

As an example change the current time to 11:56 p.m., as a root, run the following command :

[root@centos7 ~]# date +%T --set 23:56:00

3. hwclock Utility

hwclock is a utility for accessing the hardware clock. Hardware clock is independent of the operation system you use and works even when the machine is shut down. This program is used to find out the time from the hardware clock and set the system time at boot time.

3.1 How to display the Current Date and Time using hwclock ?

To display the current date and time, run hwclock with no command line options as a root :

[root@centos7 ~]# hwclock
Tue 04 Nov 2014 01:41:08 AM MYT  -0.131049 seconds

3.2. How to change the current Date and Time using hwclock ?

In order to change the hardware clock date and time, you can do so by appending –set and –date options along with your specification:

hwclock --set --date "dd mmm yyyy HH:MM"

As an example, if we want to set the date and time to to “15:20, October 29, 2015”, run the command in the following format:

[root@centos7 ~]# hwclock --set --date "29 Oct 2015 15:20"

Note : In Red Hat Enterprise Linux 6 / CentOS 6, the hwclock command was run automatically on every system shutdown or reboot, but it is not in Red Hat Enterprise Linux 7 /CentOS 7.

For more information on how to change the Linux Date and time in Red Hat Enterprise Linux 7 and CentOS 7, please read the manual page for the timedatectl, date and hwclock.

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).
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 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 brd 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

Red Hat to ditch MySQL for MariaDB in RHEL 7

In a surprise move, Red Hat has announced that version 7 of Red Hat Enterprise Linux (RHEL) will ship with the MariaDB database installed by default, in place of MySQL.

The announcement was made at the company’s Red Hat Summit, which wrapped up in Boston on Friday.

MariaDB is a fork of MySQL that was launched in 2009 by original MySQL coder Ulf Michael “Monty” Widenius. It’s meant to be a drop-in replacement, meaning any application that runs on MySQL should run unmodified on the MariaDB server. MariaDB does have one important characteristic that MySQL doesn’t share, however: MariaDB isn’t owned by Oracle.

Oracle acquired MySQL as part of its 2009 purchase of Sun Microsystems and almost immediately began tightening the reins, much to the consternation of MySQL’s fans. Support options were cut, and Oracle shifted to an “open core” development model in which the open source database server is sold alongside expensive, proprietary add-ons.

Widenius founded MariaDB largely as a reaction against these unwanted changes, and the project has steadily been gaining converts among the MySQL user community.

A number of popular community-driven Linux distributions have already begun shipping MariaDB in place of MySQL by default, including Arch Linux, OpenSuse, and Slackware. But for RHEL to do so is quite a coup indeed, and somewhat unexpected.

In May, the Fedora Project shipped a beta of Fedora 19 with MariaDB installed by default. But although Fedora is technically the upstream distribution for RHEL, and RHEL 7 will be based on Fedora 19, the actual software bundles that ship with the two distributions often differ significantly.

What’s more, last week Red Hat shipped the first beta of Red Hat Software Collections, an officially supported bundle of databases and programming languages for RHEL. But while that offering includes MariaDB, it also comes with MySQL and PostgreSQL, and Red Hat offers no preference among the three.

There is at least one good reason why Red Hat might be itching to move away from MySQL, though – namely, that there’s no love lost between Red Hat and Oracle, particularly since the database giant began offering Oracle Linux, a clone of the RHEL code base that lets Oracle keep all the money.

At Red Hat Summit, senior engineering manager Radek Vokál said that Red Hat also expected it would be easier to contribute certain patches and features to MariaDB than to MySQL. Apparently, Oracle has not been particularly amenable.

Vokál said that “some versions” of RHEL 7 will still ship with MySQL, but that MariaDB would be “the main thing” from now on.

The Reg reached out to Red Hat for further clarification, but a spokesperson did not respond by the time we pushed the big, red “Publish” button.

RHEL 7 is expected to ship with MariaDB sometime in the second half of 2013.

Click here for full Story