Monday, March 30, 2015

RedHat Packet Manager (rpm) helpful Linux commands with live examples !!

I would like to give some examples which can help everyone to refer the rpm command options in Linux OS.

1.     To install a package

#rpm –ivh packagename [install –i ,verbose –v , h – hash in the output]

2.  To query a package

#rpm –q packgename
#rpm –qa packagename*
#rpm –qa|grep packahe

3. Query RPM Packages in a various format using rpm –queryformat







Note: Just check the output , how it is showing the package version with release and arch details. This is very interesting and helpful command for me.


4.  Which RPM package does a file belong to? – Use rpm -qf


          


5. Locate documentation of a package that owns file using rpm -qdf

                                                                                                                                                                                       
        

6.   Information about Installed RPM Package using rpm -qi

 



7. If you have an rpm file that you would like to install, but want to know more information about it before installing, you can do the following














8.  List all the Files in a Package using rpm -qlp

Note: This is also a very useful command to know about the files in a package. I prefer to verify/check the files instead of blindly installing it.





9     














          9.   List the Dependency Packages using rpm –qRP 
      
                    
          
         


       10. Upgrading a RPM Package using rpm –Uvh
      
           #rpm –Uvh sendmail.rpm


11. To uninstall a package

     #rpm –e packagename

12. To verify all packages

     #yum –Va

13.  Verify a Package Owning file using rpm -Vf





     



S - file size differs

5 - MD 5 Sum differs
T - mTime  differs

Sunday, March 29, 2015

TCPDUMP – Network Packet Analyzer

This is very important and helpful command  and  every system admin should know about this .Refer this article,and try it and be an expert !!!

What is tcpdump ? 

tcpdump allows us to save the packets that are captured, so that we can use it for future analysis. The saved file can be viewed by the same tcpdump command

Here I am giving you some examples to understand...

1 .     Capture packets from a particular Ethernet interface using

#tcpdump –i eth0 



      2.  Capture only N number of packets using tcpdump

         #tcpdump –c    2 -i eth0 [It will capture 2 packets]





     3.  Display Captured Packets in ASCII using tcpdump –A






       4.   Display Captured Packets in HEX and ASCII using tcpdump -XX

     




     5.    Capture the packets and write into a file using tcpdump –w







    6.  Reading the packets from a saved file using tcpdump –r





7.  Capture packets with IP address using tcpdump –n

     



   8.  Capture packets with proper readable timestamp using tcpdump -tttt





   9.   Read packets longer than N bytes

                                                                                                                                                                   



   10.  Receive only the packets of a specific protocol type









    11. Read packets lesser than N bytes





   12.   Receive packets flows on a particular port using tcpdump port





   13. Capture packets for particular destination IP and Port 





   14.    tcpdump Filter Packets –Capture all the packets other than arp and tcp




Yellodog Update Modifier – YUM helpful commands

Here I am giving you various yum command options in Linux OS, as we  all  System Administrators needs to deal with this command frequently. Lets take a quick look and be an expert !!  

1.     To install a package
#yum install packagename
#yum install packagename –y  [y – default yes for all the available packages]

2.     To uninstall a package
#yum remove packagename
{Its safe to remove rpm –e to remove the packages in my opinion}

3.     To upgrade a package
#yum upgrade packagename

4.     To search a package
#yum search packagename

5.     To display additional information about a package
#yum info packagename

6.     View all the available packages
#yum list |less

7.     To list only the installed packages
#yum list installed|less

8.     Which package does a file belong to? – Use yum provides
Ex: #yum provides /etc/sysconfig/nfs

9.     To list available software list in the group
#yum grouplist

10.To install a specific group
#yum groupinstall  ‘groupname’

11.To update an existing group
#yum groupupdate ‘groupname’

12.To uninstall a groupname
#yum groupremove ‘groupname’

13.To display the current repositories.
#yum repolist

14.To display all repositories
#yum repolist all

15.Install from a disabled repo
#yum –enablerepo=repositoryname install packagename

16.  To exclude a package using yum
#yum -x package1 update

17.  To exclude multiple packages using yum
#yum -x package1,package2 update

Also you can give an entry in /etc/yum.conf as  given below
exclude=package1,package2 --> with comma
or
exclude=package1 package2  ---> with space
You can also add the same in the individual repo file [ /etc/repos.d/package.repo]

18. Execute yum commands using YUM SHELL 

You can write the commands and save it in a file and execute it using Yum shell as given below













Hope it should help everyone , since all the admin may execute yum at least once in a day ...
Try it let me know if it helps :)

HP ARRAY CONFIGURATION UTILITY cli – hpacucli command examples

hpacucli ------> what is it ? Don't worry, here it explains with example.

HP A{rray} C{onfiguration} U{tility} Command Line Interface .


hpacucli is used to create ,delete and repair the logical drives and physical drives on the smart array controllers on HP Servers.


Scenario ex :
Whenever there is a requirement to increase the disk size in your local disk on the server, it is really very helpful to create a disk using hpacucli via command line. It is really time saving in my experience, since I found with GUI , it takes more time and some times I got compatibility issues with browsers.

The given example here is for a HP ProLiant BL620c G7 server , You can verify this using dmidecode command.






 Make sure we have the below rpm  installed , install it and verify




Type hpacucli, it gives ‘=>’ , type the commands here












To display the controller status, type as below
















Note:It has 2 Physical drives as shown above and both are in use


1.      View the controller status only












1.      View the drive status






      


To view the individual drive status for the 2 below drives.











UMASK in Linux

When user creates a file or directory, it creates with a default permissions. As you all know, the permission values for read,write and executes are given below.
read -4
write -2
execute -1


What is umask ?

umask is the default permission for a file or directory which a user{root/other user} creates.

Where do you set up the umask value in linux OS?


It is in /etc/profile or /etc/bashrc


Note : The files are created with access permissions in 666 {files}and 777{directories}.



What is the default umask value ?


If the file/directory is created by root user  the umask value is 022

ie , for a file , the permission should be 666 - 022 = 644
and for directories , the permission should be 777 - 022 = 755


If the file/directory is created by other user , the umask value is 002.


ie , for a file , the permission should be 666 - 002 = 664

and for directories , the permission should be 777 - 002 = 775

Please find the examples here for one sample file and directory and try it yourself.












Thank you ......

Wednesday, March 18, 2015

Steps to login a linux host with a private key (.pem) via putty.?

Requirement:  You need to login into a linux host when you have only a user name with a filename.pem file.

In this example , consider [sendy.pem] as the private key file which you received from vendor.

Follow the below steps ..

1.Make sure we have puTTY and puTTYgen downloaded in your local machine.

2. Download the sendy.pem file and copy in your local machine

3. Open the puTTYgen and click on load, then select sendy.pem [*Select All file option*]




















4. Then it will import the key and you will get a message for the same and click OK




















5.Now click Save Private Key and give a name {ex: mykey} 




















6.Now open puTTY and give the hostname and goto SSH -->Auth-->Browse for mykey





















7.Then you will get the terminal to give the hostname provided, give the hostname, it will get you inside the terminal.
....

Monday, March 16, 2015

Hardlinks and Softlinks in Linux

Links are created as a reference to the original file . the different types of links are

1. Softlink or Symbolic link.

Softlinks are created as a reference to the original file across the partitions in the file systems. It will be pointing to different inode numbers.

Command to create soft link.
#ln -s <FULL PATH OF ORIGINAL FILE>   <LINKFILE>

Ex: If you want to create a link for network service in /home..Do the following

#
#ln -s /etc/init.d/network /home/network
#
#ls -lrthi /home -->Will show you the link file details with inode numbers(i) with size of file(h)
#




2. Hardlink:

Hardlinks cannot create across the partitions. You can only create hardlinks on the same file systems. Here the inode number will be same.

Command:
#ln <FILE NAME> < LINKNAME>
#
#cd /etc/init.d
#
#ln network network-hard
#