Category Archives: Ubuntu

Autostart Glassfish on startup in Ubuntu

To make the Glassfish Server auto start with startup, we need to setting up an init script, which helps us to manage all Glassfish Server startup events easily. And also make Glassfish start up automatically whenever Ubuntu is rebooting.

This script file is glassfish to be created at /etc/init.d/. For managing all Glassfish Server startup events, it ships with the asadmin tool. Use this tool in the startup script as follows,

  1. Create or edit glassfish file
  2. Paste the following lines in the file

Now, glassfish startup script is created. We need to add this file in startup to make Glassfish Server autostart during Ubuntu startup. Follow these steps,

  1. Make the startup script file executable
  2. Add this file to Ubuntu startup boot

That’s it. Now, restart Ubuntu and check if it really autostart the Glassfish Server.

You can also manage Glassfish Server startup events as follows,

  • Start the server
  • Stop the server
  • Restart the server

     

Automatically start Tomcat on startup in Ubuntu

Apache Tomcat is not configured with autostart by default in Ubuntu. So, custom init script is required to configure Tomcat for autostart on startup.

Create the init script in /etc/init.d/tomcat8 with the contents as per below.

Init script contents:

Note: Please change {tomcat_root} with your Tomcat installation folder path.

Change its permissions and add the correct symlinks automatically:

And from now on it will be automatically started and shut down upon entering the appropriate run levels.

It could be also controlled with justservice tomcat8 <stop|start|restart> like Apache control commands.

Using above process any server script can be created and configured to start on startup.

Access shell with SSH on cPanel server from Linux

Some of the important server related problems will be solved only using shell access to the server. To access the cPanel server shell using SSH, there must be an SSH client installed on PC. Most of the Linux distros include SSH client software by default. If it is not installed, then it can be easily installed with following commands,

For Ubuntu: apt-get install openssh-client
For CentOS: yum install openssh-clients

After installation, follow these steps to access the cPanel shell with SSH from Linux:

  1. Login to cPanel and go to Security > SSH/Shell Access to generate SSH key pair.
  2. Click Manage SSH Keys > Generate a New Key. You should use a password to protect the key. You will be asked the password each time you use the key.
  3. In Public Keys section click ‘Manage Authorization’ and ‘Authorize’
  4. In Private Keys section click, Vew/Download then download the key (id_dsa or id_rsa) to your PC.
  5. Save it to ~/.ssh directory on your Linux machine under a meaningful name to not overwrite your existing keys for example id_dsa.myjavahost
  6. Now make sure permissions are correct on the key (one-time task) and connect:
  7. Provide the password for the key, set up in step #2

You should be logged in by now.

Unable to use package manager due to “exclusive lock” error

After update, Synaptic Manager in Ubuntu sometimes gives error

As the message says, it means that it is already running. By default, Ubuntu runs a check after reboot — not immediately, but some time within.

Generally, it is not advised to pause an update. Once an update has started, allow it to run its course. So, wait for some time, at least 30 minutes or more to complete the background update.

In case the update takes a while, open a terminal (Ctrl+Alt+T) and type this

If it shows any text then it means system is still updating, just wait for next update.

phpMyAdmin gives 404 error in localhost

To run phpmyadmin without getting 404 error, configure apache.conf for phpmyadmin.

Then add the following line to the end of the file.

And restart apache

Please read this section in Ubuntu wiki describes the 404 error problem for phpmyadmin.