About Ubuntu 18.04

About Ubuntu 18.04

We are going to see about Ubuntu 18.04 Operating system, which is going to release on 26th April 2018.

Features of Ubuntu 18.04:

GNOME 3.28 Desktop

Ubuntu 18.04 going to give us a new experience.

Kernel 4.15

Ubuntu has scheduled to come up with new kernel version for every 6 months. Now Kernel 14.5 going to give more power to Ubuntu.

Xorg

Xorg is the default one for Ubuntu and from next release, TLS will come with both traditional Xorg graphics and Way-land based stack. It will give better performance to software like Skype, hangout and it will recover better from the shell crashes.

Minimal installation method

From ubuntu 18.04 we have an option to install with minimal packages and it will give us a desktop environment.Note: This is not a replacement for existing Ubuntu minimal ISO.

Ubuntu will collect data

As per Ubuntu announcement, canonical will collect some user data like system configuration and installed packages and this option will be available in the installer.

New installer

Subiquity will be the default one in an upcoming release and this will give new look to server installation.

Color emojis

Its important in messaging and communication. It will display colorful emojis in all the apps.

Faster boot time

Using systemd it will speed up the booting time.

zstd compression algorithm

Using facebook’s zstd compression algorithm it speeds up the Ubuntu installation process.

refrence: Ubuntu wiki

Logrotate in Linux

Will see how to configure/ use logrotate in Linux

to compress, move, delete or mail log files at the periodic time. By doing this will keep away the filesystem from the filesystem full issue.

Setting up and Manage logrotate in Linux:

In Linux/ Unix, environment /var/log is most important directory and it keeps all the activities as a log.

System administrators will use the logs to analyze any issue’s.

/var/log keeps lots of log files and here is the list.

[root@localhost ~]# ls /var/log
anaconda boot.log cron dmesg.old lastlog messages rhsm spooler tuned wtmp
audit btmp dmesg firewalld maillog ppp secure tallylog vmware-vmsvc.log

Installing logrotate:

Here I am going to use the yum package manager to install the logrotate.

[root@localhost ~]# yum install logrotate
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package logrotate-3.8.6-12.el7.x86_64 already installed and latest version
Nothing to do

look likes the package is already installed on my machine.

/etc/logrotate.conf is an important configuration file which contains all the configuration of log rotation and “include /etc/logrotate.d ” this line should be uncommented.

We have plenty of option in logrotate and below is that.

Will create /etc/logrotate.d/apache2.conf file and insert below content.

/var/log/apache/* {
weekly
rotate 5
size 25M
compress
delaycompress
}

Daily, Weekly, Monthly:  Based on this input the tool will rotate the logs.

rotate 5: This will keep the only 5 files and the old files will be removed.

size 25: log file minimum size for log rotation.

Compress & Delaycompress:  These are used to say that all are already rotated logs.

Now will do s test using the below command

[root@localhost ~]# logrotate -d /etc/logrotate.d/apache2.conf

 

 

Reference: Tecmint

RedHat Enterprise Linux 7 Installation

Will start learning RedHat Enterprise Linux 7 Installation in this post.

We have many new features in RHEL7 and simple differences in installation as well comparing to old version’s that we were given input like hostname, timezone, package selection, network configuration, kdump configuration, etc… in next next screen’s. But, in RHEL7 we can provide those details on a single screen. However all the remaining will be the same.

Using RHEL7 media boot the machine and you will receive a screen like below.

RedHat Enterprise Linux 7 Installation

Now select “Install Red Hat Enterprise Linux 7.3” to begin the installation.

As first part, you will get a screen that is asking you to select the System language and keyboard layout like below.

Then next you will get a screen which is the place to provide all information to install the operating system.

In this screen, you can provide all the information like Software selection, Partitioning in Installation destination tab, time zone, etc…

Now, will edit some of the configuration based on our requirement.

As first, here editing time zone part and selecting Asia/ Kolkata like below.

you can select the time zone in two ways one is by clicking on India over the map and another one is selecting Asia and Kolkata in the drop-down list.

And, click on the done button which is showing the left corner of upper on the screen to complete this part.

Likewise, we should click on done for each and every part.

Now, Click on “Software selection” tab to select packages

Will continue with default one which is “minimal installation”.

Based on the selected packages group, it will install the required packages.

Next, Click on “Installation destination” to create partitions.

We have two option at this stage. One is “Automatically configure partitions” and another one is “I will configure partitioning”

If you select the first option, it will create the partition automatically with LVM and if you select the second option, we need to provide the partition details manually.

Here let us see how to create manual partitions.

Once you selected the second option, you will get a screen asking for partition type Standard, LVM, etc…

select on Standard one to create a normal partition.

and click done to go next screen of partition creation.

It will ask for the mount point with size like below. Below filesystem, creation is compulsory while doing manual partitioning.

  1. boot – Contains bootloader and partition information
  2. / (root)
  3. swap – Virtual memory

Like above will create the three mandate partition to continue the installation.

and click done to go back to the main screen.

and it will ask our confirmation to write the partition changes on the disk. Click “Accept Changes”.

And now, click “Begin Installation” to start the package installation.

In package installation screen, we can see that password has not been set still. So, click on “Root Password” to set the root password. and click done.

See the screen after root password has been assigned.

Once installation completed, will ask for the reboot. Click on “Reboot” button to complete the installation.

We compeleted RHEL7 installation successfully.

 

 

 

 

 

How to boot with an old kernel version in RHEL7

In this post, will see how to boot with an old kernel version in RHEL7. When the updated kernel not suitable for your application or OS not booting.

There might be a requirement to upgrade the operating system or kernel version alone in Linux/Unix machines.

In such case, we might face issue with the upgraded kernel version. To, fix that, follow the below steps.

By default, /etc/default/grub file has entry called GRUB_DEFAULT=saved.

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

This entry instructs the system which kernel will be used to load the operating system by checking the saved_entry in the grubenv file, which is in /boot/grub2/grubenv.

[root@localhost ~]# cat /boot/grub2/grubenv
# GRUB Environment Block
saved_entry=0
#########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@localhost ~]#

So we can set the default kernel by editing /boot/grub2/grubenv file or using grub2-set-default command.

To do this, select the old kernel to boot the operating system from grub splash screen.

How to boot with old kernel in RHEL7

And use the grub2-set-default command to change the kernel.

Before changing we should remember that, the always updated kernel will be on top and will use numeric value “0” to mention this kernel in command

The old one will be available by next. So, to mention the old kernel will use numeric value “1”. Like this numeric will start from 0.

/boot/grub2/grub.cfg file contains Kernel and initramfs image details.

below command will show us the list of the kernel installed on this machine.

[root@localhost ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
Red Hat Enterprise Linux Server (3.10.0-693.17.1.el7.x86_64) 7.3 (Maipo)
Red Hat Enterprise Linux Server (3.10.0-514.el7.x86_64) 7.3 (Maipo)
Red Hat Enterprise Linux Server (0-rescue-ffc8e857b7b84166b88e7b0522c168a4) 7.3 (Maipo)

By default, saved_entry will be the latest one, which you updated.

Using below command will change the default kernel as the old one to boot the operating system without any issue.

[root@localhost ~]# grub2-set-default 1

and now check again in /boot/grub2/grunenv file to verify the default kernel.

[root@localhost ~]# cat /boot/grub2/grubenv | grep saved
saved_entry=1

Now you can see in above screen that the old kernel is set as default one.

Now rebuild the /boot/grub2/grub.cfg file using grub2-mkconfig -o command.

Use the below command in BIOS based machines:

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.17.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.17.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-ffc8e857b7b84166b88e7b0522c168a4
Found initrd image: /boot/initramfs-0-rescue-ffc8e857b7b84166b88e7b0522c168a4.img
done

Use below command for UEFI based machines:

[root@localhost ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

finally, restart the machine and check whether the machine booting using old kernel.

reference: Red Hat Document

Limiting CPU and Memory usage to users/groups(CGroups)

In this post we are going to see : Limiting CPU and Memory usage to users/groups.

In large environments, there is a chance to access single system by more than one users at a time. So, user’s can access the resources highly.

For our exercise going to use RHEL7 Operating System.

CGroups will help us to limit the resources by group of users.

We have below users created already to do practise.

[root@server ~]# grep home /etc/passwd
lbcuser1:x:1005:1007::/home/lbcuser1:/bin/bash
lbcuser2:x:1006:1008::/home/lbcuser2:/bin/bash
lbcuser3:x:1007:1009::/home/lbcuser3:/bin/bash
lbcuser:x:1008:1011::/home/lbcuser:/bin/bash

Users are assigned to below mentioned groups.

Groups:    lbcgroup, finance, admin

[root@server ~]# grep "lbcuser" /etc/group
finance:x:1003:lbcuser2
lbcgroup:x:1010:lbcuser1,lbcuser
admin:x:1012:lbcuser3

To work on this, lbcgroup package should be installed and will use /etc/cgconfig.conf and /etc/cgrules.conf to apply the rules overs the users to limit the resources use.

follow the below steps to apply rules by per Group:

[root@server ~]# vi /etc/cgconfig.conf
mount {
 cpu = /cgroup/cpu_and_mem;
 cpuacct = /cgroup/cpu_and_mem;
 memory = /cgroup/cpu_and_mem;
}

group finance {
 cpu {
 cpu.shares="250";
 }
 cpuacct {
 cpuacct.usage="0";
 }
 memory {
 memory.limit_in_bytes="1G";
 memory.memsw.limit_in_bytes="2G";
 }
}

group lbcgroup {
 cpu {
 cpu.shares="250";
 }
 cpuacct {
 cpuacct.usage="0";
 }
 memory {
 memory.limit_in_bytes="1G";
 memory.memsw.limit_in_bytes="2G";
 }
}

group admin {
 cpu {
 cpu.shares="500";
 }
 cpuacct {
 cpuacct.usage="0";
 }
 memory {
 memory.limit_in_bytes="1G";
 memory.memsw.limit_in_bytes="2G";
 }
}

While starting the server, above configuration file will mount cpu, cpuacct and memory subsystems to a cpu_and _memory cgroup.

CPU:

cpu-shares parameter used to assign the the CPU resources which is available to each and every processes. Assigning parameter values as 250, 250 and 500 for finance, lbcgroup and admin groups in cgroup will split the CPU resources in 1:1:2 ratio. If only one process is running, it doesn’t matter in which cgroup it falls. CPU limitation will be applied, when there is more than one process running.

cpuacct:

cpuacct.usage=”0″ this value is used to reset the CPU usage on cpuacct.usage and cpuacct_percpu files. These files contains the total CPU utilized time by all the process.

Memory:

memory.limit_in_bytes=”1G” parameter says that how much memory allowed to use by a cgroup.

memory.memsw.limit_in_bytes=”2G” parameter says that how much swap space allowed to use by a cgroup

cgrulesengd:

Start this daemon using below command:

[root@server ~]# systemctl start cgred

This daemon will help to move process to specific cgroup and for that we need to configure /etc/cgrules.conf like below

[root@server ~]# vi /etc/cgrules.conf
# /etc/cgrules.conf
#The format of this file is described in cgrules.conf(5)
#manual page.

@finance  cpu,memory finance
@lbcgroup cpu,memory lbcgroup
@admin    cpu        admin

Like above will assign rules to group.

In this, process will be moved to cgroup based on which user started this process and belongs to which group.

For example, Process detects the limitations from lbcgroup cgroup, which is started by lbcuser1 user and it will move to /cgroup/cpu_and_mem/lbcgroup/tasks file.

cgconfig:

Start this daemon to create hierarchy of cgroup to set the required parameters  in all cgroups.

[root@server ~]# systemctl start cgconfig

and to make all changes persistent across reboot, configure both(cgred, cgconfig) services to be started by default.

[root@server ~]# systemctl enable cgred

[root@server ~]# systemctl enable cgconfig

 

Reference: Red Hat official documentation

How to install Graphical user Interface/GUI on RedHat 7 Linux

In this post going to see How to install Graphical user Interface/GUI on RedHat Linux.

We have 7 run levels in RedHat and in that, runlevel 5 is used for GUI.

Use below command to change from current runlevel to GUI(before changing to graphical mode, make sure GNOME package installed):

[root@server ~]# init 5

To set GUI as default runlevel, use the below command and reboot the machine.

[root@server ~]# systemctl set-default graphical.target

If without any error runlevel switched to GUI, than package is already installed in your machine.

If you are receiving any error, than you should install the GNOME package.

Let’s see how to install the GUI in RedHat 7.

We will use yum package manager to install the GUI.

We have two types of repository that, one is online and another one is local repository.First decide which repository going to use to install GNOME package.

If you’re machine connected with internet, register in redhat repository using below command.

[root@server ~]# subscription-manager register
[root@server ~]# subscription-manager refresh
[root@server ~]# subscription-manager attach --auto

To use local repository make sure its already configured in your machine. Click here to know how to configure local yum repository.

Use the below command to check the group name for GNOME installation.

[root@server ~]# yum grouplist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use su bscription-manager to register.
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Available Environment Groups:
 Minimal Install
 Infrastructure Server
 File and Print Server
 Basic Web Server
 Virtualization Host
 Server with GUI
Available Groups:
 Compatibility Libraries
 Console Internet Tools
 Development Tools
 Graphical Administration Tools
 Legacy UNIX Compatibility
 Scientific Support
 Security Tools
 Smart Card Support
 System Administration Tools
 System Management
Done

We should install “Server with GUI” using yum like below.

[root@server ~]# yum -y groupinstall "Server with GUI"

Now successfully installed GUI in our machine. Try to switch using “init 5” command.

Thanks for reading this post.

Reference: Red Hat Discussion

No supported authentication methods available

Error:

Disconnected: No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)

No supported authentication methods available

Receiving error When trying to access Linux server through putty or other tool using ssh service.

Solution:

  1. Edit /etc/ssh/sshd_config configuration file using vi editor.
        [root@server ~]# vi /etc/ssh/sshd_config
  2. Check and replace with yes for below entry
     PasswordAuthentication no

    changed 

    PasswordAuthentication yes
  3. save and exit from the file using :wq
  4. Than restart the ssh service using below command.
    systemctl restart sshd
  5. Restart the network service using below command.
    systemctl restart network
  6. Now try to access the server and sure it will work. Still if you are facing error in accessing the server, that there might be issue with firewall configuration.

Reference: Super user

Permission handling in Linux

In this post we are going to see(Permission handling in Linux) how to set permission for files and directories in linux/unix.

Before set/unset permission we should check the existing permission for a file usinf ll <filename> command like below.

[root@server ~]# ll abu
-rwxrwxrwx. 1 abu root 113 Dec 11 20:22 abu

We can assign permission based on below categories and same has been display while executing ll or ls –l command.

User:    u

Group:  g

Others:  o

Numeric values used for changing/identifying the permissions:

Read:       4, r

Write:      2, w

Execute:  1, x

Command used for changing file permission:

#Chmod 655 <filename>

Example:

Command to set permission:

We are going to set permission for file abu from 777 to 755 using below command. 755 will have full permission for user, read and execute for group and others.

[root@server ~]# chmod 755 abu
[root@server ~]# ll abu
-rwxr-xr-x. 1 abu root 113 Dec 11 20:22 abu

Also will set the permissions usings characters like below.

Read:        r

Write:       w

Execute:  x

Example:

Command to set permission using characters:

In the below example going to set execute permission alone to others

[root@server ~]# ll abu1
-rwxr-xr--. 1 root abu 0 Dec 11 20:17 abu1
[root@server ~]# chmod o+x abu1
[root@server ~]# ll abu1
-rwxr-xr-x. 1 root abu 0 Dec 11 20:17 abu1

Changing ownership of a file or directory:

#Chwon user:group <filename>

example:

In below example going to change owner of the directory as lbcuser for lbc directory. User has been created already.

Note: Existing owner and group will be root.

before changing owhership:

[root@server ~]# mkdir lbc
[root@server ~]# ll | grep lbc
drwxr-xr-x. 2 root root 6 Dec 16 20:33 lbc

after changing ownership:

[root@server ~]# chown lbcuser lbc
[root@server ~]# ll | grep lbc
drwxr-xr-x. 2 lbcuser root 6 Dec 16 20:33 lbc

using chown command will change group as well like below.

Going to change group as finance.

[root@server ~]# chown :finance lbc
[root@server ~]# ll | grep lbc
drwxr-xr-x. 2 lbcuser finance 6 Dec 16 20:33 lbc

Will change the group alone using chgrp command:

[root@server ~]# mkdir lbc1
[root@server ~]# chgrp finance lbc1
[root@server ~]# ll | grep lbc1
drwxr-xr-x. 2 root finance 6 Dec 16 20:47 lbc1

 

Reference: RedHat Document

ACL in RHEL7/Cent OS 7

In this post we are going to securing files and directories using ACL in RHEL7/Cent OS 7.

In this post we are going to see how to secure files and directories using ACL.

As first step need to check kernel compatibility for ACL using below command.

[root@server ~]# grep -i acl /boot/config*
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS_POSIX_ACL=y
CONFIG_FS_POSIX_ACL=y
CONFIG_GENERIC_ACL=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_CEPH_FS_POSIX_ACL=y
CONFIG_CIFS_ACL=y

Above output will says that this kernel is compatible with ACL access since we could see all are marked as yes POSIX_ACL=y. 

If it is set as N. Than we need to rebuild the kernel.

Next need to install the packages.

Required packages for ACL:

acl

nfs4-acl-tools

libacl

Now install all the above three packages using yum:

Link to see how to configure yum locally click here

[root@server ~]# yum -y install nfs4-acl* acl libacl

Will assign read, write and execute permission to files and directories using ACL and will mention characters ugo/rwx  in commands for permissions respectively.

Now will see a example which will help us to understand clearly.

Create three users and one group respectively like below.

[root@server ~]# useradd lbcuser1
[root@server ~]# useradd lbcuser2
[root@server ~]# useradd lbcuser3
[root@server ~]# groupadd lbcgroup
[root@server ~]# passwd lbcuser1
Changing password for user lbcuser1.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

Above screen password has been generated for only lbcuser1.Same like that need to set password for other 2 users.

Now add the lbcgroup group as secondry group for lbcuser1 and lbcuser2 users.

[root@server ~]# usermod -aG lbcgroup lbcuser1
[root@server ~]# usermod -aG lbcgroup lbcuser2

Create a directory and a file inside of that directory to assign and check permissions using acl.

[root@server ~]# mkdir /tmp/data
[root@server ~]# touch /tmp/data/testfile.txt

Now change the group as lbcgroup to the file like below.

[root@server ~]# chown :lbcgroup /tmp/data/testfile.txt
[root@server ~]# ll /tmp/data/testfile.txt
-rw-r--r--. 1 root lbcgroup 0 Dec 15 21:14 /tmp/data/testfile.txt

set the permission 770 using chmod command to the testfile.txt.

Now we can login as lbcuser1 and lbcuser2 and than will try to insert content in testfile.txt.

Sure both users can able to insert content in the file. Because, both users and files group is same(lbcgroup).

[root@server ~]# su lbcuser1
[lbcuser1@server root]$ echo "My name is lbcuser1..." > /tmp/data/testfile.txt
[lbcuser1@server root]$ exit
exit
[root@server ~]# su lbcuser2
[lbcuser2@server root]$ echo "My name is lbcuser2..." > /tmp/data/testfile.txt
[lbcuser2@server root]$ exit
exit
[root@server ~]#

and now will try to insert content as lbcuser3. It will give error. Since, its not the owner and member of lbcgroup for that file.

[root@server ~]# su lbcuser3
[lbcuser3@server root]$ echo "My name is lbcuser3..." > /tmp/data/testfile.txt
bash: /tmp/data/testfile.txt: Permission denied

So, now will provide read and write permission using ACL without adding the lbcuser3 in lbcgroup and will check it again to insert content into the file.

[root@server ~]# setfacl -R -m u:lbcuser3:rw /tmp/data/testfile.txt
[root@server ~]# su lbcuser3
[lbcuser3@server root]$ echo "My name is lbcuser3..." > /tmp/data/testfile.txt
[lbcuser3@server root]$ cat /tmp/data/testfile.txt
My name is lbcuser3...

Since we user single > symbol to redirect the echo command out into the file, its showing our last content which is “My name is lbcuser3…”

To set permission for group will use in above command where we used and groupname where we given username like below.

[root@server ~]# setfacl -R -m g:lbcgroup:rw /tmp/data/testfile.txt

To check the existing ACL permission of a file use getfacl command.

[root@server ~]# getfacl /tmp/data/testfile.txt
getfacl: Removing leading '/' from absolute path names
# file: tmp/data/testfile.txt
# owner: root
# group: lbcgroup
user::rwx
user:lbcuser3:rw-
group::rwx
mask::rwx
other::---

Same like file will set permission to directory as well.

Command to set permission for directory:

below command will help us to set read permission alone for other users which is not owner/group of the directory.

[root@server ~]# setfacl -m d:o:r /tmp/data
[root@server ~]# getfacl /tmp/data
getfacl: Removing leading '/' from absolute path names
# file: tmp/data
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:other::r--

 

User/Group disk quota enabling in Linux/Unix

Now we are going to see how to enable User/Group disk quota enabling in Linux/Unix in this post. Sometimes we might have low space in on local disk. To avoid this will allocate disk size to Users/Groups by enabling and configuring quota in /home directory.

As a first step we should enable quota in Filesystem.

by editing and adding usrquota and grpquota in home directory entry at /etc/fstab file will enable quota.

 

[root@server ~]# vi /etc/fstab

# /etc/fstab
# Created by anaconda on Fri Nov 24 17:31:25 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=2f2c635e-e5fb-4c81-823a-855a334ca04c /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/rootvg/lv_tmp1 /home xfs defaults,usrquota,grpquota 0 0

save and exit from the file.

Now remount the filesystem using below command.

[root@server ~]# mount -o remount /home

Then check whether the quota has been enabled or not in /home mountpoint.

[root@server ~]# mount | grep /home
 /dev/mapper/rootvg-lv_tmp1 on /home type ext4 (rw,relatime,seclabel,quota,usrquota,grpquota,data=ordered)

Creating database using below command

[root@server ~]# quotacheck -cugv /home

C:     Key to create new quota file

U:     User quota

G:     Group quota

V:     Verbose mode

And now turn on the quota in /home directory using below command

[root@server ~]# quotaon /home

Now will assign quota using edquota command to User/Group

Syntax to create quota on user:

#edquota -u <username>

Syntax to create quota on group:

#edquota -g <groupname>

Will see a example of creating quota on user called abu

[root@server ~]# edquota -u abu

Now the above command will open quota file like below

Disk quotas for user abu (uid 1001):
 Filesystem                 blocks soft hard inodes soft hard
 /dev/mapper/rootvg-lv_tmp1    0   5000 6000   0      0    0

Above data has two quota limits. One is based on blocks and another one based on inode.

For block usage:

Soft:    Soft limit will warn the user if the user exceeds the limit. But, user allowed to write data in home directory till reaching the hard limit. In above example, we have provided 5000KB(nearby 5MB)

hard:    Hard limit will not allow user to write data in home directory once reached hard limit. In above example, we have provided 6000KB(6MB) as hard limit.

Will login and try to create 8MB of file using dd command to check the quota on user.

[root@server ~]# su abu
[abu@server ~]$ dd if=/dev/zero of=bgfile bs=1M count=8
dm-3: warning, user block quota exceeded.
dm-3: write failed, user block limit reached.
dd: error writing ‘bgfile’: Disk quota exceeded
6+0 records in
5+0 records out
6127616 bytes (6.1 MB) copied, 0.00498719 s, 1.2 GB/s

Command to display report on user quota:

[root@server ~]# repquota -as
*** Report for user quotas on device /dev/mapper/rootvg-lv_tmp1
Block grace time: 7days; Inode grace time: 7days
 Space limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20K 0K 0K 2 0 0
abu +- 6000K 5000K 6000K 6days 6 0 0

Will configure grace period for the user quota. Once grace period has been reached than the soft limit will be come hard limit.

Command to create grace period:

[root@server ~]# edquota -t

Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
 Filesystem Block grace period Inode grace period
 /dev/mapper/rootvg-lv_tmp1 7days 7days

Grace period also has two types which based on blocks and inodes.

 

Thanks for reading this post.