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

Tuesday, December 25, 2018

How to configure static IP address on Ubuntu 18.04 ?

How to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux



The objective is to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux


configure static IP address using DHCP

Most likely your current Ubuntu system uses DHCP server to configure its networking settings.
Hence, the configuration of your IP address is dynamic. In many scenarios, simply configuring
your router or local DHCP server is a preferred way to set a static address to any host regardless
of the operating system in use. Check your router manual and assign the static IP address to
your host based on its MAC address using the DHCP service.

Configure static IP address using Netplan

Netplan network configuration had been first introduced to Ubuntu 18.04 LTS Bionic Beaver.
It is available to all new Ubuntu 18.04 installations.

Depending on your Ubuntu installation Netplan may not be avaiable on upgraded Ubuntu systems.
If this is your case you might attempt to configure a static IP address for your network interface
using /etc/network/interfaces file as described at the end of this document.

Ubuntu Server

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant
netplan network configuration file within /etc/netplan/ directory.

For example you might find there a default netplan configuration file called 01-netcfg.yaml
or 50-cloud-init.yaml with a following content instructing the networkd deamon to configure
your network interface via DHCP:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   enp0s3:
     dhcp4: yes

To set your network interface enp0s3 to static IP address 192.168.1.220 with gateway 192.168.1.1
and DNS server as 8.8.8.8 and 8.8.4.4 replace the above configuration with the one below.

WARNING:
You must adhere to a correct code indent for each line of the block. In other words the prefix
number of spaces for each line is important. Othersiwe you may end up with an error message
similar to: Invalid YAML at //etc/netplan/01-netcfg.yaml line 7 column 6: did not find expected key

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   enp0s3:
    dhcp4: no
    addresses: [192.168.1.220/24]
    gateway4: 192.168.1.1
    nameservers:
      addresses: [8.8.8.8,8.8.4.4]

Once ready apply changes with:

$ sudo netplan apply



In case you run into some issues execute:


$ sudo netplan --debug apply



How to Disable, Stop or Uninstall Apport Error Reporting ?

How do I enable or disable Apport?

Apport is an Error Reporting Service provided by Ubuntu to intercept and analyze crashes and bugs as and when they occur. Crashes and Bugs may sound like bad things, but actually most operating systems will have several a day, and it doesn't mean your computer is broken, nor does it necessarily stop working. As such, Apport can usually be safely disabled, as it doesn't fix anything, it just tells developers that something went wrong.

Apport intercepts Program crashes, collects debugging information about the crash and the operating system environment, and sends it to bug trackers in a standardized form. It also offers the user to report a bug about a package, with again collecting as much information about it as possible.

How to Disable Apport at Boot ?

You need to manually edit a file to Stop Apport Running at Boot (when you turn on your machine. Open the Terminal, and paste the following command with Ctrl+Shift+V, or type it in manually.

Change the line that says enabled=1 to enabled=0 to disable Apport. To re-enable, change it back.

How to Stop Apport ?
On ubuntu 14.04 LTS
You can stop the currently running Apport service with the following command.
sudo service apport stop
Note that unless you remove it or disable it at boot it will start again the next time you turn on your computer.

On Ubuntu 16.04

To stop the service

Sudo systemctl stop apport.service

The systemd commands to enable / disable apport are:
Disable
sudo systemctl disable apport.service
If that does not work, you would then need to mask the service
Sudo systemctl mask apport.service
To re-enable
Sudo systemctl unmask apport.service # if you masked it
sudo systemctl enable apport.service

How to Uninstall Apport ?
It is fairly simple to uninstall Apport, as you can open the Ubuntu Software Centre, search for apport, and simply click Remove.
A similar process can be used for the package apport in both Synaptic and the Terminal.

sudo apt-get remove apport

sudo apt-get purge apport


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