Pawan Sharma | September 12, 2011 | | Be the first to comment!

Creating and Deleting Partitions in RHEL 6

Partitioning is a very important concept in Linux. If you have your concepts clear,  related to partitioning in Linux, it will be very helpful when you became a Linux System Administrator.

There is a new partitioning tool RHEL6 cfdisk, but we will see the traditional and most popular partitioning tool "fdisk". To use fdisk first you have to login as root. if you are a regular user and know root password, you can switch to root account using "su" command.
  • To see your current disk and partitions run: fdisk -l

In the above image you can see that I have two hard disks. The first one is /dev/sda and the other one is /dev/sdb. In the above image you can see that the HDD /dev/sda is of size 16 GB and having two partitions /dev/sda1, which is created at the time of installation as /boot, and /dev/sda2, which is a Linux Logical Volume Manager(LVM). The second HDD is /dev/sdb which is newly installed HDD of size 2 GB and does not contain any valid partition table as you can see in the image.

In this post we will create the physical partitions and mount them on particular directories.
  • To create a partition of 1 GB form /dev/sdb type :fdisk /dev/sdb, and press m to see menue.
  •  Press n to create new partition, p to create primary partition and e to create extended(always create first partition as primary), make partition 1, select first cylinder as default and on next line type +size of partition to be created,ex +1G.






















  • Now press p to print current partition table and press w to save partition table. and on command prompt type partprobe to update current partition table and run fdisk -l /dev/sdb.

  •  Now format this partition with command : mkfs.ext4 /dev/sdb1. Then create a directory /mydata, and mount /dev/sdb1 on /mydata using command : mount /dev/sdb1 /mydata.








































  • Make entry in /etc/fstab to make mounting persisting, means mount /mydata every time when server restart.
In next post we will learn how to create partition using Linux Logical Volume Manager(LVM) .
Please comment if you have any doubts.



Pawan Sharma | September 7, 2011 | | Be the first to comment!

RHEL 6 File-System


     In this post we will discuss about the file system in RHEL 6. In Linux operating system there is a pre-defined location to store different files. 


     The Linux file system can be defined as the method of storing and organizing files in a form that we can understand easily. In Linux operating system everything is a file. To manage all these files Linux have a tree like directory structure. File system is a method of storing and organizing arbitrary collection of data in a form that is human readable.


File system structure of RHEL 6:


    • / :- Root directory, which contains all other directories.
    • /bin :- Contains commands that may be used by both system administrator and by users, but which are require when no other file-systems are mounted. 
    • /boot :- This directory contains everything which required for the boot process, like kernel, GRUB, Initrd, etc.
    • /dev :- Contains device files.
    • /etc :- Contains configuration files.
    • /home :- Contains users’ home directories.
    • /lib :- Essential shared libraries and kernel modules.
    • /media :- Mount point for removable media.
    • /mnt :- Mount point for temporary mounted file-system.
    • /opt :- Contains add-on/optional packages.
    • /root :- Root user’s home directory.
    • /sbin :- Contains system binaries.
    • /tmp :- Contains temporary files.
    • /var :- Contains variable data files.
    • /proc :- Contains kernel and process information.
    Pawan Sharma | September 5, 2011 | | Be the first to comment!

    Managing User and Group in RHEL 6

         To create a user in RHEL 6 we can use commands as well as graphical user administration tools. It is advisable to use command line as much as possible because it is faster and in real business environment you have to use ssh to remotely take control to administer the system.

    • To create a user run command:
      • useradd user_name
    • To define a password for the user:
      • passwd user_name
    • Create a user with specific UID:
      • useradd -u 802 user_name
        • The above command will create a user with UID 802.
    • To create a group run command:
      • groupadd group_name
    • To delete a user run command:
      • userdel user_name
        • The above command will delete the user but it will not delete the home directory of user. To delete the home directory as well as the files contained in it run following command"
        • userdel -r user_name

    User and Group Administration
    Given below are some sample questions about user and group administration:

    Q1. Create a user rambo and make it a member of group student.
    Ans. useradd -G student rambo.
            To see the results view /etc/passwd and /etc /group files.
    Q2. Create a user sheela with UID 566 and assign it no interactive shell.
    Ans. useradd -s /bin/false sheela
            The above command will add a user sheela, and give it non interactive shell.
    Q3. Make the user munni to expire on date 17-09-2011.
    Ans. chage -E 2011-09-17 munni
            The above command will make the account of user munni unavailable from 17-09-2011
    Q4. User pandeyg have to change password at the time of next login.
    Ans. chage -d 0 pandeyg
            The above command will force user to change password when the user tries to login.

    Pawan Sharma | September 4, 2011 | | Be the first to comment!

    Sample Questions for User and Group Administration

          For the preparation of RHCSA and RHCE certification exam, the most important thing is to do lots of practicals. There are no real dumps available for RHCSA/RHCE exams as these certification exams are totally hands on. In this post I will give some sample questions and their answers. These  sample exercises are based on User and Group Administration.
          In my few next posts I will post sample questions and their answers, related to User and Group Management. The questions in next few posts are like:-

    • How to create a user in RHEL 6 with unique UID?
    • How to create a group in RHEL 6?
    • How to create a user and add it to a specific group?
    • How to create a user john and assign him no interactive shell?
    • How to set password expiration for a user?
    • Request for password change, when user next login.
    • How to change password for a user?
    • How to delete a user in RHEL 6?