Red Hat Linux 7.0 Installation with Screen Shots

Red Hat Installation 7.0 Installation Step by step with Screen-Shots

This is Red Hat 7.0(Red Hat Enterprise Linux)Installation,step by step  walk through with  screen shots.

Step:1 Boot the installation media on Intel,AMD systems.

After booting the installation media

Step:2 Select “Install Red Hat Enterprise Linux” in the boot menu and press “Enter”

Step:3 After “Anaconda Red hat installer started,Select your Language and Region ” , and click “continue”

 

Step:4 From the Installation Summary Set the Required Configuration from the options

Step:5 Select Date and Time

a)Set your Region and nearest city in your time zone

b)click done to return to Installation Summary

Here i have chosen my Region as  “Asia” and Nearest city as “Kolkata”

Step:5 Select the Keyboard Layout

a)Use the “+” and “-“ Button to add or remove the Keyboard Layouts

b)Click “Done” to return to the “Installation Summary”

 

 

Step:6 Select “Installation Source”

In this you will need to select the source media for installation,

Step:7 Select “Installation Destination”

a)Select the Target Disk. A check mark is displayed next to the selected target

The selected Target is partitioned automatically by default or If you want to configure the manual partition Layout you will need to select the manual option

Step:8  Return to “Installation Summary ” and select “Software Selection”,and choose “Server with GUI” Cluster to get the Graphical Access.

Note:If you choose the Minimal Package cluster then you will not get the Graphical Access after Installation,You will use only the Command Line options.

After Selecting the “Software Selection” Option you will  get the options to select the cluster to be install as shown below

Step:9 Select “Network and Host name”

a)Select the “Ethernet” sliding

b)Click “Done” to return to the “Installation Summary”

Note: In RHEL 7.0 Network Configuration is Done Immediately.In previous versions they are used during the setup and after installation.
Step:10 On the Installation summary screen,click “Begin Installation”

Step:11 Installation begins and the configuration menu is displayed

During the installation,

a) select root password and configure

b) Create a Non-root user account

Select “user creation”

a) Enter user full name

b)Create a password

Once configured you will get the confirmation as shown below

If you installed the server with “Server with GUI”  base environment,the initial setup application is started automatically

a)Accept the License agreement

b)Register the system

Then Click “Finish Configuration”

Step:12 Enable/Disable “kdump”

Step:13 Subscription Registration Manager

To register your server with the RHN Network you will need to connect the server to online

If you want to register later choose “No i prefer to register Later time”

Then click “Finish” to complete the installation process

Then Login in to Red hat 7.0 Desktop

After assigning the root password you will get the default desktop Look as follows

That’s all installation Done!!!!!!!!!!!!!!!!

Click here to check RHEL 6.0 Installation RHEL 6.0 Installation Step by Step with Screen Shots

RHEL 7.0 Installation Video Check it out  at my YouTube Channel RHEL 7.0 Installation video

*********************************************************************************************************************************

If you Appreciate what i do here on linuxvasanth.com,you should consider:

1.Subscribe to our email Updates: Sign Up Now

2.Subscribe to our YouTube Channel: Sign Up Now My You Tube Channel

3.Follow My Facebook Page: Sign Up Now

4.Share it with your friends

************************************************************************************************************************************

 

Yum configuration in Redhat Linux 6

In this Tutorial, we will see about yum in Red hat Linux. Yum stands for Yellow Dog Modifier. We can also use the “rpm” tool to install, uninstall the Linux packages, The difference between yum and rpm is, the “rpm” installs the given package only, whereas “yum” works with the Repository where Packages are kept.

1)Repositories(is a collection of all.rpm packages/files): It is the place where all the Packages are kept. Yum uses these repositories to get the correct and exact version of the packages while install/uninstall the packages.

2)Yum will have the URL’s of repositories in its configuration file

3)Yum is an opensource tool developed under the GPL(General Public License) which means anyone could download and they can also modify the code as per the requirement.

4)A Repository could be configured Locally or Remotely.

Configuration File for YUM:

Yum always uses its configuration file to fetch the packages. The configuration files come under the /etc/directory

The path for the configuration file is /etc/yum.repos.d

Difference Between Yum and rpm:

1. Rpm tool installs the given package only

2.rpm will not check and install the dependencies packages

3. Yum will check and install all the dependencies packages automatically.

4. Yum is capable of tracking the dependencies of packages and installing them prior to installing the package that the client needs to install

How to Configure Yum Repository?

Four packages must have installed before configuring the yum repository.

1.vsfstpd

2.deltarpm

3.python-deltarpm

4.createrepo
Check whether it is already installed or not by using the below command
#rpm   -qa   vsftpd*

#rpm  -qa   deltarpm*

#rpm -qa  python-deltarpm*

#rpm  -qa createrepo*

If the above packages are not installed  already then install it with the help of rpm command as follows

#rpm  -ivh  vsftpd

#rpm  -ivh  deltarpm

#rpm  -ivh python-deltarpm

#rpm -ivh createrepo

Let us insert the installation disk and mount it, in Linux by default the disks are mounted under /media directory path.

Step:1 Create a Directory
#mkdir /red

This Directory would be used to store all RPM Packages from Disk, here we will use /red directory.

Now copy all the .rpm Packages from the installation disk to the /red directory.

Change your path to /media

#cd  /media
#ls

You will need to copy two directories “Packages” and “RPM-GPG-0KEY-REDHAT-RELEASE” to /red location s follows,

#cp  -rvf   Packages/  RPM-GPG-KEY-REDHAT-RELEASE   /red

Now let us make that file which will be holding the package names and another repository information, for this, we should run another one tool called “createrepo” .This will create the database which will  have all the package information

#createrepo   --database  /red/Packages

The above output shows, createrepo started copying all the database under /red/Packages location

Once it is copied all the database you will get the following output as shown below

During this process, many cache files will generate you should clear them after the configuration is completed.

As we know yum uses Repository configuration file to check the available Repositories, now let us create a necessary Repository configuration file for our Local Repository.

#vi  /etc/yum.repos.d/data.repo

[linuxvasanth]

name=Yum Repository

baseurl=file:///red/Packages

enabled=1

gpgcheck=1

gpgkey=file:///red/RPM-GPG-KEY-redhat-release

:wq
[linuxvasanth]=Label of Repository, as we know repository configuration files are saved in /etc/yum.repos.d path, The repository file holds configuration file for multiple repositories. This label is used as the identifier for the repositories.

name=Is used to assign the name of the repository

baseurl=It shows the path of the  rpm files

enabled=1 It shows the state of the repository, Numeric value "1" means repository is enabled and "2" means repository is disabled

gpgcheck=1 It defines  the integrity of the package should be check or not, value "1" means integrity should check and "0" means integrity should not check

Always run the below command after the yum configuration

#yum clean all

That’s it. Yum configuration is Done!!!!!

To Check all the Enabled Repositories

#yum repolist

As you can see from the above output it shows the available Repositories ,since we have only one repository (my yum server) it shows that one here

To List all the Installed Packages by using the “yum” command
#yum list installed  |more

As you can see the above output ,it displays all the installed packages along with details.

To Display only the total  Numeric count of  all Installed Packages

#yum list installed |wc  -l

The above  syntax displays only the total count of all installed packages instead of displaying all the packages along with the details.

To Install a Package with yum command

In this example i will install the “telnet” package

#yum install  telnet

As i said “yum” will automatically check all the dependencies packages and install them as shown below,

As you can see from the above output “telnet” package has been installed successfully.

To Uninstall a Package:

To uninstall a package run the following syntax

#yum erase telnet

After giving “y” it will uninstall all the telnet packages

As you can see from the above output “telnet” package is successfully uninstalled.

To Get the Details of a Package with Yum

To get the information’s about a package before you start installing them,run the below command

#yum info  httpd

*********************************************************************************************************************************

If you Appreciate what i do here on linuxvasanth.com,you should consider:

1.Subscribe to our email Updates: Sign Up Now

2.Subscribe to our YouTube Channel: Sign Up Now My You Tube Channel

3.Follow My Facebook Page: Sign Up Now

4.Share it with your friends

************************************************************************************************************************************

Top 7 Linux Linux Scenario Based Interview Questions and answers(L1&L2)

Linux Scenario Based Interview Questions and answers
1.What is Ulimit and umask?

ulimit is an inbuilt default Linux command which is used to control over the resources available to shell and processes .

umask(User File Creation Mask) which is used to control the permissions assigned for the files and directories.

2.What is Run-level in Linux and how to change them?

A run-level is a system state of init  and the whole system that defines what system services are operating and they are identified by numbers in Linux for different purpose.

To change the runlvel you will need to edit the “/etc/inittab” file and change the default init entry “id:5:initdefault

You can switch to different run-levels with the help of “init” command followed by the run-level number (init  3)

3.Scenario 1: On one of my production server Linux,the storage team has extended   the partition from their end.Now how to re-scan the partition and extend without rebooting from Linux.

Answer:In my case 6th Disk on Controller-1 was extended by the storage team,first re scan it by using the following command

#echo 1 >/sys/class/scsi_device/device/rescan

 

Now resize the pv by using the following command

After this check the size of the volume group this time it should display the new extended size and with the help of “lvextend” command now we can easily extend the size of lv partition.

4.What is the maximum Length  for a file name allowed in Linux?

Any file name can have  a most extreme of 255 characters.This farthest point  does exclude the path name,so accordingly the whole path name  and file name could very much surpass the 255 characters.In interview ,the interviewer asks this  question to confuse the candidate by further asking if the mentioned includes the  path name.So get prepared with the complete answer.

5.What is Network Bonding and explain?

It is the process of bonding or joining two or more than two network interfaces to create one interface.It helps in improving the bandwidth,Load balancing,redundancy as in case of any of the interfaces is down,the other one will continue to work

Visit My Website to know more about Network Bonding Understanding Network Bonding
6.Scenario: On one of my Linux server the sybase database is not running because of the tmpfs. Sybase team wants to extend the size of tmpfs file system from 1.5GB to 4GB

Now check the tmpfs file-system details

#df  -h

Now edit the /etc/fstab file to increase the size

Change the size as shown below

Remount the filesystem as shown below

#mount - remount  tmpfs

#df -h

As you can see from the above output now tmpfs size has been extended to 4G

7.Sceneriao: df and du command shows different  Disk usage

Solution: This could be because of open file deletion i.e, when someone deletes the log file that is being used or open by other process if we try to delete this file then the file name will be deleted but its inode number and data will not be deleted

By using the “lsof” command we can get the list of open files,run this command under /var path to get the details

#lsof  /var |egrep  "^COMMAND|deleted"

To release the space ,we could kill the command by using its PID number.

I hope you find this guide useful

More good stuffs to come,Stay tuned!!!!

 Mail me your queries to vasanth@linuxvasanth.com
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

What is Run Level in Linux?

Run-level is a system state on  how the process is starting and what process to run ,which service to enable and disable while booting is decided by the Run-level program.While booting process after the kernel has started the init program it reads the /etc/inittab file where  the default run-level entry saved. and then it starts all the services.

There are totally seven run-levels available in UNIX ,according to the OS  the run-level number may vary.

Types of Run-levels:

In Linux by default it boots either Run-level 3 or run-level 5.You can also modify or switch to different run-levels as per the  needs.

To check the current Run Level settings:
#who  -r

r=Run-level

Sample output for the above command would be

To check the current and previous Run-level details
#runlevel

Sample output for the above command would be

n

In the above output ,“N” indicates the run-level has not been changed since the system was booted.“3” is the current run-level

To change the default Run-level 

/etc/inittab file holds the default run-level entry,open this file with the vi editor and change the run-level number to your desired one as follows,

Here am going to change the run-level from 3 to run-level 5

#vi /etc/inittab

Modify the line as follows

remove 5 and add 3 in the above line,after update reboot the system to login n to the new run-level

To reboot use the following command
#init 6

I hope you find this guide useful

More good stuffs to come,Stay tuned!!!!

Mail me your queries to vasanth@linuxvasanth.com

 

#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

 

 

 

 

Creating Shell Alias in Red-hat Linux

What is Bash Shell Alias?

A Shell Alias is a shortcut to reference a command.It can be used to avoid typing long command.So basically with this alias you can create a short name or can add group of commands including their options and arguments and many more.

Alias is an easier way to define your own commands or you can also create a shortcut name for the commands

Creating Shell Alias:

The syntax to create a new alias

#alias <alias name>=<values>
Ex:1 Creating alias name for the “date” command

In this example i wish to change the name of the command “date” to “life” ,So after assigned i could use the alias name “life” to  display the output instead of calling the “date” command

#alias life=date

The “date” command gives you the above output

New alias name is created successfully,now call the alias name“life “ to display the date command output

Note: Some of you might think the "date" command will not function after creating a new alias name,but in practical Remember both "date" and "life" will run.
Ex:2 Setting default options on commands to avoid having to type them each time a command is run.

In this example i will set the -v and -f option with the “rm” command.

When you run the “rm” command without “-f”(forcefully) option ,the rm command works with the interactive mode i.e  it will ask the confirmation from the end user.Here am going to use -v and -f option ,so that every time i run this command by default it uses -v and -f as their default settings,The user no need to manually give the -f and -v option.

without option the “rm” command works with interactive mode as shown below,

#rm  /mydoc

As you can see from the above output,the “rm” command uses the interactive method before it run

Let me apply the options with the rm command as shown below,

#alias  rm="rm  -vf"

As shown above,whenever i run the “rm” command it uses the value “rm  -vf” as their default mode.

#rm  /data

As you can see from the above output,this time it will not ask any confirmation from the end user, i.e  it uses -f option to ignore the interactive mode and coz of the -v verbose option it prints the message on the screen “removed  /data”

Like wise you can create alias name for commands and also you can set the desired options ,arguments with the command.

NOTE:In this setting an alias in this way only works for the life of a shell session,when the shell is closed the alias will be lost,i.e it uses the permanent setting. In order to make the alias values permanent you will need to update the details inside the .bashrc file.
Ex:3 To Make the alias values Permanent

Inside the /root directory you will have a file with the name .bashrc(.bashrc is a hidden file),so you should use the -a option with the ls command to get the hidden files from your path.

#cd  /root
#ls  -a

#vi  .bashrc

alias rm="rm  -vf"

That’s it ,i have made the alias value as the  permanent  one.

Ex:4 To Unalias the alias name
Syntax:

#unalias  <alias name>

In this example let me remove the alias name “life”(which is created for the date command previously) in our example.

#unalias   life
#life

Once you have removed the assigned alias name,after  that the name is no longer  available,but the “date” command works as usual without any issues as shown in the above output.

Ex:5 To have the “ls” alias always display the contents of the /etc directory,it can be rewritten as shown below,
#alias l="ls -l  /etc"

So whenever i call “l” from the shell prompt it  will display the details of the /etc/ directory

#l

 

Ask a question and VASANTH will respond to you.We are here to help you in any way we can.

How to Create a Bash Shell Script file in Linux? Tutorial video Create a Bash shell script file
You can reach me  at  vasanth@linuxvasanth.com

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

 

 

Understanding tar(Tape Archive) command in Linux

tar(Tape Archive) is used to group multiple files in to a single archive file.An Archive file it consists of any number of different files and also it contains the details to allow them to restored to their original format.Archive files are more easier to transmit or upload to the destination drive or media.

tar program first originally developed for the backups on the magnetic tape drive,later it can be now used to create archive files on a file system.tar will not compress the size of the data ‘s ,but it is very easy to compress the archive files created with tar utility.

Basic syntax for “tar”:

#tar   <options>     <archive file>    <files to be archive>

Let us  see the available options  that can be used with the tar command

-c = To create a new archive file(with the extension .tar)

-v = Verbose Output

-f = To mention the files

-x = To untar the archive file

-t = List the contents from the archive file
Ex:1 To create tar archive file

In this example i will add different files from various location in to the archive file

/backup.tar = Archive file name

/mylog = A file from / directory

/mydir/database = A file from the /mydir path

/var/userdata = A file  from /var directory path
#tar  -cvf   /backup.tar  mydata.tar  /mylog    /mydir/database   /var/userdata

#ls

As you can see from the above output ,the archived file with the name backup.tar is created successfully.

Ex:2 Untar the archive file
##If you want to unarchive in your current path run the below syntax

#tar -xvf  mydata.tar

##If you want to unarchive in different path run the below syntax

#tar -xvf  mydata.tar   -C   <destination path>

In this example i use the different destination path to untar

#tar  -xvf   mydata.tar    -C   /home/vasanth

Here i use the destination path  as /home/vasanth directory

Now go and check the destination path whether it is successfully unextracted the files

#cd   /home/vasanth

#ls

As you can see from the above output ,all the files from the archive successfully unarchived

Ex:3 To List the contents from the Archive file

To display the contents from the archive file ,apply -l option with the tar command as shown below

#tar   -tvf   <archive file>

#tar   -tvf   /backup.tar

The above command will display the contents of the /backup.tar file

The above command will not unarchive the archive file,it just list the content from the archive file.

Ex:4 To add additional file inside the archive file

If you want to add any additional files inside the  archive file apply -t option with the tar command as follows,

#touch  /rootlog

For More tutorial videos  subscribe my YouTube channel  Linux Vasanth

Now i will add /rootlog inside /backup.tar file

#tar   -rvf  backup.tar  rootlog
-r  = To add additional files in to the archive file

Check whether it is added or not

#tar  -tvf  /mybackup.tar

As we can see from the above  output,the file /rootlog is added inside the archive file

Ex:5 To delete a specified file from the archive file

In this example i will delete the file rootlog from the backup.tar file

#tar  -f   backup.tar   --delete   rootlog

Note: To delete multiple files ,add space and give the file names

To confirm whether it is removed from the archive file

#tar  -tvf  /backup.tar

As you can see from the above output rootlog file has been removed from the archive file.

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
You can reach me  at  vasanth@linuxvasanth.com
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

Understanding “fsck” in Linux

Importance of FSCK Utility

No one can predict when the system will get crash or your filesystem gets corrupt and if it happens then you may lose all of your valuable data from your hard drive. If you found that your filesystem creates such inconsistency then it is always run fsck to check the integrity, and this can be completed by using the special command called “fsck”(Filesystem consistency check). You can run this command manually or can start at the boot times.

You will need to run “fsck” on the following situation occurs

1.Taking a backup of your filesystem

2. Files on your system become corrupt

3. To do the consistency check

Ex:1 To run fsck on the filesystem

Syntax:

#fsck   <filesystem>    or   fsck   <mount point dir>

Note: To run fsck on a  filesystem, the filesystem should be in the unmounted state and inactive, You should never run fsck on the mounted partition doing so would corrupt the filesystem.

First check the filesystem is in mounted or in the unmounted state by using the following command

#df  -h

As you can see from the above output,/dev/sda2 is in the mounted state, now unmount this filesystem by using the following command

#umount  /dev/sda2
#df  -h

Now run the fsck on this filesystem for integrity check

#fsck  /dev/sda2

As you can see from the output, fsck hasn’t found any errors from the /dev/sda2 filesystem.

To Repair the Linux Filesystems errors automatically

When the filesystems have more than one errors, then for each and every scan fsck will ask the confirmation before it proceeds to repair all the errors, apply -y option with the fsck command to do the check and repair automatically.

#fsck  -y   /dev/sda2

Running fsck on the mounted partition:

If you run the fsck on the active partition  then  the file system will go to the  corrupted state,

Understanding fsck exit codes

While running the fsck, we may get some error codes, below are some of the important error codes we will get after the execution

0 =No errors

1 =File system error corrected

2 = System should be rebooted

4 =  File system error left uncorrected

16 = syntax error

32 = Checking cancelled by the user

To check the fsck error codes, run the following command after fsck,

#fsck  /dev/sda2

#echo $?

The above command will produce some error code after the execution of fsck command

As you can see from the above output echo $? command produced “0” error code which says there is no error found on the fsck scan.

Visit my youtube channel for more online tutorials 👇🏻👇🏻

To check the filesystem only for errors and don’t  repair

When you want to scan only for the errors  and you don’t want to repair, then  run the below command with -n option

#fsck  -n  /dev/sda2

The above command will scan only for the errors.

To run the fsck only on Unmounted partitions

When you are not sure about the mounted and unmounted partition details, run the below command, this will run fsck only on the unmounted partitions, when fsck detected any mounted partitions while running it will skip running on that partitions.

#fsck  -M
To run a fsck check on all the available partitions

To do a filesystem check on all partitions(including root partition), run the following command with -A option

#fsck  -A

A = Run fsck on all the available paritions

if you want to skip running fsck on the root(/) partition, then add the -R option with fsck as shown below,

#fsck -AR

The above command skips running fsck on the “/”(root) partition and it runs on all the remaining partitions.

 

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
You can reach me  at  vasanth@linuxvasanth.com
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

 

 

Rhel 6 installation Step by Step

Installing RHEL 6:

Red Hat Enterprise Linux(RHEL 6) is  Linux operating system Developed by Redhat.RHEL is available on multiple platforms including x86,x86_64, IBM P-series, IBM System-Z. Redhat is one of the most widely used Operating systems on Enterprise Level. Many other Linux distribution has been cloned from Redhat Enterprise Linux, these include CentOS and Oracle Linux.

To start the installation process:

Step:1 Select “Install or upgrade the Linux system

You can reach me  at  vasanth@linuxvasanth.com

Step:2 Begin Test Media Before Installation

It is always advisable to begin test media for any error before you starting the installation process.In this example, i choose to skip option as i have done the check already.

Step:3 Welcome screen

At this screen, choose next to continue with the installation

Step:4 Select installation Language

At this screen you should select a language you would like to use during the installation, Here i choose “English”

Step:5 Select Appropriate Keyboard

Select the keyboard you would like to use, here i have choosen  us-english

Step:6 Select the devices to be used during the installation

Two options are avaiable here,from that here i have choosen Basic storage device option as we are installing on a x86 system using local harddrive.

Step:7 Configure your Server Host name

Here you have to give one new host name by which it can be identified on your network.

Step:8  Select your Time Zone

Here you will need to locate the nearest  city to your site. I have choosen  Asia/Kolkata

Step:9 Assign a new root user password

you have to set a strong password. Never give a password based on the dictionary words. The password should contain Upper and lower cases with the mixture of special charcters.

Step:10 Select Storage Installation type

You can choose various options where you can use all space avaiable or delete any existing parition, create a custom parition type, here I go with the custom layout type

 

Step:11 Select a Disk to create Partition

Here i have only one disk /dev/sda, select “Standard partition”

 

Step:12 Add the parition “/”

Create “/” parition with the minimum size, here i gave 18Gb

Step 13: Confirm the assigned parition details

Select “yes” and press enter to go confirm

Step:14  Writing storage configuration to Disks

choose write changes to disks and press enter

Step:15 Choose the Disk to install Boot Loader

Select the disk to install the boot loader and press enter , here i choose /dev/sda disk to install the bootloader

Step:16 Select the Installation type

The default installation of RHEL is that of a basic server. There are lots of option available depending on what your server will be used for. Depending on which options you choose, various packages will be included automatically with your installation .In this i have choosen “Desktop” type.

Step:17 Package installation

Here the packages we have choosen manually  will be installed and this process may take a while depending upon your choices

Step:18 Congratulations your installation is now complete

Congratulations, you have now installed RHEL. You will need to reboot your system

 

Step:19 Welcome Screen

After the installation, you will get the welcome screen, choose  “forward” to continue

Step:20 Software updates

From this screen, you can install the updates or if you want to install the updates later you  will have the options to select that

Step:20 Create a Non-root user account

You should create a non-root user account ,This account will be used for all non-administration tasks

Step:21 Setup Date and Time

Check that you have the correct date and time . You may also specify  to syncrnoize your time with a time server over the network. In real envirnonment, many organazations will use sepreate time servers for this functionallty.

Step:22 Kdump

kdump is used to collect the server information after a server crash. You will need to give the double the size of the RAM for this configuration

Step:23 Login Screen

At this login screen, you will need to choose the user account to log in, choose others and give “root” at the username field to log in to the server as a root user.

I hope you have enjoyed this tutorial, if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏

 

You can reach me  at  vasanth@linuxvasanth.com

 

#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

Monitoring Commands in RedHat Linux Servers

Important Monitoring commands in Linux

For a system and network administrator, it’s very tough to debug and monitor the Linux servers activities and performance daily. In this tutorial, I have compiled some important monitoring commands that might be useful for the Linux/UNIX administrators. All these commands are available under all flavors of UNIX and these commands are very much useful in probing the cause for the errors.

1.vmstat(Virtual Memory Statistics):

This command will display the statistics of virtual memory, CPU activity, IO Blocks, Kernel threads and many more.

Some Linux distribution will not be having this command by default, You will need to install the systat package which contains the vmstat command.

#vmstat

2. To check the Active and Inactive Memory Details:
#vmstat -a

From the above output, you can check the active and inactive memory details, the column si and so indicates the following meaning,

si = Swapped in every second from disk in kilobytes

so = Swapped out every second to disk in kilobytes

free = Total free memory spaces
3.lsof(List of Open Files):

This command is very much useful in analyzing which processes are accessing and opening the files, and the open files include are Disk files, Pipes, Devices, Network sockets. For example when you trying to unmount a filesystem and if it not unmounting which means some process is accessing that filesystem, to check which processes are accessing the filesystem we can run this “lsof” command to get the full report. With this command, we can easily identify which files are in use

4. To list all open files
#lsof

From the above output,t it showing the long listing of open files

FD =File Descriptor and under this we will have some values ,

CWD =Current working directory

rtd = Root directory

mem = Memory mapped file

txt = Program text(Data and code)

TYPE of files and its identification

DIR =Directory

REG = Regular file

To learn more about “lsof” command visit this link Importance of lsof command

For More Linux Tutorial Videos visit my Youtube channel 👇🏻👇🏻

5.tcpdump (Network Packet Analyzer):

The tcpdump is the most useful command line  Network packet analyzer or packets sniffer program which is very much useful in capturing the TCP/IP packets that received or transferred on a specified network adapter over a network. This tool has also an option to save the captured data too a file for further analysis.

6. To capture the packets from a specific interface :
#tcpdump   -i   eth0

eth0 = Logical name of the network adapter,0 indicates the first  adapter 

Cancel the program by pressing ctrl+c, you will see the below output,

Note: This command saves the output in "pcap" format which can be viewed only by the "tcpdump" command
7. To capture only “N” number of packets:

By default the “tcpdump” command captures all the packets for the specified interface until you cancel the program, now by using one special option “-c”  you can capture the specified number of packets.

Below example  captures only 4 packets

#tcpdump   -c 4 -i eth0

8. To check the Number of Interfaces in you Server, run the following command
#tcpdump  -D

8.To capture and save the Packets in a File:
#tcpdump   -w   mylog.pcap    -i   eth0

mylog.pcap= filename along with the extension .pcap

9.To View the Captured Packet Files
#tcpdump   -r    mylog.pcap

10.To Capture Packets from a specific Port:

For example, To capture the packets from the “ssh” port, run the following command,

#tcpdump   -i  eth0  port  22

11.Netstat(Network Statistics):

This command is very much useful in monitoring the Incoming and outgoing packets and also you can monitor the interface statistics. When you are having connectivity issues to your server the first most thing is you need to check the port is in listening or non-listening state, that can be done by using the netstat command. This command is very much useful for the network administrators to check and analyze the network related problems.

12. To check all Listening ports of TCP and UDP Connections:
#netstat -a  |more

From the above output from the IP 192.168.1.175, one client is connected to my server via ssh port and the connection status is ESTABLISHED

13.To List only TCP connection details
#netstat -at

14.To Display the Full Statistics by Protocols:

By default, the statistics can be displayed only for the TCP, UDP, ICMP, and IP protocols, The -s option is used to specify a set of protocols

#netstat  -s

You can check the full statistics by protocols like Number of active connections, the total number of packets received, dropped and many more.

15.To display the statistics by TCP Protocols.
#netstat  -st

You can check the total number of active connections and failed attempts via this protocol and many more you can get from this command.

For Linux, Tutorial Videos visit my YouTube channel Linux Vasanth

16.IOTOP Command:

This command is very much similar to the “top” command, the only difference is with iotop you can check the real-time disk I/O and processe. This command is useful to find the exact process and high used Disk read/write processes

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

 

Rescue Mode In RedHat Linux

What is Rescue Mode?

When something goes wrong in your Linux box, there are so many ways to resolve that, however, these methods require that you to understand the system very well. As the name implies, rescue mode is there to rescue you from something. In normal operations, the Red Hat Linux systems use the files located on the system harddrive’s to do everything. But there may be a time when you are unable to get the Linux running completely enough to access its files on your system harddrive’s, By rescue mode, it is possible to access your files stored on your system hard drive, even if you can’t actually run the Linux from your system Harddrive.

When Rescue Mode is required?

You might need to boot in to rescue mode for any of these following reasons mentioned below;

1.You forgot the root password and bootloader password

2. You might need to re-install the Bootloader(i.e, GRUB)

3. Having Software/Hardware issues and you need to retrieve some important data from the hard drive

4.Unable to Boot the Linux in to the run level 3 or 5

Forgot the root and GRUB password:

What if you forgot your root password? You can boot your system to single user mode and from where you can reset the root password by using the “passwd” command, To boot the system to single user mode while booting, via bootloader is the only way to get in to single user mode, now what if I have assigned the bootloader password? You have no options now to get in to the single user mode when there is no way to recover your Linux box, “Rescue Mode” is the only way to resolve all these types of problems.

Having Software/Hardware issues:

There can be as many different situations under this category, Things like failing hard drive and forgetting to run the GRUB after building a new kernel, are the two things that can keep you from booting Rehat Linux. If you can get in to the rescue mode you may be able to resolve the problems and you can also get off some important files from your failing hard drives.

How to Boot the system in to Rescue Mode?

Use the following steps to boot in to the Rescue mode.

Step1: Boot the system from the Installation Media(cd/DVD)

Once the system has successfully booted  from the iso image, you will get the Red Hat Linux boot screen, choose the Rescue installed the system from the MENU SCREEN

Suppose if the Rescue option is not available means then you will need to choose the resue mode by using the following options at the boot prompt

[F1-main]  [F2:option]  [F3:Genera] [F4:Kernel] [F5:Rescue]

boot: Rescue

Step:2 Choose the Language

Select Language by using the arrow  keys and press enter

 

Step:3 Choose the Keyboard Type

Select the Keyboard type by using the arrow  keys and press enter

 

Step:4 Select the media contains the Rescue image

 

Step:5 Network type

If you want to access the system over the network in Rescue mode you can configure it from here. Mostly in the rescue mode network configuration are unnecessary.

 

Step:6 Next, a screen will appear telling you that the program now will attempt to find the RedHat Linux installation to rescue, choose “select” and enter

Step:7 Now you are in Rescue mode, if you grant it, then your root filesystem is mounted under the /mnt/sysimage directory, for example, all you files will be mounted under this location,your /etc/inittab file will get mounted under /mnt/sysimage/etc/inittab.

Once it is mounted under the /mnt/sysimage you will get the below confirmation on your screen

Step:8 Start the resuce mode shell and enter

Run the below command after entering in to the command line mode

#chroot   /mnt/sysimage

After this, you can open the system files to make the neccessary changes to make it function properly.

To exit from Rescue mode:

Type “exit” command twice to come out from the rescue envirnonment

#exit      (Leaving chroot environment)

#exit      (Leaving Rescue mode and restart)

 

Then choose “reboot” and press enter, this time your system will restart and reload all the selinux polices .

 

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
#############################################################
For More Videos Subscribe My Youtube Channel  Linux Vasanth
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

################################################################################

 

How to get user input in Bash shell script?

Getting Runtime Input values with “read” command in Bash shell scripting:

We can create a shell script by using the static and dynamic method. As we all know in the static method it will not take the runtime input values, every time you run the static script it displays the same output. dynamic scripting is different from static as it takes the runtime input values.😊

To get the run time inputs:

To get the user inputs we use the inbuilt shell command “read”, what it actuallky does is it takes the input values and save it inside the variable.

The syntax for read command:

#read  <variable name>

Let us look at a simple example script

#vi  /myscript.sh

#!/bin/bash

    #Ask the user for their name

     echo  Hi, MAy I know who is this?

     read myvar

     echo "Welcome to Vasanth blog  $myvar

     :wq

 

Line 1: Defining the Interpreter

Line2: Comment field

Line3: Display a message asking the user for input

Line4: To get the input from the user and save it in the variable "myvar"

Line5: Display another message to confirm read command executed successfully
“read” command with options:

We can use the “read” commmad with a variety of  command line options . There are two commonly used options  are p, which allows you to specify a prompt message on your console, and -s which makes the input hide  i.e will not display the  given input on the console. I will show you one example of how we can apply these two options to ask user name and password.

-p = Prompts a message

-s =To hide the inputs
#vi  /demo.sh

#!/bin/bash

#Ask the user for login details

read  -p  "Username:   "  var1

read  -ps  "Password   "  var2

echo "Thank you  $var1 your authentication is success"

:wq!

Line3&Line4:  we added the prompt with quotes so that we can have a space included with it, otherwise  the user input will straight after the; last character  of the prompt

As you can see from the above output the last line i.e the prompt message is added with the password line, To print the prompt message at the new line you can add the “echo” command without any argument as shown below,  This is a good way to get a blank line on the screen to help space things out.

#vi  /demo.sh

#!/bin/bash

#Ask the user for login details

read  -p  "Username:   "  var1

read  -ps  "Password   "  var2

echo 

echo  "Thank you  $var1 your authentication is success"

:wq

Let us see another example with more inputs,
#vi /script.sh

 #!/bin/bash 

echo "Which sports do you like?"

 read   sp1 sp2 sp3 

echo "Your first sport was:  " $sp1 

echo "Your first sport was:  " $sp2

 echo "Your first sport was:  " $sp3 

:wq!

Let as run this script as shown below

#./script.sh

The read command first it will take your input and spilt it on white space. The first input will  then be assigned  to the first variable name, the second input to the second variable name and so on it continues..👨‍💻

I hope you have enjoyed this tutorial if so Kindly subscribe and share it with your friends.
                                          🙏🙏 Thank you 🙏🙏
#############################################################
For More Videos Subscribe My Youtube Channel    https://youtu.be/A7a72pmPa5o
If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe
Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

#############################################################################################

How to Configure SAMBA Server in Red Hat Linux?

In this article, I will explain how to setup SAMBA in Red Hat Servers followed by how to access the samba shared  files from the Windows client system.

1. With the help of the SAMBA Program, you can configure Linux server for files and printer sharing with the Microsoft Windows Client.SAMBA uses the TCP/IP Protocol for sharing the data between the cross-platform servers.

2. If you want to use Linux as a file server in a windows network, then you must have to know how to configure the SAMBA in Linux. Both Windows and Linux servers use different filesystems, It is impossible to create a Linux file server just by granting the windows clients/users to access the Linux File/Directories.

3. Windows server/system would not be able to access the data/files in the Linux Directories. So many differences are there between Windows and Linux  file systems, Let me tell you one example,

Windows filenames are not  Case sensitive whereas Linux filenames are case-sensitive, In windows data.txt and Data.txt are the same file, In Linux, both the files are different individual files.

4. Windows uses the CIFS(Common Internet File System) protocol for the sharing and this protocol is developed from the Server Message Block(SMB) protocol.

5.SAMBA is implemented by these two Protocols SMB&CIFS

6. Linux Doesn’t have SMB support by default, this is why SAMBA is required here, So SAMBA just imitates the behavior of windows file server by configuring the SMB protocol, when you run the SAMBA on the Linux Server, the Windows servers on the network can able to see the Linux server.

 

RPM’s Required to Configure SAMBA:

Before we configure SAMBA in Linux Server, let me show you what all are the rpm’s required to implement SAMBA.

1.samba = This rpm needed for SAMBA server

2.samba-client = Needed for samba client

3.samba-common = This rpm includes all the samba commands needed to configure SAMA in Linux.

4.samba-winbind = This rpm establish the connection between windows and Linux servers

5.samba-domain-join-GUI = To connect the Linux users with windows domains and workgroup

6.samba-doc =  Contains  SAMBA help documents

 

Configure SAMBA in Linux:

First check the following packages are already installed or not, if it is not installed, install it

*Samba

*Samba-winbind

*samba-common

Check the  Required Samba Packages are already installed or not by using the following command,

#rpm  -qa  samba

#rpm  -qa samba-common

#rpm  -qa samba-wi*

As you can see from the above output all the required packages are installed.

Services Needed to configure SAMBA

smb = Important service for providing authorization and authentication for file sharing between the windows and Linux.

nmb = This service understands and replies to NetBIOS name service requests to those produced by the windows server.

winbind  = This service is needed for host and username resolution

Note: smb&nmb services are mandatory and winbind is an optional service.

Check the status of each service by running the following command,

#service smb status

#service nmb status

#service samba-winbind status

As you can see from the above output, both the services are stopped, Now bring the service online by using the following command,

#service smb start

#service nmb start

Check the status again,

#service smb status

#service nmb status

As you can see from the above output, both the samba services now brought it back to online.

Now make these service online always when the Linux server is booted next time by using the following command,

#chkconfig smb on

#chkconfig nmb on

From now onwards, whenever the server enters the run level,3 or 5 the above services will come to online automatically.

Create new samba users from Linux server

#useradd  nirmal

#useradd jaslyn

Create a password for both the users,i.e don’t create a password for  users to access the local system,

you need to create a samba password for these users, so that these users can access  only the samba services

To create a samba password and add the users to samba database

Syntax:

#smbpasswd -a  <user>

#smbpasswd -a nirmal

#smbpasswd -a jaslyn

 

Configure Samba:

Create a directory and assign full permission, so that other users can read or write the contents from the directory. By default, other users don’t have write access to the directory created by the root user.

#mkdir  /data

#chmod 777 /data

#cd /data

#touch f1 f2 f3

cd /

 

As you can see from the above output, a directory with the name data has been created with full permission.

Now open the samba configuration file and put the  shared data details,

#vi   /etc/samba/smb.conf

Scroll down to the workgroup directory value and mention your workgroup name

Note: Make sure you have created the same workgroup on windows system also.

Now, look for the shared definition variable and mention the directory details along with the permissions.

browsable = yes/No you can Limit the users to his own home directory.

You no need to mention the home directory details here, since the samba reads the user home directory details from the /etc/passwd file.

Now save and exit  from the samba configuration file

To check whether you have mentioned all the details correctly inside the samba configuration file, run the command “testparm”  , if any invalid entries are present it prints the error details on your screen.

#testparm

 

As you can see from the above screenshot, everything so far  configured properly, press the enter button to see the output,

From the above output, the testparm command didn’t find any errors inside the samba configuration file, we have successfully applied all the needed parameters inside the samba configuration file.

Now restart the samba services to take effect

#service smb restart

#service nmb restart

In this Lab, I will disable the firewall and SELinux security features, so that I will not block the access.

Note: If you have Enabled Firewall and SELinux Security, At the end of this article I have explained what are all the policies we need it to enable from firewall and SELinux.

 

To stop the firewall services:

#service iptables stop

#service iptables save

As you can see from the above output, firewall services have been stopped successfully.

To stop the SELinux features:

#setenforce 0

Check the workgroup name from the windows server

As you can see from the above output, windows client system is on the same workgroup LINUXVASANTH as Linux server has.

If you see here different workgroup name then change it to LINUXVASANTH.

Check the connectivity from windows client system:

#ping 192.168.1.253

Linux server IP= 192.168.1.253

As you can see from the above output Linux server is communicating from the windows system.

Now try to connect to the Linux server from windows system  to access the samba shared resources as below,

Now Login as samba user(nirmal)

Now the user(nirmal) will be logged in his home directory path as below,

That’s it…Now we have successfully configured Windows system as a  client system of SAMBA

Now try to edit some files from the shared directory “data”, Let me edit the file “f1” from this directory

Since I have given full permission to the /data directory, samba users can write all the files from the /data directory.

 

Check the /data  directory from Linux server whether the appended content is updated on Linux server samba shared directory file f1,

We have successfully configured the SAMBA in Linux server and also verified the access from the client windows system.

 

*******************************************************************************************************************************

The PORTS and BOOLEAN Needs to be Enable if Firewall and SELinux security features are Enabled:

Allow SAMBA through firewall (i.e iptables)

The following port Numbers are used by the SAMBA

PORT 137 = UDP NetBIOS name service (WINSthe )

PORT 138 = DBP NetBIOS Datagram

PORT 139 = TCP (Windows File and Printer sharing)

PORT 445 = Microsooft DS-Active Directory,shares

PORT 445 = Microsoft DS  SMB file sharing (UDP)

To allow Firewall  for SAMBA ,Add the Following Rules in iptables,

#iptables -A INPUT -m state  --state NEW -m udp -p udp  --dport 137 -j ACCEPT

#iptables -A INPUT -m state  --state NEW -m udp -p udp  --dport 138  -j ACCEPT

#iptables -A INPUT -m state  --state NEW -m tcp -p tcp  --dport 139 -j ACCEPT

#iptables -A INPUT -m state  --state NEW -m tcp  -p tcp  --dport 445 -j ACCEPT

Restart the iptables services to make the changes update

#service iptables restart

#service iptables save

Allow SAMBA through SElinux

In Linux SELinux security features by default, it denies access to any shared resources, You need to enable some couple of booleans from SELinux security

1.samba_enable_home_dirs    =  Enable  the sharing of home directories 

2.samba_export_all_ro = Enable read-only access

3.samba_export_all_rw = Enable read and write access 

4.samba_share_t_Default  = SAMBA could share
#chcon -R -t samba_share_t  /data

Always mention the directory name you would like to give access from SELinux, otherwise, it would be a security risk.

 

 

I hope you have enjoyed this article, if it was please share it with your friends, hit the Subscribe button below and be sure to share among with your friends.

###################################################################################

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe
For More Videos Subscribe My Youtube Channel    https://youtu.be/A7a72pmPa5o

 

How to Configure and Administrate Disk Quota in Linux?

In this Tutorial, I will explain how to configure Disk Quota in Linux Servers with all the basic concepts (Soft Limit, Hard Limit, Grace Period, blocks and inodes and many more)

The concept of Disk Quota:

1. In Production Servers, if there is a requirement to restrict the amount of disk space used on a partition by each and every user,  we can accomplish that by using the Disk Quota Features

2. If the Disk is being used by a single user(only one user) then there is no need of configuring the disk quota, when there are more numbers of users accessing a single partition, one or more users can upload files on an FTP server to the point of filling a file system. Eventually, other users are denied to upload access to the disk (Since the partition size is full).

3. With the Disk Quota Method in Linux, we can restrict or limit a user or group of users ability to consume disk space

Note1: User’s with quota enabled are not allowed to use additional disk space beyond his/her quota  Limit.

Note:2 Disk Quota methods are mostly used  by ISP’s by Web Hosting companies, On FTP sites (Google Drive, One drive and many more cloud services)and also on corporate file servers to make sure continuity availability on their file systems

 

How to Configure Disk Quota in RedHat Servers

In this Lab I use the regular partition for the demo setup, you can also add additional disk and then by creating one partition can enable the quota on that.

Note: Use the partition which doesn’t contain any important data in it.

Create a User and Assign a password

#useradd  Vasanth

#passwd Vasanth

Check the quota package is installed on your server

#rpm  -qa quota

Before we configure the quota we must know some of the important concepts we use it in Disk Quota.

1)Inode Number

Configuring Disk quota can be done to a user or group users based on the inode number or block size. The inode number is nothing but, it contains the entire information about the file(UID, GID, Size, Modify time, Access time etc) all these information are stored in the inode table. So every file uses one unique Inode number which contains the metadata about that file.

To control the size of the file ,we  should configure the quota based on the block size and if you want to control the number of files then we use inode number to configure disk quota, if you want to control both means, you need to configure the disk quota based on the block size and inode number.

a)For Example, if the quota is configured based on the inode number, Example 50 inode number is assigned to a user called NIRMAL, Since we haven’t assigned the block size, the user NIRMAL can create 50 files, no matter how big or small size they are, NIRMAL can create very large files,for instance NIRMAL can create a file of 50GB in size(ext4 file system supports 16Tib individual file size). here there is no control for the size of the files, the user can abuse the system.

b)For Example, if the quota is configured based on the block size, for instance, a 2GB quota is configured based on the block size for the user JOHN, Now JOHN can create files until the entire 2GB space is not filled up. But he can crash the inode tables by creating some 20000 files with each one with the size of 1kb, which means 200000 inode entries in inode table, Only with this 2GB  the user JOHN can crash the inode table.

 

c)If the quota is configured by Inode number and block size, for instance, 2GB Block size and 50 Inode numbers  are configured for a user “VASANTH”,now this user he cant crash the inode table or can abuse the disk space,coz he is not allowed to create more than 50 files and not allowed to use the disk space more than 2GB,

So I highly recommend you to use both inode number and block size while assigning a quota to a user.

Procedure to create the Disk quota:

1)Should Enable the quota

2)Remount the filesystem with quota

3)Create quota files

4)Configure inode or block-based policies.

Step:1  Save the quota details inside /etc/fstab file

In Linux,/etc/fstab file contains all the file system details to mount automatically at the time of booting. This file has the information about where it is mounted, the type of file system, permission and many more attributes.

In this example, I will use the partition /dev/sda2 to enable the quota.

#vi  /etc/fstab

To Enable the quota we should add “usrquota” in the fourth field, So from the above output, we have successfully enabled the quota on the partition /dev/sda2.

Note: Any changes made in the /etc/fstab file will not take update until next time reboots. This update can be done in two ways one is “reboot” the server and the second one is remount the partition with the quota options, In production servers, it is not advisable to reboot the server, so the second option would be better to update the /etc/fstab file changes.

Step:2  Remount the File System

Syntax:

#mount   -o  <option>   <filesystem or mount point dir>
  #mount  -o remount,usrquota   /home

As you can see from the above output we have successfully remounted the partition with quota, if the partition is remounted without any error which says the quota option is successfully applied.

Step:3  Create the Quota Files

To create the quota files run the following command,

Syntax:

#quotacheck   -cu  <quota enabled Partition >

quotacheck = Used to check the quota implementation

-c = To create the quota files in the partition

-u = To check the user quota

As you can see from the above output the “usrquota” file has been created under the partition mount point directory /home.

Step:4  Sync the disk quota database file with the current disk usage

#quotacheck -avu

-a = To check all quota enabled partitions

-v = To display the verbose output (i.e Real-time output)

-u = Check user disk quota  details

As you can see from the above output, quota database files successfully synchronized.

Step:5  Configure the Quota Limits for users

In order to configure the quota for users, we need to assign three values

1.Soft Limit

2)Hard Limit

3)Grace Period

SoftLimit= This is the maximum amount of space a user can have on that partition, If you set a grace period then this will act as an alarm, User will be notified he/she is in quota violation

HradLimit= It is Necessary only when you are using grace periods. If the grace period is enabled then this will be the absolute limit a user can use, any attempt to consume resources beyond this limit will be denied

 

Let us assign a quota for user JAS

To configure quota we need to use the command“edquota” followed by the username

#eduota   JAS

As you can see from the above output, the user “JAS” is allowed to  consume the maximum disk space is 100MB,once the user reaches the soft limit the grace period will start running and the user can use the size up to 100MB, After reaching the size 100MB, user will receive “quota exceed” message  on his screen.

Tips: Default Block size is 1kb(1block=1kb)

To check the assigned quota details  run the following command

#repquota -a

As you can see from the above output you can check the quota assigned to all the users.

The user “JAS” is allowed to consume the maximum disk space of 100MB, and the default grace period is 7 days, once the user reaches the soft limit, the grace period will start running.

Now let me log in to the JAS account and try to create some files with the size more than 50 or 100 MB

#su - JAS

$

As you can see from the above output, when JAS try to create a file with the size above 100MB  he is denied to consume the disk space beyond his limit, This is how the disk quota works.

Useful Commands:

To check the quota details for an individual user run the following command

#quota  JAS

Tips:

1)If the Soft Limit and Hard Limit are same then grace period is not required

2)If the Soft Limit and Hard Limit are  different then grace period is  required

3)Hard Limit size should be higher than the soft Limit

4)Once the grace period is expired, then users are not allowed to use any additional spaces

5)Grace period timer will be removed automatically, once the user brings the consumption below the soft Limit

***********************************************************************************************************************************

I hope you have enjoyed this article, if it was please share it with your friends, hit the Subscribe button below and be sure to share among with your friends.

###########################################################################################

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

For More Videos Subscribe My Youtube Channel    https://youtu.be/A7a72pmPa5o

############################################################################################

 

Learn how to create a Static and Dynamic Bash Shell Script file

In this article, we will learn how to create a shell script by using the following methods

1.Static Shell script

2)Dynamic shell script

Static shell script: In static scripting, you can execute any no.of times and it generates the same output i.e it is not taking the runtime input values while executing your script.

Dynamic Shell script: It always takes the runtime input values, based on the different sets of input values it will generate different outputs.

Let us create one basic monitoring script by using the static method

Ex:1 Create a script to monitor your server performance

Method: Static

#vi   /myscript.sh

#!/bin/bash

echo "Display the Memory usage details"

echo "***********************************"

free  -m

echo "Display the Server Load average and run time details"

echo "************************************"

uptime

echo "Display the  Cpu activity and RAM Details"

echo "**************************************"

cat  /proc/meminfo

echo "***************************************"

:wq!

Now Add the Execute permission

#chmod u+x   /myscript.sh

Run the script as follows

#./myscript.sh  or sh  /myscript.sh

Once you execute the script the interpreter reads each and every line from the file and displays the output on the console.

Sample Output:👇🏿👇🏿

The main advantage of using the shell programming is automatically it executes all your larger tasks, you can combine multiple commands in a single file that are required to monitor your server performance and by adding the execute permission you can run the script file as a program.

Ex:2  Display the Total Number of Lines in a file

Method: Static

when I run a script it should display the total number of lines in a file. As all we know in Linux we have many commands to get this from the command line arguments, the same task if I put it inside the script file how it works🤗

let us create the  script file as follows

#vi  /demo.sh

#!/bin/bash

echo "Display the Total Number of Lines in a file"

cat  /var/log/messages    |wc  -l

echo "End Of Script"

:wq!

Sample Output:👇🏿👇🏿

As you can see from the above output the file has a total number of 68 lines.

Ex:3  Create a script that tells the username and prints the running process

#vi  /test.sh

#!/bin/bash

echo   "Hello,$USER

echo  "Hey, I am " $USER " and I will show you the current running process details"

echo "Display the Running processes details"

ps

:wq!

Sample Output:👇🏿👇🏿

As you can see from the above output the ps displays the running processes details from your current terminal

Note: To display all the running processes from all the terminal you must have to use the option -aux with the ps command.

Ex:4 Create a script to get the runtime input values from the keyboard(Dynamic Method)

In shells scripting, we use the command “read” to get the inputs from the keyboard, the read command  what this does is wait for the user to type something followed by the enter key it  stores that given input to the variable

Let me create a simple script to get the inputs from  by using the read command

#vi  /dynamic.sh

#!/bin/bash

echo "Hi there, What is your First Name?"

read var1

echo "Welcome Mr/Mrs. $var1, Would you like to tell us the last name?"

read var2

echo "Thanks, Mr/Mrs. $a $b for telling us your name"

echo "*********************************"

echo "Mr/Mrs, $b its time to say goodbye"

:wq!

Sample Output:👇🏿👇🏿

Ex:5 Get the inputs from the keyboard

#vi  /script.sh

#!/bin/bash

echo "Please type your name"

read  data

echo "Hi $data, Let us be friends"

:wq!

As you can see from the above output, read command takes the input which is assigned from the keyboard and then it stored the value inside the variable “data”, the last line prints the value we assigned ..  next time again run the same script, give another input you will get different output this is why it is called as the dynamic scripting(i.e It always takes the runtime input values)

In our next article, I will share you more programs by using the “read command”.

Your Valuable “thoughts” in comments is highly appreciated, please do Like and share us to spread.

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

For More videos Subscribe My Youtube Channel 👉🏻https://www.youtube.com/channel/UC6bR8In-jj9-klVlZQ6YH_A

 

Follow me at twitter @linuxvasanth

 

 

Quotes in Bash Shell Scripting

Quoting

Enclosing the command or text with the quotation is a standard practice on the Linux command prompt mostly when you are assigning the values with space, or with some special character .but how to know whether you want to use ‘single quotes’ or “double quotes”?Let me explain this difference

The common rule is You can prevent the shell from substituting the value of a variable by quoting (single quotes), whereas double quotation mark do not prevent the substitution.

Quotes with text

When you are assigning a  few words of text it really doesn’t a matter whether you use, since they both will work exactly the same. Let me show this with one simple example

To Learn the basics of bash shell scripting click this link 👉🏻  http://www.linuxvasanth.com/bash-shell-scripting/

The below two commands will create a file test file.

#touch  'test file'

#touch  "test file"

Bash Shell Variable Expansion:

When you are working with a variable name in the command line the single quotes and double quotes behave very differently.

#myvar="abc is a single string"

#echo $myvar

Sample Output: abc is a single string

Now when you are using the single quotes it prevents substitute the values from the variable

#echo '$myvar'

Sample Output: $myvar

From the above output, it displays only the variable name when you are using with single quotes and double quotation mark do not prevent the substitution.

Note: Single quotes will treat every character Literally i.e Strictly follows the exact word, Double quotes will allow you to do the substitution i.e includes variables within the setting of the value.

Note: Double quotation marks are useful when you assign a value to variables, To assign a value that contains spaces or tabs to a variable, use double quotation marks around the value.

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

How to create and assign values to variables in Bash shell scripting?

What is VARIABLE?

A Variable is a character string to which we assign a value. The value could be a number, filename or any other type of data. Simply we can say a variable is a pointer to a particular value or data. By default Shell allows us to do create, modify, delete the variables, remember these variables are only a temporary one🙄 i.e when you close the session, by default these variables get deleted🤨. So if you want to make a variable and its value permanent i.e to make it as a system-wide you should export the variable or updated it in to the environmental variable.

What is Valid  and invalid variable names?

You should always remember a variable name must start with a letter or underscore, but not with a number.

For example, a valid variable name would look like this👇🏿👇🏿

1.A76 

2.my_cat 

3. _hello_

 

An invalid variable name look like this👇🏿👇🏿

1.69_street

2.my-name

If you use a hyphen(-) or u start a variable with numbers then those are considered to be as the invalid variable names.

Types of Variables

There are two types of variables exists in bash shell scripting

1.Local variable

2.Environmental variable

What is Local variable?

Local variables are the variable that is contained exclusively within the shell in which they were set or defined. i.e once you close the terminal or session the information will get erased from the memory.

What is Environmental variable?

E.v are the variables that are defined for the current shell and are inherited by any child shell or processes i.e it updates a value system-wide if you want to make a variable value permanent you should update it in an environmental variable.

Note: To export a value systemwide you will need to open the following file /root/.bashrc and update the variable and its values.

How to assign a value to a variable in bash shell script?

Assigning a value to a variable in bash shell script is quite easy🤠, use the following syntax to create a variable and assign a value to it.

syntax

#variablename=value

Ex:1 Create a variable and assign a value to it

Let me create a variable with the name myvar and assign a value ABC to it.

#myvar=ABC

How do I display the values from the variable?

Use the following syntax to display the values from a variable

Syntax:

#echo  $variablename

Ex:2 To display the value from the variable called “myvar”

#echo  $myvar

Sample output: ABC
Note: If you skip the $ sign then it would display  only the variable name “myvar”, the shell will not execute the values from the variable
Note: “echo” command which is used to read the values from the variable.

 

Ex:3 Let us create a shell script to display the total no.of lines in a file

Method: Static

#vi  /demo.sh 

       #!/bin/bash 

       echo "Display the total number of lines in a file"

       cat  /var/log/messages  |wc  -l 

      echo  "End of Script" 

      :wq!

 

Explanation:

Line:1  Define the interpreter(bash is the interpreter here)

Line:2 Prompt a message on the screen

Line:3 The command to display the no of lines in /var/log/messages file

Line:4 After displaying the output it prints end of script  message on the screen

Note: Since I have created the above script by using the static method, whenever I run this script it displays the same output.

               In our next article, I will be explaining about the “quotes” in bash shell scripting

**************************************************************************************************************************************

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

***************************************************************************************************************************************

What is Bash Shell Scripting?

Introduction

As we all know Shells are interactive i.e it accepts the inputs from the keyboard given by a user and  execute them ,Suppose if you have a routine task and that task is having some 20 to 30 Unix commands then it would be difficult for the administrator to execute each and every command one by one to create a report, to ease the administrator task we put all the Required commands in a text file and tell the user to execute them this is called as a shell script

A script could be written to start a database, shut down a database, start a backup program check whether a specific service is up and if not it could start it, so many other tasks can be done using the shell scripts.

NOTE: Writing shell scripts halt automates the administration tasks saves the admin time etc..

Advantages of having Shell Scripting:

1.Ease of use: If you have to run a sequence of commands in your daily task then it is easier to have a shell script file to do them. All you have to do is just execute the file to run the several commands.

2.Easier to Remember: If you are using man arguments and options it is quite easy to miss command options or arguments if you are typing it every time into the command line.

Procedure to create a Shell script file:

1. Create a file with the required commands or codes as per the requirements.

2. The command or code to be run by some interpreter so Add the interpreter in to the script file(here we use “bash” as the interpreter).

3. Add the commands or codes in to the script file

4. Add the execute permission to the script file

5.Run the script file

These all are the steps you need to follow to create a proper shell script file.

Ex:1 Create a basic Monitoring Shell script file

In this example, I will create a script file which is to monitor the server health performance and resources usages.

Step:1

#vi   /script.sh

#!/bin/bash

free - m

who

last |grep reboot

who -r

netstat  -l

netstat -s

cat  /var/log/messages   |wc  -l

:wq!

Step:2 Add the execute permission to the user(here as a root I will execute the script file)

#chmod   u+x   /script.sh

#ls  -l   /script.sh

Step:3 Run the script file

Syntax:  #./scriptfilename

#./script.sh

Note: For better view Output has Truncated🖕🏻

As you can see from the above output the interpreter will read and execute each and every command inside the file and prints the output on the screen.

Note: Here  “.” indicates run the script from your current path, if the script is not in your current path then you will get the message No such file or directory.

I hope you have enjoyed this article…

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

 

How to Configure RAID-1 in Redhat Linux

Configuring RAID-1(Mirroring)

RAID-1 Mirroring means having the same data on both the hard-disks,i.e exact clone of the same data copied on both the disks.

Minimum Requirements to configure RAID-1:

1.Minimum 2 Hard-disks required(You can also add more than two disks 4,6,8 for that the server should have the RAID Physical adapter installed)

Advantages of RAID-1

1. Read performance is better than writing data to the hard disk

2.If one disk fails there is no data loss since we have the same data on both the disks.

3.50% of space will be lost,i.e if we have two disks with 250GB size total, it will be 500GB but in mirroring it will show only 250GB.

Configure RAID-1

Step:1 Check the drives whether there is already RAID configured by using the below command

#mdadm  -E  /dev/[b-c]

As you can see from the above output there is no RAID superblock detected i.e no RAID defined yet

Step:2 Partition Drive for RAID

As I have mentioned already minimum 2 harddisks required to configure RAID-1, I have attached two disks /dev/sdb,/dev/sdc for configuring RAID-1, Let us create partitions on these two hard disks and change the pariton type to RAID while creation.

Procedure to create RAID type partitions on the drives

1. Choose ‘n’ to create a new partition

2. Then choose ‘p’ for a primary partition

3. Now select the partition number ‘1’

4. Give the default full size and then press enter

5. Now press ‘p’ to check the mentioned partition

6.Press “L” to list all the available partition types

7.Type ‘t‘ to choose the partition

8. Now choose ‘fd’ for the Linux RAID and press enter

9.choose ‘p’ once again to confirm the changes we made

10.type ‘w’ to save the changes

Step:3

#fdisk /dev/sdb

 

Follow the same above  procedure to create the partition on /dev/sdc drive

Step:4

#fdisk /dev/sdc

Step:5

We have successfully created the partitions on both the drives, verify the changes on both the drives /dev/sdb & /dev/sdc  using the following command

#mdadm  -E /dev/sd[b-c]

From the above output, you will see no md superblock detected because there is no RAID defined on /dev/sdb1 and /dev/sdc1.

Step:4 Configure RAID device  /dev/md0  using the following syntax

#mdadm   --create   /dev/md0   --leve=raid1 --raid-devices=2  /dev/sdb  /dev/sdc

After executing the above command, check the RAID-1 status by using the below syntax

#cat  /proc/mdstat

 

Step:7 Check the RAID Array and device types by using the following command

#mdadm  -E /dev/sd[b-c]

#mdadm  --detail   /dev/md0

From the above output, RAID devices successfully created by using the /dev/sdb and /dev/sdb drives

Step:8 Creating a file system on RAID devices

#mkfs  /dev/md0

Step:9 Mount the file system to some mount point directory

#mkdir  /RAID

#mount  /dev/md0    /RAID

To check the mounted filesystem status

#df -h

From the above output, the RAID devices successfully mounted under the RAID directory.

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

##############################################################################################

 

 

Basic concepts of RAID

RAID(Redundancy Array of Independent Disk):

A RAID  is an only way in which you can link up  several hard disks so that if any one of them fails, the other one can take over the load

Types of   RAID:

1)Hardware RAID

2) Software RAID

Hardware RAID: It has its own independent disk subsystem and resources.It doesn’t use any resource from the system such as RAM, CPU, and power.Since it has its own dedicated resources it will not put any additional Load on the system, It also provides very high performance.

Software RAID: Performance wise when compared to hardware RAID software RAID delivers slow performance since it uses all the resources from the system.

concept of RAID:

1.Hot spare: This is the additional disk in the RAID array, if any disks fail, data from the faulty disk will be migrated to the spare disk automatically.

2.Mirroring: The copy of the same data will be available on the mirror disk, like making an additional  copy of data

3.Striping: If this feature is enabled then data is written to all the available disks randomly, it is like sharing the data between all disks, so all of them fills quickly.

4.Parity: The parity regenerates the lost data from the saved parity information.

There are different levels of RAID available based on how mirroring and striping needed, Among these levels, LEVEL 0, LEVEL 1, LEVEL 5   are mostly used in Redhat Linux.

Let us have a look at these different levels of RAID

RAID 0-Striping:

It provides striping without parity, Since it doesn’t store any parity data performs the read and write operation equally, Speed would be much faster than other levels, Minimum two hard disks required for this level.All the harddisks in this levels are filled equally.You should use this level only if the read and write speed are concerned.when you decide to use this level always have a backup plan on your data because a single disk failure from the array will result in total data loss.

RAID 1-Mirroring:

In this level it provides parity without striping, data will be written on both the harddisks, if any of these failed or remove still we can get the data.This level requires two hard disks.It means if you want to use two hard disks then you will have to deploy 4 hard disks or if you want to use one hard disk then you will have to use two hard disks, First hard disk stores the original data while the other disks provides the exact same copy of the first disk, performance is reduced since data is written twice,You should use this level only if data is concerned at any cost

RAID 5 Parity with Striping:

This level provides Parity and striping, This level requires minimum 3hard disks.It writes parity data equally in all disks.If anyone of disk fails, then data can be reconstructed from the parity data available on remaining disks.

NOTE: When you are using Hardware RAID  device, use hot swappable hardware RAID device with spare disks, if any disk fails data will be reconstructed on the first available spare disk without any time.

In our next article, I will show you how to configure RAID in Red hat Linux.

If you found this article useful, Kindly Subscribe here 👉  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉 Learn Linux in an easier way

 

How to configure NFS server and NFS Client in Redhat Linux?

NFS(Network File System) developed by Sun Microsystem, for sharing the files and directories between the UNIX/Linux systems.NFS it allows you to mount your local filesystems over a network and also remote server to interact with them as they are mounted locally on the same system

NFS is purely based on the RPC(Remote Procedure Call) which allows the client to automatically mount the remote filesystems.

Advantages of NFS:

1.No manual refresh needed for new files

2.With this NFS it is Not necessary  that both the machines run on the same OS

3.secured with firewall and Kerberos

4.Files may be accessed via IP addresses, groups, users etc

5.The central management of this system would cut the workload by 80%

Disadvantages:

1.The greatest disadvantages are the issue of security because NFS is based on RPC, remote procedure calls, it is inherently insecure and should only be used on a trusted network behind a  firewall.

Let us see some of the important services that are needed  for NFS

1.nfs = It translates remote file sharing requests in to request on the local filesystem

2.rpc.mountd = This service is responsible for mounting and unmounting the filesystems

Configuration files for NFS:

1./etc/exports = Important configuration file for NFS, all exported files and directories are defined in this file at the NFS server end.

2./etc/fstab = To mount the NFS share resources automatically on system reboots, we need to manually put an entry inside this file

3./etc/sysconfig/nfs = Configuration file for NFS to control on which port RPC and other services are listening

Check NFS daemon is listening on both UDP and TCP  port 2049:
#rpcinfo -p   |grep nfs

From the above output, it is confirmed that NFS server is running and accepting calls on port 2049.

Check whether your system supports NFS or not:
#cat  /proc/filesystem  |grep nfs

Note: If you don’t see any output means NFS is not supported  or NFS module have not been loaded in to your kernel

To load the NFS module:
#modprobe  nfs

When everything is installed correctly, the NFS daemon should be now listening on both UDP and TCP 2049 port and the portmap should be waiting  for instructions on a  port 111

Check portmap is listening or not
#rpcinfo -p |grep portmap
Configure NFS server:

Setup details:

1.NFS server:  hostname=linuxvasanth.com, IP address 10.250.1.100

2.NFS Client: hostname: Dataserver, IP address=10.250.1.50

As I said above for sharing the directory we need to make an entry in “/etc/exports configuration file.In this example, i will share a directory name “myshare” in “/”  partition to share with the client-server

#mkdir  /myshare
Create some files and directories inside this directory
#cd  /myshare

#touch doc1 doc2 doc3

#mkdir d1 d2 d3

Now /myshare directory is having three files and three subdirectories.

Step:1 Make an entry in “/etc/exports” to make the directory shareable
#vi  /etc/exports

/myshare    10.250.1.50(rw,sync)

:wq!

The above entry says the directory myshare from “/” is being shared with the client IP 10.250.1.50 with read and write permission with the sync option.You can also use the hostname in place of the IP address.

NFS sharing options:

ro = can provide read-only access to the shared files,i.e the client can only able to read

sync: It confirms the requests to the shared directory only once the changes have been committed

no_subtree_check = It prevents the subtree checking when a shared directory is the subdirectory of the larger filesystem, NFS performs scans of every directory above it, in order to verify its permissions and details, disabling the subtree check may improve the performance of NFS but it reduces security

Note: The default behavior of NFS kernel daemon is to include additional option to export your line which is “no_subtree_check”

Step:2 Restart the NFS daemon

Once you have edited /etc/exports file you need to restart the NFS daemon to apply any changes

Note: Depending upon your Linux distribution restarting procedure for NFS daemon may differ

To restart the NFS service
#service nfs restart

To restart the RPC bind service
#service rpcbind restart

NFS and rpcbind are compulsory services for NFS daemon

rpcbind = Remote procedure call(RPC) service is controlled by rpcbind service

To list the NFS shared directories locally and remotely:
#showmount  -e

If this command shows error then the communication might be blocked by the firewall.

Configuring NFS client:

Now at the NFS client end, we need to mount that directory on our server to access it locally, to do this first we need to find out the shares available on the NFS server.

To mount the shared NFS directory
Syntax:
#mount  <option>  <NFSserver IP>:<NFS shared directory path>  <mount point directory path at NFS client>
To view the shared resources from NFS server:
#showmount   -e   <NFS server IP>

#showmount  -e  10.250.1.100

from the above output, one directory is shared in NFS server

Create a new mount point directory:
#mkdir  /data

Now mount the NFS share directory to your local mount point directory as follows,

#mount   -t  nfs   10.250.1.100:/myshare     /data

To check the mounted files
#df  -h

As you can see from the above output the shared directory from NFS server has been successfully mounted on NFS client at the location /data

To remove the NFS mount
#umount  /data

#df -h

Tips:

The following services are associated with NFS daemons and each service have its script files in init.d directory

1./etc/init.d/nfs =This is the main control script for NFS daemons which controls NFS services

2./etc/init.d/nfslock = Script for lock files and statd daemon, which locks and provides the status of files those are currently in use

3./etc/init.d/rpcbind = RPC program number converter

4./etc/init.d/rpcgssd = script for RPC related security services

Note: If you want to start a script manually you can execute by using the following syntax

#/etc/init.d  <script-name>

Ex: /etc/init.d/nfs

***************************************************************************************************

If you found this article useful, Kindly Subscribe here 👉🏿👉🏿  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉🏿 Learn Linux in an easier way

 

 

How to create a partition in Solaris Operating system?

In RHEL we use “fdisk” command to divide a disk in to individual partitions, likewise in Solaris, we execute “format” command to create the partitions.First, check how many hard disks available by running the following command,

Step:1 Check the Hard-disk details
#echo |format

From the above screenshot it has been confirmed we have one hard disk attached to the server.

Step:2 Check the currently configured partition details
#format

Step:3 Use “partition” from the above list to select partition table

Step:4 Use “print” from the above list to display the current partition table details

As we can see from the above output slice 0,1,2,4,7,8 are already created, we can now only create a partition under slice 5.

Step:5 Select any unassigned slice to create a new partition (Here I have applied slice 5)

Step:6 Enter the partition id tag, if you use”?” then it will display the available tag and use one of those, Here I have used “reserved”

Step:7 Enter the partition permission flags, Same as above if you use “?” it will display the available flags .you can use one of those

Step:8 Enter the new starting cylinder, here I have applied 201 according to my existing partition table

Step:9 Enter the partition size, here I have used 500MB according to the existing partition table

Step:10 Again use the “print” to see the newly created partition table

As you can see from the above output, the newly created partition is shown in the partition table(slice 5)

Step:11 Now save the partition information to the kernel memory by using the “label” followed by yes

Note: If you forget to label the partition details to the kernel memory then it won’t be available for use.
Step:12 check the partition layout once again by using the “print” and exit from the format command by using the quit followed by “q”

Step:13 Create a new filesystem

In Linux we use the command “mkfs” to create a new filesystem, here we use “newfs” to create a new “ufs “file system

Syntax:

#newfs   <physical device name>

#newfs  /dev/rdsk/c0d0s5

Note: To create a new filesystem you must use the raw disk(rdsk)

As you can see from the above output the slice s5 is formatted successfully with the “ufs” filesystem

Step:14 Check  whether the file system is in the clean state
#fsck  /dev/rdsk/c0d0s5

Step:15 Now mount the filesystem to some mount point directory to bring the partition to online
#mkdir   /ORACLE

#mount  /dev/dsk/c0d0s5   /ORACLE

Step:16 Check the currently mounted filesystem information by using the following command
#df  -h

As you can see from the above screenshot the slice /dev/dsk/c0d0s5 has been successfully mounted on the mount point directory /ORACLE

In Our next article, I will show you how to make the partition available permanently even after restarting the server.

If you found this article useful, Kindly Subscribe here 👉🏿👉🏿  Click this link to Subscribe

Never miss an article Do like my official  FB page 👉🏿 Learn Linux in an easier way

 

Managing Solaris OS FileSystem

A Filesystem is nothing but it is a collection of files and directories that make up a structured set of information.Solaris OS supports three different types of Filesystem

1.Disk-Based Filesystem

2.Distributed System

3.Pseudo filesystem

Let us see the types one by one in detail

Disk-Based Filesystem:

These types are found on the harddisks, CDROM’s, DVD, floppy.The following are the examples  of the disk-based filesystem

UFS –Unix File System is the default file system in Solaris OPerating system and it is based on the Berkeley fast filesystem

hsfs – High Sierra file system is a special type of filesystem developed for the use of CDROM’s media

pcfs – PC filesystem is the UNIX implementation of the DOS(Disk Operating System) FAT32 filesystem.The pcfs filesystem it allows the Solaris OS to access the PC-DOS formatted filesystems.It allows the users to use the UNIX commands for direct read and write access to PC-DOS files.

udfs – Universal Disk Formatted Filesystem is used for the optical storage targeted at DVDROM media.This filesystem allows universal data exchange and support read and writes operations.

 

Distributed Filesystem:

This filesystem it gives the network access to the file system resources

NFS- Network File system allows the users to share the files among many types of system on the network NFS filesystem makes part of the filesystem on one system appear as though it were part of the local directory tree.

Pseudo filesystem: 

These are the memory based filesystem.These filesystems provide for better system performance and also giving access to kernel information.The pseudo file system includes the following

1.tmpfs = The temporary file system stores files in memory, which avoids the overhead of writing to a disk-based filesystem.The tmfs filesystem is created and remob=ved automatically every time the system is rebooted.

2.swapfs = The swap filesystem is used by the kernel to manage the swap space on disks.

3.procfs = It holds the list of ongoing active processes under the /proc directory .all the processes are listed by a process number.all the information from this directory can be fetched with the ps command.

4.mntfs = The mount filesystem provides the read-only information from the kernel about the locally mounted filesystem details.

5.devfs = This filesystem is used to manage the namespace of all devices on the system This file system  is mainly used for the /devices

 

So in our next article, I will show you how to create partitions in Solaris.

If you found this article useful, Kindly Subscribe here 👉🏾 Click this link to Subscribe
Never miss an article Do like my official  FB page 👉🏿 Learn Linux in an easier way

 

Learn Solaris OS Device Naming conventions

In Solaris operating systems all the devices are identified with the three different names, Let us see what all are the  types of names available

1.Logical device name or Block disk devices

2.Physical device name or Character disk devices.

3.Instance name

Logical Device Name:

A user can access the hardware or device with this logical names, after login to the operating system if a user needs to access the system devices he/she has to access  the device with the logical name.So a logical device name is used to refer to a device when you are entering the commands on the command line

All Logical device names are kept in the directory path /dev and these logical device names are symbolically linked to the physical device names under the path /devices directory.So all the devices have an entry inside the /dev/dsk (logical device name path)and /dev/rdsk (physical device name path).

rdsk means RAW DISK

The logical device name contains the controller number, target number, disk number and slice number i.e c#t#d#s#

To check all the logical device names run the following command

# ls /dev/dsk
c0t0d0s0 c0t0d0s4 c0t2d0s0 c0t2d0s4 c1t1d0s0 c1t1d0s4
c0t0d0s1 c0t0d0s5 c0t2d0s1 c0t2d0s5 c1t1d0s1 c1t1d0s5
c0t0d0s2 c0t0d0s6 c0t2d0s2 c0t2d0s6 c1t1d0s2 c1t1d0s6
c0t0d0s3 c0t0d0s7 c0t2d0s3 c0t2d0s7 c1t1d0s3 c1t1d0s7

c0t0d0s0 to c0t0d0s7  = Represent the device name for the disk slice0 to slice 7 for a disk that is attached to the controller 0 at target 0, on disk unit 0.

c0t2d0s0 to c0t2d0s7 = Represent the device name for the disk slice0 to slice 7 for a disk that is attached to the controller 0 at target 2, on disk unit 0.

c1t1d0s0 to c1t1d0s7 = Represent the device name for the disk slice0 to slice 7 for a disk that is attached to the controller 1 at target 1, on disk unit 0.

Note: On X86 hardware you will not find target, target shows only on SPARC hardware.

Physical Device Names:

The physical device name is nothing but it has the device hardware location i.e the complete PCI address of a device, the physical addresses contain the series of nodes which is separated by slashes, that indicates the path to the devices.All the physical devie names are kept under the /devices directory.

To check all the physical device name details

#ls  -l  /dev/rdsk

To list a individual disk hardware path details

#ls -l /dev/dsk/c0d0s0

Note: Am running the Solaris server fromX86 hardware that is why from the above output it is not showing the target id.

3.Instance Names:

Kernel will assign a shorten name for all the available devices  that are connected to the server that is called as an instance name or we can say like it is a shortened name for the physical device name

Let me show you this with one example:

1.sdn = which means here sd is the disk name and n is the number, such as sd0 for the first SCSI disk  device

2.dadn = which means here dad is the disk name and n is the number, such as dad0 for the first IDE disk  device

for example run the ls -l  /dev/rdsk command to get the physical path details from that output you can find the instance name as below

 

As you can see from the above screenshot sd shows it is an SCSCI disk and the disk number is 0.

How to List the system devie details?

In solaris operating system there are several ways avaiable to list the device physical path information.Let us see that one by one

1./etc/path_to_inst_file

As I explained above the instance name for the devices, For each and every devices the  system stores its physical name and instance name inside the /etc/path_to_inst file.These names are used by the kernel to identify the devices.This file is maintained by the kernel and it is not recommed to edit this file for any purpose

Let me show the entires inside the /etc/path_to_inst file below

Note: Different system have different physical device paths

The following is  a /etc/path_to_inst file from a system that has a diffrent bus architecture, here in this case it is an example of an system that has  onboard sun system bus(SBus)

# cat /etc/path_to_inst
#
# Caution! This file contains critical kernel state
#
“/sbus@1f,0” 0 “sbus”
“/sbus@1f,0/espdma@e,8400000” 0 “dma”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000” 0 “esp”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@3,0” 3 “sd”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@2,0” 2 “sd”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@1,0” 1 “sd”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@0,0” 0 “sd”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@6,0” 6 “sd”
“/sbus@1f,0/espdma@e,8400000/esp@e,8800000/sd@5,0” 5 “sd”

2. The prtconf command

prtconf means Print configuration  to get all the system configuration details like Total memory installed, configuration of the peripheral  which is formatted as device tree.The main adavantage of prtconf is it will display all possible instances of devices, wherether the device is attached to the system or not.

#prtconf

This command display all possible instances of devices, wherether the device is attached to the system or not.

If you dont want to see the devices which are not attached you can use the option -v with the prtconf command.

#prtconf   |grep  -v not

 

3.With “format” command

By using the format command you can get the physical name as well the logical names of the disks that are connected to your server and also you can check how many harddisk connected to the server by using this command (In Linux we use fdisk command to list all the disk details the same like here in solaris we use the format command)

#format

Note: Press Control+d to exit  the format command without selecting the disk.

 

If you found this article useful, Kindly Subscribe here  👉🏿 Click this link to Subscribe
Never miss an article Do like my official  FB page 👉🏿Learn Linux in an easier way

Understanding Basic Architecture of a Disk(Solaris)

Introduction:

Before we start the administration parts of Solaris operating system it is must to know the basic architecture disk, Basically, a disk device has both physical component and logical components

The physical components have disk platters and read and write heads

The logical components have disk slices, cylinders, tracks and sectors

Structure of physical disk explanation:

1.The disk storage part is composed of a couple of platters

2.The platters rotate.

3.The head actuator arms move the read and write heads as a unit radially then the read and write heads read and write data on the magnetic surface on both the side of the platters.

Sector = Its a smallest addressable unit on a platter, by default one sector, can hold 512 bytes of data.It can be also known as disk blocks
Tracks = A series of sectors positioned end to end in a circular path.
cylinder=A bulk of tracks.

 

What are Disk Slices in Solaris?

We know after dividing the disk in to individual partitions we call it as a logical partition or LVM partition or raid based on the partition type we use in RHEL, In Solaris, we call it as a slice, once the disk is divided in to individual partitions it is known as disk slices.

For example, One slice can hold critical file system data and another slice on the same disk holds user related files and many more.

Note: A disk under the Solaris OS is divided in to 8 slices i.e labeled from slice 0 to slice 7

Note: Slice 2 it contains the important data about the whole disk, size of the disk, a total number of cylinders remains available for the storage of files and directories.

A starting cylinder and the ending cylinder define each slice.These  cylinder values say the size of a slice,

Let me show you one example

imagine I have total cylinder 3200 (in human readable format 32 GB)

slice 0 offset cylinder:(0-1500),so total cylinder value for slice 0 is 1501

slice 1 offset cylinder:(1501-2000),so total  499 cylinders

slice 2  offset cylinder:(0-3199),so entire   cylinder value is 3200

offset means starting cylinder

Let us have a look at the below tabular column about the disk slices

 

Disk slice Naming convention:

Knowing about the Disk slice naming convention is must in order to learn Solaris disk management an eight character string represent the entire name of the slice.These eight character strings include

1.controller number

2.target number

3.disk number

4.slice number

Controller number:

It identifies the Host Bus Adapter(HBA) which is responsible to control the communication between the system and disk unit. HBA is nothing but responsible for sending and receiving the commands and data to the device.

All controller numbers are assigned in sequential order such as c0,c1,c2,c3 so on…

Target Number:

Is nothing but it is a  unique hardware address that is assigned to each disk, tape, CDROM.Same as controller target numbers are assigned in sequential order such as t0,t1,t2,t3 and so on…

Disk Number:

This is the special number reflects the number of disks at the target location.The Disk Number is also called as LUN.

Slice number:

The slice number range starts from 0 to 7 i.e s0 to s7.Total eight slices

The below diagram shows the string that represents the full name of the disk slice.

In our next article, I will explain the OS device naming conventions in Solaris.

If you found this article useful, Kindly Subscribe here 👉🏿  Click this link to Subscribe
Never miss an article Do like my official  FB page 👉🏿 Learn Linux in a easier way

****************************************************************************************************

 

Understanding “Network Bonding/Teaming” in Redhat Linux

How to configure Network Bonding/Teaming in Red Hat Linux

As a system admin we would like to avoid the server down by having the redundancy for the “/” filesystem by using the RAID technology(MIRRORING THE DATA), then multiple FC links to SAN technology with the help of Multipathing software and many more.How do you provide the redundancy in network level?As all, we know having multiple network card (NIC) will not provide any redundancy if either  NIC1 or NIC2  failed then it may lead to network downstate.

In RedHat Linux with the help of Bonding/Teaming, we could accomplish the network level redundancy.Once you have configured the bonding with the help of two NIC cards, then any failure occurs on any one of the NIC cards the kernel will automatically detect the failure of NIC  and it works safely without any issues.Bonding could be also used for the load sharing between the two physical Links.

The dig shows how Bonding is working

Let me show now how to configure network bonding in RHEL

Task: Configure Network bonding between eth0 and eth1 with name of bond0

Bonding driver: Linux allows binding of multiple network interfaces in to a single channel  NIC by using kernel module called Bonding
Tips: The behavior of the bonded interface depends upon the mode(mode provides either hot standby or load balancing service.

Make sure you have two physical Ethernet cards available in your Linux server

Step:1 Check the network adapter details
#ifconfig |grep eth

As you can see from the above output we have two Network adapters with the logical name eth0 and eth1.

Step:2 Edit the configuration file for both the ethernet cards as follows
#vi  /etc/sysconfig/network-scripts/ifcfg-eth0

add the following lines inside this file

Do the same for another interface eth1

Step:3 Create a “bond0” configuration file
#vi  /etc/sysconfig/network-scripts/ifcfg-bond0

add the following parameter as shown below

you will not find the /etc/modprobe.conf in RHEL6, so you need to define your bonding option inside the above configuration file(highlighted with yellow box)

We can configure NIC bonding for various purpose, so when you do the configuration you will have to specify the purpose for which you want to use the bonding.Here are the modes available with the bonding

1.balance-rr or 0: Set a  round-robin policy for fault tolerance and load balancing.Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.

2.active-backup or 1: Set an active-backup policy for fault tolerance.Transmissions are received and sent out via the first available bonded slave interface, another bonded slave interface is only used when the active bonded slave interface fails.

3.balance -xor or 2: Sets an exclusive policy for fault tolerance and load balancing.In this method, the interface matches up the incoming request’s MAC address with the MAC address for one of the slave NIC’s.Once the link is established, transmissions are sent out sequentially beginning with the first available interface

4.broadcast or 3: Sets broadcast policy for the fault tolerance, All transmissions are sent on all slave interfaces.

Understanding miimon in network bonding: It specifies(in milliseconds) how often MII link monitoring occurs.This is very much useful when high availability is required because  MII is used to verify that the NIC is active.

 

To  check that the driver for a particular NIC  supports the MII tool,run the following command
#ethtool  <interface name> |<grep "Link detected"

#ethtool   eth0 |grep "Link detected"

as you can see from the above screenshot driver supports the MII tool.

Step:4 Load the bonding module
#modprobe  bonding

Step:5 Restart the network interface to make the changes update
#service network restart

Step:6  Confirm whether your  configuration is working properly or not by using the following command
#cat /proc/net/bonding/bond0

As you can see from the above screenshot, NIC bonding interfaces are in active state.

Step:7 Verify whether “bond0” interface has come up with IP or not
#ifconfig -a

The above screenshot has confirmed the bonding interface has the IP address and it is in running state.

You can also notice eth1 and eth2  have flag “SLAVE” and for bond0 interface has flag “MASTER”

To verify the current bonding mode, run the following command

#cat  /sys/class/net/bond0/bonding/mode

From the above output, the current mode is balance-rr  or 0

To check the currently configured bonds
#cat  /sys/class/net/bonding_masters

The above screenshot says we have one master bond with the name “bond0”

Note: So from now onwards even if anyone of your NIC adapter failed, the bond0 interface will continue running and provides the uninterrupted service to the clients. The failed interface flag will be changed to “down”  state and after resolving the issue with the failed interface the flag again will change its state to “Running”.

I hope you have enjoyed this article, Kindly subscribe 👉🏿👉🏿 Click this link to Subscribe

Never miss any updates from my blog do like my FB page here 👉🏿👉🏿Learn Linux in an easier way

 

**********************Thank you**************************************************************************

How to Extend the size of Volume Group and Logical volumes(LVM)

Volume Group/Logical Volume Extending(LVM)

In our previous article we have seen the basics of LVM, how to configure PV, VG, LV, Here we are going to see how to increase the size of the existing volume group and logical volume size.As I have stated earlier the biggest advantage of Logical volume manager is, it allows us to increase the size of the logical volumes at any time when you are running out of space.

If you missed my previous  Basic LVM article you can visit here  Understanding LVM

Now in our case we have three PV, one VG and four LV, Check the details by using the following command

#pvs
#vgs
#lvs

As you can see from the above output, we don’t have enough space available in physical volumes and volume group, For example, if there is a requirement of additional 10 GB to one of the  logical volume, will it be possible to add 10 GB extra to the logical volume???no…we couldn’t extend that as we don’t have enough space in VG,

for extending what we have to do is, we need to add one physical volume(PV) and then we have to extend the volume group(VG) by extending the VG then we will get enough space to increase the logical volume size, so first will add one physical volume

For adding the PV we need to create one LVM partition with “fdisk” command

NOTE: YOU CAN ASLO ADD A NEW PHYSICAL HARDDISK TO EXTEND THE SIZE OF VG AND LV

1.To create a new partition, Press n

2.Choose the primary partition, press p

3.Choose which number of partition to be selected to create the primary partition

4.Press 3 (coz already I have created two partitions )

5.change the type using t

6.Type 8e to change the partition type to Linux LVM

7.Press w to write the changes

Now reboot the system once completed

Now check the partition we have created with fdisk

#fdisk   -l   /dev/sda

Now create a PV(Physical volume) using the following command

#pvcreate  /dev/sda3

Check the PV details

#pvs or pvdisplay

Extending the size of the Volume Group(VG)

Now you have to add this newly created PV to the volume group VG1 to grow the size of the volume group  to get more space for expanding Logical volume (LV)

Syntax:

#vgextend   <Volume group name>    <Physical volume name>
#vgextend   VG1   /dev/sda3

Now let us check the size of the volume group by using the following command

#vgs

As you can see from the above output, now the volume group  VG1 space extended from 3.99 GB to 19.09 GB

If you want to check which PV is used to create particular volume group run the following command

#pvscan

As you can see from the above screenshot each PV and its associated VG names are listed, we have just added one PV  and it’s totally free.

Extending size of the Logical volume(LV)

Before we expanding the size let us check the size of the  each Logical volumes

#lvdisplay or lvs

For better view Output has been truncated

In this example am going to expand the size of the logical volume lv1 (current lv1 size is 2 GB)

I will add additional 10 GB to the logical volume lv1

syntax:

#lvextend  -L <+size>   <Logical volume name path>
#lvextend -L +10 GB  /dev/VG1/lv1

As you can see from the above screenshot, now the  filesystem size is extended 10 12 GB  from  3.99 GB

After extending we need to resize the filesystem by using the following command

Before you run the resize2fs command you must have to run the e2fsck command to check the

#e2fsck -f  /dev/VG1/lv1

e2fsck is used to check the integrity of ext2/ext3/ext4 filesystem types.

Note:resize2fs will not run unless you execute e2fsck . 

#resize2fs  /dev/VG1/lv1

Now let us see the size of the re-sized logical volumes by using lvdisplay

#lvdisplay

As you can see from the above output after extending there is 12.00 GB from 3.99 GB

Now if we check the VG size available

#vgs

The above output says the current available VGfree size is changed from 19.9 GB to  9.09 GB

I hope now you have got some ideas on LVM concepts, resizing the LV, VG volumes.

Never miss any articles from Vasanth blog follow my facebook page for updates Learn Linux in an easier way
If you found this article useful, Kindly Subscribe here 👉👉🏿Click this link to Subscribe

 

 

LVM Logical Volume Manager

Introduction:

Logical Volume Manager(LVM) is the powerful tool in Linux to manage the Disk management system.Adding more space to the existing filesystem or partitions can be easily done by using the LVM.If a filesystem needs more space it could be added to its logical volumes from the free spaces in its volume group and then filesystem can be resized as per the requirement.

In today’s IT environment all the server’s needs more space day by day and we need to expand that based on our requirements.LVM can be used in RAID, SAN.A physical disk will be grouped together to create a  volume group, Then from the volume group, we need to create the individual partitions and create a new filesystem then mount it on some mount point directory to make it visible to the users.

Let me say this in simple words.To bring a disk in to the LVM structure,

1.Group all the physical disks together to create a physical volume

2.Create a volume group and add all the disks in the volume group

3.Now from the total volume group size we need to create the individual partitions i.e logical volumes

Logical Volume Manager Features:

1.It is very flexible to increase the size of the partition at any time.

2.Any filesystem can be installed

3.Migration can be used to recover the defective disk.

Now let us configure the LVM disk storage,

Ex:1 How to configure LVM

In this example, i  will add three hard disks(more than 3 u can use there are no limitations) to the server.After adding the additional hard disks to the server check whether the kernel recognized the disks by using the “fdisk” command.

#ls -l     /dev/sd*

Note: You can also use the “fdisk -l” command to check.

As you can see from the above screenshot, the newly added disks are recognized by the kernel.

Now its time to configure the LVM,Before we bring the disks in to the LVM structure we should format the disks with the LVM id.This can be done in two ways, I will show you here both the methods to label the disk with LVM partition type.

Remember you have to use either method:1 or method:2 to do this if you try both the methods when you run pvcreate command. you will get the disk missing error message 

Note: LVM Partition type ID is 8e

Method:1
#fdisk  /dev/sdb

Follow the steps as shown in the screenshot to associate the harddisks with LVM id

Repeat the same steps for the remaining harddisks i.e for /dev/sdc and /dev/sdd

Now check with “fdisk -l” whether all the disks are labeled with LVM id partition type

AS YOU CAN SEE THE ABOVE SCREENSHOT ALL THE DISKS HAVE BEEN LABELED WITH THE LVM PARTITION ID.

Method:2

Syntax:

Step:1

#pvcreate   <disk1>     <disk2>   <disk3>

In our case we have /dev/sdb,/dev/sdc,/dev/sdd

#pvcreate   /dev/sdb   /dev/sdc  /dev/sdd

This will write an LVM  header to the devices to indicate that they are ready to be added to a volume group

Step:2 Check the Physical Volume Details(PV)

Now verify that LVM has  registered the physical volumes by using the following command,

#pvdisplay

or

#pvs

From the above screenshot, all the three devices are present in the PV column

To view the same in detailed output run the following command

#pvdisplay

Note: For better view output has been truncated

Step:3  Create Volume Group(VG)

Now add the physical volumes to a volume group

Syntax:

#vgcreate    <VG name>    <disk1>   <disk2>  <disk3>
#vgcreate    VG1   /dev/sdb   /dev/sdc   /dev/sdd

Now if we check the pvdisplay or pvs command again, we can see that our physical volumes are now associated with the new volume group

#pvs or pvdisplay

As you can see from the above screenshot, now the physical volume disks have been added to volume group VG1.

To check the VG details
#vgs

or

#vgdisplay

As you can see from the above output the volume group VG1 has three physical volumes and zero logical volumes.

Here is the description of each parameter as shown in above screen shot.

1.VG NAME=Volume group name

2.Format = LVM architecture used lvm2

3.VG access = Volume group is in read and write and ready to use

4.VG status = Volume group can be resized, we can expand more if we need  to add more space

5.Cur LV= Currently there were two logical volumes in this volume groups

6.PE size= Physical extents, size for a disk can be defined using PE or GB size, 4MB is the default PE size of LVM, Say for example if we need to create 5 GB size of logical volume we can use the sum of 1280 PE, Got confused????🙄🙄

let me explain this in a easier way,as we all know 1024 MB=1 GB,if so 1024 MB * 5=5120 PE =5 GB,now divide the  5120 / 4= 1280,4 is the default PE size.

7.Total PE=  This volume group have

8.Alloc PE=  Total PE used.full PE already used,6141 * 4 PE = 24564

9.Free PE= Spaces are available as the lv are not yet been started using

Step:5 Create a Logical volume from the Volumegroup pool

We have a volume group available, we can use it for creating logical volumes.Unlike conventional partitioning, when working with logical volumes, you don’t need to know the layout of the volume since LVM maps and handle this for you.You only need to provide the size of the volume and name.

Now we will create three seprate logical volumes from the volume group

2G for  “lv1” volume

4G for “lv2” volume

4G for “lv3” volume

Syntx:

#lvcreate   -L <size>  -n  <Lv Name>   <Volume group name>
#lvcreate  -L  +2G  -n  lv1   vg1
#lvcreate  -L +4G  -n  lv2  vg1
#lvcreate   -L +4G  -n    lv3  vg1

Now check the logical volumes and their relationship with the volume group

#vgs

Step:6 Create a filesystem on logical volumes

Everything is done,inorder to make use of this logical volumes to store data we need to create a filesystem

#mkfs  /dev/vg1/lv1

#mkfs /dev/vg1/lv2

#mkfs  /dev/vg1/lv3

Repeat the same for the remaining logical volumes also i.e for lv2 and lv3

Step 7: Mount the Logical volumes to some mount point directory
#mount  /devv/vg1/lv1   /BACKUP

#mount  /dev/vg1/lv2   /DATABASE

#mount  /dev/vg1/lv3  /WEBDATA

All the logical volumes have been successfully mounted and its now ready to use

check the mounted filesystem information by using the following command

#df  -h

In our next article, we will see how to grow the size of the logical volume partitions, increase the size of the volume group and many more.

Never miss any articles from Vasanth blog follow my facebook page for updates Learn Linux in an easier way

If you found this article useful, Kindly Subscribe here 👉👉🏿Click this link to Subscribe

 

 

 

Access Control List (ACL)

As a system administrator, we have to protect the files and data from unauthorized access.As we all are very much aware of the permissions we set for files and directories by using chmod,chown,chgrp, however, these permissions have some limitations and may not work as per our needs.We cannot assign different sets of permissions for different users on same directory or files, thus Access control list was implemented.

Before we set the Acl permission we need to check whether ACL is supported by the kernel.

1.Chech Kernel for ACL support.

execute the following command to check ACL support for the filesystem, POSIX_ACL=Y option, if you see ‘N’ instead of ‘Y’ it means kernel doesn’t support ACL, we need to recompile the  kernel

#grep   -i  acl /bootconfig*

Types of ACL

There are two types of ACL available

1.Access ACL Used for allowing permissions on any directory or file

2.Default ACL – Used for granting access control list on a specific directory only.

Note:1 In default, ACL can be used only on directory level, if any subdirectory or file created within that directory will inherit the ACLs from its parent directory.On the other hand, a file inherits the  default ACL’S as its access ACL’s

Note:2 we use “-d” for setting the default ACL’s(default ACL’s are optional only)

Ex:1 To check the ACL details for a directory

Syntax:

#getfacl   <Directory name>
#getfacl   /SAN

Before setting the default ACL the permissions would like above

To set the default ACL’s to a directory we will use the command “setfacl”  command.,In this example setfacl command will set read and write permission for the direcrtory /SAN.

-m indicates Modify

#setfacl  -m  d:o:rw  /SAN

After assigning the default ACL’s the permission would look like this

#getfacl  /SAN

Ex:2 To set a ACL permission for a file or directory use the setfqacl command, here in this example we will assign read and write permission to the user linuxvasanth1

Let me check the default permission set  for the file /mydoc  berfore we assign the  ACL

#getfacl  /mydoc

As you can see from the above output the file has the default permission sets only.

Now set the ACL,

#setfacl  -m u:linuxvasanth1:rw  /mydoc

Now check the ACL permission again

#getfacl /mydoc

From the above output, ACL permission set is successfully assigned to the file

Ex:3 Remove the ACL permission

To remove the ACL’s permissions we will use the option -x and -b with setfacl command

#setfacl   -x ACL file/directory (This will remove only specified ACL from file/directory)
#setfacl  -b  ACL  file/directory (This will remove all ACL from a file/directory)

In this example am going to remove the user linuxvasanth1 from the file /mydoc

#setfacl  -x  u:linuxvasanth1  /mydoc

Now run the getfacl command to check

#getfacl    /mydoc

As you can see from the above output the user has been successfully removed from the ACL set

Never miss any article from this blog ,Kindly do like my FB page Learn Linux in a easier way

If you found this article useful, Kindly Subscribe here 👉👉🏿Click this link to Subscribe

********************************************************************************************************************************