LINUX DAY WISE SCHEDULE

Similar documents
RG-MACC_2.0 Installation Manual

EX200.redhat

EX200.Lead2pass.Exam.24q. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator RHCSA. Version 14.0

Seltestengine EX200 24q

EX200.exam.35q. Number: EX200 Passing Score: 800 Time Limit: 120 min. EX200. Red Hat Certified System Administrator RHCSA

Exam Name: Red Hat Certified Engineer on Redhat

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Red Hat.Actualtests.EX200.v by.Dixon.22q. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator (RHCSA) Exam

Vendor: RedHat. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator - RHCSA. Version: Demo

EX200 EX200. Red Hat Certified System Administrator RHCSA

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Linux Administration

RH202. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs) Exam.

Testpassport.

Back Up (And Restore) LVM Partitions With LVM Snapshots

RG-MACC-BASE_v2.01. Installation Guide

example.com index.html # vim /etc/httpd/conf/httpd.conf NameVirtualHost :80 <VirtualHost :80> DocumentRoot /var/www/html/

Braindumps EX200 15q

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

RH133. Red Hat Linux System Administration

NETW 110 Lab 5 Creating and Assigning Users and Groups Page 1

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

Exam Questions RH202

An introduction to Logical Volume Management

Please choose the best answer. More than one answer might be true, but choose the one that is best.

Chapter 5: User Management. Chapter 5 User Management

Changing user login password on templates

How to add additional disks to XenServer host

TestOut Linux Pro - English 4.0.x OBJECTIVE MAPPING: CompTIA Linux+ LX0-103

RH-202. RedHat. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs)

Stop all processes and then reboot - same as above startx. Log in as superuser from current login exit

File systems and Filesystem quota

Accurate study guides, High passing rate! IT TEST BOOK QUESTION & ANSWER. Ittestbook provides update free of charge in one year!

Manage your disk space... for free :)

Cloning and Repartitioning sessionmgr Disks

Linux Essentials Objectives Topics:

How To Resize ext3 Partitions Without Losing Data

This section describes the procedures needed to add a new disk to a VM. vmkfstools -c 4g /vmfs/volumes/datastore_name/vmname/xxxx.

Computer Systems and Architecture

How to clone a Linux box using netcat

RedHat. Rh202. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs)

Chapter 6. Linux File System

Exam Questions RH133

7. Try shrinking / -- what happens? Why? Cannot shrink the volume since we can not umount the / logical volume.

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Redhat Basic. Need. Your. What. Operation G U I D E. Technical Hand Note template version

Lab on User administration

CIS UNIX System Administration

Course 144 Supplementary Materials. UNIX Fundamentals

"Charting the Course... MOC B: Linux System Administration. Course Summary

SA2 v6 Linux System Administration II Net Configuration, Software, Troubleshooting

Let us ping! First we will learn the Hello World of a networked machine.

How to increase XenServer virtual machine root or swap partition

Exam LFCS/Course 55187B Linux System Administration

Computer Systems and Architecture

LPIC-1 System Administrator

At course completion. Overview. Audience profile. Course Outline. : 55187B: Linux System Administration. Course Outline :: 55187B::

Presented by Bill Genske Gary Jackson

Installation of RHEL/CentOS/ 6 updates for Servers & Desktops

client X11 Linux workstation

Course 55187B Linux System Administration

Linux Nuts and Bolts

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

SCSI RDMA Protocol. Introduction. Configuring SRP CHAPTER

Disks, Filesystems, Booting Todd Kelley CST8177 Todd Kelley 1

CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

Disks, Filesystems Todd Kelley CST8177 Todd Kelley 1

UNIX. Basic UNIX Command

Linux Howtos. Fedora 9 Install (114) CIS Fall Fedora 9 Install (114) Fedora 9 installation with custom partitions.

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Linux Reference Card - Command Summary

UNIVERSITY OF BOLTON CREATIVE TECHNOLOGIES. BSc (Hons) COMPUTER NETWORKS AND SECURITY SEMESTER ONE EXAMINATION 2014/2015 UNIX MODULE NO: CPU5003

Outline. Structure of a UNIX command

Linux Command Line Primer. By: Scott Marshall

FastTrack to Red Hat Linux System Administrator Course Overview

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CompTIA Linux Course Overview. Prerequisites/Audience. Course Outline. Exam Code: XK0-002 Course Length: 5 Days

Linux System Administration, level 1. Lecture 4: Partitioning and Filesystems Part II: Tools & Methods

Getting Started with Pentaho and Cloudera QuickStart VM

Introduction to the UNIX command line

These documents and software are covered under the terms and conditions of the fp Technologies, Inc. Program License Agreement

Linux Systems Administration Getting Started with Linux

1. Set up the storage to allow access to the LD(s) by the server following the NEC storage user guides.

Prerequisites: General computing knowledge and experience. No prior knowledge with Linux is required. Supported Distributions:

Installing caos with Cinch on Floppy Disk

Linux Kung-Fu. James Droste UBNetDef Fall 2016

System Administration and Networking

User accounts and authorization

Exam Questions RH302

Topics. Installation Basics of Using GNU/ Linux Administration Tools

1.3 What does Ctrl-D, Ctrl-A, Ctrl-F and Ctrl-T do in terms of command line editing? (6)

CSN09101 Networked Services. Module Leader: Dr Gordon Russell Lecturers: G. Russell

Create Test Environment

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

LAB #7 Linux Tutorial

Introduction to Unix May 24, 2008

"Charting the Course... Enterprise Linux System Administration Course Summary

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Once your USB drive is formatted for the FAT32 file system it can be mounted and tested on the GESBC To do this, use the following command:

Transcription:

1

SYSTEM ADMINSITRATION LINUX DAY WISE SCHEDULE DAY 1 Introduction to Linux with Installation DAY 2 Basic Commands Part 1 DAY 3 DAY 4 DAY 5 DAY 6 DAY 7 DAY 8 DAY 9 DAY 10 DAY 11 DAY 12 DAY 13 Basic Commands Part II, Vi Editor User Administration Group Administration, Basic file permissions Partitions Part I Partitions Part II User, Group Quota & ACL RAID, Links LVM, Advance file permissions Backup, crontab, at Boot Process RPMS & YUM 2

NETWORK ADMINISTRATION DAY 14 DAY 15 DAY 16 DAY 17 DAY 18 DAY 19 DAY 20 DAY 21 DAY 22 DAY 23 DAY 24 DAY 25 DAY 26 Introduction to Networking NFS FTP SAMBA DNS Part I DNS Part II Web Server Part I Web Server Part II + Proxy MAIL NIS, DHCP Trouble Shooting Kickstart, Webmin, Virtualization, Iptables Selinux, Ldap, Live setup 3

Topics System Administration 1. Linux Installation Guide 06 2. Basic Commands 10 3. VI 15 4. Users and Group Administration 17 5. Permissions 21 6. Partitions 23 7. User and Group Quotas 27 8. Access Control List 30 9. Advanced file permissions 32 10. Link 36 11. RAID 39 12. Logical Volume Manager 41 13. Backups 48 14. Boot Process Practicals 52 15. Installation of packages through RPM and yum 53 4

Server Administration 1. Introduction to networking 55 2. NFS 59 3. FTP 62 4. Samba 65 5. DNS 69 6. APACHE web Server 77 7. Squid Proxy Server 82 8. Mail Server 85 9. NIS Server 89 10. DHCP Server 93 11. Troubleshooting 95 12. Webmin 98 13. Kickstart 99 14. iptables 102 15. SELinux 104 16. Virtualization 106 17. LDAP 108 18. Comparision between Fedora and Ubuntu 112 19. Comparision between Fedora and Suse 116 20. Comparision between Fedora and Solaris 120 21. Installation of Oracle 10g on linux 124 5

To Install linux follow following steps: - Linux Installation Guide To start the installation from DVD/CD set the BIOS to boot from CDROM This installation guide is to install Linux without any other o/s in the present Hard disk [ clean hard disk ] where the existing partitions will be overwritten. Installtion Can be done in to methods (1) Gui Mode (2) Text Mode Insert the first CD and restart the system Press Enter to Start Installation in GUI mode boot: press Enter Or Type linux text to start installation in text mode boot : linux text NEXT To do a media check select ok and press enter To skip it select skip and press enter NEXT Select Language English NEXT Select KeyBoard US English NEXT For Full installtion provide Installation Key Or Skip Note: If installation key is not selected then virtualization or Clustering will be not supported. 6

NEXT Create the Required Partition on this screen. Select Custom Layout and delete all partitions if any. Create 6 partitions. /boot = 100MB / = 2000MB /usr /var = 4000MB = 1000MB /home = 1000MB SWAP = 2 X RAM To check RAM size use Ctrl-Alt-F2 and use the free command # free To get back to the GUI interface use Ctrl-Alt-F6 NEXT Boot Loader Screen Simply select Next NEXT Select Network Devices go for Edit Select DHCP or manually provide IP Address For eg: 192.168.0.1/255.255.255.0 HostName: Station1.zoom.com Gateway 192.168.0.254 DNS 192.168.0.1 NEXT Select Time Zone 7

Asia/Calcutta NEXT Enter The Password for Root User Eg : abc123 NEXT Select the Softwares to be installed Desktop Environments GNOME Desktop Environment Application Editors Graphicle Internet Text based Internet Base Systems Select All Note : Remaining Packges can be selected even after Installation. Click Next to begin Installation NEXT After the completion of Installation Reboot After Reboot You will get Welcome Screen Select The License Agreement Check mark Yes, I agree to the License Agreement Forward Disable the Firewall. Click on Forward on confirmation click on Yes. Forward Disable the SELinux. Click on Forward on confirmation click on Yes Kdump Not Required simply uncheck Forward 8

Forward Set Date & time for system Asia/calcutta Forward Set Up Software updates Forward Finesh Updates Setup Forward Create Users Click on Continue to avoid creating normal users. Sound Card Forward Forward To Install additional Softwared Insert Installation CDs Forward Now the installation is comlpeted On the Login Screen provide => Username Password root abc123 Explore the Linux Operating System 9

Basic Commands 1. To check the present working directory [root@server ~]# pwd Example [root@server ~]# pwd /root 2. To show the contents of a directory (folder) [root@server ~]# ls Example [root@server ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog 3. To see more details including the permission regarding the contents of a directory (folder) [root@server ~]# ls -l Example [root@server ~]# ls -l total 76 -rw-r--r-- 1 root root 1049 Apr 2 2007 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Mar 14 20:13 Desktop -rw-r--r-- 1 root root 46871 Apr 2 2007 install.log -rw-r--r-- 1 root root 5175 Apr 2 2007 install.log.syslog [root@server ~]# ll total 76 -rw-r--r-- 1 root root 1049 Apr 2 2007 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Mar 14 20:13 Desktop -rw-r--r-- 1 root root 46871 Apr 2 2007 install.log -rw-r--r-- 1 root root 5175 Apr 2 2007 install.log.syslog 3. To see all contents including hidden files of a directory (folder) [root@server ~]# ls -a Example [root@server ~]# ls -a 10

..camel_certs.esd_auth.gnome2_private.metacity.tcshrc...config.evolution.gstreamer-0.8.mozilla.thumbnails anaconda-ks.cfg.cshrc.fonts.cache-1.gtkrc.nautilus.trash.bash_history Desktop.gconf.gtkrc-1.2-gnome2.recentlyused.viminfo.bash_logout.dmrc.gconfd.ICEauthority.rhnapplet.conf.Xauthority.bash_profile.eggcups.gnome install.log.rnd.bashrc.elinks.gnome2 install.log.syslog.ssh 4. To see tree structure of nested directories [root@server ~]# ls -R /opt /opt: zoom /opt/zoom: zooma /opt/zoom/zooma: zoomb /opt/zoom/zooma/zoomb: zooms /opt/zoom/zooma/zoomb/zooms: To see a file starting from f [root@server ~]# ls f* To see a file have a middle string as disk [root@server ~]# ls /bin/*disk* To see a file whose length is 3 charaters [root@server ~]# ls??? To see a file which starts with single char & ends up with any number of character [root@server ~]# ls?edh* 5. To create a file [root@server ~]# cat > file1 hi how are you, how is your zoom 11

6. To see file content [root@server ~]# cat file1 hi how are you how is your zoom 7. To append a file [root@server ~]# cat >> file1 iam fine, it is very nice [root@server ~]# cat file1 file2 >> file3 [root@server ~]# cat file3 8. To create a file using touch command [root@server ~]# touch f1 f2 f3 f4 [root@server ~]# ls 9. Creating a single directory [root@server ~]# mkdir dir 10. Creating multiple directories [root@server ~]# mkdir dir1 dir2 dir3 dir4 [root@server ~]# ls anaconda-ks.cfg dir dir2 dir4 f2 f4 file2 install.log labmanual Desktop dir1 dir3 f1 f3 file1 file3 install.log.syslog 11. To create nested directories [root@server ~]# mkdir -p d1/d2/d3/d4 To see the tree structure [root@server ~]# ls -R d1 d1: d2 d1/d2: d3 d1/d2/d3: d4 d1/d2/d3/d4: [root@server ~]# 12

12. To change a directory [root@server ~]# cd dir1 [root@server dir1]# cd.. [root@server ~]# cd../.. [root@server /]# cd - /root [root@server ~]# pwd /root [root@server ~]# cd [root@server ~]# pwd /root [root@server ~]# 13. To remove files [root@server ~]# rm file1 rm: remove regular file `file1'? y 14. To remove an empty directory [root@server ~]# rmdir dir1 [root@server ~]# ls anaconda-ks.cfg Desktop dir2 dir4 f2 f4 file3 install.log.syslog d1 dir dir3 f1 f3 file2 install.log labmanual 15. To remove a directory [root@server ~]# rm -rf dir [root@server ~]# ls anaconda-ks.cfg Desktop dir3 f1 f3 file2 install.log labmanual d1 dir2 dir4 f2 f4 file3 install.log.syslog To copy files [root@server ~]# cp anaconda-ks.cfg file1 To copy folders [root@server ~]# cp -r dir2 Desktop To rename directories and files [root@server ~]# mv dir3 d4 13

[root@server ~]# ls anaconda-ks.cfg d4 dir2 f1 f3 file1 file3 install.log.syslog d1 Desktop dir4 f2 f4 file2 install.log labmanual To move directories and files [root@server ~]# mv dir2 /opt [root@server ~]# ls anaconda-ks.cfg d4 dir4 f2 f4 file2 install.log labmanual d1 Desktop f1 f3 file1 file3 install.log.syslog [root@server ~]# cd /opt [root@server opt]# ls dir2 zoom To search a word from single or multiple file s [root@server ~]# grep tom /etc/passwd /etc/group /etc/gshadow /etc/passwd:tom:x:500:500::/home/tom:/bin/bash /etc/group:tom:x:500: /etc/gshadow:tom:!:: [root@server ~]# cat /etc/passwd grep tom To see the type of file [root@server ~]# file * To view the date [root@server ~]# date [root@server ~]# date -s "07/15/2008 00:06:00 " mm/dd/yyyy hh:mm:ss Tue Jul 15 00:06:00 EDT 2008 [root@server ~]# cal [root@server ~]# cal 12 2008 [root@server ~]# man mkdir [root@server ~]# man cal To see the content screen wise [root@server ~]# ls -l /bin less 14

Visual Interface Commands to Go into Insert mode To open a file use vi <filename> e.g. # vi test.txt i I a A o O r - inserts the text at current cursor position - inserts the text at beginning of line - appends the text after current cursor position - appends the text at end of line - inserts a line below current cursor position - inserts a line above current cursor position - replace a single char at current cursor position Commands at execute mode :q - quit without saving :q! - quit forcefully without saving :w - save :wq - save & quit :wq! - save & quit forcefully :x - save & quit :sh - Provides temporary shell :se nu - Setting line numbers :se nonu - Removing line numbers :84 - Press enter goes to line 84 To move the cursor, press the h,j,k,l keys as indicated. ^ k Hint: The h key is at the left and moves left. < h l > The l key is at the right and moves right. j The j key looks like a down arrow v w forward word to word b back side word to word Command's at command mode dd 2dd yy 2yy p u Ctrl+r G 5G - Deletes a line - Deletes 2 lines - Copy a line - Copies 2 lines - put (deleted or copied text) - Undo (can undo 1000 times) - Redo - Moves cursor to last line of file - Moves cursor to 5th line of file 15

Shift+ZZ - save & quit /<findword> - locate word To find and replace words :1,$s/<findword>/<replaceword>/gc e.g. :1,$s/world/universe/gc 1-- To start the search at from 1st line $ -> End of File s -> substitute g -> global c -> confirmation 16

User's & Group's Administration Scenario There are two groups : 1)salesgrp : salesgrp ID=2000 Sales users should exist in salesgrp 2)fingrp :fingrp ID=3000 Finance users should exist in fingrp tom joy Now create the users with following parameters: ali u - 2001 tom c - "Mang of Sales Dept" ram d - /salesdept shyam s - /bin/ksh joy g - salesgrp/2000 Create user abdul with following parameters u - 2002 c - "Director of Sales Dept" d - /salesdept s - /bin/csh g - salesgrp/2000 G - fingrp,mrkgrp Create a user ali whose user id is 2001 [root@server~]# useradd -u 2001 ali [root@server~]# grep ali /etc/passwd Create a user tom whose comment is "Mang of Sales Dept" [root@server~]# useradd -c "Mang of Sales Dept" tom [root@server~]# grep tom /etc/passwd Create a user ram whose home directory exist in /salesdept folder [root@server~]# mkdir /salesdept [root@server~]# useradd -d /salesdept/ram ram [root@server~]# grep ram /etc/passwd 17

Create a user shyam whose shell is ksh [root@server~]# cat /etc/shells [root@server~]# useradd -s /bin/ksh shyam [root@server~]# grep shyam /etc/passwd Create a user joy/jack whose primary group id is 2000/salesgrp [root@server~]# groupadd -g 2000 salesgrp [root@server~]# grep salesgrp /etc/group [root@server~]# useradd -g 2000 joy or [root@server~]# useradd -g salesgrp jack [root@server~]# grep 2000 /etc/passwd Create a user abdul with all parameters as in scenario [root@server~]# useradd -u 2000 -g salesgrp -c "Director of Sales Dept" -d /salesdept/abdul -s /bin/csh abdul [root@server~]# grep abdul /etc/passwd abdul:x:2000:2000:director of Sales Dept:/salesdept/abdul:/bin/csh To Modify the parameter of existing user abdul [root@server ~]# usermod -u 3000 -g fingrp -c "Mang of fin Dept" -d /findept/abdul -m -s /bin/ksh abdul [root@server ~]# grep abdul /etc/passwd abdul:x:3000:3000:mang of fin Dept:/findept/abdul:/bin/ksh [root@server ~]# useradd scott [root@server ~]# grep scott /etc/passwd scott:x:3001:3001::/home/scott:/bin/bash To change login name [root@server ~]# usermod -l tiger scott [root@server ~]# grep tiger /etc/passwd tiger:x:3001:3001::/home/scott:/bin/bash To lock the Account [root@server ~]# passwd tom [root@server ~]# usermod -L tom 18

login & check To Unlock the Account [root@server ~]# usermod -U tom login & check To delete only users account but not home directory & mail account. [root@server ~]# userdel tom [root@server ~]# ls /home To delete users account along with home directory & mail account. [root@server ~]# userdel -r tom [root@server ~]# ls /home Adding groups Adding a new group [root@server ~]# groupadd amerpetgrp [root@server ~]# grep amerpet /etc/group amerpetgrp:x:3002: adding a new group with gid 5000 [root@server ~]# groupadd -g 5000 banjaragrp [root@server ~]# grep banjaragrp /etc/group banjaragrp:x:5000: modifying group with gid [root@server ~]# groupmod -g 6000 banjaragrp [root@server ~]# grep banjaragrp /etc/group banjaragrp:x:6000: Changing the name of a existing group [root@server ~]# groupmod -n banjarahills banjaragrp [root@server ~]# grep banjarahills /etc/group banjarahills:x:6000: [root@server ~]# groupdel banjarahills 19

[root@server ~]# grep banjarahills /etc/group [root@server ~]# useradd jack [root@server ~]# useradd shyam [root@server ~]# useradd wiliam [root@server ~]# gpasswd -M jack,shyam,wiliam salesgrp [root@server ~]# grep salesgrp /etc/group salesgrp:x:2000:jack,shyam,wiliam Removing user wiliam from group salesgrp [root@server ~]# gpasswd -d wiliam salesgrp [root@server ~]# grep salesgrp /etc/group salesgrp:x:2000:jack,shyam Adding user wiliam to group salesgrp [root@server ~]# gpasswd -a wiliam salesgrp [root@server ~]# grep salesgrp /etc/group salesgrp:x:2000:jack,shyam,wiliam [root@server ~]# chage -l jack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^OUTPUT^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Last password change : Jul 14, 2008 Password expires : never Password inactive : never Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 99999 Number of days of warning before password expires : 7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [root@server ~]# system-config-users & 20

[root@server ~]# mkdir /myfolder [root@server ~]# cd /myfolder/ [root@server myfolder]# ls [root@server myfolder]# whoami root Permissions [root@server myfolder]# touch test_file [root@server myfolder]# ls -ld test_file -rw-r--r-- 1 root root 0 Jul 13 00:06 test_file Set write permissions to the group only. [root@server myfolder]# chmod g+w test_file [root@server myfolder]# ls -ld test_file -rw-rw-r-- 1 root root 0 Jul 13 00:06 test_file Remove read permissions for others only. [root@server myfolder]# chmod o-r test_file [root@server myfolder]# ls -ld test_file -rw-rw---- 1 root root 0 Jul 13 00:06 test_file Assign read, write, execute permissions to others only. [root@server myfolder]# chmod o=rwx test_file [root@server myfolder]# ls -ld test_file -rw-rw-rwx 1 root root 0 Jul 13 00:06 test_file Assign execute permissions to owner, group and others also. [root@server myfolder]# chmod +x test_file [root@server myfolder]# ls -ld test_file -rwxrwxrwx 1 root root 0 Jul 13 00:06 test_file Remove execute permissions from owner, group and others also. [root@server myfolder]# chmod -x test_file 21

[root@server myfolder]# ls -ld test_file -rw-rw-rw- 1 root root 0 Jul 13 00:06 test_file [root@server myfolder]# chmod 644 test_file [root@server myfolder]# ls -ld test_file -rw-r--r-- 1 root root 0 Jul 13 00:06 test_file [root@server myfolder]# pwd /myfolder [root@server myfolder]# whoami root [root@server myfolder]# mkdir dir1 [root@server myfolder]# ls -ld dir1 drwxr-xr-x 2 root root 4096 Jul 13 01:28 dir1 [root@server myfolder]# [root@server myfolder]# chmod 777 /myfolder [root@server ~]# su - tom [tom@server ~]$ whoami tom [tom@server ~]$ [tom@server ~]$ pwd /home/tom [tom@server ~]$ ls -l total 0 [tom@server ~]$ touch myfile [tom@server ~]$ ls -l total 0 -rw-rw-r-- 1 tom tom 0 Jul 12 20:20 myfile [tom@server ~]$ mkdir dir1 [tom@server ~]$ ls -ld dir1 drwxrwxr-x 2 tom tom 4096 Jul 12 20:22 dir1 [tom@server ~]$ 22

Step 1 ) To Create the partitions [root@client1 ~]# fdisk -l [root@client1 ~]# fdisk /dev/hda Partitions Command (m for help): m d delete a partition m print this menu n add a new partition p print the partition table q quit without saving changes w write table to disk and exit Command (m for help): Command (m for help): n First cylinder (1098-2434, default 1098): Using default value 1098 Last cylinder or +size or +sizem or +sizek (1098-2434, default 2434): +100M Command (m for help): p Command (m for help): n Command (m for help): p Command (m for help): n Command (m for help): p Command (m for help): d Command (m for help): 10 #write the number of partition Command (m for help): w [root@client1 ~]# To update the kernel without restarting [root@client1 ~]# partprobe /dev/hda [root@client1 ~]# fdisk -l Step 2 ) Make the filesystem ( i.e format the partition) ext2, ext3, vfat [root@client1 ~]# mkfs.ext2 /dev/hda8 [root@client1 ~]# mkfs.ext3 /dev/hda9 [root@client1 ~]# mkfs.vfat /dev/hda10 23

Step 3 ) Create a folder & Mount the partition to use [root@client1 ~]# mkdir /mnt/song /mnt/video /mnt/music [root@client1 ~]# mount /dev/hda8 /mnt/song [root@client1 ~]# mount /dev/hda9 /mnt/video [root@client1 ~]# mount /dev/hda10 /mnt/music [root@client1 ~]# mount Step 4 ) Write the data inside the partition [root@client1 ~]# cd /mnt/song [root@client1 song]# [root@client1 song]# touch myfile1 myfile2 myfile3 [root@client1 song]# mkdir hyd sec bhills ameerpet [root@client1 song]# ls ***************** This is the output ******************** ameerpet bhills hyd lost+found myfile1 myfile2 myfile3 sec [root@client1 myfolder]# Converting from ext3 to ext2 [root@client1 ~]# umount /dev/hda8 [root@client1 ~]# tune2fs -O ^has_journal /dev/hda8 [root@client1 ~]# mount /dev/hda8 /myfolder/ [root@client1 ~]# mount Convert from ext2 to ext3 [root@client1 ~]# umount /dev/hda8 [root@client1 ~]# tune2fs -j /dev/hda8 [root@client1 ~]# mount /dev/hda8 /myfolder [root@client1 ~]# mount 24

Creating a Swap Partition Step 1 ) Create the required partition (say 9 partition) [root@client1 ~]# fdisk -l [root@client1 ~]# fdisk /dev/hda :p :n :t { to change the partition ID} :82 { for swap partition } :w { save & exit } [root@client1 ~]# [root@client1 ~]# partprobe /dev/hda [root@client1 ~]# fdisk l Step 2 ) Make the partition as swap [root@client1 ~]# mkswap /dev/hda9 To see the status [root@client1 ~]# swapon s To on the swap partition [root@client1 ~]# swapon /dev/hda9 Again see the status [root@client1 ~]# swapon -s To put Off the swap partition [root@client1 ~]# swapoff /dev/hda9 [root@client1 ~]# swapon s 25

LABELS To check the label [root@client1 ~]# e2label /dev/hda8 To assign the labels [root@client1 ~]# e2label /dev/hda8 linux [root@client1 ~]# e2label /dev/hda8 linux Permanent Mounting Mounting the partition /dev/hda9 parmanently [root@client1 ~]# vi /etc/fstab LABEL=linux /myfolder ext3 defaults 0 0 :wq [root@client1 ~]# mount [root@client1 ~]# mount -a [root@client1 ~]# mount Mounting the cdrom [root@client1 ~]# mkdir /media/cdrom [root@client1 ~]# mount /dev/cdrom /media/cdrom To see the disk space [root@client1 ~]# df -h To see the block size. [root@client1 ~]# blockdev --getbsz /dev/hda8 1024 [root@client1 ~]# blockdev --getbsz /dev/hda3 4096 26

Apply Quota on users & Group Create required users & Group [root@server ~]# useradd tom [root@server ~]# groupadd salesgrp [root@server ~]# groupadd fingrp [root@server ~]# mkdir /salesdept User and Group Quotas [root@server ~]# useradd -g salesgrp sai [root@server ~]# useradd -g salesgrp ram [root@server ~]# useradd -G fingrp tata [root@server ~]# useradd -G fingrp birla Step 1 ) Create a required partition [root@server ~]# fdisk -l [root@server ~]# fdisk /dev/hda :n :w [root@server ~]# partprobe /dev/hda [root@server ~]# mkdir /salesdept [root@server ~]# mkfs.ext3 /dev/hda9 Step 2) Mount the partition with user & group quota parameters. [root@server ~]# mount -o usrquota,grpquota /dev/hda9 /salesdept [root@server ~]# mount [root@server ~]# chmod 777 /salesdept/ Step 3 ) Create the Quota Database file [root@server ~]# quotacheck -cugv /salesdept/ [root@server ~]# ls /salesdept/ aquota.group aquota.user lost+found 27

Step 4) Check the quota Status [root@server ~]# quotaon -p /dev/hda9 group quota on /salesdept (/dev/hda9) is off user quota on /salesdept (/dev/hda9) is off Step 5 ) Enable the quota partition [root@server ~]# quotaon /dev/hda9 [root@server ~]# quotaon -p /dev/hda9 group quota on /salesdept (/dev/hda9) is on user quota on /salesdept (/dev/hda9) is on Step 6 ) Apply quota on a user tom [root@server ~]# edquota -u tom Disk quotas for user tom (uid 500): Filesystem blocks soft hard inodes soft hard /dev/hda9 0 0 0 0 3 5 :wq [root@server ~]# su - tom [tom@server ~]$ cd /salesdept/ [tom@server salesdept]$ ll [tom@server salesdept]$ touch tfa [tom@server salesdept]$ touch tfb [tom@server salesdept]$ touch tfc [tom@server salesdept]$ touch tfd hda9: warning, user file quota exceeded. [tom@server salesdept]$ mkdir tda [tom@server salesdept]$ mkdir tdb hda9: write failed, user file limit reached. mkdir: cannot create directory `tdb': Disk quota exceeded 28

Step 7 ) Apply quota on a group salesgrp who has primary members as sai & ram [root@server ~]# edquota -g salesgrp [root@server ~]# edquota -g salesgrp Disk quotas for group salesgrp (gid 501): Filesystem blocks soft hard inodes soft hard /dev/hda9 0 0 0 5 3 5 :wq! [root@server ~]# cd /salesdept/ [root@server salesdept]# su sai [sai@server salesdept]$ groups salesgrp [sai@server salesdept]$ touch sai1 sai2 sai3 [sai@server salesdept]$ exit exit [root@server salesdept]# su ram [ram@server salesdept]$ groups salesgrp [ram@server salesdept]$ touch ram1 hda9: warning, group file quota exceeded. [ram@server salesdept]$ touch ram3 [ram@server salesdept]$ touch ram4 hda9: write failed, group file limit reached. touch: cannot touch `ram4': Disk quota exceeded [ram@server salesdept]$ ll total 36 -rw------- 1 root root -rw------- 1 root root drwx------ 2 root root -rw-r--r-- 1 ram salesgrp -rw-r--r-- 1 ram salesgrp -rw-r--r-- 1 sai salesgrp -rw-r--r-- 1 sai salesgrp -rw-r--r-- 1 sai salesgrp 7168 Jul 15 01:52 aquota.group 7168 Jul 15 01:53 aquota.user 16384 Jul 15 01:38 lost+found 0 Jul 15 01:53 ram1 0 Jul 15 01:53 ram3 0 Jul 15 01:53 sai1 0 Jul 15 01:53 sai2 0 Jul 15 01:53 sai3 [ram@server salesdept]$ Note : Quotas are not applicable on secondary group members 29

Access Control List Create required users & Group [root@server ~]# useradd tom [root@server ~]# groupadd salesgrp [root@server ~]# groupadd fingrp [root@server ~]# mkdir /salesdept [root@server ~]# useradd -g salesgrp sai [root@server ~]# useradd -g salesgrp ram [root@server ~]# useradd -G fingrp tata [root@server ~]# useradd -G fingrp birla Note: Acl's are applied on both primary & secondary members Step 1 ) Create a required partition [root@server ~]# fdisk -l [root@server ~]# fdisk /dev/hda :n :w [root@server ~]# partprobe /dev/hda [root@server ~]# mkdir /salesdept [root@server ~]# mkfs.ext3 /dev/hda9 Step 2) Mount the partition with ACLs parameters. [root@server ~]# mount -o acl /dev/hda9 /salesdept [root@server ~]# mount [root@server ~]# chmod 777 /salesdept/ Step 3) Apply ACLS on users & groups [root@server salesdept]# touch fabc.txt To apply acl's on users & groups [root@server salesdept]# setfacl -m u:tom:rwx,u:ram:rx,g:salesgrp:rx,g:fingrp:rw fabc.txt 30

To check acl list [root@server salesdept]# getfacl fabc.txt To modify permission for user tom [root@server salesdept]# setfacl -m u:tom:r fabc.txt [root@server salesdept]# getfacl fabc.txt To exclude user tom,group fingrp from ACL list [root@server salesdept]# setfacl -x u:tom,g:fingrp fabc.txt [root@server salesdept]# getfacl fabc.txt 31

Advanced file permissions To view the location of a command use which [root@client24 myfolder]# which cat /bin/cat [root@client24 myfolder]# ls -ld /bin/cat -rwxr-xr-x 1 root root 23100 Nov 27 2006 /bin/cat [root@client24 myfolder]# su - tom [tom@client24 ~]$ cat > myfile hello Open another terminal as root user root@client24 ~]# ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND tom 3972 0.0 0.1 3680 432 pts/1 S+ 22:01 0:00 cat [root@client24 myfolder]# ls -ld /bin/cat -rwxr-xr-x 1 root root 23100 Nov 27 2006 /bin/cat Set SUID on the file [root@client24 myfolder]# chmod 4755 /bin/cat [root@client24 myfolder]# ls -ld /bin/cat -rwsr-xr-x 1 root root 23100 Nov 27 2006 /bin/cat [root@client24 myfolder]# su - tom [tom@client24 ~]$ cat >> myfile Open another terminal as root user root@client24 ~]# ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 4032 0.0 0.1 3680 436 pts/1 S+ 22:05 0:00 cat [root@client24 ~]# mkdir /myfolder 32

[root@client24 ~]# cd /myfolder [root@client24 myfolder]# ls [root@client24 myfolder]# cat > test Learning Linux is a wise man's decesion. [root@client24 myfolder]# ls -ld test -rw-r--r-- 1 root root 41 Jul 13 21:22 test [root@client24 myfolder]# ls -ld /myfolder drwxrwxrwx 2 root root 4096 Jul 13 21:21 /myfolder Set SGID on the folder [root@client24 myfolder]# chmod 2777 /myfolder [root@client24 myfolder]# ls -ld /myfolder drwxrwsrwx 2 root root 4096 Jul 13 21:21 /myfolder [root@client24 myfolder]# ls test [root@client24 myfolder]# su - tom [tom@client24 ~]$ cd /myfolder [tom@client24 myfolder]$ ls -l total 4 -rw-r--r-- 1 root root 41 Jul 13 21:22 test [tom@client24 myfolder]$ cat > myfile file to test SGID [tom@client24 myfolder]$ ls -ld myfile -rw-r--r-- 1 tom root 18 Jul 13 22:14 myfile [root@client24 myfolder]# su - joy [joy@client24 ~]$ cd /myfolder [joy@client24 myfolder]$ ls -l total 8 -rw-r--r-- 1 tom root 18 Jul 13 22:14 myfile -rw-r--r-- 1 root root 41 Jul 13 21:22 test [joy@client24 myfolder]$ cat > joy_file 33

hello this file is created by joy but because of SGID bit set its group ownership will be root [joy@client24 myfolder]$ ls -ld joy_file -rw-rw-r-- 1 joy root 95 Jul 13 22:15 joy_file joy and tom have the same primary group called joy [root@client24 ~]# mkdir /sticky [root@client24 ~]# chmod 777 /sticky [root@client24 ~]# su - tom [tom@client24 ~]$ cd /sticky [tom@client24 sticky]$ ls -l total 0 [tom@client24 sticky]$ cat > tom_file hello am tom, am going to set sticky bit on the /sticky folder. [tom@client24 sticky]$ ls -l total 4 -rw-r--r-- 1 tom joy 64 Jul 13 22:36 tom_file [tom@client24 sticky]$ chmod 664 tom_file [tom@client24 sticky]$ ls -ld tom_file -rw-rw-r-- 1 tom joy 64 Jul 13 22:36 tom_file [root@client24 sticky]# su - joy [joy@client24 ~]$ cd /sticky [joy@client24 sticky]$ ls -l total 4 -rw-rw-r-- 1 tom joy 64 Jul 13 22:37 tom_file [joy@client24 sticky]$ rm tom_file [joy@client24 sticky]$ ls To avoid joy to del the file owned by the user tom apply sticky bit on the folder. [root@client24 sticky]# ls -ld /sticky 34

drwxrwxrwx 2 root root 4096 Jul 13 22:38 /sticky Set Sticky Bit [root@client24 sticky]# chmod 1777 /sticky [root@client24 sticky]# ls -ld drwxrwxrwt 2 root root 4096 Jul 13 22:38. [root@client24 sticky]# su - tom [tom@client24 ~]$ cd /sticky/ [tom@client24 sticky]$ ls [tom@client24 sticky]$ cat > tom_file This file is created by tom whose primary group is joy, but joy cannot delete this file. [tom@client24 sticky]$ ls -ld /sticky/tom_file -rw-r--r-- 1 tom joy 89 Jul 13 22:41 /sticky/tom_file [root@client24 sticky]# su - joy [joy@client24 ~]$ cd /sticky/ [joy@client24 sticky]$ ls -l total 4 -rw-r--r-- 1 tom joy 89 Jul 13 22:41 tom_file [joy@client24 sticky]$ rm tom_file rm: remove write-protected regular file `tom_file'? y rm: cannot remove `tom_file': Operation not permitted [joy@client24 sticky]$ ls -l total 4 -rw-r--r-- 1 tom joy 89 Jul 13 22:41 tom_file 35

Links [root@client1 ~]# mount /dev/hda3 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/hda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) /dev/hda5 on /home type ext3 (rw) /dev/hda2 on /usr type ext3 (rw) /dev/hda6 on /var type ext3 (rw) /dev/hda8 on /myfolder type ext3 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) [root@client1 ~]# [root@client1 ~]# cd /myfolder [root@client1 myfolder]# ls [root@client1 myfolder]# cat > original_file This is the original file to test links [root@client1 myfolder]# ls -ld original_file -rw-r--r-- 1 root root 40 Jul 12 21:12 original_file [root@client1 myfolder]# cd Setting a soft link [root@client1 ~]# ln -s /myfolder/original_file softlink [root@client1 ~]# ls -ld softlink lrwxrwxrwx 1 root root 23 Jul 12 21:12 softlink -> /myfolder/original_file [root@client1 ~]# cat softlink This is the original file to test links [root@client1 ~]# cat >> softlink this line is appended by the softlink [root@client1 ~]# cat /myfolder/original_file This is the original file to test links this line is appended by the softlink 36

[root@client1 ~]# ls -ld /myfolder/original_file -rw-r--r-- 1 root root 78 Jul 12 21:13 /myfolder/original_file [root@client1 ~]# ls -ld softlink lrwxrwxrwx 1 root root 23 Jul 12 21:12 softlink -> /myfolder/original_file [root@client1 ~]# rm /myfolder/original_file rm: remove regular file `/myfolder/original_file'? y [root@client1 ~]# cat softlink cat: softlink: No such file or directory Setting a Hard Link [root@client1 ~]# ln /myfolder/original_file hardlink ln: creating hard link `hardlink' to `/myfolder/original_file': Invalid cross-device link [root@client1 ~]# cd / [root@client1 /]# cat > original This is the original file to test links. [root@client1 /]# cd [root@client1 ~]# ln /original /root/hardlink [root@client1 ~]# ls -ld /root/hardlink -rw-r--r-- 2 root root 41 Jul 12 21:16 /root/hardlink [root@client1 ~]# ls -ld /original -rw-r--r-- 2 root root 41 Jul 12 21:16 /original [root@client1 ~]# cd / [root@client1 /]# cat > original This is the original file to test links. [root@client1 /]# cd [root@client1 ~]# ln /original /root/hardlink [root@client1 ~]# ls -ld /root/hardlink -rw-r--r-- 2 root root 41 Jul 12 21:16 /root/hardlink 37

[root@client1 ~]# ls -ld /original -rw-r--r-- 2 root root 41 Jul 12 21:16 /original [root@client1 ~]# cat >> hardlink this is appended by the hardlink file [root@client1 ~]# ls -ld /root/hardlink -rw-r--r-- 2 root root 79 Jul 12 21:18 /root/hardlink [root@client1 ~]# ls -ld /original -rw-r--r-- 2 root root 79 Jul 12 21:18 /original [root@client1 ~]# rm /original rm: remove regular file `/original'? y [root@client1 ~]# cat hardlink This is the original file to test links. this is appended by the hardlink file 38

Example to Configure RAID 5 Install the required packages [root@client1 ~]# yum install mdadm* -y Create the required partition [root@client1 ~]# mdadm -C /dev/md0 -n3 /dev/hda11 /dev/hda12 /dev/hda13 -l5 mdadm: array /dev/md0 started. To see the detail information of /dev/md0 [root@client1 ~]# mdadm -D /dev/md0 Format the raid meta device [root@client1 ~]# mkfs.ext3 /dev/md0 Mount the partition [root@client1 ~]# mount /dev/md0 /raid_dir [root@client1 ~]# mount [root@client1 ~]# cd /raid_dir/ [root@client1 raid_dir]# ls lost+found Write some content inside the raid partition [root@client1 raid_dir]# cat > test hello this is a test file on raid 5 [root@client1 raid_dir]# ls -l To add a new device as spare [root@client1 ~]# mdadm -a /dev/md0 /dev/hda14 [root@client1 ~]# mdadm -D /dev/md0 [root@client1 ~]# mdadm /dev/md0 -f /dev/hda12 mdadm: set /dev/hda12 faulty in /dev/md0 To see the detail information of /dev/md0 [root@client1 ~]# mdadm -D /dev/md0 39

To remove the faulty device [root@client1 raid_dir]# mdadm /dev/md0 -r /dev/hda12 mdadm: hot removed /dev/hda12 [root@client1 raid_dir]# mdadm -D /dev/md0 [root@client1 raid_dir]# cd To stop the raid first unmount the meta device. [root@client1 ~]# umount /dev/md0 [root@client1 ~]# mdadm -S /dev/md0 mdadm: stopped /dev/md0 To activate or assemble the raid meta device [root@client1 ~]# mdadm -A /dev/md0 /dev/hda11 /dev/hda14 /dev/hda13 mdadm: /dev/md0 has been started with 3 drives. 40

Logical Volume Manager To view the Hard disk name and partition information [root@client24 ~]# fdisk -l Disk /dev/hda: 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 523 4096575 83 Linux /dev/hda3 524 778 2048287+ 83 Linux /dev/hda4 779 4865 32828827+ 5 Extended /dev/hda5 779 905 1020096 83 Linux /dev/hda6 906 1032 1020096 83 Linux /dev/hda7 1033 1097 522081 82 Linux swap / Solaris /dev/hda8 1098 2314 9775521 83 Linux Create 3 partitions [root@client24 ~]# fdisk /dev/hda The number of cylinders for this disk is set to 4865. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n First cylinder (2315-4865, default 2315): Using default value 2315 Last cylinder or +size or +sizem or +sizek (2315-4865, default 4865): +200M Command (m for help): n First cylinder (2340-4865, default 2340): Using default value 2340 Last cylinder or +size or +sizem or +sizek (2340-4865, default 4865): +200M Command (m for help): n First cylinder (2365-4865, default 2365): Using default value 2365 Last cylinder or +size or +sizem or +sizek (2365-4865, default 4865): +200M 41

Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@client24 ~]# partprobe /dev/hda [root@client24 ~]# fdisk -l Disk /dev/hda: 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 523 4096575 83 Linux /dev/hda3 524 778 2048287+ 83 Linux /dev/hda4 779 4865 32828827+ 5 Extended /dev/hda5 779 905 1020096 83 Linux /dev/hda6 906 1032 1020096 83 Linux /dev/hda7 1033 1097 522081 82 Linux swap / Solaris /dev/hda8 1098 2314 9775521 83 Linux /dev/hda9 2315 2339 200781 83 Linux /dev/hda10 2340 2364 200781 83 Linux /dev/hda11 2365 2389 200781 83 Linux Create Physical Volumes [root@client24 ~]# pvcreate /dev/hda9 /dev/hda10 /dev/hda11 Physical volume "/dev/hda9" successfully created Physical volume "/dev/hda10" successfully created Physical volume "/dev/hda11" successfully created To view Physical Volumes [root@client24 ~]# pvdisplay --- Physical volume --- PV Name /dev/hda9 VG Name vg1 PV Size 196.08 MB / not usable 4.08 MB Allocatable yes (but full) PE Size (KByte) 4096 Total PE 48 Free PE 0 Allocated PE 48 PV UUID 5r8qvn-GF0k-NAfo-Rhqc-I3Qn-ZWws-zLCvks --- Physical volume --- PV Name /dev/hda10 42

VG Name PV Size Allocatable PE Size (KByte) 4096 Total PE 48 Free PE 21 vg1 196.08 MB / not usable 4.08 MB yes Allocated PE 27 PV UUID ys5wd9-yiq5-mm7c-sjrt-mcwb-35of-8mfydw --- Physical volume --- PV Name /dev/hda11 VG Name vg1 PV Size 196.08 MB / not usable 4.08 MB Allocatable yes PE Size (KByte) 4096 Total PE 48 Free PE 48 Allocated PE 0 PV UUID 5U81jh-Uddd-0giT-GYUT-pkvu-3MK3-KNkZJi To create Volume Group [root@client24 ~]# vgcreate vg1 /dev/hda9 /dev/hda10 /dev/hda11 Volume group "vg1" successfully created To display Volume Group Information. [root@client24 ~]# vgdisplay --- Volume group --- VG Name vg1 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 576.00 MB PE Size 4.00 MB Total PE 144 Alloc PE / Size 75 / 300.00 MB Free PE / Size 69 / 276.00 MB VG UUID P1zXt6-yBWW-SoUq-ZeF1-K7pf-Z69D-GVz8Up To create logical Volume [root@client24 ~]# lvcreate vg1 -L +300M -n lv1 Logical volume "lv1" created 43

To view Logical Volume Information. [root@client24 ~]# lvdisplay --- Logical volume --- LV Name /dev/vg1/lv1 VG Name vg1 LV UUID ZvsfPh-Ve0c-y4Qa-VUYy-HbdR-lG3G-66703a LV Write Access read/write LV Status available # open 0 LV Size 300.00 MB Current LE 75 Segments 2 Allocation inherit Read ahead sectors 0 Block device 253:0 [root@client24 ~]# Format the Logical Volume [root@client24 ~]# mkfs.ext3 /dev/vg1/lv1 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 102400 inodes, 409600 blocks 20480 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 50 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@client24 ~]# mkdir /mylvm [root@client24 ~]# mount /dev/vg1/lv1 /mylvm [root@client24 ~]# mount /dev/hda3 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/hda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) /dev/hda5 on /home type ext3 (rw) 44

/dev/hda2 on /usr type ext3 (rw) /dev/hda6 on /var type ext3 (rw) /dev/hda8 on /dada type ext3 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) /dev/mapper/vg1-lv1 on /mylvm type ext3 (rw) To resize the Logical Volume [root@client24 ~]# lvresize -L +100M /dev/vg1/lv1 Extending logical volume lv1 to 400.00 MB Logical volume lv1 successfully resized [root@client24 ~]# lvdisplay --- Logical volume --- LV Name /dev/vg1/lv1 VG Name vg1 LV UUID ZvsfPh-Ve0c-y4Qa-VUYy-HbdR-lG3G-66703a LV Write Access read/write LV Status available # open 0 LV Size 400.00 MB Current LE 100 Segments 3 Allocation inherit Read ahead sectors 0 Block device 253:0 [root@client24 ~]# cd /mylvm [root@client24 mylvm]# ls lost+found [root@client24 mylvm]# touch file1 file2 file3 [root@client24 mylvm]# mkdir hyd sec [root@client24 mylvm]# ls file1 file2 file3 hyd lost+found sec To remove logical Volume [root@client24 ~]# cd [root@client24 ~]# umount /mylvm [root@client24 ~]# lvremove /dev/vg1/lv1 Do you really want to remove active logical volume "lv1"? [y/n]: y Logical volume "lv1" successfully removed 45

[root@client24 ~]# fdisk /dev/hda The number of cylinders for this disk is set to 4865. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n First cylinder (2390-4865, default 2390): +300M Value out of range. First cylinder (2390-4865, default 2390): w First cylinder (2390-4865, default 2390): Using default value 2390 Last cylinder or +size or +sizem or +sizek (2390-4865, default 4865): +300M Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@client24 ~]# partprobe /dev/hda [root@client24 ~]# fdisk -l Disk /dev/hda: 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 523 4096575 83 Linux /dev/hda3 524 778 2048287+ 83 Linux /dev/hda4 779 4865 32828827+ 5 Extended /dev/hda5 779 905 1020096 83 Linux /dev/hda6 906 1032 1020096 83 Linux /dev/hda7 1033 1097 522081 82 Linux swap / Solaris /dev/hda8 1098 2314 9775521 83 Linux /dev/hda9 2315 2339 200781 83 Linux /dev/hda10 2340 2364 200781 83 Linux /dev/hda11 2365 2389 200781 83 Linux /dev/hda12 2390 2426 297171 83 Linux 46

[root@client24 ~]# pvcreate /dev/hda12 Physical volume "/dev/hda12" successfully created To extend the volume group. [root@client24 ~]# vgextend vg1 /dev/hda12 Volume group "vg1" successfully extended [root@client24 ~]# vgdisplay --- Volume group --- VG Name vg1 System ID Format lvm2 Metadata Areas 4 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 4 Act PV 4 VG Size 864.00 MB PE Size 4.00 MB Total PE 216 Alloc PE / Size 0 / 0 Free PE / Size 216 / 864.00 MB VG UUID P1zXt6-yBWW-SoUq-ZeF1-K7pf-Z69D-GVz8Up 47

Backups Create a folder [root@client24 myfolder]# mkdir /myfolder [root@client24 ~]# cd /myfolder/ [root@client24 myfolder]# mkdir dir1 [root@client24 myfolder]#touch 1 test_file tom_file [root@client24 myfolder]# ls 1 dir1 test_file tom_file Use the tar command to tape archive the folder. [root@client24 ~]# tar -cvf myfolder.tar /myfolder tar: Removing leading `/' from member names /myfolder/ /myfolder/dir1/ /myfolder/tom_file /myfolder/test_file /myfolder/1 [root@client24 ~]# ls -ld myfolder.tar -rw-r--r-- 1 root root 10240 Jul 13 03:07 myfolder.tar To zip the tar file. [root@client24 ~]# gzip myfolder.tar [root@client24 ~]# ls -ld myfolder.tar.gz -rw-r--r-- 1 root root 264 Jul 13 03:07 myfolder.tar.gz To unzip the tar file [root@client24 ~]# gunzip myfolder.tar.gz [root@client24 ~]# ls -ld myfolder.tar -rw-r--r-- 1 root root 10240 Jul 13 03:07 myfolder.tar [root@client24 ~]# rm myfolder.tar rm: remove regular file `myfolder.tar'? y 48

To create a tar file with zip [root@client24 ~]# tar -cvzf myfolder.tar.gz /myfolder tar: Removing leading `/' from member names /myfolder/ /myfolder/dir1/ /myfolder/tom_file /myfolder/test_file /myfolder/1 [root@client24 ~]# ls -ld myfolder.tar.gz -rw-r--r-- 1 root root 251 Jul 13 03:09 myfolder.tar.gz To view the contents of the tar file without extracting. [root@client24 ~]# tar -tvzf myfolder.tar.gz drwxrwxrwx root/root drwxr-xr-x root/root -rw-r--r-- tom/joy -rw-rw-rw- root/root -rw-r--r-- tom/joy 0 2008-07-13 01:31:34 myfolder/ 0 2008-07-13 01:28:39 myfolder/dir1/ 12 2008-07-13 01:29:51 myfolder/tom_file 0 2008-07-13 00:06:35 myfolder/test_file 0 2008-07-13 01:31:34 myfolder/1 [root@client24 ~]# rm -r /myfolder rm: descend into directory `/myfolder'? y rm: remove directory `/myfolder/dir1'? y rm: remove regular file `/myfolder/tom_file'? y rm: remove regular empty file `/myfolder/test_file'? y rm: remove regular empty file `/myfolder/1'? y rm: remove directory `/myfolder'? y [root@client24 ~]# cd / To extract the tar file. [root@client24 /]# tar -xvzf /root/myfolder.tar.gz myfolder/ myfolder/dir1/ myfolder/tom_file myfolder/test_file myfolder/1 [root@client24 /]# ls -ld myfolder drwxrwxrwx 3 root root 4096 Jul 13 01:31 myfolder [root@client24 /]# ls /myfolder/ 1 dir1 test_file tom_file [root@client24 ~]# cd /myfolder/ 49

To copy files to archive. [root@client24 myfolder]# ls cpio -ov > myfolder.cpio 1 dir1 myfolder.cpio test_file tom_file 1 block [root@client24 myfolder]# ls 1 dir1 myfolder.cpio test_file tom_file [root@client24 myfolder]# ls 1 dir1 myfolder.cpio test_file tom_file [root@client24 myfolder]# rm -r * rm: remove regular empty file `1'? y rm: remove directory `dir1'? y rm: remove regular file `myfolder.cpio'? n rm: remove regular empty file `test_file'? y rm: remove regular file `tom_file'? y To copy files from archive. [root@client24 myfolder]# cpio -iv < myfolder.cpio 1 dir1 cpio: myfolder.cpio not created: newer or same age version exists myfolder.cpio test_file tom_file 1 block [root@client24 myfolder]# ls 1 dir1 myfolder.cpio test_file tom_file [root@client24 ~]# cat > test test file for scp 50

Copy the test file to a remote systems /root directory [root@client24 ~]# scp -r test 192.168.0.23:/root/ root@192.168.0.23's password: test 100% 18 0.0KB/s 00:00 [root@client24 ~]# rm test rm: remove regular file `test'? y Copy the file on a remote systems to the /root/test directory [root@client24 ~]# scp -r 192.168.0.23:/root/test. root@192.168.0.23's password: test 100% 18 0.0KB/s 00:00 [root@client24 ~]# ls -ld test -rw-r--r-- 1 root root 18 Jul 13 03:27 test Scheduling using at command [root@client24 ~]# at 5:30 at> mkdir dir1 at> <EOT> job 2 at 2008-07-13 05:30 To view the at queues [root@client24 ~]# atq 2 2008-07-13 05:30 a root To remove the queue [root@client24 ~]# atrm 2 51

Boot Process Practical To view the default runlevel on boot [root@client24 ~]# vi /etc/inittab id:5:initdefault: line no 18 To view the present runlevel [root@client24 ~]# runlevel N 5 To switch to another runlevel [root@client24 ~]# init 3 [root@client24 ~]# init 0 [root@client24 ~]# init 1 [root@client24 ~]# init 6 To view the grub configuration file [root@client24 ~]# cat /boot/grub/grub.conf To view the status of the services in all runlevels. [root@client24 ~]# chkconfig --list [root@client24 ~]# chkconfig --list kudzu kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off To set the status of a service [root@client24 ~]# chkconfig bluetooth on [root@client24 ~]# chkconfig --list bluetooth bluetooth 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@client24 ~]# chkconfig bluetooth off bluetooth 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@client24 ~]# service bluetooth restart 52

Installation of Packages through RPM or YUM If you want to install from CD or DVD go to packages location generally in /media/cdrom/server To install from NFS server where NFS server's IP is 192.168.0.250 and share folder is /var/ftp/pub/server mount the share at client side. [root@client mnt]# mount 192.168.0.250:/var/ftp/pub/Server /mnt [root@client mnt]# mount [root@client mnt]# cd /mnt [root@client mnt]# ls To install packages [root@client mnt]# rpm -i [root@client mnt]# rpm -iv [root@client mnt]# rpm -iv samba* vsftpd* samba* vsftpd* samba* vsftpd* --force [root@client mnt]# rpm -ivh samba* vsftpd* --force To remove the packages [root@client mnt]# rpm -e vsftpd [root@client mnt]# rpm -e vsftpd [root@client mnt]# rpm -e samba --nodeps To query the packages [root@client mnt]# rpm -qa [root@client mnt]# rpm -qa sort less [root@client mnt]# rpm -q samba [root@client mnt]# rpm -qa samba* [root@client mnt]# [root@client mnt]# rpm -qi samba [root@client mnt]# rpm -ql samba [root@client mnt]# rpm -qd samba [root@client mnt]# rpm -qc samba [root@client mnt]# rpm -qs samba 53

Installing through yum Creating a repository at server side where all rpms are copied [root@client ~]# cd /var/ftp/pub/server [root@client Server]# rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm -- force Remove the old repodata [root@client Server]# rm -rf repodata/ Create a new repodata [root@client Server]# createrepo -g /media/cdrom/server/repodata/compsrhel5-server-core.xml. [root@client Server]# cd [root@client ~]# At client side edit the yum configuration file, provide the path of repository [root@client ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo [core] name= Linux $releasever - $basearch - Debug baseurl=ftp://192.168.0.250/pub/server enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rp :wq! Installing through yum [root@client ~]# yum list [root@client ~]# yum list installed [root@client ~]# yum list installed samba* [root@client ~]# yum install vsftpd* samba* [root@client ~]# yum remove vsftpd* samba* [root@client ~]# yum grouplist [root@client ~]# yum groupinstall "Mail Server" [root@client ~]# yum groupremove "Mail Server" [root@client ~]# cd /media/cdrom/server [root@client ~]# yum localinstall vsftpd* 54

Introduction to Networking To set the hostname temporarily [root@station9 ~]# hostname station9.example.com To view the hostname [root@station9 ~]# hostname station9.example.com Set hostname permanently [root@station9 ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=station9.example.com :wq! Set ip address temporarily [root@station9 ~]# ifconfig eth0 192.168.0.9 netmask 255.255.255.0 View the interfaces. [root@station9 ~]# ifconfig eth0 Link encap:ethernet HWaddr 00:13:20:B7:1D:44 inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48153 errors:4 dropped:0 overruns:0 frame:4 TX packets:21992 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:39512670 (37.6 MiB) TX bytes:1720318 (1.6 MiB) lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1249 errors:0 dropped:0 overruns:0 frame:0 TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB) 55

Set permanent ip address [root@station9 ~]# netconfig Select yes and press the enter key Press tab and select the text box for IP address Enter the new IP address similarly enter the subnet mask, default gateway and primary nameserver. Select OK and press enter. Restart the service to activate the new ip address [root@station9 ~]# service network restart [root@station9 ~]# ifconfig eth0 Link encap:ethernet HWaddr 00:13:20:B7:1D:44 inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48173 errors:4 dropped:0 overruns:0 frame:4 TX packets:22001 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:39514528 (37.6 MiB) TX bytes:1720864 (1.6 MiB) lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1249 errors:0 dropped:0 overruns:0 frame:0 TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB) [root@station9 ~]# netconfig --device eth0:1 [root@station9 ~]# service network restart [root@station9 ~]# ifconfig eth0 Link encap:ethernet HWaddr 00:13:20:B7:1D:44 inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48749 errors:4 dropped:0 overruns:0 frame:4 TX packets:22678 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:39873471 (38.0 MiB) TX bytes:1802196 (1.7 MiB) eth0:1 Link encap:ethernet HWaddr 00:13:20:B7:1D:44 inet addr:192.168.1.9 Bcast:192.168.1.255 56