Changing hostname in RHEL7 / CentoS 7

Hostname is like labeling for Computers/ Other devices which is connected in internet/network.
hostname is used to identify/access the computers/devices easily in network.

Will see how to check and change the hostname in RHEL 7/ Cent OS 7

Using “hostname” command will check the existing hostname.

nmtui:

Will use this Network managet tool to set the hostname and it will edit the “/etc/hostname” in background.

Now the hostname has been changed  from “localhost.localdomain” to “server.localdomain” and by  issueing “hostname” command will check whether the change has been implemented or not. If the hostname still shows the “localhost.localdomain” old one, we should restart the hostnamed to force the change in hostnamectl.
Will check the hostname now.
Successfully hostname has been changed.

Failed to start docker.service: Unit not found / Installation of docker in RHEL7.x / CentOS 7.x

Failed to start docker.service: Unit not found / Installation of  docker in RHEL7.x / CentOS 7.x

Will see how to fix Failed to start docker.service: Unit not found / Installation of docker in RHEL7.x / CentOS 7.x.

Docker is open source and it will help us to deploy applications over the Linux containers.
Docker CLI command line tool will help to manage the lifecycle management of  image based containers.

Linux container will enable fast application deployment, simplest testing, troubleshooting and maintenance.

Check for the installed docker details and remove the docker which is already installed.

Again install docker using below command:

#curl -fsSL https://get.docker.com/ | sh



Enable the docker service permanently in this runlevel

Start the docker service

Now docker has been installed started successfully.

To check docker installed correctly or not issue the below command

Configuring LVM in redhat

For LVM Configuration need to follw the below steps.

1. Partition creation
2. Physical volume creation
3. Volume group creation
4. Logical volume creation

Here i’m using /dev/sda and /dev/sdb hard disks

Size:

/dev/sda – 500GB
/dev/sdb – 500GB

I already shared the steps to create partitions in previous post.

Click here to create new partition/filesystem in a physical disk.

Using fdisk we have to change the partition type by changing the ID.

For that we should use “t” option to change the partition type. Once we executed this, it will ask for
the Hex code of partition type. Here we need to mention “8e” as Hex code for LVM partition type.

Note: change the partition type for all HDD/ Partitions which we are going to configure LVM.

Than follow the below steps for LVM configuration.

Next we have to create physical volumes using below mentioned commands.

#pvcreate /dev/sda1 /dev/sdb1


#vgcreate -s 16M newvg /dev/sda1 /dev/sdb1

“newvg” is new volume group name and /dev/sda1, /dev/sdb1 will be added in this volume group.
Now this two hard disks will act as a single hard disk and the new size of hard disk is 1000GB.

Next we have to create logical volumes over the volume group, which is like a partitioning here.

#lvcreate -n lv1 -L 200G newvg

-n:  This option is to mention the new logical volume group.
lv1: new logical volume group name.
-L:  this option is to mention the size of new logical volume.

Now we have created logical volume and we should format and mount the lv.

#mkfs.xfs /dev/newvg/lv1

directory is required to mount the lv.

#mkdir /data

#mount /dev/newvg/lv1 /data


Now we successfully configured LVM. Follow the lvcreate steps to create more lv’s.



Linux kernel update


We are going to see Linux kernel update in this post.
Note: Here kernel is already upgraded one. So, we can’t show different here

Using “uname -r” command will check the current kernel version.

[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64


To update the kernel use the below command.
[root@localhost ~]# yum install kernel*



Again use the uname -r command to check whether the kernel has been updated or not.
[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64

Will undo the upgrade or installation using yum. For that have to check the current activity of yum using “yum history list”

We can use the ID to undo the upgrade/ installed packages.

Now am going to use ID 8 do undo the kernel upgrade

#yum history undo 8

Linux kernel update


Now use the "yum history list" command to check

Again will check whether the kernel upgrade has been removed or not.

Will use same yum option to upgrade/ undo any packages in Linux.

RHEL7 – New features

RHEL7 - New features
We are going to see RHEL7 New features in this post.
Docker    – Popular application-virtualization technology
Systemd  – Systemd was developed to replace the init system. more efficient loading of                       services during the boot process.
XFS         – it’ll support file systems of up to 500TB in size
Microsoft compatible identity management  – it’ll support file systems of up to 500TB in size
Performance co pilot – Performance tuning

Ubuntu operating system 17.04 installation

We can see How to do Ubuntu operating system 17.04 installation in this post.
Step 1 :
Boot the machine using OS media and click on “Install Ubuntu”.

Ubuntu operating system 17.04 installation

Step 2:  Now select the language and click on continue to proceed further.

Step 3:  We could see there are two check box which is mentioning here to enable the “Downloading                 updates while installation and Third party software installation” by checking this two box.

Step 4:  Now in next screen will ask for installation type. On this screen select as per your requirement. I’m going to select “Something else” option and click continue.


Step 5: Select the free space and click on “+”

Step 6:  Provide the required information to create root(/) file system and click ok.

Step 7:  Follow above step to create filesystem whatever you want and here i am create one more directory called “swap”  which doesn’t have filesystem type and it is called as virtual memory as well.

Step 8: Now you could see the created filesystem lists like below.

Step 9:  Click on “Install now” to continue with installation and click continue to confirm the changes.

Step 10: Select the time zone from next screen.

Step 11:  Than select Keyboard layout language.

Step 12:  Provide the username details which we need to create new user and which will help us to manage the system(This is not a default administrator – root) and click continue.

Step 13:  Finally files will be copied from the media to our hard disk and will ask for reboot as a final step.

Now the Ubuntu 17.04 has been installed successfully and ready to use.

Thanks for supporting.

Reference: Ubuntu Docs

Finding files in linux



“Find” command:

This will allow you to find the files/folders within a directory or recursively, that match the searching pattern whichever you are given to search.

#find .

Above command will indicate search in the current directory.

-name: This option will help you to find a file that matches the specific pattern.

And we can use metacharacters like “*”,” ” with enclosure of double quotes “”

Example:

[root@linux etc]# find . -name mtab./mtab

[root@linux /]# find /etc -name passwd/etc/passwd/etc/pam.d/passwd  -> this command will find files for starting like passwd under the /etc directory.

Using the “Locate” command:

     Locate command is faster than find command. Because it’s using a database which is previously built the database for search. Locate command will list all the path names which containing your search pattern.

The database is updated using corn or we can also manually update the database using below command.

#sudo updatedb

Example:

#locate mydata

Configuring syslogd in linux

Will see Configuring syslogd in Linux in this post

Follow the below steps on server:

Required services for syslogd

1. portmap
2 xinetd
3. syslog

Run the below command to keep on running above mentioned service after server reboot

#chkconfig portmap on
#chkconfig xinetd on
#chkconfig syslog on

Start portmap and xinetd services

#service portmap start
#service xinetd start

Check the service status

#service portmap status
#service xinetd status

Now edit “/etc/sysconfig/syslog” file using vi editor

#vi /etc/sysconfig/syslog

find for SYSLOGD_OPTIONS=”-m 0″

and add -r option to accept the logs from system

SYSLOGD_OPTIONS=”-r -m 0″

save and quit from the file :wq

-x disable DNS lookups on messages with -r option
-m 0 disabled MARK messages
-r enables logging

Once edited the file restart the syslog service

#service syslog retsrat

Follow the steps on client

Edit /etc/syslog.conf file and add a entry at end of file for server as shown below.

:Lets assume server ip as 192.168.1.10

#vi /etc/syslog.conf
user.* @192.168.1.10

Save and quit from the file :wq

now restart the syslog service on client

#service syslog restart

Now restart the client and check log entry in server. it will generate logs in server.

Checking logs on server

#less /var/log/messages

end of this log file you can see the recent logs.

Log analysis in Linux

We have lots of default and third-party tool/commands for log analysis in Linux.
Will see some default commands which is used in Linux for log analysis.
 
Awk
Cut
Grep
Tail
Syslogd
 
Usage of  awk command
 
   We can find and replace text and will sort the output of this command.  It will search for a given pattern by us and if any text matches for that pattern then it will do the further action which given in the command.
 
For example, if we need to the second item from an output of the command will use in below format
 
#ls -l | ask '{print $2}'

12
5
13
 
Likewise will use ask command Wherever we need a specific value from a log file/output of command or text file.
 
 
 
 

YUM Configuration in RHEL7/ CentOS 7

YUM Configuration in RHEL7/ CentOS 7

We are going to see YUM Configuration in RHEL7/ CentOS 7 in this post.

In Linux mostly we are using RPM and Yum Package management.

YUM- Yellowdog Updater Modified

Yum is mostly used to install a package without fail by resolving software dependencies.

We can configure yum locally/in network

Required RPM:
1. Yum
2. Createrepo
3. deltarpm
4. python-deltarpm

Configuring YUM in RHEL7

1. Insert RHEL7 media and mount it under /mnt

#mount /dev/cdrom /mnt

2. All the RPM’s available under Packages directory. change to Package Directory and
copy all the RPM’s under any local directory which you have already created.

3. Creating local directory to use as repository

#mkdir /yumpkg

4. Copying RPM’s from media to local directory

#cd /mnt/Packages
#cp *.* /yumpkg

5. Ensure all the required RPM’s installed or not by using below commands

#rpm -qa yum
#rpm -qa createrepo

6. Generate local repository files from yumpkg and create xml file


#cp /mnt/repodata/59eXXXXXX.xml /yumpkg/comps.xml
#cd /yumpkg
#createrepo -g /yumpkg/comps.xml .
7. Create repo file

#vi /etc/yum.repos.d/yum.repo
[server_name]
name=YUM_Server
baseurl=file:///yumpkg
enabled=1
gpgcheck=0

:wq save and exit from yum.repo file

Note: For using ftp/http as repository, we must enter the concerns path in baseurl field

#yum clean all
#yum makecache

8. Now check yum by listing all available RPM’s

#yum list all

9. Than try to install any package using YUM

# yum install vsftp

Other commands of yum

#yum remove <package_name>
#yum update <package_name>
#yum search <package_name>
#yum info <package_name>
#yum list installed
#yum check-update
#yum update
yum groupinstall <package_name>