Tuesday, August 7, 2012

FILE AND FOLDER PERMISSION IN LINUX

Permissions –

#chmod
           As shown in the output of ls -l command above, each and every file has the permissions associated with it. These permissions are defined for three types of persons namely- the owner of the file, the group members of the owner, and all other persons who are not the members of the group whom this owner belongs to. Let us have a look on following line:


-rwxrw-r--   1   root   root   468   Aug   8 07:15   file1

Permissions are defined within first ten characters of the above like output from ls -l. normally, the first character can either be - or d, - represents that it is a file while d represents a directory. Remaining characters are grouped in set of three characters which are r (read), w (write), and x (execute).
In the above example first three characters are rwx which means owner of the file has all the permissions on file1. Next three characters are rw- which will mean the group members will have read and write permission on file1 but not execute permission on it. The last set is r—which will mean that others will only have read permission on file1 but they will not have write and execute permission on file1.

Note –
        The default permission for file is 664 and for directory 755. 
The value of permission –

444 are set the read only permission:-

7                 :               rwx
0                 :               no permission
6                 :               rw
4                 :               r only
2                 :               write x

#chmod –
       This command is used to set permission of the file.

Example –
               Chmod   700   filename
               7 for owner
               0 for group owner
               0 for every one

#chown –
      This command is used to set the permission for the owner.

Example –
            #chown   root   filename

Syntax:-
        Chown command for change owner ship root presented owner.

#chown   ram: ram   name.conf

We can set the permissions by using chmod command. For example, for setting the permissions as above us can run the following command:

#chmod   764   file1

We can use the following example to find any type of permission, we want to set.


Saturday, May 12, 2012

LINUX XEN – VIRTUALIZATION


What is Virtualization? –
                       A functional Red Hat Virtualization system is multilayer and is driven by the privileged Red Hat Virtualization component. Red Hat Virtualization can host multiple guest operating systems. Each guest operating system runs in its own domain, Red Hat Virtualization schedules virtual CPU's within the virtual machines to make the best use of the available physical CPU's. Each guest operating systems handles its own applications. These guest operating systems schedule each application accordingly. 

You can deploy Red Hat Virtualization in one of two choices:

full virtualization or Para virtualization. Full virtualization provides total abstraction of the underlying physical system and creates a new virtual system in which the guest operating systems can run. No modifications are needed in the guest OS or application (the guest OS or application is not aware of the virtualized environment and runs normally). Para virtualization requires user modification of the guest operating systems that run on the virtual machines (these guest operating systems are aware that they are running on a virtual machine) and provide near-native performance. You can deploy both Para virtualization and full virtualization across your virtualization infrastructure.

For create a Virtual machine -

STEP 1 –
      At 1st we should install required RPMs.

#yum   groupinstall   Virtualization

#yum   install   xen

#yum   install   nfs-utils-1.1.3.-1 .i386. rpm

#yum   install   portmap-4.0-57. i386 .rpm

#yum   install   nfslock-1.1.3 -2 .i386 .rpm

STEP 2 –
         Now create a partition or a directory in (/) partition.

#mkdir   virt

STEP 3 –
        Now share the directory through NFS where your linux cd is copied.

#vi   /etc/exports

/var/ftp/pub/  *  (rw,sync)

Note –

      Pub is a directory where my CD is copied.

STEP 4 –
              Now run the following commands to make sure that the file you edit and going to share is correct or not…
#exportfs –a

#exportfs –r

#exportfs –u

#exportfs –v
             It will show what is share…
Note –
  • a for allow the shared document on the network
  • r for refresh the new shared directory
  • u for show the share directory
 
STEP 5 –
        Now restart the services

#Service   network   restart

#Service   portmap   restart

#Service   nfs   restart

#Service   nfslock   restart

#Service   iptables   stop

STEP 6 –
       Now restart the computer. You will find 3 Operating systems boot loader.



1-    Redhat Enterprise Linux – 5 (xen)

2-    Redhat Enterprise Linux – 5

3-    Other

Choose 1st loader and boot the system (Redhat Enterprise Linux – 5)

STEP 7 –
         Open graphic mode and follow following links.



Click at main menu ------- system ------------ virtual machine.



Now connect the local machine.

And right click on the upper machine. You will find New.

Click that option and get ready for create a virtual machine.

STEP 8 –

1-    Creating a new virtual system. (click next)

2-    Naming your virtual system. (guest machine) (click next)

3-    Choosing the virtualization method.

A – Paravirtualization –
                         Paravirtualization is lightweight method of virtualizing machine. Red Hat Virtualization's paravirtualization mode allows you to utilize high performance virtualization on architectures that are potentially difficult to virtualize such as x86 based systems. To deploy Para virtualization across your operating system(s), you need access to the Para virtual guest kernels that are available from a respective Red Hat distros (for example, RHEL 4.0, RHEL 5.0, etc.). Whilst your operating system kernels must support Red Hat Virtualization, it is not necessary to modify user applications or libraries.

B – Fully Virtualization –

                      In the fully virtualization, allowing for a greater range of operating system (does not require operating system specification) it is slower than Para – virtualization.

4-    Choose 1st option of virtualizing (Para virtualization). And click next.

5-    locating installation media

A – Install media URL – nfs://192.168.0.5/var/ftp/pub

B – Kick start - ______________

C – Kernel Para meters - __________________

    Choose one of them installation media. If you want to install operating system through NFS choose 1st option for installation media.

6-    Assigning disk storage space

    A – Normal disk partition (i.e. - /dev/hda6)

    B – Simple file (i.e. - /virt)

Choose one of them and click next. If you don’t have new partition on your disk choose 2nd option.



      7– Define here the file size. (10000MB)

      8- Now share the host machine’s hardware. Choose 2nd option (shared physical device) and click next.

       9- Allocate the memory and CPU.

Click next and then finish. And start installation.




             

  •   After starting installation choose nfs image for Install new machine.


  • Enable IPv4 and manually configure the IP for new machine.
                                  

  • Now named of NFS server name and directory which has your shared.
  • Click OK and next and get ready for install new virtual machine.


Friday, February 17, 2012

DISK QUOTA AND DISK PARTITION


What is Disk quota? –
               A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems. The function of using disk quotas is to allocate limited disk space in a reasonable way. Quotas are used to manage storage in distributed environments. Disk quotas are abilities to manage and limit disk resources to those who abuse the system in the form of storage facility.
Disk quotas allow you to monitor the amount of disk space left against the limit assigned to individual users or groups. Disk quotas can be controlled by per volume, per user and per group. If you suspect that a particular user is using disk space to download files from the Internet and is consuming a considerable amount of space… limit their space with quotas.

About Partition – 

Hard disk partitions: The disk available, now a days, are quite large. Partitions help us manage the disks easily. Also they help protect our system. Linux is organized into directories. We can mount different directories on different partitions.

Partition types: There are four ways of partitioning a hard disk-

Primary partition: We can have up to 4 different primary partitions on a single hard disk. One of these partitions should be marked as active, to boot the O.S. from. This partition can have the boot loader, such as LILO (Linux Loader) or GRUB (Grand Unified Boot Loader).

Extended partition: If the above four partitions are not just enough, then we can convert any of the primary partition into Extended partition. We can then subdivide this partition into multiple logical partitions, as we require. We cannot use extended partition directly i.e. we cannot mount a directory on it.

Logical partition: We use the extended partition by making logical partitions. Logical partitions are volumes or in Microsoft terms, these are the logical drives.

Swap partition: The swap partition is an exclusive are on the hard disk, which is used as virtual memory. Swap is not the different type of partition, but we can mount swap either on the primary or on the logical partition itself. Recommended size of swap partition is twice the amount of installed RAM.

Partition names: The first two letters of the disk name tell about the kind of disk we are using. For IDE hard disks the letters are hd and for SCSI or SATA disks the letters are sd.

The third letter tells the disk’s position on motherboard. For IDE or SATA it is as under:

1- Primary Master a                2- Primary Slave b
3- Secondary Master c             3- Secondary Slave d

And for SCSI, disks letters correspond to their designated ID numbers. For example

1- SCSI with ID 0 a                 2- SCSI with ID 1 b

Naming of CD and DVD drives has also been, categorized as the hard disk drives.

The fourth letter tells the type and position of the partition on hard disk. The primary partitions have numbers reserved as 1, 2, 3 and 4. The logical partitions get their numbers 5 onwards. Even if we have only one primary partition, the first logical partition will get its position number 5 only.

Typical partition names –

Name and details –

/dev/hdb2 the second primary partition on the hard disk on primary slave
/dev/hda8 the fourth logical partition on hard disk on primary master
/dev/sda1 the first primary partition on first SCSI disk or primary master SATA
/dev/hdc as this has no number; it means it is secondary master CD or DVD on IDE controller.

Red Hat Linux file system – 

File system of any operating system used to be the structure, in which all the information on our system is stored. The file system is organized in hierarchy of directories, which may contain files or the subdirectories as well. These file system types determine how the information can be stored as files or as directory. In Linux there are following types file system, which we generally use: ext3, swap, LVM and RAID.

Linux file system structure – 

Red Hat Linux organizes file into directories. The standard directories are as follows…
/ - This is top level root directory. The remaining directories are kept below this root (/) directory, i.e. these are subdirectories of root directory.
Note: / is different from root. Both are pronounced as root, but former is directory while later is a user with administrative privileges.
/root: This is the home directory for root user (administrator).
/home: This directory is place for keeping all the user’s home directories except root user.
/dev: This directory will list all available device drivers.
/mnt: It contains the mount points of removable media, like /mnt/cdrecorder
/etc: It contains the basic Linux configuration files related to passwords, X window and daemons etc.
/boot: It stores the file and commands to boot Linux on our system.
/bin: It has all the basic command line utilities.
/lib: It lists program libraries, which may be needed by different applications or Linux kernel.
/proc: It includes the kernel related processes which are running currently.
/initrd: It configures one empty directory which is used by Initial RAM disk during boot. We should not delete this directory; else we will not be able to boot the Linux system.
/sbin: It contains commands for system administration.
/var: It contains log file and print spools etc.
/usr: It contains programs and data which is available to all the users.

Assigning Quota on Linux – 

STEP 1 –
       At 1st see the information about the disk partition and disk space…
#fdisk   -l
The above command is used for the getting information about the disk partition and disk space detail in linux operating system.

STEP 2 –
        Then create a new partition on the disk. The methods of creating new partition in linux are following –

Steps in creating a new partition – 

1. Install a fresh hard disk in the system.
2. Boot the system from already installed Red Hat Linux.
3. As root user, type the following command to check whether new disk has been detected.


# dmesg | less
                    
                  In the output of this command, check for the device name. If the hard disk added was second SATA, then we should see something like sdb: Or, you can run the command.

# fdisk –l

             Some where near the end of its output you should see a line like.
Disk /dev/sda doesn’t contain a valid partition table.

4. Now since you have come to the device name for this hard disk, you can run the following command to open up this hard disk:

# fdisk /dev/sda

If it is a completely new hard disk, you will see a message telling that this hard disk does not contain a valid partition table, as we saw in the previous command. If it doesn’t show it, this will mean that it is old hard disk.

5. We can get help of all the commands which can be used here. For these just press m on the prompt like Command (m for help):

6. To create new partition type n, as follows.
Command (m for help)
Command (n for new partition): n

7. Here you will be asked to choose primary or extended partition. To choose for primary partition, type the following:

Command action –
Extended primary partition (1-4): p

8. Now you will be asked for the partition number. If you are creating first partition, type one:

Partition number (1-4): 1

9. Now you will have to tell the cylinder number. Here just press ENTER, to accept default, or specify the desired number:

First cylinder (1-4865, default 6): 6

10. Lastly, either define the last cylinder, if you know, else define the space in MB. Default is last cylinder to use entire hard disk.

Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): +5000M

11. Repeat the previous five steps to create more partitions on the disk.
12. Save changes to the disk using w, this will send you back to the shell.
13. At this point of time, to make the changes effective, just restart the system. Instead of restarting the system, you can run the partprobe command as well.

# Partprobe – (#partprobe   /dev/sda)  

14. Now we will have to make the file system on this partition, i.e. format the partition. To create an ext3 file system on the first partition of this disk, type the following:

# mkfs -t ext3 /dev/sda6 (6 – the partition number)

Alternatively, if you are formatting a partition for Linux swap space, you can use mkswap command, e.g. if you want to setup /dev/sdb2 as swap partition, you can run the following command:

#mkfs.ext3   /dev/sda6            or                #mkfs   -t   ext3   /dev/sda6

16. To use the partition for quota or general use just created, make a directory to mount on it.

# mkdir /quota

STEP 3 –
             Now for assigning the quota on the created partition; use following command –
#quotaoff   /quota     (/quota – is a directory on which you are going to mount it)

STEP 4 –
           Now mount the created partition at the created directory.
For temporary mounting method

#mount   /dev/sda6   /quota

For permanent mounting method
For mount the partition permanently edit the following lines in fstab file.

# vi /etc/fstab
And now edit following lines in the last of the file-

/dev/sda6
/quota
ext3
Defaults,userquota,grpquota
  1  2

STEP 5 –
         For active the partition run the following command in the terminal-
#mount   -a

And then remount the partition for assigning the quota successfully. Run the following command in the terminal.
#mount   -o   remount   /quota

STEP 6 –
           And the checking about the quota runs the following command.
#quotacheck   -ucg   /quota
(Here you will find every thing is okay)
And then run the following command for make on the quota.
#quotaon   /quota          (/quota – is a directory on which the disk partition is mounted)

STEP 7 –
          Now configure the quota for users and groups. Run following command.
#edquota   -u   ram (user name)

You will find a file after this command. Edit the file as you need…
Soft link for – warning level of quota
Hard link for – limit level of quota
(Note - you can configure quota limitation as the cylinder space or number of files for that user or group)

#edquota   -g   ajay (group name)

The above command is used for the assigning quota for the group…

STEP 8 –
      At last give the permission for quota.

#chmod   777   /quota     (777 are for – full permission of the directory and the /quota is the directory on which the partition is mounted…

Monday, January 9, 2012

ADVANCE SERVICES


Apply multiple IP on single interface – 
                                
#cd   /etc/sysconfig/network-scripts

#cp   ifcfg-etho   ifcfg-eth: 01

#vi  ifcfg-etho: 01

Now open ifcfg-eth: 01 for configure the second Ip for your LAN.

#vi   /etc/sysconfig/network-scripts/ifcfg-eth: 01




Change the ip and device name of the second file…