Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Linux

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

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

If we want to install an application(Ex: apache), rpm need to


install all the packages required for this application, these
packages may vary from 1 rpm to several rpms depending on
shared rpm packages.

RPM package dependencies is bit tough

Batch installation of applications is possible with one command

RPM can not handle updated software installation automatically

Can not connect to online repositories

Install an application with single


command
Ex: yum install httpd
YUM resolves dependencies with
ease
YUM command can install number
of applications in one single
command
Ex: yum install httpd vsftpd
Does YUM install updates of the
existing packages by using
yum install upgrade
Can connect to on-line repositories
to get latest software before
installing the applications

=====================================================
====================================
Disk partitions
============

# cat /proc/partitions | grep hd (Information of current partions (IDE))

# cat /proc/partitions | grep sd (Information of SCSI disks)


# fdisk l (To list the current partitions on all disks)

# 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

1.Syntax: fdisk [options] [device]


To list the current partitions on all disks, use this command:
***fdisk l***
Disk /dev/hda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00021654
Device Boot Start End Blocks Id System
/dev/hda1 * 1 64 512000 83 Linux
/dev/hda2 64 2611 20458496 8e Linux LVM
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
Disk /dev/hdb doesnt contain a valid partition table
Disk /dev/hdc: 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: 0x00000000
Disk /dev/hdc doesnt contain a valid partition table
You could also use the parted command to obtain the same information.
Syntax:
2.***parted [options] [device [command]] ***
Options:
MIGRATION TIP
Starting with RHEL6, Red Hat recommends using the parted utility over fdisk.
REAL-WORLD TIP
There are some limitations when it comes to working with partitions. You can have
only four partitions to a physical diskwith one exception. If you want to make
View all partitions using parted:

# 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:

Command (m for help): m


Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partitions system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

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:

Command (m for help): n


Command action
e extended
p primary partition (1-4)p
Partition number (1-4): 2
First cylinder (549-1044, default 549):
Using default value 549
Last cylinder or +size or +sizeM or +sizeK (8322-16644, default16644):1044
Using default value 1044
Step 6. Verify your newly created partitions:
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
Device Boot Start End Blocks Id System
/dev/hdb1 1 548 4401778+ 83 Linux
/dev/hdb2 549 1044 3984120 83 Linux
Step 7. Write the changes to disk:
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
To make sure that it recognizes
all disks and partitions correctly. To do this, you use the partprobe
command.
Syntax: partprobe [OPTIONS] [DEVICE]
Options:
-d Does not actually inform the operating system
-s Prints a summary of contents
Step 8. Call the partprobe command:
# partprobe /dev/hdb
This command has no output to it.
Step 9. Verify the partition creation one last time:
# fdisk -l
Disk /dev/hda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00021654
Device Boot Start End Blocks Id System
/dev/hda1 * 1 64 512000 83 Linux
/dev/hda2 64 2611 20458496 8e Linux LVM
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
Device Boot Start End Blocks Id System

/dev/hdb1 1 548 4401778+ 83 Linux


/dev/hdb2 549 1044 3984120 83 Linux
=====================================================
=====================================

You might also like