Monday, 23 July 2018

RPM Package Commands

1. How to Check an RPM Signature Package
Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK.
Use the following command with –checksig (check signature) option to check the signature of a package called pidgin.

[root@tecmint]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK

2. How to Install an RPM Package
For installing an rpm software package, use the following command with -i option.
For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm.

[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
Preparing...                ########################################### [100%]
1:pidgin                 ########################################### [100%]
RPM command and options

-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked.

3. How to check dependencies of RPM Package before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package.
For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package.
It will display the list of dependencies of package.

[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
RPM command and options

-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..

4. How to Install a RPM Package Without Dependencies
If you know that all needed packages are already installed and RPM is just being stupid,
you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
Preparing...                ########################################### [100%]
1:BitTorrent             ########################################### [100%]
The above command forcefully install rpm package by ignoring dependencies errors,
but if those dependency files are missing, then the program will not work at all, until you install them.

5. How to check an Installed RPM Package
Using -q option with package name, will show whether an rpm installed or not.

[root@tecmint]# rpm -q BitTorrent
BitTorrent-5.2.2-1.noarch

6. How to List all files of an installed RPM package
To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.

[root@tecmint]# rpm -ql BitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrent-console
/usr/bin/bittorrent-curses
/usr/bin/bittorrent-tracker
/usr/bin/changetracker-console
/usr/bin/launchmany-console
/usr/bin/launchmany-curses
/usr/bin/maketorrent
/usr/bin/maketorrent-console
/usr/bin/torrentinfo-console

7. How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

[root@tecmint]# rpm -qa --last
BitTorrent-5.2.2-1.noarch                     Tue 04 Dec 2012 05:14:06 PM BDT
pidgin-2.7.9-5.el6.2.i686                     Tue 04 Dec 2012 05:13:51 PM BDT
cyrus-sasl-devel-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:06 PM BDT
cyrus-sasl-2.1.23-13.el6_3.1.i686             Tue 04 Dec 2012 04:43:05 PM BDT
cyrus-sasl-md5-2.1.23-13.el6_3.1.i686         Tue 04 Dec 2012 04:43:04 PM BDT
cyrus-sasl-plain-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:03 PM BDT

8. How to List All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.

[root@tecmint]# rpm -qa
initscripts-9.03.31-2.el6.centos.i686
polkit-desktop-policy-0.96-2.el6_0.1.noarch
thunderbird-17.0-1.el6.remi.i686

9. How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used.
One of the major advantages of using this option is that it will not only upgrade the latest version of any package,
but it will also maintain the backup of the older package
so that in case if the newer upgraded package does not run the previously installed package can be used again.

[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
Preparing...                ########################################### [100%]
1:nx                     ########################################### [100%]

10. How to Remove a RPM Package
To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm.
The -e (erase) option is used to remove package.

[root@tecmint]# rpm -evv nx

11. How to Remove an RPM Package Without Dependencies
The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system.
But keep in mind removing particular package may break other working applications.

[root@tecmint]# rpm -ev --nodeps vsftpd

12. How to Query a file that belongs which RPM Package
Let’s say, you have list of files and you would like to find out which package belongs to these files.
For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.

[root@tecmint]# rpm -qf /usr/bin/htpasswd
httpd-tools-2.2.15-15.el6.centos.1.i686

13. How to Query a Information of Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package.
The following -qi (query info) option will print the available information of the installed package.

[root@tecmint]# rpm -qi vsftpd
Name        : vsftpd                                   Relocations: (not relocatable)
Version     : 2.2.2                                   Vendor: CentOS
Release     : 11.el6                                   Build Date: Fri 22 Jun 2012 01:54:24 PM BDT
Install Date: Mon 17 Sep 2012 07:55:28 PM BDT      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Daemons           Source RPM: vsftpd-2.2.2-11.el6.src.rpm
Size        : 351932                               License: GPLv2 with exceptions
Signature   : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

14. Get the Information of RPM Package Before Installing
You have download a package from the internet and want to know the information of a package before installing.
For example, the following option -qip (query info package) will print the information of a package sqlbuddy.

[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
Name        : sqlbuddy                     Relocations: (not relocatable)
Version     : 1.3.3                        Vendor: (none)
Release     : 1                            Build Date: Wed 02 Nov 2011 11:01:21 PM BDT
Install Date: (not installed)              Build Host: rpm.bar.baz
Group       : Applications/Internet        Source RPM: sqlbuddy-1.3.3-1.src.rpm
Size        : 1155804                      License: MIT
Signature   : (none)
Packager    : Erik M Jacobs
URL         : http://www.sqlbuddy.com/
Summary     : SQL Buddy รข Web based MySQL administration
Description :
SQLBuddy is a PHP script that allows for web-based MySQL administration.

15. How to Query documentation of Installed RPM Package
To get the list of available documentation of an installed package,
use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.

[root@tecmint]# rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO

16. How to Verify a RPM Package
Verifying a package compares information of installed files of the package against the rpm database.
The -Vp (verify package) is used to verify a package.

[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf

17. How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.

[root@tecmint]# rpm -Va
S.5....T.  c /etc/rc.d/rc.local
.......T.  c /etc/dnsmasq.conf
.......T.    /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T.  c /etc/yum.conf
S.5....T.  c /etc/yum.repos.d/epel.repo

18. How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.

[root@tecmint]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

19. How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.

[root@tecmint]# rpm -qa gpg-pubkey*
gpg-pubkey-0608b895-4bd22942
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-0f2672c8-4cd950ee
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-00f97f56-467e318a
gpg-pubkey-6b8d79e6-3f49313d
gpg-pubkey-849c449f-4cb9df30

20. How To rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So,
at the time we need to rebuild the rpm database and restore it with the help of following command.

[root@tecmint]# cd /var/lib
[root@tecmint]# rm __db*
[root@tecmint]# rpm --rebuilddb

[root@tecmint]# rpmdb_verify Packages

VMstat Example Commands

10+ “vmstat” Command Usage Examples in Linux
----------------------------------------------
This tutorial explains Linux “vmstat” command, options and its usage with examples.

vmstat – Virtual Memory Statistics
Description:
vmstat command is used to report virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.

Synopsis:
vmstat [-a] [-n] [-t] [-S unit] [delay [ count]] vmstat [-s] [-n] [-S unit] vmstat [-m] [-n] [delay [ count]] vmstat [-d] [-n] [delay [ count]] vmstat [-p disk partition] [-n] [delay [ count]] vmstat [-f] vmstat [-V]

OPTIONS:

-a
switch displays active/inactive memory, given a 2.5.41 kernel or better.
-f
switch displays the number of forks since boot. This includes the fork, vfork, and clone system calls, and is equivalent to the total number of tasks created. Each process is represented by one or more tasks, depending on thread usage. This display does not repeat.
-t
switch adds timestamp to the output.
-m
switch displays slabinfo.
-n
switch causes the header to be displayed only once rather than periodically.
-s
switch displays a table of various event counters and memory statistics. This display does not repeat.
delay
delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
count
number of updates. If no count is specified and delay is defined, count defaults to infinity.
-d
reports disk statistics (2.5.70 or above required)
-w
enlarges field width for big memory sizes
-p
followed by some partition name for detailed statistics (2.5.70 or above required)
-S
followed by k or K or m or M switches outputs between 1000, 1024, 1000000, or 1048576 bytes
-V
switch results in displaying version information.

Examples:

1) Simple example along-with field descriptions
------------------------------------------------
$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in cs us sy id wa st
 0  0 305416 260688  29160 2356920   2    2     4     1    0  0  6  1 92  2  0

Field Description For Vm Mode
-------------------------------
Procs

r: The number of processes waiting for run time.
b: The number of processes in uninterruptible sleep.

Memory

swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)

Swap

si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).

IO

bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).

System

in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

CPU

These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

2) To execute every 2 seconds for 10 times, do the following.
You don’t need to press Ctrl-C in this case. After executing 10 times,
it will stop automatically.
-------------------------------------------------------------
$ vmstat 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in cs us sy id wa st
 1  0      0 537144 182736 6789320   0    0     0     0    1  1  0  0 100  0  0
 0  0      0 537004 182736 6789320   0    0     0     0   50 32  0  0 100  0  0
..

3) Using vmstat, this next command will grep the memory and give a good overview of the memory used in the computer.
-------------------------------------------------------------
$ vmstat -s -S M | grep mem

5965 M total memory
5136 M used memory
3580 M active memory
1176 M inactive memory
829 M free memory
474 M buffer memory

4) Display active and inactive memory
---------------------------------------
By default vmstat doesn’t display this information. Use option -a, to display active and inactive memory information as shown below.

$ vmstat -a
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
 0  0 305416 253820 1052680 2688928    2    2     4     1    0    0  6  1 92  2  0

5) Display number of forks since last boot
--------------------------------------------
This displays all the fork system calls made by the system since the last boot. This displays all fork, vfork, and clone system call counts.

$ vmstat -f
     81651975 forks

6) Display timestamp
----------------------------
When you use vmstat to monitor the memory usage repeately, it would be nice to see the
timestap along with every line item. Use option -t to display the time stamp as shown below.

$ vmstat -t 1 100
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 3608728 148368 3898200    0    0     0     0    1    1  0  0 100  0  0     2011-07-09 21:16:28 PDT
 0  0      0 3608728 148368 3898200    0    0     0     0   60   15  0  0 100  0  0     2011-07-09 21:16:29 PDT
 0  0      0 3608712 148368 3898200    0    0     0     0   32   28  0  0 100  0  0     2011-07-09 21:16:30 PDT

7) Display slab info
--------------------
Use option -m, to display the slab info as shown below.

$ vmstat -m
Cache                       Num  Total   Size  Pages
fib6_nodes                    5    113     32    113
ip6_dst_cache                 4     15    256     15
ndisc_cache                   1     15    256     15
RAWv6                         7     10    768      5
UDPv6                         0      0    640      6
tw_sock_TCPv6                 0      0    128     30
...

8) Display statistics in a table format
----------------------------------------
Instead of displays the values in the record format, you can display the output of vmstat in table format using option -s as shown below.

$ vmstat -s
      4149928  total memory
      3864824  used memory
      2606664  active memory
      1098180  inactive memory
       285104  free memory
        19264  buffer memory
      2326692  swap cache
      4192956  total swap
       274872  used swap
      3918084  free swap
   1032454000 non-nice user cpu ticks
        14568 nice user cpu ticks
     89482270 system cpu ticks
  16674327143 idle cpu ticks
    368965706 IO-wait cpu ticks
      1180468 IRQ cpu ticks
..

9) Display disk statistics
-------------------------------------
Use option -d to display the disk statistics as shown below. This displays the reads, writes, and I/O statistics of the disk.

$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
sda   153189971 69093708 2719150864 737822879 329617713 157559204 3965687592 4068577985      0 1102243
sdb   501426305 97099356 2345472425 731613156 419220973 533565961 2661869460 1825174087      0 1510434
sdc   884213459 22078974 513390701 452540172 127474901 8993357 2411187300 2133226954      0 1569758

10) Changing width of output
The default output without increasing the width is shown below.
-------------------------------------------------------------
$ vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 3608688 148368 3898204    0    0     0     0    1    1  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   72   30  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   60   27  0  0 100  0  0

Use option -w to increase the width of the output columns as shown below. This give better readability.

$ vmstat -w 1 3
procs -------------------memory------------------ ---swap-- -----io---- --system-- -----cpu-------
 r  b       swpd       free       buff      cache   si   so    bi    bo   in   cs  us sy  id wa st
 0  0          0    3608712     148368    3898204    0    0     0     0    1    1   0  0 100  0  0
 0  0          0    3608712     148368    3898204    0    0     0     0   93   23   0  0 100  0  0
 0  0          0    3608696     148368    3898204    0    0     0     0   35   34   0  0 100  0  0

11) Display statistics for a partition
------------------------------------------
To display the disk I/O statistics of a specific disk partition use option -p as shown below.

$ vmstat -p sdb1
sdb1          reads   read sectors  writes    requested writes
           501423248 2345417917  419221612 2661885948
  
12) Display in MB
---------------------
By default vmstat displays the memory information in kb. To disply in MB, use the option “-S m” as shown below.

$ vmstat -S m
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

 0  0    281    288     19   2386    0    0     4     1    0    0  6  1 92  2  0

Linux Basic Commands

1) How to find Red Hot Linux Version:
cat /etc/redhat-release
cat /etc/os-release
cat /etc/issue
$ hostnamectl
2) How to find my redhot 32 or 64 bit:
You can also do uname -i
Yours will probably respond with i386 for 32bit
If you had a 64 bit version of the OS installed, it would respond with x86_64

3) Wget comands examples:


4) Use ssh to login to your remote servers without using a password:

--Step 1: Generate a public and private key pair
$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/al/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/al/.ssh/id_rsa.
Your public key has been saved in /Users/al/.ssh/id_rsa.pub.
The key fingerprint is:
6f:16:29:90:46:b6:88:34:3d:81:07:fc:bd:1a:fc:db al@Al-Alexanders-MacBook.local
The key's randomart image is:
+--[ RSA 2048]----+
| .++..o          |
| .oo++ o         |
|  .o.o=          |
|    ....   .     |
|   .   .S o      |
|    o .  o .     |
|     +    +      |
|    . .. o       |
|      ..E        |
+-----------------+
As you can see from the output of this command:

Your private key is in a file named ~/.ssh/id_rsa
Your public key is in a file named ~/.ssh/id_rsa.pub

--- Step 2: Copy the ssh keys to all the nodes:

ssh-copy-id usename@

--- Step 3: Test ssh to machine_hostname, it should not ask password:

ssh-copy-id localhost

5) How to login sudo user with out giving password:

visudo (Add a line as below)
root ALL =(ALL) : ALL
username ALL=(ALL) NOPASSWORD: ALL

su - username
then now its comes from  root user to my username

6) How to Use Pscp to Transfer/Copy Files to Multiple Linux Servers:

pscp – is utility for copying files in parallel to a number of hosts.
prsync – is a utility for efficiently copying files to multiple hosts in parallel.
pnuke – it helps to kills processes on multiple remote hosts in parallel.
pslurp – it helps to copy files from multiple remote hosts to a central host in parallel.

Let’s create a new file called “myscphosts.txt” and add the list of Linux hosts IP address and SSH port (default 22) number as shown.

192.168.0.3:22
192.168.0.9:22

# pscp -h myscphosts.txt -l User_name -Av wine-1.7.55.tar.bz2 /tmp/
OR
# pscp.pssh -h myscphosts.txt -l User_name -Av wine-1.7.55.tar.bz2 /tmp/

Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 17:48:25 [SUCCESS] 192.168.0.3:22
[2] 17:48:35 [SUCCESS] 192.168.0.9:22

Explanation about the options used in the above command.

-h switch used to read a hosts from a given file and location.
-l switch reads a default username on all hosts that do not define a specific user.
-A switch tells pscp ask for a password and send to ssh.
-v switch is used to run pscp in verbose mode.

7) How to get Weblogic Version :

-- Command line: registry.xml
-- java -cp WLS_HOME/wlserver_10.3/server/lib/weblogic.jar weblogic.version
-- From Admin console:
Login to WebLogic Administration Console and navigate to Servers –> AdminServer –> Monitoring tab        

here it will shows , 1. Weblogic version 2. jdk vendor and version 3. OS name and version

8) How to get the Java Version:

--java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)

java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

9) How to Replace a string in Linux and VI Editor?

sed "s/oldstring/newstring/g" filename and sed :%s/oldstring/newstring/g

10) How to display TOP 10 disk space files?
du -sh* | sort -nr|head -10

11) tar -cvf filename.tar file1 file2 file3

How to extract tar.bz2 files: tar jxvf filename.tar.bz2
How to create tar.bz2 files: tar jcvf filename.tar.bz2 file1 file2 file3

TAR.BZ2
This format has the best level of compression among all of the formats I’ve mentioned here.
But this comes at a cost – in time and in CPU. Here’s how you compress a directory using tar.bz2:
# tar -jcvf archive_name.tar.bz2 directory_to_compress
# tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/

12) tar -xvf filename.tar

13) tar -zcvf filename.tar.gz file1 file2 file3 , tar -zxvf filename.tar.gz

14) Apache --- httpd.conf , ssl.conf and mod_wl_22.so

15) OHS --- mod_wl_ohs.conf , mod_wl_ohs.so

16) How to take the Thread dump if server in hand state:(Server Hang)

1. ps -ef | grep java
kill -3
2. Weblogic.Admin utilities
java weblogic.admin t3://localhost:7001 -username=weblogic -password=weblogic123 THREAD_DUMP
3. From Admin Console: Server-> Monitoring-> threads -> click on Dump Thread Stuck.
4. WLST
connect('weblogic','weblogic123','t3://localhost:7001')
cd ('servers')
cd ('AdminServer')
Thread dump()
disconnect()
exit()
17) Server crash:
Resongs:
1. Native IO
2. SSL Native Libraries
3. JVM
4. Supported Configuration
5. JDBC driver issue
Analysis:
1. hr_err_p*.log
2. pmap core or pstack
3. debugger mode enable
1. From Admin console :
Environment -> Cluster ->name ->Configuration -> Server Start Sub-tab ->Arguments
2. Copy the existing startWebLogic.sh script to a new script file, startWebLogic_Debug.sh.
JAVA_OPTIONS="-Xdebug -Djava.compiler=NONE -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=10171,suspend=n $JAVA_OPTIONS"

18) Symbolic Links

$ ln -s {source-filename} {symbolic-filename}

s means symbolic link  not hard link

ln -s /etc/httpd/vhosts/example.com /etc/httpd/sites-enabled/example.com

unlink {symbolic-filename}
unlink  /etc/httpd/vhosts/example.com

19) Examples of RPM Commands in Linux:-

1- How to Check an RPM Signature Package
# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
2- How to Install an RPM Package
# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
3- How to check dependencies of RPM Package before Installing
# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
4- How to Install a RPM Package Without Dependencies
# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
5- How to check an Installed RPM Package
# rpm -q BitTorrent
6- How to List all files of an installed RPM package
# rpm -ql BitTorrent
7- How to List Recently Installed RPM Packages
# rpm -qa --last
8- How to List All Installed RPM Packages
# rpm -qa
9- How to Upgrade a RPM Package
# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
10- How to Remove a RPM Package
# rpm -evv nx
11- How to Remove an RPM Package Without Dependencies
# rpm -ev --nodeps vsftpd
12- How to Query a file that belongs which RPM Package
# rpm -qf /usr/bin/htpasswd
13- How to Query a Information of Installed RPM Package
# rpm -qi vsftpd
14- Get the Information of RPM Package Before Installing
# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
15- How to Query documentation of Installed RPM Package
# rpm -qdf /usr/bin/vmstat
16- How to Verify a RPM Package
# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
17- How to Verify all RPM Packages
# rpm -Va
18- How to Import an RPM GPG key
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
19- How to List all Imported RPM GPG keys
# rpm -qa gpg-pubkey*
20- How To rebuild Corrupted RPM Database
[root@tecmint]# cd /var/lib
[root@tecmint]# rm __db*
[root@tecmint]# rpm --rebuilddb
[root@tecmint]# rpmdb_verify Packages


rpm –ivh httpd-2.4.x-1.i686.rpm

rpm –Uvh httpd-2.4.x-1.i686.rpm

20) find – search for files in a directory hierarchy                 
        Usage: find [OPTION] [path] [pattern]                    
        eg. find file1.txt, find ­name file1.txt

21) history – prints recently used commands                         
         Usage: history  

22) 3 types of file permissions – read, write, execute
• 10 bit format from 'ls ­l' command
                 1             2 3 4      5 6 7     8 9 10
             file type    owner     group    others
eg. drwxrw­r­­   means owner has all three permissions,
              group has read and write, others have only read             
  permission
• read permission – 4, write – 2, execute ­1    
        eg. rwxrw­r­­   = 764
              673    =   rw­rwx­wx

23) chmod – change file access permissions                                          
       Usage: chmod [OPTION] [MODE] [FILE]                               
      eg. chmod 744 calculate.sh   

24) chown – change file owner and group                                              
      Usage: chown [OPTION]... OWNER[:[GROUP]] FILE...        
      eg. chown remo myfile.txt

25) du – estimate file space usage                                                           
     Usage:  du [OPTION]... [FILE]...                                                
     eg. du -sh  

26) df – report filesystem disk space usage                                            
    Usage: df [OPTION]... [FILE]...                                                   
    eg. df -h 
  
27) quota – display disk usage and limits                                              
    Usage: quota [OPTION]                                                               
    eg. quota ­v   

28) reboot – reboot the system                                                     
       Usage: reboot [OPTION]                                                 
     eg. reboot                                                                          
                
29) poweroff – power off the system                                           
       Usage: poweroff [OPTION]
     eg. poweroff 

30) locate – find or locate a file
     Usage: locate [OPTION]... FILE...
     eg. locate file1.txt

31) File Commands
------------------
ls – directory listing
ls -al – formatted listing with hidden files
cd dir - change directory to dir
cd – change to home
pwd – show current directory
mkdir dir – create a directory dir
rm file – delete file
rm -r dir – delete directory dir
rm -f file – force remove file
rm -rf dir – force remove directory dir *
cp file1 file2 – copy file1 to file2
cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it
doesn't exist
mv file1 file2 – rename or move file1 to file2
if file2 is an existing directory, moves file1 into
directory file2
ln -s file link – create symbolic link link to file
touch file – create or update file
cat > file – places standard input into file
more file – output the contents of file
head file – output the first 10 lines of file
tail file – output the last 10 lines of file
tail -f file – output the contents of file as it
grows, starting with the last 10 lines

32) Process Management
-----------------------
ps – display your currently active processes
top – display all running processes
kill pid – kill process id pid
killall proc – kill all processes named proc *
bg – lists stopped or background jobs; resume a
stopped job in the background
fg – brings the most recent job to foreground
fg n – brings job n to the foreground

33) File Permissions
-------------------------
chmod octal file – change the permissions of file
to octal, which can be found separately for user,
group, and world by adding:
4 – read (r)
2 – write (w)
1 – execute (x)
Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world/others
For more options, see man chmod.

34) System Info
--------------------
date – show the current date and time
cal – show this month's calendar
uptime – show current uptime
w – display who is online
whoami – who you are logged in as
finger user – display information about user
uname -a – show kernel information
cat /proc/cpuinfo – cpu information
cat /proc/meminfo – memory information
man command – show the manual for command
df – show disk usage
du – show directory space usage
free – show memory and swap usage
whereis app – show possible locations of app
which app – show which app will be run by default

35) Compression
-------------------------

tar cf file.tar files – create a tar named
file.tar containing files
tar xf file.tar – extract the files from file.tar
tar czf file.tar.gz files – create a tar with
Gzip compression
tar xzf file.tar.gz – extract a tar using Gzip
tar cjf file.tar.bz2 – create a tar with Bzip2
compression
tar xjf file.tar.bz2 – extract a tar using Bzip2
gzip file – compresses file and renames it to file.gz
gzip -d file.gz – decompresses file.gz back to        file

36) Network
------------------------
ping host – ping host and output results
whois domain – get whois information for domain
dig domain – get DNS information for domain
dig -x host – reverse lookup host
wget file – download file
wget -c file – continue a stopped download

37) Installation
---------------------
Install from source:
./configure
make
make install
dpkg -i pkg.deb – install a package (Debian)
rpm -Uvh pkg.rpm – install a package (RPM)

38) SSH
---------------------
ssh user@host – connect to host as user
ssh -p port user@host – connect to host on port
port as user
ssh-copy-id user@host – add your key to host for
user to enable a keyed or passwordless login

39) Searching
-------------------
grep pattern files – search for pattern in files
grep -r pattern dir – search recursively for
pattern in dir
command | grep pattern – search for pattern in the
output of command
locate file – find all instances of file

40) Shortcuts
--------------------
Ctrl+C – halts the current command
Ctrl+Z – stops the current command, resume with
fg in the foreground or bg in the background
Ctrl+D – log out of current session, similar to exit
Ctrl+W – erases one word in the current line
Ctrl+U – erases the whole line
Ctrl+R – type to bring up a recent command
!! - repeats the last command
exit – log out of current session        


41) vmstat

vmstat reports virtual memory statistics and is used to help identify performance bottlenecks
vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activityactivity.

vmstat syntax: vmstat [options] [delay [count]]

$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r  b   swpd   free   buff  cache   si   so    bi    bo   in cs us sy id wa st

0  0 305416 260688  29160 2356920   2    2     4     1    0  0  6  1 92