Concatenate MP4 files

Ubuntu CLI

If you are looking to combine MP4 files from the command line here is the easiest solution. First you need to use the following command to install the program.

Once installed you will be able to run the following command to join the files.

You should now be able to combine MP4 files from the command line, and pretty quick at that.


Samsung Smart TVs speak DLNA-UPnP – uShare

http://askubuntu.com/questions/38021/how-to-add-a-ppa-on-a-server

sudo apt-get install python-software-properties

=====================================

Using PLEX: http://www.plexapp.com/ because it works on the Samsung tv.

=====================================

https://help.ubuntu.com/community/MiniDLNA

http://www.slsmk.com/how-to-install-ps3-media-server-to-ubuntu-in-headless-mode/

Quick Tip: DLNA Server on Linux (Ubuntu 12.04 Precise Pangolin)

My Samsung Smart TVs speak DLNA, my Android phones and tablets speak DLNA – time to teach my small headless Ubuntu home server to speak it as well.

It seems that most people are using uShare, but I personally like MiniDLNA (aka ReadyDLNA) better. On Precise, just install the package

# apt-get install minidlna

and create directories for Music, Pictures and Videos, for example:

# tree /dlna//dlna/

├── Music

├── Pictures

└── Videos

3 directories, 0 files

Drop your files into those directories and add some basic configuration to MiniDLNA:

# grep -o "^[a-z].*" /etc/minidlna.conf

port=8200

media_dir=A,/dlna/Music

media_dir=P,/dlna/Pictures

media_dir=V,/dlna/Videos

friendly_name=DLNA

Serverinotify=yes

enable_tivo=no

strict_dlna=no

notify_interval=900

serial=12345678

model_number=1

Now just force-reload MiniDLNA (force-reload rescans the folders)

# /etc/init.d/minidlna force-reload

and that should be it! The server now shows up on my Samsung Smart TV and on my Galaxy SIII:

http://2.bp.blogspot.com/-io13OaD2_Do/T-hKjO3SeCI/AAAAAAAAA6c/xmhW2g2ACaE/s320/Screenshot_2012-06-25-21-20-43.png

From there, I can browse my files.

# /etc/init.d/minidlna stop

# /etc/init.d/minidlna start

Samsung Smart TVs speak DLNA – uShare

http://askubuntu.com/questions/38021/how-to-add-a-ppa-on-a-server

sudo apt-get install python-software-properties

http://www.slsmk.com/how-to-install-ps3-media-server-to-ubuntu-in-headless-mode/

How To install Media Server to Ubuntu in Headless mode

PS3 media server is now my go to application for trancoding and playing media around the house since development on Mediatomb came to a halt. And this PS3 Media Server is sweet. So far it plays anything I throw at it on the Ps3 and the Sony NMP-200 I use around the house.

P.M.S. was meant to run in a GUI display. So there are a few extra things we need to do so that it runs on a Ubuntu Server in headless mode (without a GUI). After all, who needs a GUI on a server anyway… Since PMS version 1.81.0, I’ve stopped using the manual installation and instead am using the repository. It makes for an easier install and updates are handled via apt-get.

I’ve used this on Ubuntu 12.04.

We will need a few pre-reqs:

apt-get install mplayer mencoder ffmpeg openjdk-6-jre

Let’s add the repository from which we will install the PMS and run the installation.

sudo add-apt-repository ppa:happy-neko/ps3mediaserver
sudo apt-get update
sudo apt-get install ps3mediaserver

Next we create a system user account for the PMS to use. By default, PMS runs under the root account, but it’s always a good idea to keep things as secure as possible.

sudo adduser --system --group ps3mediauser

Now lets edit the PMS config file and setup the custom user and set it to autorun on startup. Edit /etc/default/ps3mediaserver, locate the following items in the file and make the changes as indicated.

PMS_START="yes"
PMS_USER="ps3mediauser"
PMS_PROFILE="/home/$PMS_USER/.config/ps3mediaserver"

Next, we need to create a PMS.conf file in the ps3mediauser home directory. You will need to run these commands as root since the ps3mediauser account is a system only account. Copy in the default PMS.conf file.

su -i
mkdir -p /home/ps3mediauser/.config/ps3mediaserver
cp /etc/skel/.config/ps3mediaserver/PMS.conf /home/ps3mediauser/.config/ps3mediaserver

Next you should edit the PMS.conf file and change the ‘folders’ to reflect the location of your Media files. The other settings can be left at default for the most part, but it doesn’t hurt to familiarize yourself with whats available.

folders =/mnt/media/tv,/mnt/media/movies,/mnt/media/music

With all the settings in place, you need to change ownership of the ps3mediauser home folder:

chown -R ps3mediauser:ps3mediauser /home/ps3mediauser

Last thing to check is the /tmp/ folder. PMS will use this folder and if the ‘root’ user had stuff in that folder related to PMS, the non-root user will have issues running the service. It doesn’t hurt to remove any older remnants.

rm -F /tmp/jna
rm -F /tmp/ps3*
rm -F /tmp/hsperfdata*

Some people have reported that they needed to change permissions in /tmp/. I’ve never had to do that, but it is something to keep in mind.

Lastly, just start the service:

sudo start ps3mediaserver

Tagged with: no tags.

=========================================

http://www.conrad.id.au/2012/06/quick-tip-dlna-server-on-linux-ubuntu.html

How to install apache2 mod_security and mod_evasive on Ubuntu 12.04 LTS server

http://www.thefanclub.co.za/how-to/how-install-apache2-modsecurity-and-modevasive-ubuntu-1204-lts-server

Submitted by The Fan Club on Sun, 2012-04-29 23:33

Last Update : August 2013

This guide is based on various community forum posts, and hours of frustration.

This guide is intended as a relatively easy step by step guide to:

  • Install and configure Apache2 ModSecurity and mod_evasive modules on Ubuntu 12.04 LTS server.
  • Things have become much easier than before installing both these two excellent security modules for Apache2 in Ubuntu 12.04 LTS, as both modules are available in the standard Ubuntu 12.04 repositories.
  • This is only a starting point for getting mod_security and mod_evasive working. Refer to both projects documentation for the various configuration option available and configure your security settings as required.

Requirements:

  • Ubuntu 12.04 LTS server, or later installed on your machine.
  • Apache2 webserver setup and configured.

1. Install ModSecurity on your server.

  • Install the dependencies. Open the Terminal Window and enter :
sudo apt-get install libxml2 libxml2-dev libxml2-utils
sudo apt-get install libaprutil1 libaprutil1-dev
  • 64bit users please note – Because of this bug you need to create a symbolic link to libxml2.so.2 or the installation will report the file missing and fail.
ln -s /usr/lib/x86_64-linux-gnu/libxml2.so.2 /usr/lib/libxml2.so.2
  • Now install ModSecurity
sudo apt-get install libapache-mod-security

2. Configure ModSecurity rules.

sudo mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
  • The default folder for ModSecurity rules is /etc/modsecurity/ . All .conf files will be included and need to be configured as required.
  • We need to activate all the base rules and make sure they also get loaded.
  • You might want to edit the SecRequestBodyLimit option in the modsecurity.conf file.
  • SecRequestBodyLimit limits the page request size and limits file uploads to 128 KB by default. Change this to the size of files you would accept uploaded to the server.
  • This settings is very important as it limits the size of all files that can be uploaded to the server. For CMS sites using Drupal or WordPress this setting is the source of much pain.
  • Open the Terminal Window and enter :
sudo vi /etc/modsecurity/modsecurity.conf
  • First activate the rules by editing the SecRuleEngine option and set to On.
SecRuleEngine On
  • Edit the following to option to increase the request limit to 16 MB and save the file :
SecRequestBodyLimit 16384000SecRequestBodyInMemoryLimit 16384000

3. Download and install the latest OWASP Core Rule Set.

  • We need to download and install the latest OWASP ModSecurity Core Rule Set from the project website. Click here for more information.
  • We will also activate the default CRS config file modsecurity_crs_10_setup.conf.example
  • If you prefer not to use the latest rules, replace master below with the a specific version you would like to use e.g : v2.2.5
  • Open the Terminal Window and enter :
cd /tmp
sudo wget -O SpiderLabs-owasp-modsecurity-crs.tar.gz http://github.com/SpiderLabs/owasp-modsecurity-crs/tarball/master
sudo tar -zxvf SpiderLabs-owasp-modsecurity-crs.tar.gz
sudo cp -R SpiderLabs-owasp-modsecurity-crs-*/* /etc/modsecurity/
sudo rm SpiderLabs-owasp-modsecurity-crs.tar.gz
sudo rm -R SpiderLabs-owasp-modsecurity-crs-*
sudo mv /etc/modsecurity/modsecurity_crs_10_setup.conf.example /etc/modsecurity/modsecurity_crs_10_setup.conf
  • Now we create symbolic links to all activated base rules. Open a terminal window and enter :
cd /etc/modsecurity/base_rulesfor f in * ; do sudo ln -s /etc/modsecurity/base_rules/$f /etc/modsecurity/activated_rules/$f ; donecd /etc/modsecurity/optional_rulesfor f in * ; do sudo ln -s /etc/modsecurity/optional_rules/$f /etc/modsecurity/activated_rules/$f ; done 
  • Now add these rules to Apache2. Open a terminal window and enter:
sudo vi /etc/apache2/mods-available/mod-security.conf
  • Add the following to towards the end of the file with other includes and save the file :
Include "/etc/modsecurity/activated_rules/*.conf"

4. Check if ModSecurity is enabled and restart Apache.

  • Before restarting Apache2 check if the modules has been loaded.
  • Open the Terminal Window and enter :
sudo a2enmod headerssudo a2enmod mod-security
  • Then restart the Apache2 webserver :
sudo /etc/init.d apache2 restart
  • OR
service apache2 restart

5. Install ModEvasive.

  • Open the Terminal Window and enter :
sudo apt-get install libapache2-mod-evasive

6. Create log file directory for mod_evasive.

  • Open the Terminal Window and enter :
sudo mkdir /var/log/mod_evasive
  • Change the log folder permissions :
sudo chown www-data:www-data /var/log/mod_evasive/

7. Create mod-evasive.conf file and configure ModEvasive.

  • Open the Terminal Window and enter :
sudo vi /etc/apache2/mods-available/mod-evasive.conf
  • and add the following, changing the email value, and other options below as required :
<ifmodule mod_evasive20.c>   DOSHashTableSize 3097   DOSPageCount  2   DOSSiteCount  50   DOSPageInterval 1   DOSSiteInterval  1   DOSBlockingPeriod  10   DOSLogDir   /var/log/mod_evasive   DOSEmailNotify  EMAIL@DOMAIN.com   DOSWhitelist   127.0.0.1</ifmodule>

8. Fix mod-evasive email bug

  • Because of this bug mod-evasive does not send emails on Ubuntu 12.04.
  • A temporary workaround is to create symlink to the mail program.
  • Open the Terminal Window and enter :
sudo ln -s /etc/alternatives/mail /bin/mail/

9. Check if ModEvasive is enabled and restart Apache.

  • Before restarting Apache2 check if the module has been loaded.
  • Open the Terminal Window and enter :
sudo a2enmod mod-evasive
  • Then restart the Apache2 webserver :
sudo /etc/init.d/apache2 restart
  • OR
service apache2 restart

How to secure an Ubuntu 12.04 LTS server – Part 1 The Basics

This guide is based on various community forum posts and webpages. Special thanks to all. All comments and improvements are very welcome as this is purely a personal experimental project at this point and must be considered a work in progress.

This guide is intended as a relatively easy step by step guide to:

Harden the security on an Ubuntu 12.04 LTS server by installing and configuring the following:

  1. Install and configure Firewall – ufw
  2. Secure shared memory – fstab
  3. SSH – Disable root login and change port
  4. Protect su by limiting access only to admin group
  5. Harden network with sysctl settings
  6. Disable Open DNS Recursion and Remove Version Info – Bind9 DNS
  7. Prevent IP Spoofing
  8. Harden PHP for security
  9. Restrict Apache Information Leakage
  10. Install and configure Apache application firewall – ModSecurity
  11. Protect from DDOS (Denial of Service) attacks with ModEvasive
  12. Scan logs and ban suspicious hosts – DenyHosts and Fail2Ban
  13. Intrusion Detection – PSAD
  14. Check for RootKits – RKHunter and CHKRootKit
  15. Scan open Ports – Nmap
  16. Analyse system LOG files – LogWatch
  17. SELinux – Apparmor
  18. Audit your system security – Tiger

If you are looking for a GUI script to install and configure all the steps explained here automatically,
visit How to secure an Ubuntu 12.04 LTS server – Part 2 The GUI Installer script

Requirements:

  • Ubuntu 12.04 LTS server with a standard LAMP stack installed.

1. Firewall – UFW

  • A good place to start is to install a Firewall.
  • UFW – Uncomplicated Firewall is a basic firewall that works very well and easy to configure with its Firewall configuration tool – gufw, or use Shorewall, fwbuilder, or Firestarter.
  • Use Firestarter GUI to configure your firewall or refer to the Ubuntu Server Guide, UFW manual pages or the Ubuntu UFW community documentation.
  • Install UFW and enable, open a terminal window and enter :
sudo apt-get install ufwsudo ufw enable
  • Check the status of the firewall.
sudo ufw status verbose
  • Allow SSH and Http services.
sudo ufw allow sshsudo ufw allow http

2. Secure shared memory.

  • /dev/shm can be used in an attack against a running service, such as httpd. Modify /etc/fstab to make it more secure.
  • Open a Terminal Window and enter the following :
sudo vi /etc/fstab
  • Add the following line and save. You will need to reboot for this setting to take effect :
tmpfs     /dev/shm     tmpfs     defaults,noexec,nosuid     0     0

3. SSH Hardening – disable root login and change port.

  • The easiest way to secure SSH is to disable root login and change the SSH port to something different than the standard port 22.
  • Before disabling the root login create a new SSH user and make sure the user belongs to the admin group (see step 4. below regarding the admin group).
  • If you change the SSH port also open the new port you have chosen on the firewall and close port 22.
  • Open a Terminal Window and enter :
sudo vi /etc/ssh/sshd_config
  • Change or add the following and save.
Port <ENTER YOUR PORT>Protocol 2PermitRootLogin noDebianBanner no
  • Restart SSH server, open a Terminal Window and enter :
sudo /etc/init.d/ssh restart

4. Protect su by limiting access only to admin group.

  • To limit the use of su by admin users only we need to create an admin group, then add users and limit the use of su to the admin group.
  • Add a admin group to the system and add your own admin username to the group by replacing <YOUR ADMIN USERNAME> below with your admin username.
  • Open a terminal window and enter:
sudo groupadd adminsudo usermod -a -G admin <YOUR ADMIN USERNAME>sudo dpkg-statoverride --update --add root admin 4750 /bin/su

5. Harden network with sysctl settings.

  • The /etc/sysctl.conf file contain all the sysctl settings.
  • Prevent source routing of incoming packets and log malformed IP's enter the following in a terminal window:
sudo vi /etc/sysctl.conf
  • Edit the /etc/sysctl.conf file and un-comment or add the following lines :
# IP Spoofing protectionnet.ipv4.conf.all.rp_filter = 1net.ipv4.conf.default.rp_filter = 1# Ignore ICMP broadcast requestsnet.ipv4.icmp_echo_ignore_broadcasts = 1# Disable source packet routingnet.ipv4.conf.all.accept_source_route = 0net.ipv6.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_route = 0net.ipv6.conf.default.accept_source_route = 0# Ignore send redirectsnet.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0# Block SYN attacksnet.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_syn_backlog = 2048net.ipv4.tcp_synack_retries = 2net.ipv4.tcp_syn_retries = 5# Log Martiansnet.ipv4.conf.all.log_martians = 1net.ipv4.icmp_ignore_bogus_error_responses = 1# Ignore ICMP redirectsnet.ipv4.conf.all.accept_redirects = 0net.ipv6.conf.all.accept_redirects = 0net.ipv4.conf.default.accept_redirects = 0 net.ipv6.conf.default.accept_redirects = 0# Ignore Directed pingsnet.ipv4.icmp_echo_ignore_all = 1
  • To reload sysctl with the latest changes, enter:
sudo sysctl -p

6. Disable Open DNS Recursion and Remove Version Info – BIND DNS Server.

  • Open a Terminal and enter the following :
sudo vi /etc/bind/named.conf.options
  • Add the following to the Options section :
recursion no;version "Not Disclosed";
  • Restart BIND DNS server. Open a Terminal and enter the following :
sudo /etc/init.d/bind9 restart

7. Prevent IP Spoofing.

  • Open a Terminal and enter the following :
sudo vi /etc/host.conf
  • Add or edit the following lines :
order bind,hostsnospoof on

8. Harden PHP for security.

  • Edit the php.ini file :
sudo vi /etc/php5/apache2/php.ini
  • Add or edit the following lines an save :
disable_functions = exec,system,shell_exec,passthruregister_globals = Offexpose_php = Offdisplay_errors = Offtrack_errors = Offhtml_errors = Offmagic_quotes_gpc = Off
  • Restart Apache server. Open a Terminal and enter the following :
sudo /etc/init.d/apache2 restart

9. Restrict Apache Information Leakage.

  • Edit the Apache2 configuration security file :
sudo vi /etc/apache2/conf.d/security
  • Add or edit the following lines and save :
ServerTokens ProdServerSignature OffTraceEnable OffHeader unset ETagFileETag None
  • Restart Apache server. Open a Terminal and enter the following :
sudo /etc/init.d/apache2 restart

10. Web Application Firewall – ModSecurity.

11. Protect from DDOS (Denial of Service) attacks – ModEvasive

12. Scan logs and ban suspicious hosts – DenyHosts and Fail2Ban.

  • DenyHosts is a python program that automatically blocks SSH attacks by adding entries to /etc/hosts.deny. DenyHosts will also inform Linux administrators about offending hosts, attacked users and suspicious logins.
  • Open a Terminal and enter the following :
sudo apt-get install denyhosts
  • After installation edit the configuration file /etc/denyhosts.conf and change the email, and other settings as required.
  • To edit the admin email settings open a terminal window and enter:
sudo vi /etc/denyhosts.conf
  • Change the following values as required on your server :
ADMIN_EMAIL = root@localhostSMTP_HOST = localhostSMTP_PORT = 25#SMTP_USERNAME=foo#SMTP_PASSWORD=barSMTP_FROM = DenyHosts nobody@localhost#SYSLOG_REPORT=YES 
  • Fail2ban is more advanced than DenyHosts as it extends the log monitoring to other services including SSH, Apache, Courier, FTP, and more.
  • Fail2ban scans log files and bans IPs that show the malicious signs — too many password failures, seeking for exploits, etc.
  • Generally Fail2Ban then used to update firewall rules to reject the IP addresses for a specified amount of time, although any arbitrary other action could also be configured.
  • Out of the box Fail2Ban comes with filters for various services (apache, courier, ftp, ssh, etc).
  • Open a Terminal and enter the following :
sudo apt-get install fail2ban
  • After installation edit the configuration file /etc/fail2ban/jail.local and create the filter rules as required.
  • To edit the settings open a terminal window and enter:
sudo vi /etc/fail2ban/jail.conf
  • Activate all the services you would like fail2ban to monitor by changing enabled = false to enabled = true
  • For example if you would like to enable the SSH monitoring and banning jail, find the line below and change enabled from false to true. Thats it.
[ssh]enabled  = trueport     = sshfilter   = sshdlogpath  = /var/log/auth.logmaxretry = 3
  • If you have selected a non-standard SSH port in step 3 then you need to change the port setting in fail2ban from ssh which by default is port 22, to your new port number, for example if you have chosen 1234 then port = 1234
[ssh]enabled  = trueport     = <ENTER YOUR SSH PORT NUMBER HERE>filter   = sshdlogpath  = /var/log/auth.logmaxretry = 3
  • If you would like to receive emails from Fail2Ban if hosts are banned change the following line to your email address.
destemail = root@localhost
  • and change the following line from :
action = %(action_)s
  • to:
action = %(action_mwl)s
  • You can also create rule filters for the various services that you would like fail2ban to monitor that is not supplied by default.
sudo vi /etc/fail2ban/jail.local
  • Good instructions on how to configure fail2ban and create the various filters can be found on HowtoForgeclick here for an example
  • When done with the configuration of Fail2Ban restart the service with :
sudo /etc/init.d/fail2ban restart
  • You can also check the status with.
sudo fail2ban-client status

13. Intrusion Detection – PSAD.

  • Cipherdyne PSAD is a collection of three lightweight system daemons that run on Linux machines and analyze iptables log messages to detect port scans and other suspicious traffic.
  • Currently version 2.1 causes errors during install on Ubuntu 12.04, but apparently does work. Version 2.2 resolves these issues but is not yet available on the Ubuntu software repositories. It is recommended to manually compile and install version 2.2 from the source files available on the Ciperdyne website.
  • To install the latest version from the source files follow these instruction : How to install PSAD Intrusion Detection on Ubuntu 12.04 LTS server
  • OR install the older version from the Ubuntu software repositories, open a Terminal and enter the following :
sudo apt-get install psad

14. Check for rootkits – RKHunter and CHKRootKit.

  • Both RKHunter and CHKRootkit basically do the same thing – check your system for rootkits. No harm in using both.
  • Open a Terminal and enter the following :
sudo apt-get install rkhunter chkrootkit
  • To run chkrootkit open a terminal window and enter :
sudo chkrootkit
  • To update and run RKHunter. Open a Terminal and enter the following :
sudo rkhunter --updatesudo rkhunter --propupdsudo rkhunter --check

15. Scan open ports – Nmap.

  • Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing.
  • Open a Terminal and enter the following :
sudo apt-get install nmap
  • Scan your system for open ports with :
nmap -v -sT localhost
  • SYN scanning with the following :
sudo nmap -v -sS localhost

16. Analyse system LOG files – LogWatch.

  • Logwatch is a customizable log analysis system. Logwatch parses through your system's logs and creates a report analyzing areas that you specify. Logwatch is easy to use and will work right out of the package on most systems.
  • Open a Terminal and enter the following :
sudo apt-get install logwatch libdate-manip-perl
  • To view logwatch output use less :
sudo logwatch | less
  • To email a logwatch report for the past 7 days to an email address, enter the following and replace mail@domain.com with the required email. :
sudo logwatch --mailto mail@domain.com --output mail --format html --range 'between -7 days and today' 

17. SELinux – Apparmor.

  • National Security Agency (NSA) has taken Linux to the next level with the introduction of Security-Enhanced Linux (SELinux). SELinux takes the existing GNU/Linux operating system and extends it with kernel and user-space modifications to make it bullet-proof.
  • More information can be found here. Ubuntu Server Guide – Apparmor
  • It is installed by default since Ubuntu 7.04.
  • Open a Terminal and enter the following :
sudo apt-get install apparmor apparmor-profiles
  • Check to see if things are running :
sudo apparmor_status

18. Audit your system security – Tiger.

  • Tiger is a security tool that can be use both as a security audit and intrusion detection system.
  • Open a Terminal and enter the following :
sudo apt-get install tiger
  • To run tiger enter :
sudo tiger
  • All Tiger output can be found in the /var/log/tiger
  • To view the tiger security reports, open a Terminal and enter the following :
sudo less /var/log/tiger/security.report.*

How to Install Oracle Java 7 on Ubuntu Linux






This tutorial will cover the installation of 32-bit and 64-bit Oracle Java 7 (currently version number 1.7.0_25) JDK/JRE on 32-bit and 64-bit Ubuntu operating systems. These instructions will also work on Debian and Linux Mint.

If you already have Oracle Java 7 installed on your system, using this method but need to upgrade.

For those who only want to install Oracle Java JRE for running Java applications and not to develop Java programs.

For those who want to install Oracle Java JDK to develop Java programs and applications the Oracle JDK with the Oracle Java JRE included in the Oracle JDK.

Also to enable/upgrade the Oracle Java in your web browsers.

EditSteps

  1. 1
    Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit, open up a terminal and run the following command below.
    • Type/Copy/Paste: file /sbin/init
      • Note the bit version of your Ubuntu Linux operating system architecture it will display whether it is 32-bit or 64-bit.
  2. 2
    Check if you have Java installed on your system. To do this, you will have to run the Java version command from terminal.
    • Open up a terminal and enter the following command:
      • Type/Copy/Paste: java -version
    • If you have OpenJDK installed on your system it may look like this:
      • java version "1.7.0_15"
        OpenJDK Runtime Environment (IcedTea6 1.10pre) (7b15~pre1-0lucid1)
        OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
    • If you have OpenJDK installed on your system, you have the wrong vendor version of Java installed for this exercise.
  3. 3
    Completely remove the OpenJDK/JRE from your system and create a directory to hold your Oracle Java JDK/JRE binaries. This will prevent system conflicts and confusion between different vendor versions of Java. For example, if you have the OpenJDK/JRE installed on your system, you can remove it by typing the following at the command line:
    • Type/Copy/Paste: sudo apt-get purge openjdk-\*
      • This command will completely remove OpenJDK/JRE from your system
    • Type/Copy/Paste: sudo mkdir -p /usr/local/java
      • This command will create a directory to hold your Oracle Java JDK and JRE binaries.
  4. 4
    Download the Oracle Java JDK/JRE for Linux. Make sure you select the correct compressed binaries for your system architecture 32-bit or 64-bit (which end in tar.gz).
    • For example, if you are on Ubuntu Linux 32-bit operating system download 32-bit Oracle Java binaries.
    • For example, if you are on Ubuntu Linux 64-bit operating system download 64-bit Oracle Java binaries.
    • Optional, Download the Oracle Java JDK/JRE Documentation
      • Select jdk-7u25-apidocs.zip
    • Important Information: 64-bit Oracle Java binaries do not work on 32-bit Ubuntu Linux operating systems, you will receive multiple system error messages, if you attempt to install 64-bit Oracle Java on 32-bit Ubuntu Linux.
  5. 5
    Copy the Oracle Java binaries into the /usr/local/java directory. In most cases, the Oracle Java binaries are downloaded to: /home/"your_user_name"/Downloads.
    • 32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
      • Type/Copy/Paste: cd /home/"your_user_name"/Downloads
      • Type/Copy/Paste: sudo cp -r jdk-7u25-linux-i586.tar.gz /usr/local/java
      • Type/Copy/Paste: sudo cp -r jre-7u25-linux-i586.tar.gz /usr/local/java
      • Type/Copy/Paste: cd /usr/local/java
    • 64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
      • Type/Copy/Paste: cd /home/"your_user_name"/Downloads
      • Type/Copy/Paste: sudo cp -r jdk-7u25-linux-x64.tar.gz /usr/local/java
      • Type/Copy/Paste: sudo cp -r jre-7u25-linux-x64.tar.gz /usr/local/java
      • Type/Copy/Paste: cd /usr/local/java
  6. 6
    Unpack the compressed Java binaries, in the directory /usr/local/java
    • 32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
      • Type/Copy/Paste: sudo tar xvzf jdk-7u25-linux-i586.tar.gz
      • Type/Copy/Paste: sudo tar xvzf jre-7u25-linux-i586.tar.gz
    • 64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
      • Type/Copy/Paste: sudo tar xvzf jdk-7u25-linux-x64.tar.gz
      • Type/Copy/Paste: sudo tar xvzf jre-7u25-linux-x64.tar.gz
  7. 7
    Double-check your directories. At this point, you should have two uncompressed binary directories in /usr/local/java for the Java JDK/JRE listed as:
    • Type/Copy/Paste: ls -a
    • jdk1.7.0_25
    • jre1.7.0_25
  8. 8
    Edit the system PATH file /etc/profile and add the following system variables to your system path. Use nano, gedit or any other text editor, as root, open up /etc/profile.
    • Type/Copy/Paste: sudo gedit /etc/profile
    • or
    • Type/Copy/Paste: sudo nano /etc/profile
  9. 9
    Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:
    • Type/Copy/Paste:

      JAVA_HOME=/usr/local/java/jdk1.7.0_25
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
      JRE_HOME=/usr/local/java/jre1.7.0_25
      PATH=$PATH:$HOME/bin:$JRE_HOME/bin
      export JAVA_HOME
      export JRE_HOME
      export PATH
  10. 10
    Save the /etc/profile file and exit.
  11. 11
    Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.
    • Type/Copy/Paste: sudo update-alternatives –install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_25/bin/java" 1
      • this command notifies the system that Oracle Java JRE is available for use
    • Type/Copy/Paste: sudo update-alternatives –install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_25/bin/javac" 1
      • this command notifies the system that Oracle Java JDK is available for use
    • Type/Copy/Paste: sudo update-alternatives –install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_25/bin/javaws" 1
      • this command notifies the system that Oracle Java Web start is available for use
  12. 12
    Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java.
    • Type/Copy/Paste: sudo update-alternatives –set java /usr/local/java/jre1.7.0_25/bin/java
      • this command will set the java runtime environment for the system
    • Type/Copy/Paste: sudo update-alternatives –set javac /usr/local/java/jdk1.7.0_25/bin/javac
      • this command will set the javac compiler for the system
    • Type/Copy/Paste: sudo update-alternatives –set javaws /usr/local/java/jre1.7.0_25/bin/javaws
      • this command will set Java Web start for the system
  13. 13
    Reload your system wide PATH /etc/profile by typing the following command:
    • Type/Copy/Paste: . /etc/profile
    • Note your system-wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system
  14. 14
    Test to see if Oracle Java was installed correctly on your system. Run the following commands and note the version of Java:
  15. 15
    A successful installation of 32-bit Oracle Java will display:
    • Type/Copy/Paste: java -version
      • This command displays the version of java running on your system
    • You should receive a message which displays:
      • java version "1.7.0_25"
        Java(TM) SE Runtime Environment (build 1.7.0_25-b25)
        Java HotSpot(TM) Server VM (build 23.1-b03, mixed mode)
    • Type/Copy/Paste: javac -version
      • This command lets you know that you are now able to compile Java programs from the terminal.
    • You should receive a message which displays:
      • javac 1.7.0_25
  16. 16
    A successful installation of Oracle Java 64-bit will display:
    • Type/Copy/Paste: java -version
      • This command displays the version of java running on your system
    • You should receive a message which displays:
      • java version "1.7.0_25"
        Java(TM) SE Runtime Environment (build 1.7.0_25-b25)
        Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
    • Type/Copy/Paste: javac -version
      • This command lets you know that you are now able to compile Java programs from the terminal.
    • You should receive a message which displays:
      • javac 1.7.0_25
  17. 17
    Congratulations, you just installed Oracle Java on your Linux system. Now reboot your Ubuntu Linux system. Afterwards, your system will be fully configured for running and developing Java programs. Later on you may want to try compiling and running your own Java programs by following this article How to Create your First Java Program on Ubuntu Linux

EditOptional: How to enable Oracle Java in your Web Browsers

  1. 1
    To enable your Java plug-in in your web browsers you must make a symbolic link from the web browsers plug-in directory to the location of the Java plug-in included in your distribution of Oracle Java.

Important Note: I would urge caution when enabling Oracle Java 7 in your web browsers, due to the fact there have been many numerous security flaws and exploits. Essentially, by enabling Oracle Java 7 in your web browsers if a security flaw or exploit is discovered this is how the bad guys break in and compromise your system. For more information on security flaws and exploits in Java see the following website: Java Tester

EditGoogle Chrome

32-bit Oracle Java instructions:

  1. 1
    Issue the following commands.
    • Type/Copy/Paste: sudo mkdir -p /opt/google/chrome/plugins
      • this will create a directory called /opt/google/chrome/plugins
    • Type/Paste/Copy: cd /opt/google/chrome/plugins
      • this will change you into the google chrome plugins directory,make sure you are in this directory before you make the symbolic link
    • Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_25/lib/i386/libnpjp2.so
      • this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Google Chrome web browser

64-bit Oracle Java instructions:

  1. 1
    Issue the following commands.
    • Type/Copy/Paste: sudo mkdir -p /opt/google/chrome/plugins
      • this will create a directory called /opt/google/chrome/plugins
    • Type/Paste/Copy: cd /opt/google/chrome/plugins
      • this will change you into the google chrome plugins directory,make sure you are in this directory before you make the symbolic link
    • Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_25/lib/amd64/libnpjp2.so
      • this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Google Chrome web browser

Reminders:

  1. 1
    Note: Sometimes when you issue the above command you may receive a message which states:
    • ln: creating symbolic link `./libnpjp2.so': File exists
    • To correct this issue simply remove the previous symbolic link using the following command:
    • Type/Copy/Paste: cd /opt/google/chrome/plugins
    • Type/Copy/Paste: sudo rm -rf libnpjp2.so
    • Make sure you are in the /opt/google/chrome/plugins directory before you issue the command
  2. 2
    Restart your web browser and go to Java Tester to test if Java is functioning in your web browser.

EditMozilla Firefox

32-bit Oracle Java instructions:

  1. 1
    Issue the following commands.
    • Type/Paste/Copy: cd /usr/lib/mozilla/plugins
      • this will change you into the directory /usr/lib/mozilla/plugins, create this directory if you do not have it
    • Type/Paste/Copy: sudo mkdir -p /usr/lib/mozilla/plugins
      • this will create the directory /usr/lib/mozilla/plugins, make sure you are in this directory before you make the symbolic link
    • Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_25/lib/i386/libnpjp2.so
      • this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Mozilla Firefox web browser

64-bit Oracle Java instructions:

  1. 1
    Issue the following commands.
    • Type/Paste/Copy: cd /usr/lib/mozilla/plugins
      • this will change you into the directory /usr/lib/mozilla/plugins, create this directory if you do not have it
    • Type/Paste/Copy: sudo mkdir -p /usr/lib/mozilla/plugins
      • this will create the directory /usr/lib/mozilla/plugins, make sure you are in this directory before you make the symbolic link
    • Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_25/lib/amd64/libnpjp2.so
      • this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Mozilla Firefox web browser

Reminders:

  1. 1
    Note: Sometimes when you issue the above command you may receive a message which states:
    • ln: creating symbolic link `./libnpjp2.so': File exists
    • To correct this issue simply remove the previous symbolic link using the following command:
    • Type/Copy/Paste: cd /usr/lib/mozilla/plugins
    • Type/Copy/Paste: sudo rm -rf libnpjp2.so
    • Make sure you are in the /usr/lib/mozilla/plugins directory before you issue the command
  2. 2
    Restart your web browser and go to Java Tester to test if Java is functioning in your web browser.

EditTips

  • With Ubuntu Linux, you have the choice of whether to use OpenJDK, which is a free and open-source implementation of the Java programming language, or to use Oracle Java JDK and JRE. Some prefer to use Oracle Java (as it is the most up-to-date version of Java and it comes directly from the maintainers of Java technology), but this varies.
  • Please note that this document is in continual revision because Oracle sometimes changes the installation method of their Java JDK/JRE binaries.
  • Keep in mind that Oracle makes security upgrades and bug fixes and enhances performance issues for each new release of Oracle Java. When installing Oracle Java on your system, be aware of the version number changes. See How to Upgrade Oracle Java on Ubuntu Linux for more information.

Startup/Shutdown script

1) Create the startup script file

in /etc/init.d – sudo nano /etc/init.d/StartVM.

Copy Past the following in the file and replace "My VM Name" for your vm name:

#! /bin/sh
# /etc/init.d/StartVM
#
#Edit these variables!
VMUSER=spode
VMNAME="My VM Name"
case "$1" in
start)
echo "Starting VirtualBox VM..."
sudo -H -b -u $VMUSER /usr/bin/VBoxVRDP -s "$VMNAME"
;;
stop)
echo "Saving state of Virtualbox VM..."
sudo -H -u  $VMUSER /usr/bin/VBoxManage controlvm "$VMNAME" savestate
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0

2) Give the script executable permission

with sudo chmod +x /etc/init.d/StartVM.

3) Tell script to run at startup.

tell the script be the first to shutdown and the last to startup.

sudo update-rc.d StartVM defaults 99 01


Tag Cloud