Command to Delete mails from one particular domain.tld
“mailq | awk ‘$7 ~ /@sfa.co.in$/ { print $1 }’ | tr -d ‘*!’ | postsuper -d –“
Command to Delete mails from one particular domain.tld
“mailq | awk ‘$7 ~ /@sfa.co.in$/ { print $1 }’ | tr -d ‘*!’ | postsuper -d –“
YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems. It was developed and released by Seth Vidal under GPL (General Public License) as an open source, means anyone can allowed to download and access the code to fix bugs and develop customized packages. YUM uses numerous third party repositories to install packages automatically by resolving their dependencies issues.
To install a package called Firefox 14, just run the below command it will automatically find and install all required dependencies for Firefox.
# yum install firefox Loaded plugins: fastestmirror Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Updating: firefox i686 10.0.6-1.el6.centos updates 20 M Updating for dependencies: xulrunner i686 10.0.6-1.el6.centos updates 12 M Transaction Summary ================================================================================================ Install 0 Package(s) Upgrade 2 Package(s) Total download size: 32 M Is this ok [y/N]: y Downloading Packages: (1/2): firefox-10.0.6-1.el6.centos.i686.rpm | 20 MB 01:10 (2/2): xulrunner-10.0.6-1.el6.centos.i686.rpm | 12 MB 00:52 ------------------------------------------------------------------------------------------------ Total 63 kB/s | 32 MB 02:04 Updated: firefox.i686 0:10.0.6-1.el6.centos Dependency Updated: xulrunner.i686 0:10.0.6-1.el6.centos Complete!
The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in below example.
# yum -y install firefox
To remove a package completely with their all dependencies, just run the following command as shown below.
# yum remove firefox Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package firefox.i686 0:10.0.6-1.el6.centos set to be erased --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Removing: firefox i686 10.0.6-1.el6.centos @updates 23 M Transaction Summary ==================================================================================================== Remove 1 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : firefox-10.0.6-1.el6.centos.i686 1/1 Removed: firefox.i686 0:10.0.6-1.el6.centos Complete!
Same way the above command will ask confirmation before removing a package. To disable confirmation prompt just add option -y as shown in below.
# yum -y remove firefox
Let’s say you have outdated version of MySQL package and you want to update it to the latest stable version. Just run the following command it will automatically resolves all dependencies issues and install them.
# yum update mysql Loaded plugins: fastestmirror Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Updating: vsftpd i386 2.0.5-24.el5_8.1 updates 144 k Transaction Summary ============================================================================================================ Install 0 Package(s) Upgrade 1 Package(s) Total size: 144 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Updating : vsftpd 1/2 Cleanup : vsftpd 2/2 Updated: vsftpd.i386 0:2.0.5-24.el5_8.1 Complete!
Use the list function to search for the specific package with name. For example to search for a package called openssh, use the command.
# yum list openssh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: mirror.nus.edu.sg Installed Packages openssh.i386 4.3p2-72.el5_6.3 installed Available Packages 4.3p2-82.el5 base
To make your search more accurate, define package name with their version, in case you know. For example to search for a specific version openssh-4.3p2 of the package, use the command.
# yum list openssh-4.3p2
If you don’t remember the exact name of the package, then use search function to search all the available packages to match the name of the package you specified. For example, to search all the packages that matches the word .
# yum search vsftpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in ============================== Matched: vsftpd ======================== ccze.i386 : A robust log colorizer pure-ftpd-selinux.i386 : SELinux support for Pure-FTPD vsftpd.i386 : vsftpd - Very Secure Ftp Daemon
Say you would like to know information of a package before installing it. To get information of a package just issue the below command.
# yum info firefox
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* epel: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* rpmforge: mirror.nl.leaseweb.net
* updates: ftp.iitm.ac.in
Available Packages
Name : firefox
Arch : i386
Version : 10.0.6
Release : 1.el5.centos
Size : 20 M
Repo : updates
Summary : Mozilla Firefox Web browser
URL : http://www.mozilla.org/projects/firefox/
License : MPLv1.1 or GPLv2+ or LGPLv2+
Description: Mozilla Firefox is an open-source web browser, designed for standards
: compliance, performance and portability.
To list all the available packages in the Yum database, use the below command.
# yum list | less
To list all the installed packages on a system, just issue below command, it will display all the installed packages.
# yum list installed | less
Yum provides function is used to find which package a specific file belongs to. For example, if you would like to know the name of the package that has the /etc/httpd/conf/httpd.conf.
# yum provides /etc/httpd/conf/httpd.conf Loaded plugins: fastestmirror httpd-2.2.3-63.el5.centos.i386 : Apache HTTP Server Repo : base Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-63.el5.centos.1.i386 : Apache HTTP Server Repo : updates Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-65.el5.centos.i386 : Apache HTTP Server Repo : updates Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-53.el5.centos.1.i386 : Apache HTTP Server Repo : installed Matched from: Other : Provides-match: /etc/httpd/conf/httpd.conf
To find how many of installed packages on your system have updates available, to check use the following command.
# yum check-update
To keep your system up-to-date with all security and binary package updates, run the following command. It will install all latest patches and security updates to your system.
# yum update
In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.
# yum grouplist Installed Groups: Administration Tools DNS Name Server Dialup Networking Support Editors Engineering and Scientific FTP Server Graphics Java Development Legacy Network Server Available Groups: Authoring and Publishing Base Beagle Cluster Storage Clustering Development Libraries Development Tools Eclipse Educational Software KDE (K Desktop Environment) KDE Software Development
To install a particular package group, we use option as groupinstall. Fore example, to install “MySQL Database“, just execute the below command.
# yum groupinstall 'MySQL Database' Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Updating: unixODBC i386 2.2.11-10.el5 base 290 k Installing for dependencies: unixODBC-libs i386 2.2.11-10.el5 base 551 k Transaction Summary ================================================================================================= Install 1 Package(s) Upgrade 1 Package(s) Total size: 841 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : unixODBC-libs 1/3 Updating : unixODBC 2/3 Cleanup : unixODBC 3/3 Dependency Installed: unixODBC-libs.i386 0:2.2.11-10.el5 Updated: unixODBC.i386 0:2.2.11-10.el5 Complete!
To update any existing installed group packages, just run the following command as shown below.
# yum groupupdate 'DNS Name Server' Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Updating: bind i386 30:9.3.6-20.P1.el5_8.2 updates 981 k bind-chroot i386 30:9.3.6-20.P1.el5_8.2 updates 47 k Updating for dependencies: bind-libs i386 30:9.3.6-20.P1.el5_8.2 updates 864 k bind-utils i386 30:9.3.6-20.P1.el5_8.2 updates 174 k Transaction Summary ================================================================================================================ Install 0 Package(s) Upgrade 4 Package(s) Total size: 2.0 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Updating : bind-libs 1/8 Updating : bind 2/8 Updating : bind-chroot 3/8 Updating : bind-utils 4/8 Cleanup : bind 5/8 Cleanup : bind-chroot 6/8 Cleanup : bind-utils 7/8 Cleanup : bind-libs 8/8 Updated: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2 Dependency Updated: bind-libs.i386 30:9.3.6-20.P1.el5_8.2 bind-utils.i386 30:9.3.6-20.P1.el5_8.2 Complete!
To delete or remove any existing installed group from the system, just use below command.
# yum groupremove 'DNS Name Server' Dependencies Resolved =========================================================================================================== Package Arch Version Repository Size =========================================================================================================== Removing: bind i386 30:9.3.6-20.P1.el5_8.2 installed 2.1 M bind-chroot i386 30:9.3.6-20.P1.el5_8.2 installed 0.0 Transaction Summary =========================================================================================================== Remove 2 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Erasing : bind 1/2 warning: /etc/sysconfig/named saved as /etc/sysconfig/named.rpmsave Erasing : bind-chroot 2/2 Removed: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2 Complete!
To list all enabled Yum repositories in your system, use following option.
# yum repolist repo id repo name status base CentOS-5 - Base enabled: 2,725 epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783 extras CentOS-5 - Extras enabled: 282 mod-pagespeed mod-pagespeed enabled: 1 rpmforge RHEL 5 - RPMforge.net - dag enabled: 11,290 updates CentOS-5 - Updates enabled: 743 repolist: 20,824
The following command will display all enabled and disabled yum repositories on the system.
# yum repolist all repo id repo name status C5.0-base CentOS-5.0 - Base disabled C5.0-centosplus CentOS-5.0 - Plus disabled C5.0-extras CentOS-5.0 - Extras disabled base CentOS-5 - Base enabled: 2,725 epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783 extras CentOS-5 - Extras enabled: 282 repolist: 20,824
To install a particular package from a specific enabled or disabled repository, you must use –enablerepo option in your yum command. For example to Install PhpMyAdmin 3.5.2 package, just execute the command.
# yum --enablerepo=epel install phpmyadmin Dependencies Resolved ============================================================================================= Package Arch Version Repository Size ============================================================================================= Installing: phpMyAdmin noarch 3.5.1-1.el6 epel 4.2 M Transaction Summary ============================================================================================= Install 1 Package(s) Total download size: 4.2 M Installed size: 17 M Is this ok [y/N]: y Downloading Packages: phpMyAdmin-3.5.1-1.el6.noarch.rpm | 4.2 MB 00:25 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : phpMyAdmin-3.5.1-1.el6.noarch 1/1 Verifying : phpMyAdmin-3.5.1-1.el6.noarch 1/1 Installed: phpMyAdmin.noarch 0:3.5.1-1.el6 Complete!
Yum utility provides a custom shell where you can execute multiple commands.
# yum shell Loaded plugins: fastestmirror Setting up Yum Shell > update httpd Loading mirror speeds from cached hostfile * base: mirrors.sin3.sg.voxel.net * epel: ftp.riken.jp * extras: mirrors.sin3.sg.voxel.net * updates: mirrors.sin3.sg.voxel.net Setting up Update Process >
By default yum keeps all the repository enabled package data in /var/cache/yum/ with each sub-directory, to clean all cached files from enabled repository, you need to run the following command regularly to clean up all the cache and make sure that there is nothing unnecessary space is using. We don’t want to give the output of the below command, because we like to keep cached data as it is.
# yum clean all
To view all the past transactions of yum command, just use the following command.
# yum history
Loaded plugins: fastestmirror
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
10 | root | 2012-08-11 15:19 | Install | 3
9 | root | 2012-08-11 15:11 | Install | 1
8 | root | 2012-08-11 15:10 | Erase | 1 EE
7 | root | 2012-08-10 17:44 | Install | 1
6 | root | 2012-08-10 12:19 | Install | 2
5 | root | 2012-08-10 12:14 | Install | 3
4 | root | 2012-08-10 12:12 | I, U | 13 E<
3 | root | 2012-08-09 13:01 | Install | 1 >
2 | root | 2012-08-08 20:13 | I, U | 292 EE
1 | System | 2012-08-08 17:15 | Install | 560
history list
Find all the files whose name is tecmint.txt in a current working directory.
# find . -name tecmint.txt ./tecmint.txt
Find all the files under /home directory with name tecmint.txt.
# find /home -name tecmint.txt /home/tecmint.txt
Find all the files whose name is tecmint.txt and contains both capital and small letters in /home directory.
# find /home -iname tecmint.txt ./tecmint.txt ./Tecmint.txt
Find all directories whose name is Tecmint in / directory.
# find / -type d -name Tecmint /Tecmint
Find all php files whose name is tecmint.php in a current working directory.
# find . -type f -name tecmint.php ./tecmint.php
Find all php files in a directory.
# find . -type f -name "*.php" ./tecmint.php ./login.php ./index.php
Find all the files whose permissions are 777.
# find . -type f -perm 0777 -print
Find all the files without permission 777.
# find / -type f ! -perm 777
Find all the SGID bit files whose permissions set to 644.
# find / -perm 2644
Find all the Sticky Bit set files whose permission are 551.
# find / -perm 1551
Find all SUID set files.
# find / -perm /u=s
Find all SGID set files.
# find / -perm /g+s
Find all Read Only files.
# find / -perm /u=r
Find all Executable files.
# find / -perm /a=x
Find all 777 permission files and use chmod command to set permissions to 644.
# find / -type f -perm 0777 -print -exec chmod 644 {} \;
Find all 777 permission directories and use chmod command to set permissions to 755.
# find / -type d -perm 777 -print -exec chmod 755 {} \;
To find a single file called tecmint.txt and remove it.
# find . -type f -name "tecmint.txt" -exec rm -f {} \;
To find and remove multiple files such as .mp3 or .txt, then use.
# find . -type f -name "*.txt" -exec rm -f {} \;
OR
# find . -type f -name "*.mp3" -exec rm -f {} \;
To file all empty files under certain path.
# find /tmp -type f -empty
To file all empty directories under certain path.
# find /tmp -type d -empty
To find all hidden files, use below command.
# find /tmp -type f -name ".*"
To find all or single file called tecmint.txt under /root directory of owner root.
# find / -user root -name tecmint.txt
To find all files that belongs to user Tecmint under /home directory.
# find /home -user tecmint
To find all files that belongs to group Developer under /home directory.
# find /home -group developer
To find all .txt files of user Tecmint under /home directory.
# find /home -user tecmint -iname "*.txt"
To find all the files which are modified 50 days back.
# find / -mtime 50
To find all the files which are accessed 50 days back.
# find / -atime 50
To find all the files which are modified more than 50 days back and less than 100 days.
# find / -mtime +50 –mtime -100
To find all the files which are changed in last 1 hour.
# find / -cmin -60
To find all the files which are modified in last 1 hour.
# find / -mmin -60
To find all the files which are accessed in last 1 hour.
# find / -amin -60
To find all 50MB files, use.
# find / -size 50M
To find all the files which are greater than 50MB and less than 100MB.
# find / -size +50M -size -100M
To find all 100MB files and delete them using one single command.
# find / -size +100M -exec rm -rf {} \;
Find all .mp3 files with more than 10MB and delete them using one single command.
# find / -type f -name *.mp3 -size +10M -exec ls -l {} \;
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
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%]
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
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.
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
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
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
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
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%]
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
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
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
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.
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.
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
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
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
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
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
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
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
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%]
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
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.
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
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
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
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
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%]
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
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
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
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.
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.
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
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
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
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
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
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
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
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%]
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
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.
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
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
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
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
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%]
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
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
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
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.
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.
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
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
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
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
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
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
chattr : chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2/ext3/ext4 based filesystem.
Syntax :
#chattr [operator] [switch] [file name]
Operator :
+ Add attribute.
– Remove attribute.
= Assign attributes (removing unspecified attributes)
Switch :
-R Recursively change attributes of directories and their contents. Symbolic links encountered during recursive directory traversals are ignored.
-a A file with the ‘a’ attribute set can only be open in append mode for writing. Only the superuser can set or clear this attribute.
-i A file with the ‘i’ attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser can set or clear this attribute.
Example 1:

Example 2 :

Main difference between a and i switch is in i you cannot append the file while in a switch you can append the file.
Example 3:

split command is used to to split large files into smaller files in Unix.. Syntax of Split command :
# split [options] filename prefix
Replace filename with the name of the large file you wish to split. Replace prefix with the name you wish to give the small output files. You can exclude [options], or replace it with either of the following:
-l linenumber
-b bytes
If we use -l (a lowercase L) option, replace linenumber with the number of lines you’d like in each of the smaller files (the default is 1,000). If you use the -b option, replace bytes with the number of bytes you’d like in each of the smaller files.
The split command will give each output file it creates the name prefix with an extension tacked to the end that indicates its order. By default, the split command adds aa to the first output file, proceeding through the alphabet to zz for subsequent files. If you do not specify a prefix, most systems use x.
Examples :
# split testfile
This will output three 1000-line files: xaa, xab, and xac.
# split -l 500 testfile segment
This will output six 500-line files: segmentaa, segmentab, segmentac, segmentad, segmentae, and segmentaf.
# split -b 40k testfile segment
This will output four 40KB files: segmentaa, segmentab, segmentac, and segmentad.
In my case I will shrink or reduce the /home size using lvreduce command. To reduce lvm size first umount the partition and run e2fsck & resize2fs.
Steps to reduce the /home partition to 5GB
Step:1 Check the disk space using below command

Umount /home using below command :
[root@localhost ~]# umount /home
Step:2 Use e2fsck command to check the file system
[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-LogVol01
Step:3 Resize the partition using below command

Step:4 Use lvreduce command to reduce the size as shown below

Step:5 Mount and check the partition size

LVM stands for Logical Volume Manager. One of the biggest advantage of lvm partitions is that we can extend file-system size using lvextend command.
I am taking the example of /home partition which is lvm based , currently /home is of 5GB , We will extend the size to 7GB , means we have to add 2GB space.
Steps to Extend the size of /home by 2GB
Step:1 Check the space using below command

Step:2 After extending the size of /home by 2GB, it should be 7GB.
Umount /home partition using below command
[root@localhost ~]# umount /home/
Step:3 Use e2fsck command to check the file system as shown below

Step:4 Use resize2fs to resize the ext2,ext3 & ext4 file system

Now Mount /home using mount command and check the space using df command

Note : lvextend uses free space of the volume group for extending the size.To check the free size of volume group use vgs or vgdisplay command.
The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.
Here’s an excerpt:
The London Olympic Stadium is 53 meters high. This blog had about 740 visitors in 2012. If every visitor were a meter, this blog would be 14 times taller than the Olympic Stadium – not too shabby.
Qmqtool – a qmail queue manipulation program geared towards the viewing and safe modification of the contents in a qmail queue
Qmqtool is a utility designed for viewing and safely modifying the contents of a qmail queue. It is extremely feature rich, with features including finding abusers, sorting messages by sender/sender’s IP, showing stats, requeueing messages, queue consistency check, queue backup/restore, and others.
Configure it
You should have such result
if any of these values need changing, try ./configure –help
Making sure this package is intact..
src/qmqtool syntax OK
…done.
Writing Makefile…
now type ‘make’ and then ‘make install’
Compile it
You should have such result
Use it
qmqtool version 1.14
syntax: qmqtool [-l] [-L] [-R] [-S [-nN]] [-T] [-s] [-Q] [-c] [-r] [-i [-nN]] [-V]
[-E(A|R|L)] [-U(A|R|L)] [-vN [-w]] [-e(N|[-f 'STRING'][-oN])] [-u(N|[-f 'STRING'][-oN])]
[-d(N|[-f 'STRING'][-oN])] [-f 'STRING'] [-oN] [-B(b|r)] [-x(N|[-f 'STRING'][-oN])]
-l list messages in all parts of the queue
-L list messages with local recipients
-R list messages with remote recipients
-T list messages not completely processed
-s show statistical information
-Q be as quiet as possible (useful for snmp, cron, and such)
-V be more verbose
-B
b Backup queue into /var/qmail/queue.backup/
r Restore backup from /var/qmail/queue.backup/
-c check queue consitancy
-r repair queue (by deleting fragments) found by checking queue consistancy
-i show how many messages are queued per ip address
-nN pay attention to the Nth last smtp-hop
-S show how many bytes are queued per ip address
-e expire message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-u unexpire message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-d delete message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-E expire messages in [A]ll, [R]emote, or [L]ocal queues
-U unexpire messages in [A]ll, [R]emote, or [L]ocal queues
-v
N view first 100 lines of message number N
N -w view whole message N
-f 'STRING' display comma separated list of message number(s) containing STRING.
prints 0 if no matches are found.
-o N display comma separated list of message number(s) older than N hours.
prints 0 if no matches are found.
-x N prints extended information on message N. format identical to -l.
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
Usage samples :
List all messages in the queue having the subject “XXX” (case insensitive)
Delete all messages in the queue having the subject “XXX” (case insensitive)
Who are the top senders for the remote queue
Who are the top recipients of the remote queue
What are the top subjects of the remote queue
What domains are being sent the most mail from the server
Who are the top receivers for the local queue
What domains are have the most mail in the local queue
Who most of my remotely queued messages are destined for ?
How can I expire messages with a subject of “Failure Notice” that are have been queued for 18+ hours ?