RHEL

Introduction

RHEL is short for Community ENTerprise Operating System — a Linux distribution based on the commercial Red Hat Enterprise Linux from Red Hat and compatible with it.

According to the Red Hat Enterprise Linux (RHEL) life cycle , RHEL 5, 6 and 7 will be supported "for up to 10 years", since they are based on RHEL.

Previously, RHEL 4 was supported for seven years.

Red Hat Enterprise Linux consists of free and open-source software, but it is available as discs with binary packages only to paying subscribers.

As required by the GPL and other licences, Red Hat provides all the source code.

The RHEL developers use this source code to build the final product, which is very close to Red Hat Enterprise Linux and available for download.

Installing RHEL

You can download the image from the website www.rhel.org

RHEL 7 image download site, an image from www.aredel.com
Mirror for downloading RHEL 7

You can learn how to write an image to a USB card in the article UltraISO

Read more about installing RHEL in the article «Installing RHEL»

To learn how to install RHEL 7 on VirtualBox you can read the article «Installing RHEL on VirtualBox»

After installation

I recommend running the following

sudo yum -y update
yum install -y redhat-lsb-core net-tools epel-release kernel-headers kernel-devel
yum groupinstall -y "Development Tools"

If the interface should be enabled at boot:

sudo sed -i s/ONBOOT=no/ONBOOT=yes/ /etc/sysconfig/network-scripts/ifcfg-enp0s3

Finding the version

You can find the version of the installed Centos with the command

cat /etc/system-release

RHEL Linux release 7.9.2009 (Core)

Or (starting with version 6)

cat /etc/rhel-release

RHEL Linux release 7.9.2009 (Core)

Starting with RHEL 6 you can use

rpm -q rhel-release

rhel-release-7-9.2009.0.el7.centos.x86_64

If you install the package redhat-lsb

lsb_release -a

\LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: RHEL Description: RHEL Linux release 7.9.2009 (Core) Release: 7.9.2009 Codename: Core You have new mail in /var/spool/mail/andrei [andrei@demoad ~]$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: RHEL Description: RHEL Linux release 7.9.2009 (Core) Release: 7.9.2009 Codename: Core

If the major version is enough, you can use

lpm -E %{rhel}

7

Or

rpm --eval %{rhel_ver}

7

Installing software

To begin with, it is a good idea to update the package manager. In RHEL it is called yum

yum update

For a silent installation use the -y flag

yum install -y redhat-lsb-core net-tools epel-release kernel-headers kernel-devel

yum groupinstall -y "Development Tools"

To install the graphical shell use the command

yum groupinstall -y "X Window System" "MATE Desktop"

Adding a user to the sudo group

All users in the group wheel have the ability to run the command sudo so you need to become root.

su

And from under root add the user to the wheel group with the command

usermod -aG wheel andrei

You can become the user again by running

su andrei

Network configuration

Covered in a separate article - «Configuring network connections in RHEL»

Installing wget

sudo yum install wget

Installing Go

You can download Golang from the website golang.org

wget https://golang.org/dl/go1.15.5.linux-386.tar.gz

After downloading, check that the checksum matches the one recorded on the website

sha256sum go1.15.5.linux-386.tar.gz

4c8179d406136979724c71732009c7e2e7c794dbeaaa2a043c00da34d4be0559 go1.15.5.linux-386.tar.gz

It matches the value on the website - look at the bottom line

Installing an image over the VirtualBox network, an image from www.aredel.com

Unpack the archive

sudo tar -C /usr/local -xzf go1.15.5.linux-386.tar.gz

Add the path to go to PATH

vi ~/.bash_profile

export PATH=$PATH:/usr/local/go/bin

Create a working directory

mkdir ~/go

Check whether Go is installed

go version

If you got something like this

go version go1.15.5 linux/386

Then all is well

If you got an error

-bash: /usr/local/go/bin/go: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

Try installing glibc.i686

sudo yum install glibc.i686

Installing X

Installing and configuring the X server are covered in a separate article - «X Window System in RHEL»

Useful commands

Switching between X and the real terminal (physical terminal) is done by pressing the right CTRL + F2 - to go to the console

Right CTRL + F1 - to go back to X

To find out the name of your console run

tty

/dev/pts/0

To find out who is connected to the system run

who

andrei tty1 2020-11-19 11:03 (:0) andrei pts/0 2020-11-19 11:45 (:0) andrei tty2 2020-11-19 11:42 andrei pts/1 2020-11-19 11:48 (192.168.56.1)

tty1 and tty2 are real terminals

pts/0 is a pseudo terminal started in X on the local machine

pts/1 is a pseudo terminal on a remote machine with IP 192.168.56.1, from which I connected over ssh

In Linux everything is a file, and tty terminals are no exception.

Run

ls -l $(tty)

Or a similar command

ls -l /dev/pts/1

crw--w----. 1 andrei tty 136, 1 Nov 19 12:43 /dev/pts/1

The first character is the file type.

There are seven file types: regular files, directories, character devices, blocks, sockets, named pipes, symbolic links

- : regular file
d : directory
c : character device file
b : block device file
s : local socket file
p : named pipe
l : symbolic link

Type c means character. That is, this file can receive and display characters

If you run

ls -ld /etc

drwxr-xr-x. 118 root root 8192 Nov 19 11:02 /etc

You can see that the file type is d. That is directory

To view disks/blocks run

lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 8G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 7G 0 part ├─rhel-root 253:0 0 6.2G 0 lvm / └─rhel-swap 253:1 0 820M 0 lvm [SWAP] sr0 11:0 1 57.7M 0 rom /run/media/andrei/VBox_GAs_6.1.10

If you run

ls -l /dev/sda*

brw-rw----. 1 root disk 8, 0 Nov 19 11:02 /dev/sda brw-rw----. 1 root disk 8, 1 Nov 19 11:02 /dev/sda1 brw-rw----. 1 root disk 8, 2 Nov 19 11:02 /dev/sda2

You can make sure that the file type is b. That is block

? means that there must be exactly one arbitrary character.

ls -l /dev/sda?

brw-rw----. 1 root disk 8, 1 Nov 19 11:02 /dev/sda1 brw-rw----. 1 root disk 8, 2 Nov 19 11:02 /dev/sda2

[12] means that there must be either the character 1 or the character 2

ls -l /dev/sda[12]

brw-rw----. 1 root disk 8, 1 Nov 19 11:02 /dev/sda1 brw-rw----. 1 root disk 8, 2 Nov 19 11:02 /dev/sda2

When you want to find out the system version you can run

ls -l /etc/system-release

lrwxrwxrwx. 1 root root 14 Nov 17 13:44 /etc/system-release -> rhel-release

The file type l means link that is, it is not a real file but a link

Run

ls -l /etc/system-release /etc/rhel-release /etc/redhat-release

-rw-r--r--. 1 root root 37 Oct 23 17:53 /etc/rhel-release lrwxrwxrwx. 1 root root 14 Nov 17 13:44 /etc/redhat-release -> rhel-release lrwxrwxrwx. 1 root root 14 Nov 17 13:44 /etc/system-release -> rhel-release

/etc/rhel-release is a real (regular) file and the rest are links to it.

If you were using redhat, the real file would be redhat-release

Another way to get version information is to run lsb_release -d, where -d means description

lsb_release -d

Description: RHEL Linux release 7.9.2009 (Core)

You can find out where the lsb_release file is with the command which lsb_release. To get more information at once, run

ls -lF $(which lsb_release)

-rwxr-xr-x. 1 root root 15929 Mar 27 2015 /usr/bin/lsb_release*

The -F option means show the file types. That is why we were able to see * after lsb_release. * means that the file is executable.

To find out where the file came from you can use the rpm command with the options q (query) and f (file)

rpm -qf $(which lsb_release)

redhat-lsb-core-4.1-27.el7.rhel.1.x86_64

To copy a file in interactive mode use the command cp with the option i (interactive)

interactive means that if a file with that name already exists, you will be asked before it is overwritten

cp -i /etc/hosts .
cp -i /etc/hosts .

cp: overwrite ‘./hosts’?

To create a directory together with a subdirectory inside it use the command mkdir with the option p (parent)

mkdir -p sites/heiheiru
ls -l sites

total 0
drwxrwxr-x. 2 andrei andrei 6 Nov 19 13:40 heiheiru

To create several files with sequential names at once, run touch with {}

touch files/file{1..5}
ls -l files

-rw-rw-r--. 1 andrei andrei 0 Nov 19 13:46 file1 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:46 file2 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:46 file3 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:46 file4 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:46 file5

To copy the files directory into the sites directory with all its contents, run

cp -R files sites
ls -l sites/files/

total 0 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:49 file1 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:49 file2 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:49 file3 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:49 file4 -rw-rw-r--. 1 andrei andrei 0 Nov 19 13:49 file5

The files directory was copied into the sites directory, so now sites has a files subdirectory.

If the tree module is installed you can study the nesting visually. If not, first run sudo yum install tree

tree sites

sites └── files ├── file1 ├── file2 ├── file3 ├── file4 └── file5 1 directory, 5 files

You can create a link with the ln command, and a symbolic link with ln -s

You can clear the terminal by pressing CTRL + l

You can study the details of your SSH connection with the command

echo $SSH_CONNECTION

192.168.56.1 52350 192.168.56.101 22

First come the client IP and port, then the server IP and port

To study the contents of a long text file run

less filename

To search forward press /, to search backward press ?

Search

Just find

find /usr/share/doc -name '*.pdf'

Find and immediately copy to the current directory

find /usr/share/doc -name '*.pdf' -exec cp {} . \;

Find in the current directory

find -name '*.pdf'

Delete from the current directory

find -name '*.pdf' -delete

Find all links

find /etc -type l

Find all links only at the top nesting level

find /etc -maxdepth 1 -type l

df -h /boot

Filesystem Size Used Avail Use% Mounted on /dev/sda1 1014M 194M 821M 20% /boot

Find regular files of a certain size

find /boot -size +20000k -type f

find: ‘/boot/efi/EFI/rhel’: Permission denied find: ‘/boot/grub2’: Permission denied /boot/initramfs-0-rescue-389ee10be1b38d4281b9720fabd80a37.img /boot/initramfs-3.10.0-1160.el7.x86_64.img /boot/initramfs-3.10.0-1160.2.2.el7.x86_64.img

find /boot -size +10000k -type f

find: ‘/boot/efi/EFI/rhel’: Permission denied find: ‘/boot/grub2’: Permission denied /boot/initramfs-0-rescue-389ee10be1b38d4281b9720fabd80a37.img /boot/initramfs-3.10.0-1160.el7.x86_64.img /boot/initramfs-3.10.0-1160.el7.x86_64kdump.img /boot/initramfs-3.10.0-1160.2.2.el7.x86_64.img /boot/initramfs-3.10.0-1160.2.2.el7.x86_64kdump.img

The same plus show the file sizes

find /boot -size +10000k -type f -exec du -h {} \;

find: ‘/boot/efi/EFI/rhel’: Permission denied find: ‘/boot/grub2’: Permission denied 60M /boot/initramfs-0-rescue-389ee10be1b38d4281b9720fabd80a37.img 21M /boot/initramfs-3.10.0-1160.el7.x86_64.img 13M /boot/initramfs-3.10.0-1160.el7.x86_64kdump.img 21M /boot/initramfs-3.10.0-1160.2.2.el7.x86_64.img 14M /boot/initramfs-3.10.0-1160.2.2.el7.x86_64kdump.img

Changing a user's password

To change a user's password in RHEL, run the command passwd

[andrei@localhost ~]$ sudo passwd andrei

[sudo] password for andrei:
Changing password for user andrei.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

locale

To find out the current locale in RHEL run

cat /etc/locale.conf

LANG="en_US.UTF-8"

or

localectl status

System Locale: LANG=en_US.UTF-8 VC Keymap: us X11 Layout: us

List of available locales

localectl list-locales

aa_DJ aa_DJ.iso88591 aa_DJ.utf8 aa_ER aa_ER.utf8 aa_ER.utf8@saaho aa_ER@saaho aa_ET aa_ET.utf8 af_ZA af_ZA.iso88591 af_ZA.utf8 am_ET am_ET.utf8 an_ES an_ES.iso885915 an_ES.utf8 ar_AE ar_AE.iso88596 ar_AE.utf8 ar_BH ar_BH.iso88596 ar_BH.utf8 ar_DZ ar_DZ.iso88596 ar_DZ.utf8 ar_EG ar_EG.iso88596 ar_EG.utf8 ar_IN ar_IN.utf8 ar_IQ

Select only English

localectl list-locales | grep en_US

en_US en_US.iso88591 en_US.iso885915 en_US.utf8

The list of system variables related to the locale is available with the command

locale

LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=en_US.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8 LC_ALL=

Detailed information about each variable can be obtained with the -c -k flags

locale -c -k LC_TIME

LC_TIME abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat" day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday" abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec" mon="January;February;March;April;May;June;July;August;September;October;November;December" am_pm="AM;PM" d_t_fmt="%a %d %b %Y %r %Z" d_fmt="%m/%d/%Y" t_fmt="%r" t_fmt_ampm="%I:%M:%S %p" era= era_year="" era_d_fmt="" alt_digits= era_d_t_fmt="" era_t_fmt="" time-era-num-entries=0 time-era-entries="S" week-ndays=7 week-1stday=19971130 week-1stweek=7 first_weekday=1 first_workday=2 cal_direction=1 timezone="" date_fmt="%a %b %e %H:%M:%S %Z %Y" time-codeset="UTF-8"

locale -c -k LC_CTYPE

LC_CTYPE ctype-class-names="upper";"lower";"alpha";"digit";"xdigit";"space";"print";"graph";"blank";"cntrl";"punct";"alnum";"combining";"combining_level3" ctype-map-names="toupper";"tolower";"totitle" ctype-width=16 ctype-mb-cur-max=6 charmap="UTF-8" ctype-class-offset=72 ctype-map-offset=86 ctype-indigits_mb-len=1 ctype-indigits0_mb="0" ctype-indigits1_mb="1" ctype-indigits2_mb="2" ctype-indigits3_mb="3" ctype-indigits4_mb="4" ctype-indigits5_mb="5" ctype-indigits6_mb="6" ctype-indigits7_mb="7" ctype-indigits8_mb="8" ctype-indigits9_mb="9" ctype-indigits_wc-len=1 ctype-outdigit0_mb="0" ctype-outdigit1_mb="1" ctype-outdigit2_mb="2" ctype-outdigit3_mb="3" ctype-outdigit4_mb="4" ctype-outdigit5_mb="5" ctype-outdigit6_mb="6" ctype-outdigit7_mb="7" ctype-outdigit8_mb="8" ctype-outdigit9_mb="9" ctype-outdigit0_wc=48 ctype-outdigit1_wc=49 ctype-outdigit2_wc=50 ctype-outdigit3_wc=51 ctype-outdigit4_wc=52 ctype-outdigit5_wc=53 ctype-outdigit6_wc=54 ctype-outdigit7_wc=55 ctype-outdigit8_wc=56 ctype-outdigit9_wc=57 ctype-translit-tab-size=4554 ctype-translit-default-missing-len=1 ctype-translit-ignore-len=0 ctype-translit-ignore="" map-to-nonascii=0

List of available locales

locale -a

Changing the locale

To change the locale in RHEL you can either edit the file locale.conf in /etc/ or apply the command localect (starting with RHEL 7)

Suppose you need to change the locale to en_us.iso88591

Open locale.conf and find the LANG line

sudo vi /etc/locale.conf

LANG="en_US.UTF-8"

Replace UTF-8 with iso88591

LANG="en_US.iso88591"

An alternative way using sed - run the command

sudo sed -i s/LANG=\"en_US\.UTF-8\"/LANG=\"en_US\.iso88591\"/ /etc/locale.conf

To check the changes run

localectl status

System Locale: LANG=en_US.iso88591 VC Keymap: us X11 Layout: us

To change a system variable, for example LC_CTYPE, run

sudo vi ~/.bashrc

And add the following code to the end of the file

LC_CTYPE="en_US.iso88591" export LC_CTYPE

locale -c -k LC_CTYPE

LC_CTYPE ctype-class-names="upper";"lower";"alpha";"digit";"xdigit";"space";"print";"graph";"blank";"cntrl";"punct";"alnum";"combining";"combining_level3" ctype-map-names="toupper";"tolower";"totitle" ctype-width=16 ctype-mb-cur-max=1 charmap="ISO-8859-1"

Article author: Andrei Olegovich