Linux
Linux
Linux
=====
*
*
*
*
Commands
Kickstart
YUM & RPM
Disk partition
Commands
==========
# lshw --short
# hwinfo --short
CPU
===
# mpstat -P ALL
# top
# sar
---cat /proc/cpuinfo
Memory
=======
# dmidecode -t 17
# free -m
# top
----cat /proc/meminfo
Service
======
Syntax:
chkconfig [option] service_name
Options:
--list [name]
Shows the status of the service at each runlevel
--add <name>
Adds a service to be managed by the chkconfig command
--del <name>
Removes a service from being managed by the chkconfig
command
--level <levels>
Enables or disables the service at the given levels
<name> <on|off|
Enables or disables the service at levels 25
reset>
===============
/SYS/class/scsi-host
Echo --->scan
================
=====================================================
===================================
Kickstart
========
1. Need to install the Apache web server:
# yum install -y httpd
2. Verify the package was installed:
# rpm -qa | grep httpd
httpd-2.2.15-5.el6.x86_64
httpd-tools-2.2.15-5.el6.x86_64
3. Start the Apache service:
# service httpd start
4. Enable the service to start on boot:
# chkconfig httpd on
5. Verify:
# chkconfig httpd list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6. Create the following directory:
# mkdir /var/www/pub
7. You should ensure that the Red Hat CD is mounted in the CD drive:
# mount /dev/cd-rom /mnt
8. Now copy the files from the CD to the directory previously created:
# cp -vR /mnt/* /var/www/pub/
9. When the install files are in place, you need to make one last directory:
# mkdir /var/www/pub/kickstart
10. Verify that you now have a directory structure that looks like the following:
# tree /var/www/pub
/var/www/pub
|-- EFI
| |-- BOOT
| | |-- BOOTX64.
11. At this point, you would normally create your kickstart file, but we look at that in the
next section, so for now just create a placeholder:
# touch /var/www/pub/kickstart/redhat-base.cfg
12. Use the iptables command to create your firewall rule:
# iptables -I INPUT 5 -p tcp -m tcp --dport 80 -j ACCEPT
13. Save the rule you just created:
# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
14. Restart the firewall service for the changes to take effect:
# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
15. Your kickstart server setup is now complete. To get the client to access the kickstart
server, you need to boot the client from the Red Hat CD.
When you reach the boot prompt, type the following command:
# linux ks=http://172.168.1.1/pub/kickstart/redhat-base.cfg append
ip=172.168.1.105 netmask=255.255.255.0
=====================================================
===================================
YUM (Yellow dog updater and modifier)
=================================
Finding package name which install a particular file in the machine by using yum
command.
yum provides /usr/bin/script
yum install -y lvm2
rpm qa | grep lvm2
Options:
=======
-c Specifies the location of the config file
-q Specifies quiet, no output
-y Indicates to always answer yes to prompts
-v Provides verbose output
Commands
========
clean
Removes cached data
erase
Removes a package from the system
grouplist
Displays available package groups
groupinstall Installs the packages within a group
info
Displays information about a package
install
Installs a package on the system
search
Enables you to search for a package
update
Updates a package
For making RPM package
=====================
yum install y rpm-build make
# rpm -qa | grep rpm-build
rpm-build-4.8.0-12.el6.x86_64
# rpm -qa | grep make
make-3.81-19.el6.x86_64
mkdir p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
# mkdir /usr/src/redhat/mysample
# cd /usr/src/redhat/mysample
# touch first_file second_file keys config_file
# cd /usr/src/redhat
# tar cf mysample.tar.gz mysample
# mv mysample.tar.gz SOURCES/
# rpmbuild v bb /usr/src/redhat/SPECS/sample.spec
# ls /usr/src/redhat/RPMS/x86_64/
# cd /usr/src/redhat/RPMS/x86_64
# rpm -ivh mysample-1.0-0.x86_64.rpm
Preparing...
########################################### [100%]
1:mysample
########################################### [100%]
# rpm -qa | grep mysample
mysample-1.0-0
# ls/opt/sample_pkge/
config_file first_file keys second_file
RPM
====
Finding package name which install a particular file in the machine by using rpm
command.
rpm -qf /usr/bin/script
-e Removes a given package
-i Installs a given package
-h Shows hash progress when installing
-U Upgrades a given package
-v Provides verbose output
Query Options (with -q):
====================
-c Lists all config files
-d Lists all documentation files
-i Displays information about the package
-l Lists the files in a package
Verify Options (with -v):
========================
-a Queries all packages
-f Displays information about the specified file
RPM YUM
=====================================================
====================================
Disk partitions
============
# parted l
# fdisk /dev/hdb
#partprobe /dev/hdb
To view information about the current partition layout, use the following command:
# cat /proc/partitions | grep hd
8
8
8
8
8
8
0 20971520 hda
1 512000 hda1
2 20458496 hda2
16 8388608 hdb
32 8388608 hdc
48 8388608 hdd
If you are using SCSI disks instead of IDE disks, you can just change the command to
# cat /proc/partitions | grep sd
# parted -l
Model: VBOX HARDDISK (ide)
Disk /dev/hda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 525MB 525MB primary ext4 boot
2 525MB 21.5GB 20.9GB primary lvm
Error: Unable to open /dev/hdb - unrecognised disk label.
Error: Unable to open /dev/hdc - unrecognised disk label.
Creating Partition.
===============
Step 1. Choose the disk:
# fdisk /dev/hdb
Step 2. View all the options available to you:
Step 3. Use the p command to print out the current partition table (this
shouldnt exist, but just verify):
Command (m for help): p
Disk /dev/hdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004b72d
Step 4. Create a new partition:
Command (m for help): n
Command action
e extended
p primary partition (1-4) p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or or +size or +sizeM or +sizeK (1-1044, default 1044): +4294M
Step 5. Create a second partition: