Posts

How to Install, Delete, Update packages in RedHat/Fedora/CentOS

Introduction

RPM (Red Hat Package Manager) is an open source package management utility for RHEL, CentOS and Fedora based systems and is used for following purposes:

  • Install
  • Delete
  • Update
  • Query
  • List
  • Verify

Syntax

RPM filename contains four parts Package Name, Version, Release & Architecture Name

vsftpd-2.2.2-14.el6.i686.rpm

Package Name – vsftpd
Version – 2.2.2-14
Release – el6
Architecture – i686

1) Install an RPM Package

To install an RPM Package on linux machine use the following command.

# rpm -ivh vsftpd-2.2.2-14.el6.i686.rpm

Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

where
-i : install
-v : verbose
-h: print hash marks

2) Delete an RPM Package

To remove a package use -e option in order to delete an RPM package.

# rpm -e vsftpd

3) Update an RPM Package

Use -U option to update/upgrade an RPM package.

# rpm -Uvh vsftpd-2.2.2-14.el6.i686.rpm
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

4) Query an RPM Package

To query specific package use -qa option

# rpm -qa|grep vsftpd
vsftpd-2.2.2-14.el6.i686

-q : Query a package

5) List an RPM Package

To view the package list use -ql option

# rpm -ql vsftpd-2.2.2-14.el6.i686.rpm

6) Verify an RPM Package

In order to verify RPM package use the following command

# rpm -Va

Note: There is another easiest method to install,delete,update packages in RedHat/Fedora/CentOS based machine through YUM commands.

How to Delete Database in mysql through Linux Shell

There are 2 methods in order to delete the database in mysql through Linux Shell.

Method 1:

Delete through mysqladmin Command

You can delete the database without logging in mysql database;

# mysqladmin -u[username] -p[password] drop [database]

Method 2:

Step 1: Login in mysql Database

First we’ll login to the MySQL server from the command line with the following command:

# mysql -u root -p
mysql>

Step 2: Delete Database

mysql> DROP DATABASE test_database;

How to Create/delete Softlink & Hardlink

A link is nothing more than a way of matching two or more file names to the same set of file data.

How to create softlink

A soft link, or more common, a symlink, is link a shortcut to the targeted file or directory. So when is removed the original target stays present. This is the opposite of a hard link which is a reference to the target and so, if the hard link is removed, so is the target.

# ln -s /directory/ xymon

How to delete the softlink

#unlink xymon

How to create hardlink

Hard links are essentially a file with multiple names. Hard links share the same data blocks on the hard disk (have the same inode), while they continue to behave as independent files. If one of the hard links is deleted, the hard link count decreases by one. When all hard links are deleted, the data ceases to exist.

# ln -i /directory/file hardlink/file

How to delete the hardlink

#rm hardlink/file

How to Clean History in linux

Step 1: Check the History

In order to check the executed shell commands in linux, use the history command

# history
  366  cd ..
  367  make
  368  cd posix-local/
  369  cd app/
  370  less Makefile
  371  ls -l
  372  cd bin/

Step 2: Clear the History

To clear all your history, use

# history -c

To delete a single line, use

# history -d linenumber

How to Uninstall MySQL Server in Debian/Ubuntu

Step 1: Remove mysql Server

We can use apt-get command in order to remove both MySQL server and client in Debian / Ubuntu:

# apt-get --purge remove mysql-client mysql-server mysql-common
# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.2.0-31-virtual linux-headers-3.2.0-31
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
libdbd-mysql-perl* libmysqlclient18* mysql-client* mysql-client-5.5* mysql-common* mysql-server*
mysql-server-5.5*
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
After this operation, 67.5 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 105097 files and directories currently installed.)
Removing mysql-server ...
Removing mysql-server-5.5 ...
mysql stop/waiting
Purging configuration files for mysql-server-5.5 ...
Removing mysql-client ...
Removing mysql-client-5.5 ...
Removing libdbd-mysql-perl ...
Removing libmysqlclient18 ...
Purging configuration files for libmysqlclient18 ...
Removing mysql-common ...
Purging configuration files for mysql-common ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Step 2: Delete mysql Directory

Also delete the mysql directory

rm -rf /etc/mysql/