When you encounter commands that you don't understand, use manual pages.
This big command can be separated in three main parts :
- Adding VirtualBox repository to the system
- Register Oracle public keys
- Installing Oracle VirtualBox
1. Adding VirtualBox repository to the system
sudo sh -c "echo 'deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free' > /etc/apt/sources.list.d/virtualbox.list"
Let's breack up each part :
sh -c
If you type man sh
you will get :
-c Read commands from the command_string operand
instead of from the standard input. Special
parameter 0 will be set from the command_name operand
and the positional parameters ($1, $2, etc.)
set from the remaining argument operands.
Now :
deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free
is the address where the VirtualBox packages are located.
When you run the command lsb_release -cs
it will output your Ubuntu version :
$ lsb_release -cs
trusty
>
is a redirection operator. It writes the previous output to the following file :
/etc/apt/sources.list.d/virtualbox.list
When you run
echo 'deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free'
it will output in your terminal :
deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free
Running
echo 'deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free' > /etc/apt/sources.list.d/virtualbox.list
will write the line :
deb http://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free
to the /etc/apt/sources.list.d/virtualbox.list
file instead of giving a terminal output.
Note : This is not the advised method to use. It may lead to duplicate entries when running twice.
The recommended way to add the VirtualBox repository to the system is add-apt-repository
:
sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian trusty contrib"
Replace trusty with your current Ubuntu version.
2. Register Oracle public keys
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
man wget
output :
DESCRIPTION
GNU Wget is a free utility for non-interactive download of files from
the Web
[...]
-q
--quiet
Turn off Wget's output.
With this command you download the VirtualBox public key...
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O-
...and register it to the system (What does the “-” mean?):
sudo apt-key add -
3. Installing Oracle VirtualBox
sudo apt-get update
man apt-get
output :
update
update is used to resynchronize the package index files from their
sources. The indexes of available packages are fetched from the
location(s) specified in /etc/apt/sources.list.
And finally sudo apt-get install virtualbox-5.0
installs the virtualbox-5.0
package.
If you need additional clarification, do not hesitate to ask.
More information you can find in the answer from @takkat.
There is a list of all separated commands necessary to install VirtualBox.