skip to main | skip to sidebar

Linux Tutorial for Beginners

Pages

  • Home
 
  • RSS
  • Twitter
Showing posts with label File system. Show all posts
Showing posts with label File system. Show all posts
Monday, January 23, 2012

Utilities for check current status of free space

Posted by Raju Gupta at 9:21 AM – 0 comments
 
Before using the fdisk or parted utilities to create or modify a partition, it’s Important to check currently available free space along with mounted filesystems. That process is made easy with the df and mount commands. The following example illustrates how the df command displays the total, used, and available free space on all currently mounted filesystems.

[root@server1 ~]# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/vda2 8063408 2158968 5494840 29% /
tmpfs 384576 0 384576 0% /dev/shm
/dev/vda1 495844 32140 438104 7% /boot
/dev/vda5 1007896 17716 938980 2% /home
/dev/sr0 2381288 2381288 0 100% /media

The second command, mount, lists the way each filesystem is formatted. In this case, examine the partition represented by device /dev/vda5 mounted with the ext4 file type on the /home directory. It separates the directories of regular users in a dedicated partition.
[root@server1 root]# mount
/dev/vda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/vda1 on /boot type ext4 (rw)
/dev/vda5 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/tmp on /tmp type none (rw,bind)
/var/tmp on /var/tmp type none (rw,bind)
/home on /home type none (rw,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sr0 on /media type iso9660 (ro)
[ Read More ]
Read more...

fdisk help options

Posted by Raju Gupta at 9:20 AM – 0 comments
 
The following screen output lists commands that show how to start the fdisk program, how to get help, and how to quit the program. The /dev/vda drive is associated with the first virtual drive on a KVM-based virtual machine. As other systems may be configured with different hard drive device files, you may need to check the output from the df and mount commands for clues.

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help):
There are a wide variety of commands associated with fdisk—and more if you run
the x command to access fdisk’s extra functionality.
[ Read More ]
Read more...

How to define File system?

Posted by Raju Gupta at 9:19 AM – 0 comments
 

Filesystem

Everything in Linux can be reduced to a file. Partitions are associated with filesystem device nodes such as /dev/sda1. Hardware components are associated with node files such as /dev/dvd. Detected devices are documented as files in the /proc directory. The Filesystem Hierarchy Standard (FHS) is the official way to organize files in Unix and Linux directories. As with the other sections, this introduction provides only the most basic overview of the FHS. More information is available from the official FHS home page at www.pathname.com/fhs.
There are several major directories are associated with all modern Unix/Linux operating systems. Files, drivers, kernels, logs, programs, utilities, and more are organized in these directories. They way these components are organized on storage media is known as a filesystem. It’s based on the way the filesystem is formatted, and the directory where that filesystem is mounted. The FHS makes it easier for users of other Unix-based operating systems to understand the basics of Linux.
[ Read More ]
Read more...

Define the fdisk Utility

Posted by Raju Gupta at 9:18 AM – 0 comments
 
The fdisk utility is a near-universal tool available for a variety of computer operating systems. A capable version of fdisk is available on Macintosh OSes. A less capable version of fdisk is even available on older versions of Microsoft Windows. There are many commands within fdisk, more in expert mode, but you need to know only the few discussed here. Though you can modify the physical disk partition layout using many programs, this section explores the Linux implementation of fdisk. In contrast, the Microsoft version is based on its heritage as the Disk Operating System (DOS) and works only on Microsoft partitions.
[ Read More ]
Read more...

How to set permission in Linux

Posted by Raju Gupta at 5:20 AM – 0 comments
 
What is Permissions?
"Every file or folder in Linux has access permissions. There are three types of permissions "
  • Read access
  • Write access
  • Execute access
For File :--
  • Read access :-- Permission to read a file
  • Write access :-- Permission to write to a file
  • Execute access :-- Permission to execute a program
For Directory :--
  • Read access :-- Permission to list a directory's contents
  • Write access :-- Permission to create and remove files from a directory.
  • Execute access :-- Permission to change in to a directory and do a long listing of the directory.

Change file ownership :--
  • #chown for file
  • #chown -R for directory
Change Permissions –
Symbolic method :--
  • #chmod -R <mode> <file>
Mode
  • u,g,o for user, group, other
  • + or - for grant or deny.
  • r,w,x for read, write and execute.
Example:--
#chmod -R ugo +rwx <file name>
Numeric Method :--
Uses a three digit mode number.
  • First digit specifies owner's permission
  • Second digit specifies group permission
  • third digit specifies other's permission
Permission are calculated by adding
  • 4 (for read)
  • 2 (for write)
  • 1 (for execute)
Example
chmod 640 <file name>
[ Read More ]
Read more...

How to set permission for particular user (ACL)

Posted by Raju Gupta at 5:19 AM – 0 comments
 

ACCESS CONTROL LIST (ACL)

  • To set acl for user
#setfacl -m u:<username>:<permission> <file&folder name>
EX.
#setfacl -m u:root:rwx /home/raj
  • To check acl
#getfacl <file&folder name>
EX.
#getfacl /home/raj

  • To set acl for group
#setfacl -m g:<group name>:<permission> <file&folder name>
EX.
#setfacl -m g:root:rwx /home/raj
  • To remove acl
#setfacl -x u:<username> <file&folder>
EX.
#setfacl -x u:root /home/raj
#setfacl -x g:<group name> <file&folder name>
EX.
#setfacl -x g:root /home/raj
[ Read More ]
Read more...

How to manage user in linux

Posted by Raju Gupta at 5:05 AM – 0 comments
 
  • To add new user
#adduser <username>
#useradd <username>
EX.
#adduser text
#useradd text1

  • To set password for user
#passwd <username>
EX.
#passwd text
#passwd text1
  • Follow files are able to save user's information.

/etc/password
/etc/group
/etc/shadow
/etc/gshadow
Note : "default home directory will be /home/<username>"
  • vim /etc/shadow

  1. User name
  2. Encrypted Password
  3. Max Age
  4. Max Password age
Note : "This file stores the user's password and a/c & password ageing information"
  • vim /etc/passwd

  1. User name
  2. Link to shadow file for chacking password
  3. User id
  4. Group ID
  5. User description
  6. User home Directory
  7. User interface
Note : "This file stors the user's id no, group id no, home directory and shell prompt information."
  • vim /etc/group
cdrom : x : 24 : vivek, student13, raj
group_name : Password : Group ID(GID) : Group list.
Note : "This file stores only group releteated information"
  • To set defaults password and a/c policy for user & group

#vim /etc/login.defs
  • To change defaults home directory, shell, Skel for user

#vim /etc/default/useradd
  • Hidden file for create home directory

#vim /etc/skel
  • To change user's home director

#useradd -d <path> <username>

EX.

#useradd -d /text text
  • Do not create home directory

#useradd -m <username>

EX.

#useradd -m text
  • To delete user and user's releted all information

#userdel -r <user name>

EX.

#userdel -r text
  • To remove password for user

#passwd -d <username>

EX.

#passwd -d text
  • To chech password status

#passwd -s <username>
EX.
#passwd -s text
  • To lock user's a/c

#usermod -L <username>

EX.

#usermod -L text
  • To unlock user's a/c
#usermod -U <username>
EX.
#usermod -U text
  • To change user a/c and password age

#chage <username>
EX.

#chage text

  • To check age list

#chage -l <username>
EX.
#chage -l text
  • to change user's shell

#chsh -s <shell path> <username>

EX.

#chsh -s /bin/bash text
#chsh -s /sbin/nologin text
[ Read More ]
Read more...

How to manage Group in linux

Posted by Raju Gupta at 5:02 AM – 0 comments
 
  • To create group

#groupadd <username>
  • Group level

Group level : option : no of group
Primary Group : -g : single group
Secondary Group : -G : multiple group
  • To add new user in existing group

#adduser -g <primary grup> -G <secondary group> <username>
EX.
#adduser -g root -G claps raj

  • To check user's Group

#groups <username>
EX.
#groups text
  • To add existing user in existing group

#usermod -g <primary group> -G <secondary group> <usermane>
EX.
#usermod -g root -G claps raj
  • To delete group

#groupdel <groupname>
EX.
#groupdel claps
[ Read More ]
Read more...

how to define file system hierarchy

Posted by Raju Gupta at 4:55 AM – 0 comments
 
In this article, let us review the Linux filesystem structures and understand the meaning of individual high-level directories.
/ – Root
  • Every single file and directory starts from the root directory.
  • Only root user has write privilege under this directory.
  • Please note that /root is root user’s home directory, which is not same as /.
/bin – User Binaries
  • Contains binary executables.
  • Common linux commands you need to use in single-user modes are located under this directory.
  • Commands used by all the users of the system are located here.
  • For example: ps, ls, ping, grep, cp.
/sbin – System Binaries
  • Just like /bin, /sbin also contains binary executables.
  • But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose.
  • For example: iptables, reboot, fdisk, ifconfig, swapon


/etc – Configuration Files
  • Contains configuration files required by all programs.
  • This also contains startup and shutdown shell scripts used to start/stop individual programs.
  • For example: /etc/resolv.conf, /etc/logrotate.conf
/dev – Device Files
  • Contains device files.
  • These include terminal devices, usb, or any device attached to the system.
  • For example: /dev/tty1, /dev/usbmon0
/proc – Process Information
  • Contains information about system process.
  • This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.
  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime
/var – Variable Files
  • var stands for variable files.
  • Content of the files that are expected to grow can be found under this directory.
  • This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);
/tmp – Temporary Files
  • Directory that contains temporary files created by system and users.
  • Files under this directory are deleted when system is rebooted.
/usr – User Programs
  • Contains binaries, libraries, documentation, and source-code for second level programs.
  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
  • /usr/lib contains libraries for /usr/bin and /usr/sbin
  • /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2
/home – Home Directories
  • Home directories for all users to store their personal files.
  • For example: /home/john, /home/nikita
/boot – Boot Loader Files
  • Contains boot loader related files.
  • Kernel initrd, vmlinux, grub files are located under /boot
  • For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic
/lib – System Libraries
  • Contains library files that supports the binaries located under /bin and /sbin
  • Library filenames are either ld* or lib*.so.*
  • For example: ld-2.11.1.so, libncurses.so.5.7
/opt – Optional add-on Applications
  • opt stands for optional.
  • Contains add-on applications from individual vendors.
  • add-on applications should be installed under either /opt/ or /opt/ sub-directory.
/mnt – Mount Directory
  • Temporary mount directory where sysadmins can mount filesystems.
/media – Removable Media Devices
  • Temporary mount directory for removable devices.
  • For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer
/srv – Service Data
  • srv stands for service.
  • Contains server specific services related data.
  • For example, /srv/cvs contains CVS related data.
[ Read More ]
Read more...

create swap partition

Posted by Raju Gupta at 4:26 AM – 0 comments
 

Technical definition of swap space.

  • Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space.
  • Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

Some Basic information

  • Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
  • Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
So, if:
M = Amount of RAM in GB, and S = Amount of swap in GB, then
If M < 2
S = M *2
Else
S = M + 2
  • Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
  • For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM).
  • File systems and LVM2 volumes assigned as swap space cannot be in use when being modified. For example, no system processes can be assigned the swap space, as well as no amount of swap should be allocated and used by the kernel. Use the free and cat /proc/swapscommands to verify how much and where swap is in use.

Why swapping is Important ?

  • Swapping is necessary for two important reasons.:--
    • when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately.
    • a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

How to generat Swap File?

As well as the swap partition, Linux also supports a swap file that you can create, prepare, and mount in a fashion similar to that of a swap partition. The advantage of swap files is that you don't need to find an empty partition or repartition a disk to add additional swap space.

To create a swap file, use the dd command to create an empty file. To create a 1GB file, type:
 dd if=/dev/zero of=/swapfile bs=1024 count=1048576
/swapfile is the name of the swap file, and the count of 1048576 is the size in kilobytes (i.e. 1GB).

Prepare the swap file using mkswap just as you would a partition, but this time use the name of the swap file:
 mkswap /swapfile

And similarly, mount it using the swapon command: swapon /swapfile.
The /etc/fstab entry for a swap file would look like this:
/swapfile none swap sw 0 0
[ Read More ]
Read more...

ext3 vs ext4

Posted by Raju Gupta at 4:24 AM – 0 comments
 
Install any latest version of the kernel so that the ext4 patch can be applied to it.

yum -y install e4fsprogs

Then convert "/dev/sdb1" to EXT4 and run the following commands:

#cd /; umount /dev/sdb1
#tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
Next run fsck

#fsck -pf /dev/sdb1
Now, simply mount the partition that you have converted.

#mount -t ext4 /dec/sdb1 /
The following steps are for converting "/boot" to "ext4" :

1. First convert the "/boot" file system as the ext4 file system using the commands above and then open the Grub file and add "rootfstype=ext4" as the kernel parameter.
#mkinitrd --with=ext4 --with=ext3 -f /boot/initrd-2.6.18-194.3.1.el5.img 2.6.18-194.3.1
#tune4fs -O extents,uninit_bg,dir_index /dev/mapper/VolGroup00-LogVolRoot
* Need to use tune4fs on ext4 filesystems instead of tune2fs. This is
only needed for RHEL5.

2. Now, run the command to update Grub:

# update-grub

3. Next, update your "/etc/fstabe" file so that it can be mounted as an ext4 file system.
vi /etc/fstab
(change ext3 to ext4 for my / partition)

4. Than reboot the system.
[ Read More ]
Read more...
Older Posts
Subscribe to: Posts (Atom)

Our Blogs

  • Java Programs with Output
  • C Programming Tutorial
  • Language Tutorial
  • Android Development Tutorial
  • Web Development Tutorial
  • Popular
  • Recent
  • Archives

Popular Posts

  • Apache Configuration File Security Option
    you’ll examine the security options available in the main Apache configuration file, httpd.conf. That file can be modified to secure the e...
  • AWS VPC Overview
    What is VPC ? A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other vir...
  • Advantages & Disadvantages of Kerberos
    Advantages of Kerberos Most conventional network services use password-based authentication schemes. Such schemes require a user to au...
  • SSH login without password
    The following steps can be used to ssh from one system to another without specifying a password: 1. On the client run the following com...
  • Apache Installation and Configuration through source code
    In this example we extract the source code to a directory under /usr/local/src/ cp httpd-2.0.46.tar.gz /usr/local/src cd /usr/local/src...
  • How to automatically chroot jail selected ssh user logins
    1. Creating basic chroot environment First we need to create a simple chroot environment. Our chroot environment will consist of a bash she...
  • How to Create the Kerberos database
    Create the database with the following command.  [root@coma ~] kdb5_util create -s This will prompt you for a password. You will ...
  • Kerberos and PAM
    Kerberos-aware services do not currently make use of Pluggable Authentication Modules (PAM) — these services bypass PAM completely. However...
  • Apache and SELinux File Labels
    Take a look at the SELinux settings associated with Apache. To review, SELinux settings, as they relate to a service, mostly fall into tw...
  • History of MINIX 3
    MINIX has a long history. It goes back to 1987 when the first edition of the book Operating Systems: Design and Implementation by Andrew S...
Powered by Blogger.

Archives

  • ▼  2014 (1)
    • ▼  May (1)
      • AWS VPC Overview
  • ►  2013 (4)
    • ►  February (4)
  • ►  2012 (89)
    • ►  November (1)
    • ►  March (4)
    • ►  February (36)
    • ►  January (48)
 

Followers

Labels

  • Apache (8)
  • aws (1)
  • Bridge (1)
  • cloud computing (1)
  • Configuration (1)
  • dhcp server (7)
  • DNS (8)
  • File system (11)
  • Fping (1)
  • Iptable basic (3)
  • KDC slave server (1)
  • Kerberos (14)
  • kerberos configuration (5)
  • kerberos database (1)
  • LaTeX (1)
  • Ldap basic (2)
  • Linux aliases (1)
  • Linux Commands (4)
  • Linux History (2)
  • Linux Installation (3)
  • Linux kernel (3)
  • Linux shell (2)
  • Linux software (2)
  • Lvm (1)
  • Mail Server (3)
  • Network Script (1)
  • PHP (1)
  • Raid (6)
  • SELinux (1)
  • Sendmail (3)
  • ssh (2)
  • Tcpdump example (1)
  • Virtualization (5)
  • Webmin (1)
  • Yum (2)
 
 
© 2011 Linux Tutorial for Beginners | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger