ubuntu 12.04 server guide.pdf (1.33 mb)
Recommended way is to use mkvtoolnix
sudo apt-get install mkvtoolnix mkvtoolnix-gui
Subtitles are preserved and properly concatenated, so are audio and video. Chapters can be edited in the resulting file with mmg.
This procedure creates a properly muxed file. Any problems should be mentioned in the "log"-window in mmg. You can even set and name audio and subtitle tracks with the correct language codes and Annotations like "Forced" or "Directors Commentary".
If you plan to do this repeatedly on different files you better use the command line version mkvmerge("mkvmerge –help")
mkvmerge -o output.mkv input1.mkv +input2.mkv
# update permissions
find /local/apps/ -type d -exec chmod o+rx {} ";"
find /local/apps/ -type f -exec chmod o+r {} ";"
Result of FIND placed in {}
-type f=file d=directory
Terminate cmd ";"
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.
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:
From there, I can browse my files.
# /etc/init.d/minidlna stop
# /etc/init.d/minidlna start
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
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.
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
apt-get install nfs-common portmap
mkdir -p /mnt/nfs/fs-01.sda1
mkdir -p /mnt/nfs/fs-01.sdb1
prevent accedent writes:
sudo chmod 000 /mnt/nfs/fs-01.sda1
sudo chmod 000 /mnt/nfs/fs-01.sdb1
sudo mount fileshare-01:/mnt/local/sda1/ /mnt/nfs/fs-01.sda1/
You can use the df -h command to check that the directories have been mounted. You will see them last on the list.
df -h
Filesystem Size Used Avail Use% Mounted on/dev/sda 20G 948M 19G 5% /udev 119M 4.0K 119M 1% /devtmpfs 49M 208K 49M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 122M 0 122M 0% /run/shmfileshare-01:/home 20G 948M 19G 5% /mnt/nfs/homefileshare-01:/var/nfs 20G 948M 19G 5% /mnt/nfs/var/nfs
mount
/dev/sda on / type ext4 (rw,errors=remount-ro,barrier=0) [DOROOT]proc on /proc type proc (rw,noexec,nosuid,nodev)sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)none on /sys/fs/fuse/connections type fusectl (rw)none on /sys/kernel/debug type debugfs (rw)none on /sys/kernel/security type securityfs (rw)udev on /dev type devtmpfs (rw,mode=0755)devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)none on /run/shm type tmpfs (rw,nosuid,nodev)rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)fileshare-01:/home on /mnt/nfs/home type nfs (rw,vers=4,addr= fileshare-01,clientaddr=192.168.1.xxx)fileshare-01:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,vers=4,addr=12.34.56.78,clientaddr=192.168.1.xxx)
touch /mnt/nfs/fs-01.sda1/test.txt
touch /mnt/nfs/fs-01.sdb1/test.txt
You should then be able to find the files on the Server in the /home and /var/nfs directories.
ls /home
ls /mnt/nfs/
vi /etc/fstab
fileshare-999:/mnt/local/sdx1/test/ /mnt/nfs/fs-99.sdx1.test/ nfs4 _netdev,auto,hard,intr,retry=1,nolock,bg 0 0
fileshare-01:/mnt/local/sda1/ /mnt/nfs/fs-01.sda1/ nfs4 _netdev,auto,retry=1,nolock,bg,intr 0 0
You can learn more about the fstab options by typing in:
man nfs
df -h
mount
sudo umount /directory name
df -h
http://blog.teksol.info/pages/daemontools/tutorial
http://thedjbway.b0llix.net/daemontools/uidgid.html
http://manpages.ubuntu.com/manpages/precise/man8/setuidgid.8.html
Your environment variables will contain passwords, and you don’t want those files to be world-readable. Set your environment’s directory permissions to 0700, and the individual files to 0600. Then, ensure you always setuidgid last in your run scripts.
sudo apt-get install daemontools
### vi touch1.sh ============================
#!/bin/sh
exec 2>&1
exec setuidgid www-data touch /mnt/nfs/fs-01.sdb1/www.data1.log
### vi touch2.sh ============================
#!/bin/sh
exec 2>&1
exec setuidgid www-data sh -c 'echo "hello world" > /mnt/nfs/fs-01.sdb1/www.data2.log'
### vi touch3.sh ============================
#!/bin/sh
exec 2>&1
sh ./touch1.sh
sh ./touch2.sh
Might seem like a stretch, but clearly given the number of people asking the question out on the internet this is common enough. And I wanted to do it, so…..
The scenario. You have two private networks, home.local which is 192.168.0.0 netmask 255.255.255.0 and office.local numbered 192.168.1.0 netmask 255.255.255.0. They’re regular private networks connected to the internet via ADSL with routers of some description or other – could be the freebies that come from the service provider, or something you bought or built yourself. Either way it’s likely to be running NAT at the very least, possibly with some firewall as well, but for whatever reason, you can’t make these do the VPN for you (if you can, you should – it’s by far the simplest route).
On each network there’s an Ubuntu machine that’s on all the time for whatever reason, and you figure you can use these to connect the two networks together somehow.
Good news, you can.
Please remember that connecting two networks like this has security issues. Unless you also run firewalls on the Ubuntu machines that run the VPN each network is only as secure as the other, so if one network was “more secure” than the other suddenly it will become less secure! Make sure that you own both networks, or if you don’t that you have the permission of whoever owns the remote network to do this and that you trust the remote network not to connect to your home Samba share and steal or delete all your music (but of course, you set up Samba so that can’t happen, right?).
Also note that if the two networks are not numbered differently – i.e. they’re both 192.168.0.0 netmask 255.255.255.0 – then you’re going to run into a whole mess of trouble. If this is the case, consider looking at a “Bridged VPN” that will make it seem like one big network (though if you do you’re going to run into a real whole mess of trouble as IP addresses must be unique across both networks!). Bridged VPNs are a whole other topic, and not covered here.
There are plenty of sites that will tell you how to set up the actual VPN, for example here and here to name just two. But they don’t really talk about anything other than the actual VPN itself and the basic routing between the two machines.
First things first, you need some way to look up the external IP of each network. This means registering with some kind of DNS service. If you’re lucky enough to have your own server out on the internet you can use a script to find out what your external IP is and use nsupdate to register this with your DNS server on the internet.
If not, there are plenty of “Dynamic DNS” services out there that can do this.
Ok, so you have your networks successfully registering with a DNS server somewhere out on the internet. Now you can create the actual VPN.
I like Sébastian Wains’ solution best as it doesn’t require configuration of the routers to open NAT ports etc. (but you might need to set some routes, more later).
So, the setup so far:
The private IP addresses of the machines don’t matter too much for the VPN configuration but it’s handy to know what they are for testing and diagnostic purposes and you will probably need them for routing purposes later.
First, you need to install openvpn by running the following on both computers:
apt-get install openvpn
Then you need a pre-shared key for securing the VPN. On ubuntubox.home.local run:
openvpn --genkey --secret /etc/openvpn/static.key
You need to copy this file from one machine to the other some way. They must be identical on both machines. Best not to use email! Cut and paste over an SSH link or copy using a USB key or something similar.
Once this is done you can create the actual VPN:
On computer ubuntubox.home.local in /etc/openvpn/office.mycompany.com.conf:
remote office.mycompany.com float port 8000 dev tun ifconfig 10.0.0.2 10.0.0.1 persist-tun persist-local-ip persist-remote-ip comp-lzo ping 15 secret /etc/openvpn/static.key route 192.168.1.0 255.255.255.0 chroot /var/empty user nobody group nogroup # Nobody on RedHat, but we're on Ubuntu, right? log vpn.log verb 1
On computer myubuntu.office.local in /etc/openvpn/myhomenetwork.dyndns.org.conf:
remote myhomenetwork.dyndns.org float port 8000 dev tun ifconfig 10.0.0.1 10.0.0.2 persist-tun persist-local-ip persist-remote-ip comp-lzo ping 15 secret /etc/openvpn/static.key route 192.168.0.0 255.255.255.0 chroot /var/empty user nobody group nogroup # Nobody on RedHat, but we're on Ubuntu, right? log vpn.log verb 1
You’ll need to create ‘/var/empty’ if it doesn’t already exist. Then restart the VPN on each machine:
/etc/init.d/openvpn restart
At this point you should be able to ping each machine from the other, for example:
ubuntubox# ping -c1 192.168.1.57 PING 192.168.1.57 (192.168.1.57) 56(84) bytes of data. 64 bytes from 192.168.1.57: icmp_seq=1 ttl=64 time=100 ms --- 192.168.1.57 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 100.456/100.456/100.456/0.000 ms
As you can see, all works great. If it doesn’t work, you should at least be able to ping both 10.0.0.1 and 10.0.0.2 from both machines. These are the addresses at the ends of the VPN tunnel. If that doesn’t work, then the tunnel doesn’t even exist. Check /etc/openvpn/vpn.log to find out why, often it’s because it can’t reach the remote host (lookup of office.mycompany.com for example).
If you can ping 10.0.0.1 and 10.0.0.2 but can’t ping the IP of the remote machine then it’s the routes that are broken. These are set up automatically thanks to the “route 192.168.0.0 255.255.255.0″ and “route 192.168.1.0 255.255.255.0″ lines in each of the configuration files. Check these first and restart the VPN if you need to make changes.
The routes should look something like:
ubuntubox# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 10.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 tun0 192.168.1.0 10.0.0.1 255.255.255.0 UG 0 0 0 tun0 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.0.254 0.0.0.0 UG 0 0 0 eth0
This shows that anything destined for ip address 10.0.0.1 (the remote end of the VPN tunnel) will go down the tun0 interface, anything destined for network 192.168.1.0 (the office.local subnet) will be directed to 10.0.0.1 (therefore down the tunnel), anything for 192.168.0.0 (the home.local subnet, the one we’re actually connected to) will go out the local ethernet port, and that anything else (0.0.0.0) will go to whatever is connected to 192.168.0.254 – this ideally is the address of your ADSL router or similar device.
If you can ping both 10.0.0.x addresses but can’t ping the other machine’s IP address then check your /etc/openvpn config files that the “route” lines are correct, and check that there aren’t conflicting routes configured somewhere else on your machines.
So now that’s all working. But what about all the other machines on the network? You want everything on each side to reach everything else no?
Well, yes. So first off, you need to turn on IP forwarding on both machines. By default this is turned off, specifically to prevent information from one network “polluting” another.
To do this, on each machine type:
sysctl -w net.ipv4.ip_forward=1
To make this permanent across reboots you also need to edit /etc/sysctl.conf on both machines and make sure that there’s a line that looks like:
net.ipv4.ip_forward=1
Often this is simply commented out, though sometimes it says ‘=0′ rather than ‘=1′.
The last bit is tricky as a lot depends on your default routers. Remember that in ‘netstat -rn’ there’s a last route that looks like ’0.0.0.0′ (this is sometimes labelled ‘default’)? This is the IP address of the device that receives anything not destined for any of the other routes. Chances are that everything on your network sends anything not destined for the local private network to this IP address.
You have two choices at this point:
Option 1 is the simplest, assuming the router has the ability to let you do it. Option 2 may be easier but is not ideal, as everything will rely on your Ubuntu box for their internet connection and your Ubuntu box will be working a bit harder!
Remember, you need to do this on both networks, and you need to set routes for 192.168.x.0/255.255.255.0, 10.0.0.1 and 10.0.0.2. Why?
Assume all the routes are properly configured:
Let’s say machine 192.168.0.16 wants to ping 192.168.1.12. The default route on network 192.168.0.0 is for whatever is connected to 192.168.0.254 (and 192.168.1.0 it’s 192.168.1.254).
Assuming everything is set up correctly 192.168.0.16 will send a packet destined for 192.168.1.12 to 192.16.0.254 – the default route. This device knows that it must forward anything for 192.168.1.x to your Ubuntu box as you gave it a static route. So, it then forwards the packet for 192.168.1.12 on to 192.168.0.23 – your Ubuntu box ubuntubox.home.local.
Thanks to the VPN your Ubuntu box knows to send this packet down the tunnel to 10.0.0.1. The office Ubuntu box then forwards this on directly to 192.168.1.12, however at this point the originating IP address of the packet is no longer 192.168.0.16, it’s 10.0.0.2 – the IP address of the end of the tunnel on ubuntubox.home.local! So when 192.168.1.12 receives the packet and wants to send a reply, it’s going to send it to 10.0.0.2. This is why you need the extra static routes. Use ‘tcpdump’ to watch ping requests across the VPN and you’ll see what I mean.
In my case I chose option 1. So, I logged on to the routers 192.168.0.254 and set up a static route for 192.168.1.0 netmask 255.255.255.0 to point to 192.168.0.23 and for 10.0.0.1 netmask 255.255.255.255 to 192.168.0.23.
Then I logged on to the router at 192.168.1.254 and set up a static route for 192.168.0.0 netmask 255.255.255.0 to point to myubuntu.office.local and for 10.0.0.2 netmask 255.255.255.255 to myubuntu.office.local. I see you noticed the hostnames. Why the hostname and not the IP? Remember, myubuntu.office.local is configured using DHCP and so the IP address may change. If your router forces you to use the IP address make sure it’s a static IP address and not assigned via DHCP, as if the address changes for some reason your shiny VPN will break!
If what you’re configuring doesn’t like the host specific 10.0.0.x routes you can specify a route of 10.0.0.0 netmask 255.255.255.0 (yes I know this is bad behaviour, but it works) – this will obviously cause problems if you have anything that uses the 10.0.0.0 subnet! You can change these addresses and network numbers to suit your requirements though, just remember to change them in both config files and both default routers!
That’s it. You can now access any IP on either network from any IP on the other network.
Of course, you now have the issue of DNS. Set up a forwarding zone on the DNS server on each network using the IP address of the DNS server on the remote network in each case so that requests for the remote network are forwarded to the DNS server for the remote network. But that’s a whole other topic!
Also see: http://www.debian-administration.org/articles/35
YOUTUBE: http://www.youtube.com/watch?v=C_B9k0l6kEs
I just tried out this guide today, and I was successful in connecting my two home networks together. Thanks for the well written advice!
Two minor mistakes that I found were:
– Left out .conf at the end of the line: “On computer myubuntu.office.local in /etc/openvpn/myhomenetwork.dyndns.org:” ie. it should read: “On computer myubuntu.office.local in /etc/openvpn/myhomenetwork.dyndns.org.conf:”
– A config thing really, in the latest version of Ubuntu 11.04 there is no /var/empty directory. So you need to run the command “sudo mkdir /var/empty” on each server.
Thanks again for the detailed guide. Now I can connect to my samba share and printers from either of my home networks!
~David
Pingback: David and Claire’s Blog»Blog Archive » Link two private networks using a VPN on Ubuntu Linux machines each behind NAT