i m a rhce certified person. This blog contain RH033,RH133,RH233 practice,tasks,question,video,dumps,etc. use it and spread to your friends.. Also i am working as oracle database administrator. I am positing documents which could help you to administrate oracle database.
Showing posts with label redhat linux commands. Show all posts
Showing posts with label redhat linux commands. Show all posts
Thursday, September 26, 2013
COMMONG NETWORK UTILITES IN REDHAT LINUX
COMMONG NETWORK UTILITES
Features:
1. Useful for basic troubleshooting
PING:
Features:
1. ability to communicate with hosts using ICMP
•PING sends ICMP echo-requests
•PING expects to receive ICMP echo-replies
Task:
PING some hosts and evaluate the output
1. ping localhost (127.0.0.1)
2. ping -c 3 localhost - sends 3 ICMP echo-requests
Note:
•'ping localhost' performs name resolution using /etc/hosts
•/etc/hosts stores static name-to-IP mappings
•127.0.0.0/8 is fully-reserved to the loopback adapter of ALL IPv4 hosts
3. ping -c 3 192.168.75.199
4. ping -c 3 -i 3 192.168.75.199 - delays PINGs to 3 seconds apart
Note:
•PING defaults to a standard 1-second interval
•Firewall(s) may block ICMP traffic, causing PING to fail
Saturday, January 2, 2010
OPEN PGP|GNU PRIVACY GUARD (GPG) IN REDHAT LINUX
OPEN PGP|GNU PRIVACY GUARD (GPG)
Features:
1. Confidentiality - Data (Files or e-mail) are encrypted
2. Integrity - Digital signatures
3. Compression
4. Public Key Infrastructure (PKI)
a. Public key - used to encrypt data to a recipient
b. Private key - used to decrypt data from a sender
5. GPG is OpenPGP compliant
Usage:
1. gpg --list-keys - this enumerates keys in ~/
2. gpg --gen-key - generates a PKI keypair for the current user
3. gpg --encrypt -r LinuxCBT --armor sample.txt - encrypts sample.txt using
our 'LinuxCBT's' public key
4. gpg --decrypt sample.txt.asc
5. gpg --decrypt sample.txt.gpg
6. gpg --export -a - dumps public key to STDOUT
7. gpg --import - waits on STDIN for user to paste a key for import
8. gpg --decrypt -o sample.txt sample.txt.gpg
Features:
1. Confidentiality - Data (Files or e-mail) are encrypted
2. Integrity - Digital signatures
3. Compression
4. Public Key Infrastructure (PKI)
a. Public key - used to encrypt data to a recipient
b. Private key - used to decrypt data from a sender
5. GPG is OpenPGP compliant
Usage:
1. gpg --list-keys - this enumerates keys in ~/
2. gpg --gen-key - generates a PKI keypair for the current user
3. gpg --encrypt -r LinuxCBT --armor sample.txt - encrypts sample.txt using
our 'LinuxCBT's' public key
4. gpg --decrypt sample.txt.asc
5. gpg --decrypt sample.txt.gpg
6. gpg --export -a - dumps public key to STDOUT
7. gpg --import - waits on STDIN for user to paste a key for import
8. gpg --decrypt -o sample.txt sample.txt.gpg
Thursday, December 31, 2009
TELNET IN REDHAT LINUX
TELNET:
Features:
1. Great for basic TCP port diagnosis
Task:
1. Connect to TCP ports on various hosts
•telnet 192.168.75.100 22
•telnet www.linuxcbt.com 80
Netstat:
Features:
1. Provides network connection information from /proc/net/*
Task:
1. Return useful information for various protocols
•netstat
•netstat -a - returns all protocols/sockets
•netstat -ntlp - returns all TCP LISTENERS without name resolution
•netstat -nulp - returns all UDP lISTENERS without name resolution
Note:
•netstat uses /etc/services to translate ports to names
•0.0.0.0:514 - this means that Syslog will accept traffic to any of the defined IP
addresses/interfaces on the system
• netstat -ntp - returns established connections (sockets)
• netstat -rn - returns the routing table
Features:
1. Great for basic TCP port diagnosis
Task:
1. Connect to TCP ports on various hosts
•telnet 192.168.75.100 22
•telnet www.linuxcbt.com 80
Netstat:
Features:
1. Provides network connection information from /proc/net/*
Task:
1. Return useful information for various protocols
•netstat
•netstat -a - returns all protocols/sockets
•netstat -ntlp - returns all TCP LISTENERS without name resolution
•netstat -nulp - returns all UDP lISTENERS without name resolution
Note:
•netstat uses /etc/services to translate ports to names
•0.0.0.0:514 - this means that Syslog will accept traffic to any of the defined IP
addresses/interfaces on the system
• netstat -ntp - returns established connections (sockets)
• netstat -rn - returns the routing table
COMMONG NETWORK UTILITES IN REDHAT LINUX
COMMONG NETWORK UTILITES
Features:
1. Useful for basic troubleshooting
PING:
Features:
1. ability to communicate with hosts using ICMP
•PING sends ICMP echo-requests
•PING expects to receive ICMP echo-replies
Task:
PING some hosts and evaluate the output
1. ping localhost (127.0.0.1)
2. ping -c 3 localhost - sends 3 ICMP echo-requests
Note:
•'ping localhost' performs name resolution using /etc/hosts
•/etc/hosts stores static name-to-IP mappings
•127.0.0.0/8 is fully-reserved to the loopback adapter of ALL IPv4 hosts
3. ping -c 3 192.168.75.199
4. ping -c 3 -i 3 192.168.75.199 - delays PINGs to 3 seconds apart
Note:
•PING defaults to a standard 1-second interval
•Firewall(s) may block ICMP traffic, causing PING to fail
Features:
1. Useful for basic troubleshooting
PING:
Features:
1. ability to communicate with hosts using ICMP
•PING sends ICMP echo-requests
•PING expects to receive ICMP echo-replies
Task:
PING some hosts and evaluate the output
1. ping localhost (127.0.0.1)
2. ping -c 3 localhost - sends 3 ICMP echo-requests
Note:
•'ping localhost' performs name resolution using /etc/hosts
•/etc/hosts stores static name-to-IP mappings
•127.0.0.0/8 is fully-reserved to the loopback adapter of ALL IPv4 hosts
3. ping -c 3 192.168.75.199
4. ping -c 3 -i 3 192.168.75.199 - delays PINGs to 3 seconds apart
Note:
•PING defaults to a standard 1-second interval
•Firewall(s) may block ICMP traffic, causing PING to fail
SYSLOGD IN REDHAT LINUX
SYSLOGD
Features:
1. Handles logging
2. Unix Domain Sockets (/dev/log)
3. Internet Sockets (UDP:514)
4. Ability to log to local and remote targets
5.Implented as 'sysklogd' package
6.Primary configuration file: /etc/syslog.conf
Standard syslog.conf file contains:
1. Rules
•a.facilities -> applications/daemons/network device/etc.
•b. levels -> Importance of message
Range: 0-7
•7 = emergency (less information)
•6 = alert
•5 = critical
•4 = error
•3 = warning
•2 = notice
•1 = info
•0 = debug (more information)
2. Targets
•file - /var/log/messages
•b. tty - /dev/console
•c. remote hosts - @IP_ADDR_of_REMOTE_HOST
•'*' = catchall/wildcard to mean any facility or level
•'.none' = exclusion rule
'man syslog.conf' to learn about the support facilities.levels
Task:
1. Enable UDP logging for remote Cisco gateway (192.168.75.1)
•netstat -nul | grep 514 - reveals UDP:514 listener
•nano /etc/sysconfig/syslog
'SYSLOGD_OPTIONS="-r"'
•restart syslog and confirm UDP:514 listener
confirm using 'netstat -nul | grep 514'
•Configure the router using facility 'local0' and level 'info'
•configure /etc/syslog.conf to accept 'local0.info'
•restart or reload 'syslog'
Features:
1. Handles logging
2. Unix Domain Sockets (/dev/log)
3. Internet Sockets (UDP:514)
4. Ability to log to local and remote targets
5.Implented as 'sysklogd' package
6.Primary configuration file: /etc/syslog.conf
Standard syslog.conf file contains:
1. Rules
•a.facilities -> applications/daemons/network device/etc.
•b. levels -> Importance of message
Range: 0-7
•7 = emergency (less information)
•6 = alert
•5 = critical
•4 = error
•3 = warning
•2 = notice
•1 = info
•0 = debug (more information)
2. Targets
•file - /var/log/messages
•b. tty - /dev/console
•c. remote hosts - @IP_ADDR_of_REMOTE_HOST
•'*' = catchall/wildcard to mean any facility or level
•'.none' = exclusion rule
'man syslog.conf' to learn about the support facilities.levels
Task:
1. Enable UDP logging for remote Cisco gateway (192.168.75.1)
•netstat -nul | grep 514 - reveals UDP:514 listener
•nano /etc/sysconfig/syslog
'SYSLOGD_OPTIONS="-r"'
•restart syslog and confirm UDP:514 listener
confirm using 'netstat -nul | grep 514'
•Configure the router using facility 'local0' and level 'info'
•configure /etc/syslog.conf to accept 'local0.info'
•restart or reload 'syslog'
CRON-SCHEDULER IN REDHAT LINUX
CRON-SCHEDULER
Features:
1. Scheduler
2. Rules (Cron entries) are based on times:
• minute (0-59)
• hour (0-23)
• day of the month (1-31)
• month (1-12)
• day of the week (Sun,Mon,Tue, etc. OR 0-7)
• command to execute (shell, perl, php, etc.)
3. Wakes up every minute in search of programs to execute
4. Reads cron entries from multiple files
5. Maintains per-user and system-wide (/etc/crontab) schedules
In /etc:
•cron.d/
•cron.deny - denies cron execution by user
•cron.monthly/ - runs jobs monthly
•cron.weekly/ - runs jobs weekly
•cron.daily/ - runs jobs daily
•cron.hourly/ - runs jobs hourly
•crontab - contains system-wide schedules
Note: '*' wildcard in a time column means to run for all values
6. Per-user Crontabs:
Stored in: /var/spool/cron
Task:
1. Create a cron entry for the user 'student1'
• su student1
• crontab -e
• create an entry, minus the name of the user
Note: 'crontab -l' - enumerates per-user cron entries
System-wide Crontab:
Stored in: /etc/crontab
Task:
1. Create a cron entry in: /etc/crontab
Note: 'crontab -l -u username' - enumerates per-user cron entries
Features:
1. Scheduler
2. Rules (Cron entries) are based on times:
• minute (0-59)
• hour (0-23)
• day of the month (1-31)
• month (1-12)
• day of the week (Sun,Mon,Tue, etc. OR 0-7)
• command to execute (shell, perl, php, etc.)
3. Wakes up every minute in search of programs to execute
4. Reads cron entries from multiple files
5. Maintains per-user and system-wide (/etc/crontab) schedules
In /etc:
•cron.d/
•cron.deny - denies cron execution by user
•cron.monthly/ - runs jobs monthly
•cron.weekly/ - runs jobs weekly
•cron.daily/ - runs jobs daily
•cron.hourly/ - runs jobs hourly
•crontab - contains system-wide schedules
Note: '*' wildcard in a time column means to run for all values
6. Per-user Crontabs:
Stored in: /var/spool/cron
Task:
1. Create a cron entry for the user 'student1'
• su student1
• crontab -e
• create an entry, minus the name of the user
Note: 'crontab -l' - enumerates per-user cron entries
System-wide Crontab:
Stored in: /etc/crontab
Task:
1. Create a cron entry in: /etc/crontab
Note: 'crontab -l -u username' - enumerates per-user cron entries
YUM CONFIGURATION IN REDHAT LINUX
YUM CONFIGURATION
Features:
1. The ability to centralize packages (updates)
Installation & Setup:
1. Install 'createrepo*rpm'
2. Setup directory structure
• /srv/www/linuxcbt.com/RH5/yum
3. Run 'createrepo /srv/www/linuxcbt.com/RH5/yum'
4. Publish the yum repository using HTTP
5. Configure yum client to use HTTP to fetch the RPMs
• /etc/yum.conf
• a1. ###Included as our first repository on the SUSE box###
[0001]
• name=linuxcbtsuse1
• baseurl=http://192.168.75.100/RH5/yum
Note: Ensure that about 3GBs are available for the yum respository
tar -cjvf yum_metadata.bz2 repodata
Yum Usage:
1. Search for packages
a. 'yum search gftp'
2. Install packages - Requires RedHat GPG Key for RPMs
rpm --import http://192.168.75.100/RH5/i386/RPM-GPG-KEY-redhat-release
• 'yum -y install gftp'
• 'yum -y install gftp dhcp' installs 2 packages'
3. Remove Package
• 'yum -y remove gftp'
Features:
1. The ability to centralize packages (updates)
Installation & Setup:
1. Install 'createrepo*rpm'
2. Setup directory structure
• /srv/www/linuxcbt.com/RH5/yum
3. Run 'createrepo /srv/www/linuxcbt.com/RH5/yum'
4. Publish the yum repository using HTTP
5. Configure yum client to use HTTP to fetch the RPMs
• /etc/yum.conf
• a1. ###Included as our first repository on the SUSE box###
[0001]
• name=linuxcbtsuse1
• baseurl=http://192.168.75.100/RH5/yum
Note: Ensure that about 3GBs are available for the yum respository
tar -cjvf yum_metadata.bz2 repodata
Yum Usage:
1. Search for packages
a. 'yum search gftp'
2. Install packages - Requires RedHat GPG Key for RPMs
rpm --import http://192.168.75.100/RH5/i386/RPM-GPG-KEY-redhat-release
• 'yum -y install gftp'
• 'yum -y install gftp dhcp' installs 2 packages'
3. Remove Package
• 'yum -y remove gftp'
RPM IN REDHAT LINUX
RPM
Features:
1. Provides package management
• Query
• Install
• Uninstall
• Upgrade
• Verify
2. Auto-verifies packages using GPG, MD5, SHA1SUMs
3. Automatically reports on unresolved dependencies
'rpm'
Query:
1. rpm -qa - dumps all installed packages
2. rpm -qa | wc -l - this dumps all packages and provides a count
3. rpm -qa | grep -i nano
4. rpm -qi nano - dumps info. about the 'nano' package as it's recorded in the
local RPM database
5. rpm -qf /usr/bin/nano - dumps package membership info. for the 'nano' file
6. rpm -qpi http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm -
dumps info. about the uninstalled 'dhcp' package, which resides on the
repository
7. rpm -ql package_name - returns all included files
Verify:
1. rpm -Va - verifies ALL packages on the system, returning info. only if there
are discrepancies from the original installation
2. rpm -Vf /usr/bin/nano
3. rpm -Vp nano
Install (Does NOT overwrite previous package):
Note: Use this method to install a new version of the kernel
1. rpm -ivh *.rpm
2. rpm -ivh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm
Task:
Change '/usr/bin/nano' then verify
SM5....T /usr/bin/nano
S(file size), M(mode or permissions), 5(MD5), T(mod time)
Upgrade (Installs or overwrites existing package):
1. rpm -Uvh *.rpm
2. rpm -Uvh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm
Freshen (Updates an existing package):
Note: Will NOT install the package, if it doesn't exist locally
1. rpm -Fvh *.rpm - freshens the current version of a package
Removal:
1. rpm -ev *.rpm - removes a pacakge
Note: removal process considers dependencies and will complain if the removal will break 1 or more packages. To get around this, use '--nodeps' option with 'rpm -ev --nodeps *.rpm'
2. rpm -ev gftp
Package Management GUI:
1. Add/Remove Software
2. system-config-packages
Features:
1. Provides package management
• Query
• Install
• Uninstall
• Upgrade
• Verify
2. Auto-verifies packages using GPG, MD5, SHA1SUMs
3. Automatically reports on unresolved dependencies
'rpm'
Query:
1. rpm -qa - dumps all installed packages
2. rpm -qa | wc -l - this dumps all packages and provides a count
3. rpm -qa | grep -i nano
4. rpm -qi nano - dumps info. about the 'nano' package as it's recorded in the
local RPM database
5. rpm -qf /usr/bin/nano - dumps package membership info. for the 'nano' file
6. rpm -qpi http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm -
dumps info. about the uninstalled 'dhcp' package, which resides on the
repository
7. rpm -ql package_name - returns all included files
Verify:
1. rpm -Va - verifies ALL packages on the system, returning info. only if there
are discrepancies from the original installation
2. rpm -Vf /usr/bin/nano
3. rpm -Vp nano
Install (Does NOT overwrite previous package):
Note: Use this method to install a new version of the kernel
1. rpm -ivh *.rpm
2. rpm -ivh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm
Task:
Change '/usr/bin/nano' then verify
SM5....T /usr/bin/nano
S(file size), M(mode or permissions), 5(MD5), T(mod time)
Upgrade (Installs or overwrites existing package):
1. rpm -Uvh *.rpm
2. rpm -Uvh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm
Freshen (Updates an existing package):
Note: Will NOT install the package, if it doesn't exist locally
1. rpm -Fvh *.rpm - freshens the current version of a package
Removal:
1. rpm -ev *.rpm - removes a pacakge
Note: removal process considers dependencies and will complain if the removal will break 1 or more packages. To get around this, use '--nodeps' option with 'rpm -ev --nodeps *.rpm'
2. rpm -ev gftp
Package Management GUI:
1. Add/Remove Software
2. system-config-packages
RAID IN REDHAT LINUX
RAID
Features:
1. The ability to increase availability and reliability of data
Tasks:
1. Create a RAID-1 Device (/dev/md0..n)
• fdisk /dev/sdb - to create usable raw partitions
• partprobe /dev/sdb - to force a kernel update of the partition layout of
the disk: /dev/sdb
• mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb5 /dev/sdb6
• cat /proc/mdstat - lists active RAID (md) information
• mke2fs -j /dev/md0 - overlays a file system on the RAID device
• mount /dev/md0 /raid1
• update: /etc/fstab
Note:
• use 'mdadm --query /dev/md0' to get information about a RAID device
• You may create RAID volumes/devices on a single or on multiple disks
Ideally, your RAID volumes should span multiple physical disks to improve:
• reliability
• performance
• availability
2. Remove the RAID-1 device
• umount /dev/md0
• mdadm --manage --stop /dev/md0
3. Create a RAID-5 Volume
• fdisk /dev/sdb - to create a partition number 7
• partprobe /dev/sdb - to update the kernel's view of the partition table
• mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb5
/dev/sdb6 /dev/sdb7
• watch cat /proc/mdstat - refreshes every 2 seconds
• Overlay a file system: mke2fs -j /dev/md0
• mount /dev/md0 /raid5
• Test I/O to RAID-5 device
• Update: /etc/fstab
Features:
1. The ability to increase availability and reliability of data
Tasks:
1. Create a RAID-1 Device (/dev/md0..n)
• fdisk /dev/sdb - to create usable raw partitions
• partprobe /dev/sdb - to force a kernel update of the partition layout of
the disk: /dev/sdb
• mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb5 /dev/sdb6
• cat /proc/mdstat - lists active RAID (md) information
• mke2fs -j /dev/md0 - overlays a file system on the RAID device
• mount /dev/md0 /raid1
• update: /etc/fstab
Note:
• use 'mdadm --query /dev/md0' to get information about a RAID device
• You may create RAID volumes/devices on a single or on multiple disks
Ideally, your RAID volumes should span multiple physical disks to improve:
• reliability
• performance
• availability
2. Remove the RAID-1 device
• umount /dev/md0
• mdadm --manage --stop /dev/md0
3. Create a RAID-5 Volume
• fdisk /dev/sdb - to create a partition number 7
• partprobe /dev/sdb - to update the kernel's view of the partition table
• mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb5
/dev/sdb6 /dev/sdb7
• watch cat /proc/mdstat - refreshes every 2 seconds
• Overlay a file system: mke2fs -j /dev/md0
• mount /dev/md0 /raid5
• Test I/O to RAID-5 device
• Update: /etc/fstab
LOGICAL VOLUME MANAGEMENT(LVM) IN REDHAT LINUX
Features:
1. Ability to create volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
• Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
• b. Logical Volumes
b1. File systems
4. LVM physical volumes can be of various sizes
5. Ability to resize volumes on the fly
Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)
6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
• fdisk /dev/sda, /dev/sdb, /dev/sdc
• n
• p
• +10G
• t - change to type '8e' (LVM)
• w
• partprobe /dev/sda
2. Create Physical Volumes using 'pvcreate'
• pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3
3. Create Volume Groups using 'vgcreate'
• vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes
4. Create one or more Logical Volumes
• lvcreate -L 10GB -n logvolvar1 volgroup001
• b. lvcreate -L 10GB -n logvolusr1 volgroup001
5. Create File system on logical volume(s)
• mke2fs -j /dev/volgroup001/logvolvar1
• b. mke2fs -j /dev/volgroup001/logvolusr1
6. Mount logical volume
• mkdir /var1
• mount /dev/volgroup001/logvolvar1 /var1
• mkdir /usr1
• mount /dev/volgroup001/logvolusr1 /usr1
Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots
3-tiers of LVM display commands include:
• pvdisplay - physical volumes - represent raw LVM partitions
• vgdisplay - volume groups - aggregate physical volumes
• lvdisplay - logical volumes - file systems - mount here
Rename of Logical Volume:
1. lvrename volume_group_name old new - used to rename volumes
Task:
Rename 'logvolvar1' to 'logvolopt1'
• lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
• b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
• c. Update /etc/fstab
Remove Logical Volume:
Task:
Remove 'logvolusr1' from the logical volume pool
• umount /usr1
• lvremove /dev/mapper/volgroup001-logvolusr1
• use 'lvdisplay' to confirm removal
Resize Logical Volume:
Task:
Grow (resize) 'logvolopt1' to 20GB
• lvresize -L 20GB /dev/volgroup001/logvolopt1
• lvdisplay - to confirm new size of logical volume
• df -h - will still reveal the current size
• Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'
Note: You may resize file systems online if the following are met:
2.6x kernel series
MUST be formatted with ext3
Task:
Shrink (resize) 'logvolopt1' to 15GB
• lvresize -L 15GB /dev/volgroup001/logvolopt1
• lvdisplay
• df -h
• resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
• e. df -h
Note: Check disk utilization prior to shrinking to reduce the risk of losing data
LVM GUI utility:
• system-config-lvm
1. Ability to create volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
• Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
• b. Logical Volumes
b1. File systems
4. LVM physical volumes can be of various sizes
5. Ability to resize volumes on the fly
Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)
6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
• fdisk /dev/sda, /dev/sdb, /dev/sdc
• n
• p
• +10G
• t - change to type '8e' (LVM)
• w
• partprobe /dev/sda
2. Create Physical Volumes using 'pvcreate'
• pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3
3. Create Volume Groups using 'vgcreate'
• vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes
4. Create one or more Logical Volumes
• lvcreate -L 10GB -n logvolvar1 volgroup001
• b. lvcreate -L 10GB -n logvolusr1 volgroup001
5. Create File system on logical volume(s)
• mke2fs -j /dev/volgroup001/logvolvar1
• b. mke2fs -j /dev/volgroup001/logvolusr1
6. Mount logical volume
• mkdir /var1
• mount /dev/volgroup001/logvolvar1 /var1
• mkdir /usr1
• mount /dev/volgroup001/logvolusr1 /usr1
Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots
3-tiers of LVM display commands include:
• pvdisplay - physical volumes - represent raw LVM partitions
• vgdisplay - volume groups - aggregate physical volumes
• lvdisplay - logical volumes - file systems - mount here
Rename of Logical Volume:
1. lvrename volume_group_name old new - used to rename volumes
Task:
Rename 'logvolvar1' to 'logvolopt1'
• lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
• b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
• c. Update /etc/fstab
Remove Logical Volume:
Task:
Remove 'logvolusr1' from the logical volume pool
• umount /usr1
• lvremove /dev/mapper/volgroup001-logvolusr1
• use 'lvdisplay' to confirm removal
Resize Logical Volume:
Task:
Grow (resize) 'logvolopt1' to 20GB
• lvresize -L 20GB /dev/volgroup001/logvolopt1
• lvdisplay - to confirm new size of logical volume
• df -h - will still reveal the current size
• Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'
Note: You may resize file systems online if the following are met:
2.6x kernel series
MUST be formatted with ext3
Task:
Shrink (resize) 'logvolopt1' to 15GB
• lvresize -L 15GB /dev/volgroup001/logvolopt1
• lvdisplay
• df -h
• resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
• e. df -h
Note: Check disk utilization prior to shrinking to reduce the risk of losing data
LVM GUI utility:
• system-config-lvm
BASIC PROVISIONING OF PARTITIONS AND FILE SYSTEMS IN REDHAT LINUX
BASIC PROVISIONING OF PARTITIONS AND FILE SYSTEMS
Features:
1. Ability to provision extra storage on-the-fly
Steps:
1. Identify available storage
• 'fdisk -l' - returns connected storage
2. Create partitions on desired hard drive:
• 'fdisk /dev/sdb' - interacts with /dev/sdb drive
• 'n' - to add a new partition
• 'p' - primary
• '1' - start cylinder
• '+4096M' - to indicate 4 Gigabytes
• 'w' - to write the changes to the disk
Note:
• use 'partprobe partition (/dev/sdb1)' to force a write to a hard drive's
partition table on a running system
• 'fdisk' creates raw partitions
3. Overlay (format) the raw partition with a file system
• mke2fs -j /dev/sdb1 - this will write inodes to partition
4. Mount the file system in the Linux file system hierarchy:
• mkdir /home1 && mount /dev/sdb1 /home1
• mount OR df -h - either will reveal that /dev/sdb1 is mounted
Note: lost+found directory is created for each distinct file system
5. Configure '/home1' to auto-mount when the system boots
• nano /etc/fstab and copy and modify the '/home' entry
Features:
1. Ability to provision extra storage on-the-fly
Steps:
1. Identify available storage
• 'fdisk -l' - returns connected storage
2. Create partitions on desired hard drive:
• 'fdisk /dev/sdb' - interacts with /dev/sdb drive
• 'n' - to add a new partition
• 'p' - primary
• '1' - start cylinder
• '+4096M' - to indicate 4 Gigabytes
• 'w' - to write the changes to the disk
Note:
• use 'partprobe partition (/dev/sdb1)' to force a write to a hard drive's
partition table on a running system
• 'fdisk' creates raw partitions
3. Overlay (format) the raw partition with a file system
• mke2fs -j /dev/sdb1 - this will write inodes to partition
4. Mount the file system in the Linux file system hierarchy:
• mkdir /home1 && mount /dev/sdb1 /home1
• mount OR df -h - either will reveal that /dev/sdb1 is mounted
Note: lost+found directory is created for each distinct file system
5. Configure '/home1' to auto-mount when the system boots
• nano /etc/fstab and copy and modify the '/home' entry
USER QUOTAS IN REDHAT LINUX
USER QUOTAS
Features:
1. Limits disk usage (blocks or inodes)
2. Tied to file systems (set on a per file system basis)
3. Can be configured for users and groups
Steps to enable quota support:
1. Enable quota support per file system in: /etc/fstab
• defaults,usrquota,grpquota
2. Remount the file system(s)
• mount -o remount /
• use 'mount' to confirm that 'usrquota,grpquota' support are enabled
3. Create quota database files and generate disk usage table
• quotacheck -mcug / - this creates /aquota.user & /aquota.group
• quotacheck -mavug
4. Assign quota policies
• edquota username - set blocks/inodes soft_limits hard_limit
• edquota student1 - sets quotas for user 'student1'
• export EDITOR=nano - to have edquota default to 'nano' editor
5. Check quotas
• quota username
Ex: quota student1
Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily)
6. Report on usage
• repquota -a - this reports on usage
Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB
Features:
1. Limits disk usage (blocks or inodes)
2. Tied to file systems (set on a per file system basis)
3. Can be configured for users and groups
Steps to enable quota support:
1. Enable quota support per file system in: /etc/fstab
• defaults,usrquota,grpquota
2. Remount the file system(s)
• mount -o remount /
• use 'mount' to confirm that 'usrquota,grpquota' support are enabled
3. Create quota database files and generate disk usage table
• quotacheck -mcug / - this creates /aquota.user & /aquota.group
• quotacheck -mavug
4. Assign quota policies
• edquota username - set blocks/inodes soft_limits hard_limit
• edquota student1 - sets quotas for user 'student1'
• export EDITOR=nano - to have edquota default to 'nano' editor
5. Check quotas
• quota username
Ex: quota student1
Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily)
6. Report on usage
• repquota -a - this reports on usage
Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB
SYMLINKS IN REDHAT LINUX
SYMLINKS
Features:
1. Provides shortcuts to files (including directories)
2. Provides hard links to inode (file system) locations
Soft Links:
1. ln -s source_file target
a. ln -s ./regextest.pl lastscript.pl
Note:
• Soft links may span multiple file systems/hard drives
• Symlink count is NOT increased when using soft links
2. ln -s /home/linuxcbt/testRH5/regextest.pl . - this will symlink (soft) to
the /boot file system
Note: With soft links, if you change the name or location of the source file, you will break ALL of the symlinks (soft)
Hard Links:
Features:
1. The ability to reference the same inode/hard drive location from multiple
places within the same file system
• ln source target
• ln regextest.pl ./testhardregextest.pl - creates a hard link
Features:
1. Provides shortcuts to files (including directories)
2. Provides hard links to inode (file system) locations
Soft Links:
1. ln -s source_file target
a. ln -s ./regextest.pl lastscript.pl
Note:
• Soft links may span multiple file systems/hard drives
• Symlink count is NOT increased when using soft links
2. ln -s /home/linuxcbt/testRH5/regextest.pl . - this will symlink (soft) to
the /boot file system
Note: With soft links, if you change the name or location of the source file, you will break ALL of the symlinks (soft)
Hard Links:
Features:
1. The ability to reference the same inode/hard drive location from multiple
places within the same file system
• ln source target
• ln regextest.pl ./testhardregextest.pl - creates a hard link
SETUID IN REDHAT LINUX
SETUID:
Features:
a.ability to execute file as owner
b.chmod 4760 regextest.pl - this will ensure that the perl script always
executes as the user 'linuxcbt'
-rwsrw---- 1 linuxcbt sales 787 Jan 13 16:08 regextest.pl
's' in the execute position means that the program will execute as that user
SETGID:
Features:
Ability to enforce permissions to a directory structure
• mkdir /sales
• chmod 2775 /sales
Example:
Create a file in the '/sales' directory as 'linuxcbt'
• seq 1000000 > linuxcbt.1million.txt
chgrp:
Permits updating of group permissions
Sticky Bit:
Features:
Ability to ensure that users cannot delete others' files in a directory
drwxrwxrwt 23 root root 4096 Jan 13 15:05 /tmp/
/tmp - users cannot delete other user's files in '/tmp'
chmod 3777 /sales - ensures that /sales will not lose files from incorrect users
Task:
Set '/sales' using sticky bit and test
a. chmod 3777 /sales && ls -ld /sales OR chmod 777 /sales && chmod +t /sales
Features:
a.ability to execute file as owner
b.chmod 4760 regextest.pl - this will ensure that the perl script always
executes as the user 'linuxcbt'
-rwsrw---- 1 linuxcbt sales 787 Jan 13 16:08 regextest.pl
's' in the execute position means that the program will execute as that user
SETGID:
Features:
Ability to enforce permissions to a directory structure
• mkdir /sales
• chmod 2775 /sales
Example:
Create a file in the '/sales' directory as 'linuxcbt'
• seq 1000000 > linuxcbt.1million.txt
chgrp:
Permits updating of group permissions
Sticky Bit:
Features:
Ability to ensure that users cannot delete others' files in a directory
drwxrwxrwt 23 root root 4096 Jan 13 15:05 /tmp/
/tmp - users cannot delete other user's files in '/tmp'
chmod 3777 /sales - ensures that /sales will not lose files from incorrect users
Task:
Set '/sales' using sticky bit and test
a. chmod 3777 /sales && ls -ld /sales OR chmod 777 /sales && chmod +t /sales
FILE TYPES-PERMISSIONS-SYMLINKS IN REDHAT LINUX
FILE TYPES-PERMISSIONS-SYMLINKS
Features:
1. The ability to restrict/control access to files
Note:
• 10 bits represent permissions for files (including directories)
• use 'ls -l' to examine permissions or GUI application like 'Nautilus'
-rwxrwxr-x 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
• 1st bit = file type. '-' = file, 'd' = directory
• 2nd - 4th bits = owner's permissions
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
• 5th - 7th bits = group owner's permissions
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
• 8th - 10th bits = everyone (world)
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
Task:
1. Manipulate file permissions using 'chmod'
• chmod -x regextest.pl
• -rw-rw-r-- 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
• rw = 6 or 4+2 for owner
• rw = 6 or 4+2 for group owner
• r = 4 for everyone else (world)
• Octal notation: 664 for file 'regexetest.pl'
• chmod 664 regextest.pl - removes execution for ALL users
• chmod 775 regextest.pl - enables execution for ALL users
2. Ensure that 'regextest.pl' is rw by owner and noone else
• chmod 600 regextest.pl
Note: File will now be rw by owner (linuxcbt) and 'root'
3. Ensure that 'regextest.pl' is r by owner and noone else
• chmod 400 regextest.pl && ls -l regextest.pl
Note: chmod supports string values, which represent octal values
• chmod +/- x file
• chmod +/- w file
• chmod +/- r file
• chmod +/- u+x file - updates owner's execute permissions on the file
• chmod +/- o+x file - updates other's execute permissions on the file
• chmod +/- g+x file - updates group's execute permissions on the file
• chmod a+rwx = chmod 777
• chown - permits changing of ownership of files
chown root regextest.pl - changes ownership to 'root'
chown linuxcbt:sales regextest.pl - changes owner and group to
'linuxcbt:sales'
Task:
Update 'regextest.pl' so that owner and group owner may modify the file
• chmod 660 regextest.pl
Features:
1. The ability to restrict/control access to files
Note:
• 10 bits represent permissions for files (including directories)
• use 'ls -l' to examine permissions or GUI application like 'Nautilus'
-rwxrwxr-x 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
• 1st bit = file type. '-' = file, 'd' = directory
• 2nd - 4th bits = owner's permissions
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
• 5th - 7th bits = group owner's permissions
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
• 8th - 10th bits = everyone (world)
• r = read = 4
• w = write = 2
• x = execute = 1
• -= none = 0
Task:
1. Manipulate file permissions using 'chmod'
• chmod -x regextest.pl
• -rw-rw-r-- 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
• rw = 6 or 4+2 for owner
• rw = 6 or 4+2 for group owner
• r = 4 for everyone else (world)
• Octal notation: 664 for file 'regexetest.pl'
• chmod 664 regextest.pl - removes execution for ALL users
• chmod 775 regextest.pl - enables execution for ALL users
2. Ensure that 'regextest.pl' is rw by owner and noone else
• chmod 600 regextest.pl
Note: File will now be rw by owner (linuxcbt) and 'root'
3. Ensure that 'regextest.pl' is r by owner and noone else
• chmod 400 regextest.pl && ls -l regextest.pl
Note: chmod supports string values, which represent octal values
• chmod +/- x file
• chmod +/- w file
• chmod +/- r file
• chmod +/- u+x file - updates owner's execute permissions on the file
• chmod +/- o+x file - updates other's execute permissions on the file
• chmod +/- g+x file - updates group's execute permissions on the file
• chmod a+rwx = chmod 777
• chown - permits changing of ownership of files
chown root regextest.pl - changes ownership to 'root'
chown linuxcbt:sales regextest.pl - changes owner and group to
'linuxcbt:sales'
Task:
Update 'regextest.pl' so that owner and group owner may modify the file
• chmod 660 regextest.pl
USER/GRUOP MANAGEMENT IN REDHAT LINUX
USER/GRUOP MANAGEMENT
Features:
The ability to control users and groups
Primary tools:
1. useradd - used to add users and modify group membership
2. system-config-users
Task:
1. Create a user named 'student1' using 'useradd'
Note:
a.Default user settings derive from: /etc/login.defs
b.useradd student1
c.set password for user 'student1': passwd student1
d.Default User Accounts DB: /etc/passwd
e.student1:x:501:501::/home/student1:/bin/bash
f.username:shadow_reference:uid:gid:Description(GECOS):$HOME:$SHELL
Note:
a./etc/passwd is a world-readable file
b./etc/shadow now stores passwords in encrypted form
c./etc/shadow is NOT world-readable
Fields in /etc/shadow:
a.student1:$1$XSFMv2ru$lfTACjN.XxaxbHA0EkB4U0:13891:0:99999:7:::
b.username:
encrypted_password:
Days_since_Unix_epoch_password_was_changed (01/01/1970)
Days before password may be changed
Days after which the password MUST be changed
Days before password is to expire that user is warned
Days after password expires, that account is disabled
Days since Unix epoch, that account is disabled
Reserved field (currently unused)
2. Modify user 'student1' to have password expire after 45 days
usermod
Groups:
1. groupadd - adds new group
2. groups - lists groups on the system: /etc/group
/etc/group - maintains group membership information
Task:
a.Create a 'sales' group and add 'linuxcbt' and 'student1' as members
b.groupadd sales
c.usermod -G sales linuxcbt
d.usermod -G sales student1
Note: 2 types of groups exist:
1. Primary - used by default for a user's permissions
2. Supplemental - used to determine effective permissions
Note:
• use 'id' to determine the group information of user
• Create a new shell session to realize new group membership information
userdel/groupdel are used to delete users and groups, respectively
Features:
The ability to control users and groups
Primary tools:
1. useradd - used to add users and modify group membership
2. system-config-users
Task:
1. Create a user named 'student1' using 'useradd'
Note:
a.Default user settings derive from: /etc/login.defs
b.useradd student1
c.set password for user 'student1': passwd student1
d.Default User Accounts DB: /etc/passwd
e.student1:x:501:501::/home/student1:/bin/bash
f.username:shadow_reference:uid:gid:Description(GECOS):$HOME:$SHELL
Note:
a./etc/passwd is a world-readable file
b./etc/shadow now stores passwords in encrypted form
c./etc/shadow is NOT world-readable
Fields in /etc/shadow:
a.student1:$1$XSFMv2ru$lfTACjN.XxaxbHA0EkB4U0:13891:0:99999:7:::
b.username:
encrypted_password:
Days_since_Unix_epoch_password_was_changed (01/01/1970)
Days before password may be changed
Days after which the password MUST be changed
Days before password is to expire that user is warned
Days after password expires, that account is disabled
Days since Unix epoch, that account is disabled
Reserved field (currently unused)
2. Modify user 'student1' to have password expire after 45 days
usermod
Groups:
1. groupadd - adds new group
2. groups - lists groups on the system: /etc/group
/etc/group - maintains group membership information
Task:
a.Create a 'sales' group and add 'linuxcbt' and 'student1' as members
b.groupadd sales
c.usermod -G sales linuxcbt
d.usermod -G sales student1
Note: 2 types of groups exist:
1. Primary - used by default for a user's permissions
2. Supplemental - used to determine effective permissions
Note:
• use 'id' to determine the group information of user
• Create a new shell session to realize new group membership information
userdel/groupdel are used to delete users and groups, respectively
SYSTEM UTILITIES IN REDHAT LINUX
SYSTEM UTILITIES
Features:
1. Process listing
2. Free/available memory
3. Disk utilization
1. ps - process status/listing
ps -ef or ps -aux
2. top - combines, ps, uptime, free and updates regulary
3. uptime - returns useful system utilization information:
a.current time
b. uptime - days, hours and minutes
c. connected users
d. load averaged - 1,5,15 minute values
4. free - returns memory utilization
a.RAM
b.SWAP
c.free -m - for human readable format
5. df - returns disk partition/mount point information
a.df - returns info. using kilobytes
b.df -h - returns info. using megabytes/human readable (gigs/teray/etc.)
6. vmstat - reports on: processes, memory, paging, block I/O, traps, CPU activity
a.vmstat
b.vmstat -p /dev/hda1 - returns partitions stats for /dev/hda1 (/boot)
7. gnome-system-monitor - GUI, combining most system utilities
8. ls -ltr /proc
a.cat /proc/cpuinfo
9. kill PID - kills the process with a given PID
10. runlevel - returns runlevel information using 2 fields:
a.represents previous runlevel
b.represents current runlevel
Features:
1. Process listing
2. Free/available memory
3. Disk utilization
1. ps - process status/listing
ps -ef or ps -aux
2. top - combines, ps, uptime, free and updates regulary
3. uptime - returns useful system utilization information:
a.current time
b. uptime - days, hours and minutes
c. connected users
d. load averaged - 1,5,15 minute values
4. free - returns memory utilization
a.RAM
b.SWAP
c.free -m - for human readable format
5. df - returns disk partition/mount point information
a.df - returns info. using kilobytes
b.df -h - returns info. using megabytes/human readable (gigs/teray/etc.)
6. vmstat - reports on: processes, memory, paging, block I/O, traps, CPU activity
a.vmstat
b.vmstat -p /dev/hda1 - returns partitions stats for /dev/hda1 (/boot)
7. gnome-system-monitor - GUI, combining most system utilities
8. ls -ltr /proc
a.cat /proc/cpuinfo
9. kill PID - kills the process with a given PID
10. runlevel - returns runlevel information using 2 fields:
a.represents previous runlevel
b.represents current runlevel
SED-STREAM EDITOR
SED-STREAM EDITOR
Features:
1. Faciliates automated text editing
2. Supports RegExes (POSIX)
3. Like Awk, supports scripting using '-F' option
4. Supports input via: STDIN, pipe, file
Usage:
1. sed [options] 'instruction[s]' file[s]
2. sed -n '1p' grep1.txt - prints the first line of the file
3. sed -n '1,5p' grep1.txt - prints the first 5 lines of the file
4. sed -n '$p' grep1.txt - prints the last line of the file
5. sed -n '1,3!p' grep1.txt - prints ALL but lines 1-3
6. sed -n '/linux/p' grep1.txt - prints lines with 'linux'
7. sed -e '/^$/d' grep1.txt - deletes blank lines from the document
8. sed -e '/^$/d' grep1.txt > sed1.txt - deletes blank lines from the document
'grep1.txt' and creates 'sed1.txt'
9. sed -ne 's/search/replace/p' sed1.txt
10. sed -ne 's/linux/unix/p' sed1.txt
11. sed -i.bak -e 's/3/4' sed1.txt - this backs up the original file and creates
a new 'sed1.txt' with the modifications indicated in the command
Note:
1)Generally, to create new files, use output redirection, instead of
allowing sed to write to STDOUT
2)Sed applies each instruction to each line
Features:
1. Faciliates automated text editing
2. Supports RegExes (POSIX)
3. Like Awk, supports scripting using '-F' option
4. Supports input via: STDIN, pipe, file
Usage:
1. sed [options] 'instruction[s]' file[s]
2. sed -n '1p' grep1.txt - prints the first line of the file
3. sed -n '1,5p' grep1.txt - prints the first 5 lines of the file
4. sed -n '$p' grep1.txt - prints the last line of the file
5. sed -n '1,3!p' grep1.txt - prints ALL but lines 1-3
6. sed -n '/linux/p' grep1.txt - prints lines with 'linux'
7. sed -e '/^$/d' grep1.txt - deletes blank lines from the document
8. sed -e '/^$/d' grep1.txt > sed1.txt - deletes blank lines from the document
'grep1.txt' and creates 'sed1.txt'
9. sed -ne 's/search/replace/p' sed1.txt
10. sed -ne 's/linux/unix/p' sed1.txt
11. sed -i.bak -e 's/3/4' sed1.txt - this backs up the original file and creates
a new 'sed1.txt' with the modifications indicated in the command
Note:
1)Generally, to create new files, use output redirection, instead of
allowing sed to write to STDOUT
2)Sed applies each instruction to each line
Labels:
linux,
redhat linux,
redhat linux commands,
SED-STREAM EDITOR
TAR,GZIP,BZIP2,ZIP
TAR,GZIP,BZIP2,ZIP
Features:
Compression utilities (gzip, bzip2, zip)
File rollers (the ability to represent many files as one)
GZIP:
Includes:
gzip - compresses/decompresses files
gunzip - decompresses gzip files
Tasks:
1. compress '1million.txt' file using gzip
gzip -c 1million.txt > 1million.txt.gz
Note: gzip auto-dumps to STDOUT, by default
gzip -l 1million.txt.gz - returns status information
• gunzip 1million.txt.gz - dumps to file, and removes compressed version
• gzip -d 1million.txt.gz
• zcat 1million.txt.gz - dumps the contents to STDOUT
• less 1million.txt.gzip - dumps the contents of gzip files to STDOUT
Bzip2:
1. bzip2 -c 1million.txt > 1million.txt.bz2
Note: Bzip2 tends to outperform gzip on larger files
2. bunzip2 1million.txt.bz2
3. bzip2 -d 1million.txt.bz2
4. bzcat 1million.txt.bz2 - dumps contents to STDOUT
5. less 1million.txt.bz2 - also dumps the contents to STDOUT
Zip & unzip:
1. zip filename.zip path/ - general usage
2. zip 1million.txt.zip 1million.txt
Note: zip differs slight from gzip and bzip2 in that the destination file (resultant zip file) is specified before the source
3. unzip 1million.txt.zip
Tar & Gzip/Bzip2:
1. tar -cvf filename.tar path/ - creates a non-compressed archive
2. tar -cvf 1million.txt.tar 1million.txt
Note: tar, requires a small overhead for itself in each file
3. tar -czvf 1million.txt.tar.gz 1million.txt - creates, tar/gzip document
4. tar -cjvf 1million.txt.tar.bz2 1million.txt - creates, tar/bzip2 document
5. tar -tzvf
6. tar -cjvf 1million.txt.tar.bz2 1million.txt testRH5/- creates, tar/bzip2
document for the text file and 'testRH5' directory tree
Features:
Compression utilities (gzip, bzip2, zip)
File rollers (the ability to represent many files as one)
GZIP:
Includes:
gzip - compresses/decompresses files
gunzip - decompresses gzip files
Tasks:
1. compress '1million.txt' file using gzip
gzip -c 1million.txt > 1million.txt.gz
Note: gzip auto-dumps to STDOUT, by default
gzip -l 1million.txt.gz - returns status information
• gunzip 1million.txt.gz - dumps to file, and removes compressed version
• gzip -d 1million.txt.gz
• zcat 1million.txt.gz - dumps the contents to STDOUT
• less 1million.txt.gzip - dumps the contents of gzip files to STDOUT
Bzip2:
1. bzip2 -c 1million.txt > 1million.txt.bz2
Note: Bzip2 tends to outperform gzip on larger files
2. bunzip2 1million.txt.bz2
3. bzip2 -d 1million.txt.bz2
4. bzcat 1million.txt.bz2 - dumps contents to STDOUT
5. less 1million.txt.bz2 - also dumps the contents to STDOUT
Zip & unzip:
1. zip filename.zip path/ - general usage
2. zip 1million.txt.zip 1million.txt
Note: zip differs slight from gzip and bzip2 in that the destination file (resultant zip file) is specified before the source
3. unzip 1million.txt.zip
Tar & Gzip/Bzip2:
1. tar -cvf filename.tar path/ - creates a non-compressed archive
2. tar -cvf 1million.txt.tar 1million.txt
Note: tar, requires a small overhead for itself in each file
3. tar -czvf 1million.txt.tar.gz 1million.txt - creates, tar/gzip document
4. tar -cjvf 1million.txt.tar.bz2 1million.txt - creates, tar/bzip2 document
5. tar -tzvf
6. tar -cjvf 1million.txt.tar.bz2 1million.txt testRH5/- creates, tar/bzip2
document for the text file and 'testRH5' directory tree
Labels:
BASIC LINUX COMMANDS,
BZIP2,
GZIP,
redhat linux commands,
TAR,
ZIP in redhat linux
COMMAND CHAINING
COMMAND CHAINING
Features:
1.Permits the execution of multiple commands in sequence
2.Also permits execution based on the success or failure of a previous command
3.cat 123.txt ; ls -l - this runs first command, then second command
without regards for exit status of the first command
4.cat 123.txt && ls -l - this runs second command, if first command
is successful
5.cat 1234.txt && ls -l
6.cat 123.txt || ls -l - this runs second command, if first command fails
1. more|less - paginators, which display text one-page @ a time
1.1)more /etc/fstab
1.2)less 1thousand.txt
2. seq - echoes a sequence of numbers
seq 1000 > 1thousand.txt - creates a file with numbers 1-1000
3. su - switches users
su - with no options attempts to log in as 'root'
4. head - displays opening lines of text files
head /var/log/messages
5. tail - displays the closing lines of text files
tail /var/log/messages
6. wc - counts words and optionally lines of text files
wc -l /var/log/messages
wc -l 123.txt
7. file - determines file type
file /var/log/messages
Features:
1.Permits the execution of multiple commands in sequence
2.Also permits execution based on the success or failure of a previous command
3.cat 123.txt ; ls -l - this runs first command, then second command
without regards for exit status of the first command
4.cat 123.txt && ls -l - this runs second command, if first command
is successful
5.cat 1234.txt && ls -l
6.cat 123.txt || ls -l - this runs second command, if first command fails
1. more|less - paginators, which display text one-page @ a time
1.1)more /etc/fstab
1.2)less 1thousand.txt
2. seq - echoes a sequence of numbers
seq 1000 > 1thousand.txt - creates a file with numbers 1-1000
3. su - switches users
su - with no options attempts to log in as 'root'
4. head - displays opening lines of text files
head /var/log/messages
5. tail - displays the closing lines of text files
tail /var/log/messages
6. wc - counts words and optionally lines of text files
wc -l /var/log/messages
wc -l 123.txt
7. file - determines file type
file /var/log/messages
Subscribe to:
Posts (Atom)