apt-get: How to remove a package in Ubuntu?

In Ubuntu, you can easily remove a package using apt-get

Take for example, you want to remove the vim editor package

$ sudo apt-get remove vim

You can check the shell script to remove all the packages mentioned in a file

Advertisements

apt-get: Shell Script to remove the packages mentioned in a File

Check this simple shell script which reads all the packages mentioned in a file and removes them one by one.

#! /bin/sh
if [ $# -ne 1 ]
then echo "Usage: read.sh filename";
exit 1;
fi

if [ ! -f $1 ]
then echo "File $1 doesn't exist";
exit 1;
fi

while read line
do
  pkg=`echo $line| awk '{print $1}'`
  echo $pkg
  yes|sudo apt-get remove $pkg
done < $1

To use this script, mention the packages to be removed in a file. Take for example, pkgs.txt contains the files to be removed

$ cat pkgs.txt
vim
emacs

To execute the above script,

$ ./remove.sh pkgs.txt

It will remove all the packages one by one.

How to install Firebird in Ubuntu?

Firebird is a database server and can be considered as an alternative to MySQL. Let’s see the various Firebird packages available in Ubuntu

$ apt-cache search firebird
libdbi-perl - Perl Database Interface (DBI)
dbi-link - A partial implementation of SQL/MED to PostgreSQL
firebird2.1-classic - Firebird Classic Server - an RDBMS based on InterBase 6.0 code
firebird2.1-common - common files for firebird 2.1 servers and clients
firebird2.1-common-doc - copyright, licensing and changelogs of firebird2.1
firebird2.1-dev - Development files for Firebird - an RDBMS based on InterBase 6.0 code
firebird2.1-doc - Documentation files for firebird database version 2.1
firebird2.1-examples - Examples for Firebird - an RDBMS based on InterBase 6.0 code
firebird2.1-server-common - common files for firebird 2.1 servers
firebird2.1-super - Firebird Super Server - an RDBMS based on InterBase 6.0 code
firebird2.5-classic - Firebird Classic Server - an RDBMS based on InterBase 6.0 code
firebird2.5-classic-common - common files for firebird 2.5 "classic" and "superclassic" servers
firebird2.5-common - common files for firebird 2.5 servers and clients
firebird2.5-common-doc - copyright, licnesing and changelogs of firebird2.5
firebird2.5-dev - Development files for Firebird - an RDBMS based on InterBase 6.0 code
firebird2.5-doc - Documentation files for firebird database version 2.5
firebird2.5-examples - Examples for Firebird - an RDBMS based on InterBase 6.0 code
firebird2.5-server-common - common files for firebird 2.5 servers
firebird2.5-super - Firebird Super Server - an RDBMS based on InterBase 6.0 code
firebird2.5-superclassic - Firebird SupecClassic Server - an RDBMS based on InterBase 6.0 code
flamerobin - graphical database administration tool for Firebird DBMS
gambas2-gb-db-firebird - The Firebird driver for the Gambas database component
libfbclient2 - Firebird client library
libfbembed2.1 - Firebird embedded client/server library
libfbembed2.5 - Firebird embedded client/server library
libib-util - Firebird UDF support library
libmono-firebirdsql1.7-cil - Mono FirebirdSql library

Thus you can see two versions Firebird2.1 and Firebird2.5.

Let’s install the latest version. You can install either Firebird-classic or Firebird super.

$ sudo apt-get install firebird2.5-classic

This will also install firebird2.5-classic-common firebird2.5-server-common packages. After installation, the Firebird server will be started.

How to install the packages mentioned in a file?

Using apt-get, you can easily install any package in debian/ubuntu based system. Suppose you have a list of files mentioned in a file and you want to install all those packages, you can easily do so with the help of the following shell script

#! /bin/sh
if [ $# -ne 1 ]
then echo "Usage: install.sh filename";
exit 1;
fi

if [ ! -f $1 ]
then echo "File $1 doesn't exist";
exit 1;
fi

while read line
do
  pkg=`echo $line| awk '{print $1}'`
  echo $pkg
  yes|sudo apt-get install $pkg
done < $1

Suppose the packages to be installed is mentioned in the file libraries-php.txt

$ cat libraries-php.txt
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-recode - recode module for php5

Now let’s execute the above script

./install.sh libraries-php.txt

You will be asked password during the first package installation. Thus with the above script, you can easily specify the packages you want to install and specify the file name as argument

$ ./install.sh filename

How to install Codelite in Ubuntu?

Codelite is an IDE for C and C++. It is powerful and lightweight. To install Codelite in Ubuntu


$ sudo apt-get install codelite codelite-plugins

It is a crosss platform IDE, which means it is available in Ubuntu, Windows and Mac OS. Once installed it can be accessed
Applications>Programming>Codelite

How to install Readline/libreadline in Ubuntu?

Readline is used to read a line after editing. To work with readline in C/C++, you must install the readline packages.

Let’s see the different readline packages

$ apt-cache search readline

libreadline-dev - GNU readline and history libraries, development files
libreadline-java - GNU readline and BSD editline wrappers for Java
libreadline-java-doc - API docs for readline/editline wrappers for Java
libreadline5 - GNU readline and history libraries, run-time libraries
libreadline5-dbg - GNU readline and history libraries, debugging libraries
libreadline5-dev - GNU readline and history libraries, development files
libreadline6 - GNU readline and history libraries, run-time libraries
libreadline6-dbg - GNU readline and history libraries, debugging libraries
libreadline6-dev - GNU readline and history libraries, development files

You can see a number of packages. To work with readline, the important requirements are
libreadline: For running applications using readline command
libreadline-dev: For developing applications using readline. Compilation purposes

Let’s install the packages

$ sudo apt-get install libreadline6 libreadline6-dev

Now you can successfully compile a readline program

How to install WordPress in Ubuntu?

WordPress can be easily installed in your Ubuntu machine. If you want to manually install wordpress from scratch, you can refer the post on how to install wordpress in Localhost. Let’s take a look into the procedures. As you know WordPress works on LAMP (Linux Apache MySQL and PHP). WordPress can also work in Windows based machines.

Let’s take a look into the procedure for installation

1. Install the mysql-server


$ sudo apt-get install mysql-server

2. The second step is to install the wordpress.This can be easily done by the following command


$ sudo apt-get install wordpress

The above command installs PHP, MySQL and Apache and starts the apache server as well. The wordpress is installed in the /usr/share directory. Let’s check this by checking the contents of the wordpress package.


$ dpkg -L wordpress

/.
/etc
/etc/wordpress
/etc/wordpress/wp-config.php
/etc/wordpress/htaccess
/usr
/usr/share
/usr/share/wordpress
/usr/share/wordpress/wp-admin
/usr/share/wordpress/wp-admin/admin-ajax.php
/usr/share/wordpress/wp-admin/comment.php
/usr/share/wordpress/wp-admin/link-category.php
/usr/share/wordpress/wp-admin/profile.php

..

3. Apache makes use of the web pages available in the /var/www directory. So the next step to do is to create a symbolic link to the above directory


$ sudo ln -s /usr/share/wordpress /var/www/wordpress

4. Now you have to create the setup: setting up database and creating the configuration files. The best part is that you can easily do it by the following command. All you need to do is to specify the database name of your choice and the hostname

Here, we are using the database name as wordpress and the hostname as localhost.

You can choose any name. The hostname can be the name of your website for which you are following this post


$ sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

5. All the setup will be complete by the above command. Now you have to restart the apache server


$ sudo /etc/init.d/apache2 restart

6. Go to your browser and specify the following address

http://localhost/wordpress

Note that if your hostname is not localhost, you have to type the following address

http://hostname/wordpress

7. Enter your blog name and title and save the user name and password you get

8. Login with the credentials you got from the previous step