Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Wednesday, February 14, 2018

what is the difference between apt-get remove and purge and autoremove in ubuntu?

apt-get remove vs  purge vs autoremove

Let's explain this by taking wget package as the one to be removed.
remove

apt-get remove wget
This removes the wget binaries, but it's configuration files and installed dependencies will remain in the system.
purge

apt-get purge wget
This removes the package as well as its configuration files. But the dependencies will remain in the system. However, configuration files in the home directory won't get removed.
This command is same as using --purge option with the above remove command.
autoremove

apt-get autoremove wget
This will remove the package as well as its dependencies, if those dependencies aren't used by other packages.
apt-get autoremove
If the package name is not specified with autoremove, it will remove all the unused dependencies in the system.

Tuesday, December 8, 2015

Setup Local Repository In Ubuntu 15.04

Setup Local Repository In Ubuntu 15.04


Why Local repository is important?

As a System administrator, you have to install software, security updates and fixes often in all systems. Obviously, it will consume more Internet bandwidth. So instead of downloading and installing applications every time in all systems from the Ubuntu repositories, it is good idea to save all applications in a local server in your LAN and distribute them to the other Ubuntu systems when required. Having a local repository is really fast and efficient way, because all required applications will be transferred over the fast LAN connection from your local server. So that it will save the Internet bandwidth and ultimately it reduces the annual cost of Internet.

In this tutorial, I will show you how to setup local repository in Ubuntu 15.04 server in two methods.

APT-Mirror ;
APT-Cacher.

Both methods are very easy to set up and configure.
All you need is sufficient hard drive space. At least 50GB or more free space in your local or external hard drive is recommended. Also, you can use an external hard drive to setup a portable repository. So, you can use the portable repository on multiple locations in your LAN.

Method 1: APT-Mirror

In this method, we are going to pull all packages from the public repository (Ubuntu global server) and save them in our local Ubuntu server hard drive.
First install Apache server. Apache web server is important to share the packages over the network.

sudo apt-get install apache2

Now, install APT-Mirror using command:

sudo apt-get install apt-mirror

Now, create a directory to save all packages.
For example, let us create a directory called “/myrepo”. We are going to save all packages in this directory:

sudo mkdir /myrepo

Now, open the file /etc/apt/mirror.list file,

sudo vi /etc/apt/mirror.list

Add the line: set base_path    /myrepo
############# config ##################
#
# set base_path /var/spool/apt-mirror

set base_path /myrepo

#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse

deb-src http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse

clean http://archive.ubuntu.com/ubuntu
In the above configuration file, you can add the Ubuntu source lists depending upon the distribution you use.
For this tutorial, I use the default source list. Change them as per your requirements.
If you use both 32bit and 64bit architectures, you should name them separately in the above file. For example, if you use 32bit architecture, the lines should start with deb-i386 and for 64bit, the lines should start as deb-amd64. Clear? Well, once you saved the configuration file, populate your repository using the following command:
sudo apt-mirror
Sample output:
Downloading 162 index files using 20 threads...
Begin time: Wed Aug 5 16:09:16 2015
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]...
Now the packages from the Ubuntu public repositories are being pulled and saved to your local directory (In our case it’s /myrepo). Depending upon your Internet speed, it will take hours.
You can cancel this process at any time. When you start it again, it will resume the downloading process where you left it off.  I strongly advise you to use a fast broadband Internet connection.
You don’t have to run this command every day to get new softwares/updates. You can schedule this process using a cron job. So your machine will automatically run the apt-mirror command on a regular daily basis and will keep your repository up-to-date.

To do that, edit file /etc/cron.d/apt-mirror,

sudo vi /etc/cron.d/apt-mirror
Uncomment the line shown in bold:
#
# Regular cron jobs for the apt-mirror package
#
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
As per the above example, the cron job will run every day morning 4am and will start to download the packages.

As I mentioned above, all downloaded packages are saved in “/myrepo” directory on our local server.
Let us have a look under the /myrepo directory to make sure the packages are downloaded as shown below:

ls /myrepo/

Sample output:

mirror  skel  var

Now the contents of /myrepo directory should be made available over HTTP (web) to our clients. To do that, simply create a symbolic link to the /myrepo directory:

cd /myrepo/

sudo ln -s /myrepo/mirror/us.archive.ubuntu.com/ubuntu/ ubuntu

Please note: I made this article only for the testing purpose. So I didn’t download the whole public repository. I canceled the download process after a couple of minutes.
Client Configuration

It’s quite easy to configure in client side. Just open your client systems /etc/apt/sources.list file,

sudo vi /etc/apt/sources.list
and add your local repository path:
[...]
deb http://192.168.1.102/ubuntu trusty universe
deb http://192.168.1.102/ubuntu trusty main restricted
deb http://192.168.1.102/ubuntu trusty-updates main restricted
[...]
That’s it. Here 192.168.1.102 is my Ubuntu server IP address.
Now, update the sources list using command:
sudo apt-get update
Finally, install packages of your choice using command:
sudo apt-get install <package-name>
That’s it. The clients need not to be connected to the Internet to download packages. Instead, it will get all packages and updates from your Ubuntu server’s local repository.
Method 2: APT-Cacher
APT-Cacher is different from APT-Mirror. It does not mirror the entire repository contents. Instead, It saves the packages requested by the clients on your local network and make them available to the rest of the clients for future use.
First install Apache server. This is required to share the packages to your Ubuntu clients over the network:
sudo apt-get install apache2
Now install APT-Cacher.
sudo apt-get install apt-cacher
Choose daemon to run as a standalone daemon and click OK.
sk@server: -myrepo_001
Now, Edit file /etc/default/apt-cacher,
sudo vi /etc/default/apt-cacher
and set autostart=1 if it is 0, else leave as it is.
# apt-cacher daemon startup configuration file

# Set to 1 to run apt-cacher as a standalone daemon, set to 0 if you are going
# to run apt-cacher from /etc/inetd or in CGI mode (deprecated).  Alternatively,
# invoking "dpkg-reconfigure apt-cacher" should do the work for you.
#
AUTOSTART=1

# extra settings to override the ones in apt-cacher.conf
# EXTRAOPT=" daemon_port=3142 limit=30 "
You can also allow or deny the no of hosts to access the cache (packages).
To do that, open the /etc/apt-cacher/apt-cacher.conf file.
sudo vi /etc/apt-cacher/apt-cacher.conf
Uncomment and update the value for allowed_hosts to match the individual hosts. Here I allowed systems from 192.168.1.20 to 192.168.1.30.
[...]
## Uncomment and set the IP range ##
allowed_hosts = 192.168.1.20 - 192.168.1.30
#denied_hosts =
[...]
After completing all the steps, restart apache2 service:
sudo systemctl restart apache2
Or,
sudo service apache2 restart
Client Side Configuration
Now, create a file called /etc/apt/apt.conf.d/01proxy:
sudo nano /etc/apt/apt.conf.d/01proxy
Add the following line:
Acquire::http::Proxy "http://192.168.1.102:3142";
Here, 192.168.1.102 is my Ubuntu local repository server’s IP address. Replace the IP address with your server IP address.
Now, update the sources list using command:
sudo apt-get update
Finally, install packages of your choice using command:
sudo apt-get install <package-name>
That’s it.

Conclusion

Due to lack of resources, time and Internet bandwidth, I didn’t completely test both methods. As far as I know, both methods should work fine and they are highly recommended to save your Internet bandwidth. Although, both methods are pretty easy to configure and maintain. You don’t need to be a master In Linux to setup local repository. Give it a try, you won’t be disappointed.

Good luck!

Monday, September 14, 2015

How to install eclipse on ubuntu 14.04

Eclipse is a open-source development environment used to develop applications . In this article we can see about installing eclipse in ubuntu 14.04 Manually.

Step 1 » Update repostories.
sudo apt-get update

Step 2 »check the java version
java  -version

Step 3 »Install Java by the below command.
sudo apt-get install openjdk-7-jdk

Step 4 » Download latest eclipse from here ( Download Eclipse )
Download from below link

Step 5 » Move the downloaded package to /opt/ directory.
sudo mv Downloads/eclipse-standard-kepler-SR2-linux-gtk-x86_64.tar.gz  /opt/

Step 6 » Unzip the downloaded file.

cd  /opt/
sudo tar -xvf eclipse-standard-kepler-SR2-linux-gtk-x86_64.tar.gz

Step 7 » Create a new file eclipse.desktop in /usr/share/applications/ and add the below code .

cd /usr/share/applications/

sudo nano eclipse.desktop

[Desktop Entry]
Name=Eclipse
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=eclipse.desktop

Step 8 » Now install that desktop file using the below command.

sudo desktop-file-install /usr/share/applications/eclipse.desktop

sudo ln -s /opt/eclipse/eclipse /usr/local/bin

you can launch by 



how to install apache tomcat on ubuntu 14.04




Step 1 » Install JDK 7 before installing tomcat.


Step 2 » Download latest tomcat version ( Choose latest version from here –Download Apache Tomcat ).
cd /usr/local


Step 3 » Extract the package
sudo tar –xvf apache-tomcat-7.054.tar.gz


Step 4 » Configure  /etc/environment

set the java and tomcat home directories
PATH=":/usr/local/games:/usr/lib/jvm/java-7-openjdk-amd64/bin: /usr/local/apache-tomcat-7.0.54/bin”
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/bin"
CATALINA_HOME="/usr/local/apache-tomcat-7.0.54/bin"

sorce the environment file by using
source /etc/environment command.

Step 5 »

Choose username and password to manage tomcat and add to the file /usr/local/apache-tomcat-7.0.54/conf/tomcat-users.xml like the below. The below code must be within < tomcat-users > …. < /tomcat-users > tags.

<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="passwd" roles="manager-gui,admin-gui"/>

Step 6 »

Tomcat and Java should now be installed and configured on your server. To activate Tomcat, run the following script:

start the server

sudo $CATALINA_HOME/startup.sh

You should get a result similar to:



Step 7 »

Now open http://serve-IP:8080 in your browser, you will get





Step 8 »
stop the server

sudo $CATALINA_HOME/shutdown.sh





Sunday, September 13, 2015

How to install NFS server on ubuntu 14.04

NFS ( Network file systems ) is used to share files with other computers over the network.
It is mainly used for centralized home folders. This article explains, how to setup NFS server on ubuntu 14.04 . also explains about mounting nfs shares on client machine .

Setup NFS server on ubuntu 14.04

Step 1 » Update the repositories.
sudo apt-get update

Step 2 » Install nfs server package by typing the command.
sudo apt-get install nfs-kernel-server

Step 3 » Make directory you want to share with other computers.
sudo mkdir /nhome

Step 4 » Here /etc/exports is the main config file for NFS.
Vim /etc/exports

#Share access to all networks
/nhome        *(rw,sync,no_root_squash)
#Share access to particular network
/nhome1       192.168.1.1/24(rw,sync,no_root_squash)
#Share access to particular host
/nhome2       host.example.com(rw,sync,no_root_squash)
/nhome3       192.168.1.153(rw,sync,no_root_squash)
#Share access to all hosts in particular domain
/nhome4       *linux.com(rw,sync,no_root_squash)


·         rw: This option gives the client computer both read and write access to the volume.
·         ro:  This option gives the client computer both read-only access to the volume.
·         sync: This option forces NFS to write changes to disk before replying. This results in a more stable and consistent environment, since the reply reflects the actual state of the remote volume.
·         nosubtreecheck: This option prevents subtree checking, which is a process where the host must check whether the file is actually still available in the exported tree for every request. This can cause many problems when a file is renamed while the client has it opened. In almost all cases, it is better to disable subtree checking.
·         norootsquash: By default, NFS translates requests from a root user remotely into a non-privileged user on the server. This was supposed to be a security feature by not allowing a root account on the client to use the filesystem of the host as root. This directive disables this for certain shares.

Step 5 » Start service by the below command.
sudo /etc/init.d/nfs-kernel-server start

Step 6 » Now check the NFS share status.
linux@ubuntu:~$ sudo exportfs -u
/nhome1 192.168.1.1/24
/nhome2 192.168.1.153
/nhome3 *.linux.com
/nhome world

Ubuntu – Client side

Step 1 » Install nfs client and dependencies .
sudo apt-get install nfs-common rpcbind

Step 2 » Create a directory /rhome .
sudo mkdir /rhome

Step 3 » Mount the remote share /nhome on local directory /rhome.
Temporary mount
sudo mount -t nfs 192.168.1.153:/nhome /rhome
add the following line in /etc/fstab file for permanent mount.
192.168.1.153:/nhome /rhome nfs rw,sync,hard,intr 0 0

Step 4 » Check the mounted share directory using mount command.
linux@ubuntu:~$ mount
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
192.168.1.153:/nhome on /rhome type nfs (rw,vers=4,addr=192.168.1.153,clientaddr=192.168.1.201)


Now local rhome is remote NFS directory . whatever data copied to that folder will be stored in remote directory /nhome.

Monday, June 8, 2015

How to install Apache OpenOffice 4.1.1 on Ubuntu

How to install Apache OpenOffice 4.1.1 on Ubuntu 14.04 Trusty Tahr (LTS). You can also install Apache OpenOffice 4.1.1 on Ubuntu 12.04 Precise Pangolin, Linux Mint 17 Qiana, Elementary OS 0.3 and other Ubuntu and Debian (Linux) derivative systems.

Apache OpenOffice is the leading open-source office software suite for word processing, spreadsheets, presentations, graphics, databases and more. It is available in many languages and works on all common computers. It stores all your data in an international open standard format and can also read and write files from other common office software packages. It can be downloaded and used completely free of charge for any purpose.

To install Apache OpenOffice 4.1.1 on Ubuntu 14.04, we will download the deb packages (installer packages) from sourceforge and install it via dpkg command.

Before you begin the installation, you will have to remove the already installed versions of either OpenOffice and LibreOffice software on your Ubuntu 14.04 system.  You have to uninstall/remove the already installed OpenOffice or LibreOffice, irrespective of the Ubuntu 14.04 system architecture (32 bit or 64 bit).

Open the Terminal and run the following commands to remove the already installed versions of either openoffice and libreoffice software:


 sudo apt-get remove libreoffice* openoffice*
 sudo apt-get autoremove
Please restart your system before you begin the fresh installation.

How to install Apache OpenOffice 4.1.1 on 32 bit Ubuntu

Open the Terminal and run the following commands to download OpenOffice, extract the archive and install the deb packages (OpenOffice 4.1.1):


wget sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/en-GB/Apache_OpenOffice_4.1.1_Linux_x86_install-deb_en-GB.tar.gz
 tar -xzvf Apache_OpenOffice_4.1.1_Linux_x86_install-deb_en-GB.tar.gz

 cd en-GB/DEBS
 sudo dpkg -i *.deb
 cd desktop-integration
 sudo dpkg -i *.deb


How to install Apache OpenOffice 4.1.1 on 64 bit Ubuntu

Open the Terminal and run the following commands to download OpenOffice, extract the archive and install the deb packages (OpenOffice 4.1.1):


 wget sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/en-GB/Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
 tar -xzvf Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz

 cd en-GB/DEBS
 sudo dpkg -i *.deb
 cd desktop-integration
 sudo dpkg -i *.deb


How to remove/un-install Apache OpenOffice 4.1.1

Open the Terminal and run the fowlloing commands to remove Apache OpenOffice 4.1.1 from Ubuntu 14.04 Trusty Tahr (LTS) system (either 32 bit or 64 bit Ubuntu 14.04 system).


$ sudo apt-get remove openoffice*