A series of Posts that involve the entire process of setting up a file server using Ubuntu Server 12.04. Covering installing the OS, LAMP stack, Samba for file sharing with Windows machines, OwnCloud for personal cloud storage.
Also covered is waking the server using wake-on-LAN and using a CRON job script to automatically shut down the server when idle. Thrown in are some educational pieces and tips on utilities. Plus how to backup MS machines to the server by waking it up and performing the backup and then allowing the machine(s) to shutdown.
Sometimes it is nice to have an ftp server, you might have Samba and ownCloud, but sometimes you really need ftp to do something. It is the right tool at the right time and I can’t imagine running a server without FTP installed.
sudo apt-get install vsftpd
Edit the configuration file
Back it up first then do an edit
sudo cp /etc/vsftpd.conf /etc/vsftpd.orig
sudo nano /etc/vsftpd.conf
uncomment local_enable = YES
uncomment write_enable = YES
In this manner you will be able to read and write to your home directory. With SSH and FTP you can do just about anything remotely to your server. You can ( put ) FTP a file up to your home and move it anywhere and in the opposite direction also ( get ).
For example I downloaded the zip file for the OwnCloud Music App on a Windows computer, then FTP’d it the Linux server into my home directory and moved and unzipped it in the proper directory using SSH. Zip/unzip is not loaded by default with the Ubuntu Server disc, to get it see below.
This is powerful and with that power comes danger. You don’t want anyone to be able to SSH and FTP in, so be careful when opening these ports. I get “hits” on port 22 for SSH a lot, I don’t even open port 21 for FTP outside of my LAN. When I mean hits, I mean I can see IP addresses come in on my routers log that are from outside the US, by looking them up, or browsing to them. Sometimes using a ping command to the IP a return will come from another IP. These cyber-criminals try to get in on open ports.
Editing shell or config files on a Windows machine, presents you with the CR-LF and LF issue, for Win and UNIX respectively. Scripts won’t run, problems happen with config files when they are not in the right format. Frequently I encounter this when I coy and paste some code from the Web into eMacs or Notepad, then save it on the Linux server. Then I need to execute dos2unix on it to make it run right.
UNIX and DOS endlines
I had a brain dead moment where I forgot about the entire UNIX and DOS endline thing when I was working on getting the server to auto shutdown.
So when I grabbed the autosuspend script with copy and paste and I brought it into eMacs in Windows, saved it to my /files/public folder on the server and tried to execute it. Lots of $’\r’: command not found.
The solution is to use dos2unix to convert the endlines, if you don’t have it, just do…
sudo apt-get install dos2unix
Then do dos2unix filename and it will modify it in place. Which is good but beware of this default behavior. It does have other options, which can be explored using dos2unix –help.
It’s one and only job is to remove CR-LF (Carriage Return-Line Feed )and just leaving LF ( Line Feed ) as UNIX/Linux wants it to be. If a file acts screwy when brought in from Windows it is most likely this issue. I even had to do it on the autosuspend.conf file!
You can always check a file with the command
cat -e filename
BAD example…
#!/bin/bash^M$
^M$
# Source the configuration file^M$
. /etc/autosuspend.conf^M$
^M$
GOOD example….
#!/bin/bash$
# Source the configuration file$
. /etc/autosuspend.conf$
$
The caret M$ is DOS, $ is UNIX.
Emails using ssmtp
It is great that CRON and other applications send an email to the root on a Linux server, which can be read simply by using mailx from the CLI. But, what if you are not logging into the machine very often at all. Using ssmtp might work well for those situations. Even my Netgear N150 router has something similar as far as sending email. On the router, you input email account settings on it and will email you the log file and other information you would like at regular intervals. Ssmtp may be of interest to me with regards to the server at some point and I have noted it for reference.
It would be interesting and a great idea to have the server be able to send emails of certain things, issues it may be encountering.
This looks interesting, I might do this at some point….
The first line adds to the sources list for apt and will affect the operation of the apt-get update command, more stuff related to OwnCloud gets applied. When I first did this I accidentally hit the up arrow and return and pasted it in twice. The update command complained about this as a warning, the fix is to remove the extra copy from the bottom of the /etc/apt/sources.list.d
Although the OwnCloud install pages shows this second in line. I think I had to do it first, before the above command or errors will happen regarding a missing key.
When loading the OwnCloud repository, it failed on the first try. I forget the error, but update was failing. Something was off base with my Ubuntu install, I could not update & upgrade correctly. I had to search the Internet for a fix. Which involved running
sudo rm -FR /var/lib/apt/lists/*
which cleared out the lists that apt was running on then…
sudo apt-get update
…worked fine!
If you have LAMP installed (which you should), configure OwnCloud to use mySQL when the question comes up when you login for the first time at http://youraddr/owncloud.
Leave database as owncloud and localhost.
OwnCloud Apps
Some apps can be downloaded via the normal click and download/install as an administrator. But some are not available like that. For example Music.
Installing OwnCloud apps by downloading zips.
I went to install Music, which would not install via the web interface.
I had to download the zip file and put it in the folder by ftping to the server. It is worth having vsFTP installed on the server, or at least on your machine that you are accessing the server through. With SSH and vsFTP it is easy to get a lot of work done.
Put the zip file at…
/var/www/ownloud/apps
zip/unzip do not come with Ubuntu server by default, use
sudo apt-get install zip
to get it. Then simply unzip the zip file in the apps folder, it will make it’s own folder. Then the app is installed and will appear in the menu.
Backup /etc/samba/smb.conf before toying with it! Copy it somethings like /etc/samba/smb.bak or /etc/samba/smb.orig for the original and bak for files that you are modding along the way to getting this working. I admit Samba was a bit of a pain to get working, I fussed around a bit on the server and the Windows machines until success occurred.
One mistake I made was to name the folders by the paths as they appear on the server. Bad idea, Microsoft Windows did not like forward slashes and denied access to the folders. Using slashes and perhaps other non-alphanumeric characters are a no-no in the server folder names.
Make Folders on the Server
I created folders named /files/public and /files/erick on the server. More can be added for additional users. What I am doing with the folders is backing up user profiles from Windows machines in the /files/user folders. The public folder is going to hold things like install files for the Windows machines, anti-malware & etc tools, C compiler and DOS DOS-UNIX equivalent tools and so on.
I executed the following commands on the server…
sudo mkdir /files
cd /files
sudo mkdir public
sudo chmod 777 public
mkdir erick
I believe I did a chmod to 777 on files as well. I made the erick directory with my own credentials, I am owner. Directory is created as a 775 by default…
rwxrwxr-x 2 erick erick 4096 Dec 10 21:12 erick
Later on I created a renee folder. Same drill, I did an su and logged in as the user renee after I created the account and ran a mkdir renee under files.
You need to create a Samba password for yourself and any users. Make it the same as the password that you log into the Win machines, especially important if you want to access home folders.
The command for adding a Samba user and password is…
smbpasswd -a user
Linux Users
While on the users topic adding a Linux user with a home directory is accomplished with the following command…
sudo useradd -d /home/username -m username
Adding the password, don’t skip this, if you forget to do this it will cause problems down the road and it might take a while to figure the problems out.
sudo passwd username
There is a command that can take the contents of the skel directory /etc/skel, into a users home directory. This sets up the files and folders. Normally this will happen when you use the -d /home/username option on useradd. But if you create a user without a home directory and add one later the following command may be helpful…
mkhomedir_helper username
I followed the method above to add a user renee and then created a /files/renee directory on the server.
Editing the smb.conf file
For the following, I opened my /etc/samba/smb.orig and etc/samba/smb.conf files in the eMacs editor and differenced them. The gray lines and sections show the changes, I have highlighted them with red rounded rectangles for clarity. The biggest change is at the bottom of the file where I added code to allow access to the /files/public, /files/erick and /files/renee directories.
Global Settings Changes in smb.conf
Authentication Section changes in smb.conf
Share Definitions sections changes in smb.conf.
This is optional and will allow the home directories of the users to be made accessible with read/write access on the network. In this section the changes are post the most part the uncommenting of the grayed out lines that you see below. I think the only change beyond that was setting read only = no.
Section added to tail of smb.conf for user defined directories
Follow this example to add your own directories to be accessible from the Windows network.
Don’t use any slashes in the names in the [brackets]. I imagine a lot of non-alphanumeric characters will make this fail. Slashes were my problem. I was trying to be clever and using things like [/files/erick]. Also I went to using an underscore instead of a space in the names. This makes it work better from the Windows CLI and scripts, space does not always translate well. I have had issues with scripts where it takes the first part of the folder name and thinks the 2nd part is a switch to the command or something, resulting in failure. Basically the DOS like Windows CLI (Command Line Interface) environment does not like spaces!
I have not tried setting browsable to no. I imagine it can be only access by knowing the names of the files and probably by navigating using the CLI from Windows. This would be acceptable for the two named directories as they are only backup directories and I don’t imagine I would have to browse to the often.
Restart
Samba needs to be restarted any time you change the smb.conf file. Use the command….
sudo service smbd restart
…to restart.
Windows Machine
The Windows machine needs to be set to the same workgroup. It is best to have the same user names and passwords to both the Win users and the Samba users, in this manner all will work including home file sharing. When you make changes, sometimes you have to log out and in to the Windows user for them to take effect or else you get errors like the folder is not accessible, and other like it about permissions. Windows will prompt for a username and password to access folders as well, especially if the users and passwords do not match between Windows and the Samba server.
smbclient command
Running smbclient -L servername from the server is a good sanity check that the shares are showing up and that the server actually sees the Windows network. If this looks good generally you are in business with Samba at least from the server side.
erick@ubuntuserver:/etc/samba$ smbclient -L ubuntuserver
Enter erick's password:
Domain=[MSHOME] OS=[Unix] Server=[Samba 3.6.3]
Sharename Type Comment
--------- ---- -------
homes Disk Home Directories
print$ Disk Printer Drivers
Erick_Backup Disk Erick's Files at /files/erick
Renee_Backup Disk Renee's Files at /files/renee
Public Disk Public Files at /files/public
IPC$ IPC IPC Service (ubuntuserver server (Samba, Ubuntu))
erick Disk Home Directories
Domain=[MSHOME] OS=[Unix] Server=[Samba 3.6.3]
Server Comment
--------- -------
RENEECOMPUTER Renee's Computer
UBUNTUSERVER ubuntuserver server (Samba, Ubuntu)
Workgroup Master
--------- -------
MSHOME RENEECOMPUTER
smbstatus command
Executing smbstatus from the server command line can tell you what computers are connected and if any files are locked. Try executing it while file operations are in progress to see how it behaves. After seeing it in operation, what is going on becomes obvious for the most part. Without any computers connected to Samba folders, nothing interesting is reported. This means that this tool be helpful troubleshooting Samba if you can’t even connect to the folders. But may be of use to troubleshoot issues when all is working OK and then an issue arises. I also have a script that runs and allows the server to shut down when idle, it executes smbstatus as a test to see if any computers are using Samba so the server won’t shutdown while Samba is in use.
It has command line options which I haven’t explored much myself yet.
At this point, I get off of the server, I mean disconnect the monitor and keyboard. But first remember to configure the BIOS to ignore keyboard errors, important for unattended operation! I wait until at least the updates are done and I have tested out the static IP to “unhook”. If you are setting up firewalls it is best to do it sitting at the machine as well. Because a mistake setting up the firewall can lock you out of connecting with SSH remotely! The firewall, set via the iptables, can block or allow access to incoming or outgoing ports, by passing or dropping packets. The firewall can be configured via tools such as ufw (uncomplicated firewall) to allow certain services to go through. IP addresses and ranges can be blocked or allowed as well. This can get complicated in a hurry. More on this later.
Logging onto the machine remotely from Linux, is done at the command prompt using either of these…
ssh machines-name
ssh machines-ip-address
From Windows, fire up Putty and put in the machines-name or machines-ip-address in the appropriate spot. You will be presented with a CLI ( Command Line Interface ) prompting for password on connection.
If the machines-name one doesn’t work, then the name is not mapping to the IP address locally, it is a DNS thing in this case. You can just go ahead and use the machines IP. Which you should have configured static previously.
With both Win and Linux you will get a warming the first time you SSH into the server. The warning has to do with not trusting the RSA key, which makes sense, giving that it is the first time the connection is being made. The machines don’t know each other, so just enter yes and they will be key-paired so that in the future you won’t be presented with this question.
With SSH you can continue with the configuration of the machine remotely. The next item on the list is Samba. If you are configuring remotely at a Windows machine it is easy to see if you are configuring Samba correctly. It can be tricky to get working. Searching on line, I found a lot of posts on folks struggling to get Samba to work.
Getting it to the outside world
So far all of this operation has occurred on the LAN. What if you want to make a website or any other port connected to the outside world.
For me, I went into my router via its web config page and opened up port 80 to the outside word, by forwarding the port, connecting the forwarded port to the local IP address of the server. Along with the Port 22 for SSH as well. If you run Webmin you can forward port 10000 for Webmin. Now I could navigate to my external IP and see the web page of the web server from anywhere. Initially I made port 8080 available so that I could login to the router as well, but then I decided against it. I figure why open more ports than you need. Keep it simple. How many times will I need to actually get to the router, it’s mostly set it and forget it. The inexpensive Netgear N150 router has worked reliably and has near perfect up-time so far.
Noip for a Static Address
Install noip2. Not sure, my notes aren’t clear but, I think I had to compile and install it after it didn’t work via sudo apt-get install noip2. This is dynamic DNS support support for the URL. The noip2 program runs at startup and periodically reports the IP address of my ISP to the noip headquarters, I suppose, so the URL I picked out goes to my server. Otherwise I would have to go to the actually IP address and then find out what it is when it changes. This seems like a pain if you have to do it remotely, even while experimenting initially. Luckily my ISP does not change my address very often so this step for me is optional. I did run noip with my last server. I may run it for this one at some point. But the IP address stays the same for months so it is not a pain, even if I wanted to point to it with a name. I could even so something clever like send myself an email when it changes.
Router support for noip or dyn-DNS
A new firmware upgrade for my router has added support for noip, so now it would be possible to do this from the router itself. I haven’t investigated yet, but check yours it may be possible to use noip or dyn-DNS right from the router end and not have to mess with the server at all.
Beware of opening ports
Having things like SSH and FTP, ports 22 and 21 respectively open to the outside world can invite trouble. My router logs routinely show attempts to access the SSH port by various IP’s, if I leave them open, which trace to foreign countries, China mostly. I don’t leave FTP open at all and am keeping SSH off as well until I can firewall this server. For now accessing SSH and FTP from the LAN is good enough. Ideally I want to modify iptables to only allow trusted IP addresses into SSH, the rest, drop the packets as they arrive.
These attempts I see in the router log probably try to hit the username and password with a bunch of guesses or try to look for obvious ones. These cyber-criminals are trying to jack into your machine and do whatever damage they can to the web. So be cautious.
Next do some file sharing with Windows machines using Samba…
One of the first steps when configuring a server post-install is to set up a static IP address. A resource that I followed to remember how to do it is this is The following instructions will vary widely based on your router, this is just a guideline.
The following is the mods to the network config file using the nano editor, you can use pico or vi, or if you really want to you could move the file off the computer using ftp and put it back if you prefer. But I figure it is best to edit most things in place.
But make a backup first on a critical file like this one
I found the broadcast and netmask from using the ifconfig command. The router address (gateway), I knew from installing the router, look it up in your router admin page. The network is the same address as the gateway with the last digit set to zero, in my case at least. The address is what I want the static IP to be for this server, 10 works OK, 192.168.1.1 is the router add a zero and you’ve got the server.
For me I commented out the line for dhcp added the
iface eth0 inet static
…and added the right values for address ( my static IP), netmask, network, broadcast and gateway…
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# nameservers
dns-nameservers 8.8.8.8 8.8.4.4
Set DNS
There is a little trick I found somewhere online for putting name servers right into the interfaces file. Use Google’s DNS 8.8.8.8, 8.8.4.4 or use the ones provided by your ISP. You can usually find your ISP’s name-servers by looking at your router settings.
dns-nameservers 8.8.8.8, 8.8.4.4
After the static IP is set restart the network…
sudo service networking restart
or if the machine is rebooted r the changes will take effect.
Verify All is Well
Ping Google…
ping www.google.com
use ctrl-c to stop the pinging. It should give this kind of output if all is well…
erick@ubuntuserver:/etc/samba$ ping www.google.com
PING www.google.com (173.194.123.51) 56(84) bytes of data.
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=1 ttl=53 time=37.9 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=2 ttl=53 time=37.6 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=3 ttl=53 time=34.6 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=4 ttl=53 time=37.9 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=5 ttl=53 time=37.5 ms
^C
--- www.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 34.649/37.151/37.961/1.272 ms
or run the update and upgrade commands used in the earlier installation post, again to see if all is well they should complete without error.
sudo apt-get update
sudo apt-get upgrade
Since you executed them earlier ( see previous post) not much will happen but it is a good validation that the static IP is working correctly.
Installing NTP
Install NTP, so that the computers time can be synced with the network
This is meant to be an outline not a complete guideline. It is based off on notes I took and may be helpful to keep me or someone else straight on the process in the future. There are some sections that are a bit light, but there is more out there on the web and half the problem for me at least is remembering this kind of outline. If I have the outline, I can jump off and find more. This particular post on the install is rather long, but it didn’t seem like a good idea to break it up.
Install, using Ubuntu Server 12.04
Boot via the DVD that was created by burning the downloaded ISO to it.
Select Install Ubuntu Server, unless of course you want to test out RAM, a good idea if it has been freshly installed. Which was true in my case. So I ran MEMTEST overnight via this menu first.
Next you will be presented with screens to select language, location and keyboard type.
If you know what kind of keyboard you have select no to the next screen. If not selecting yes will put the keyboard through a test, having you press various keys to identify it.
Next the Ubuntu Server install will start loading additional components, this can take a few minutes…
Networking Setup
Ubuntu Server will automatically configure DHCP. Later on, after the install, this will be switched to a static IP address.
Create a hostname for the computer. Choose something that makes sense for you. A really long hostname ( I think > 14 chars) can present issues with Windows when using Samba. It will truncate the name, just something to be aware of.
User and Password
You can set up a user next by filling out a username and password. After the installation you can add more users if you need to.
The first screen will ask for your name, this could be your real name.
Next you will enter your username. Something simple like your first name in all caps is a good choice.
Choose a decent password. Something not listed in a dictionary is a good choice, with some numbers and a capitalized letter, punctuation as well. One approach taken is to take two unrelated words that are easy to remember and concatenating them. Whatever you do, don’t lose it, I am not sure you can recover it unless you can reset it as root, provided you have that password. In Ubuntu, you have to log in as a user to even execute sudo. So if you have one user and lose the password, it’s probably game over.
To encrypt or not to encrypt your home directory on your Ubuntu Server install. I chose no, it’s a server, I am not going to do much with the home directory. Encryption is nice, but it comes with a small speed cost of decoding, this could be a burden on a slow processor.
Time Zone
Where are you in the world? I think the install is taking an educated guess as to where you are, so what it chooses may be correct, just double check. If not, set up your time zone via this drop down menu. After the install it is possible to install ntp which can keep the server clock sync’ed up with an atomic clock time.
Partitioning
Whole disk, LVM. Lots of options. I choose to wipe the disk clean and use LVM. I will be adding disks to this machine and with LVM, they can appear as one big disk, not mounting required. LVM is a thin layer of software that manages the Logical Volumes. Therefor it does consume a small amount of resources and must lower disk transfers slightly. One thing that I did noticed once with an LVM disk, is that I could not read it using a IDE to USB adapter. It was invisible to it. I have to try plugging that disk into a Linux machine at some point to see if I can read it’s contents. So it seems that LVM could complicate a recovery of a disk. Supposedly an advantage of LVM is that you can mirror copy the volumes and expand them across disk. I need to research this some more as it is new to me.
If you have more than one disk, you have to choose which one the OS will install to.
At this point in the install, I ran into an issue with the fact that the disk I was trying to use was originally used in another Linux machine with 3 disks used in LVM. Nothing I did seemed to work as it gave me a warning about the disk being a part of a 3 disk LVM set. I stopped the install and used a CD that came with a drive I bought years ago and wiped out the drive. Then I did the reinstall and successfully made it to the following confirmation screen. If all looks well you can hit Yes, if not hitting No will allow you to work backwards. Hitting Yes is final as disk writes will occur.
System Install, Configuring Updates and Installing Software
Once the partition in complete the OS will install, which will take several minutes.
There is an option to have automatic updates, this is a good idea, especially for a headless server. So it can take care of itself with a minimum of fuss.
Choose software to install. Open SSH is a must if you are to remotely shell into the server. Because I will be running OwnCloud on this unit and it uses a web interface and a database and PHP, installing LAMP Server is a must. I will also make a few folders that can be reached directly from Windows computers on the network, mostly for direct backups, so Samba file server is a must.
Final Steps for Ubuntu Server 12.04 install
The Ubuntu server install will prompt for installation of software. Install the following when prompted by the screen.
Open SSH
LAMP
Samba Server
MySql Password
Because the LAMP Server (Linux-Apache-MySql-PHP) installs MySql a password is needed for the “root” user of the database. During the process of configuring LAMP, a prompt will appear for a MySQL root password, make it something memorable in case you ever have to manage or do work with the database manually, or if a program asks for it, such as when doing a WordPress install.
GRUB
As the description for GRUB states this is the only install going in, so it safe to hit Yes and go ahead. Results may vary for you specific case. If you have a multi boot machine, GRUB will setup Ubuntu Server to load first, if you are configuring a multi boot machine.
The done screen, pull out the disk hit continue and the PC now will reboot, I went into the BIOS and did a few more things to it.
Additional Steps in the BIOS
All BIOS are a bit different. Yours may not look the same, but should have similar settings. This is a Dell Dimension 2400. Configure the BIOS to ignore keyboard errors “Do Not Report”, important for unattended operation with a keyboard and monitor!
I also set “Remote Wake Up” to On as I will use Wake On LAN to wake this machine up remotely. I cover it here … Wake On LAN via Ubuntu Linux
I will set Suspend Mode to S3. This has worked well for me with Dell machines in the past. I am considering writing a CRON script that will suspend to RAM when the server is idle for a period of time, so setting this to what I want it to be now is a good idea.
If the power goes out and comes back on I want the server to go back to what ever state it was in, if off stay off, if it was on, restart. I have used this in the past and it does work well.
Final Steps for Install when the machine reboots
When you exit the BIOS, you be prompted for your username and password.
For good measure run the update and upgrade commands, if all is well they should complete without error.
sudo apt-get update
sudo apt-get upgrade
One of the first steps when configuring a server post-install is to set up a static IP address.
Navigate to the page and look to see if GD works. Might be good to remove test.php after using it as it might be a security hole, not sure about this myself, but just a thought.
Wake on LAN (WOL), works great, sometimes it is a bit tricky to configure. With Linux, the client that sends the magic packet requires etherwake and the unit to be waked requires ethtool to be installed. Ethtool configures the OS to actually boot on the Network Interface Card NIC’s command. The NIC has to support Wake on LAN and the BIOS has to be set up to use it.
Installing etherwake…
sudo aptitude install etherwake
Installing this package actually installs both etherwake and wakeonlan. To wake the computer….
wakeonlan MAC-Address-Here
or
etherwake MAC-Address-Here
MAC Address
MAC Address, aka Physical Address of a Linux machines NIC can be found by executing ifconfig. In Windows, you can use ipconfig /all.
Ethtool
Install…
sudo apt-get install ethtool
Use for eth0, enabling WOL…
sudo ethtool -s eth0 wol g
To check if the system is armed for WOL, run…
sudo ethtool eth0
Towards the bottom you should see
Supports wake on: g
Wake on : g
On my PC, I noticed that once it is waked. It is necessary to run…
sudo ethtool -s eth0 wol g
To re-arm the WOL, every time it is remote waked.
I will write a bash script to shutdown the server. It will execute…
sudo ethtool -s eth0 wol g
sudo shutdown -P now
Ensuring that when I power the server down remotely, it will be armed for WOL.
Better than that I found out by looking online while researching how to auto-suspend the server, this little piece…
Create “/etc/udev/rules.d/50-wol.rules” with the following contents:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/usr/bin/ethtool -s %k wol g"
Check the syslog after creating it, errors will appear there if you spelled something wrong or whatnot.
tail /var/log/syslog
but as of now, no errors, but not setting wol g either. Still trouble shooting.
The article talks about auto-suspending. But I found another article on auto-suspending that requires only a simple bash script that I have placed in /etc/cron.hourly but the article
that does have a conf file and it seems to work, at least it runs. I have yet to see if it actually will auto-suspend! I am working on it right now and will post an entire write up when the bugs are worked out.
Remote vs Local
The first try most likely be on your own LAN. To do it for real remotely requires setting up your router to forward ports. I had to set it to forward port 7 and 9 to the outside world. Then it is a matter of sending a magic packet to the ISP address that your router reports of a FQDN ( Fully Qualified Domain Name), remotely I had to have the bit mask set to 255.255.255.255 when using a utility on a website. Locally I noticed 0.0.0.0 ( broadcast ) worked.
I read a bit about WOL here before attempting to set it up.
I had an old NEC P3-500 computer from 2000 set up as a server. It ran Lubuntu 13.10. SSH, vsFTP, LAMP stack, Webmin, Samba, code for remote desktopping and a WordPress install.
I used it to test out things, I learned a lot about WordPress in a short span of time on it. Plus I had it running two web cams and placing time lapse frames on line. I was using the cams to monitor indoor temperatures when I was away from home in the winter. It was a good test bed, but quit in late March. No video, no booting, I decided not to troubleshoot, it was old and worked long enough. It still had the original 8gb HD, which started with Win98 then XP, the Ubuntu 9.10, then Lubuntu, good life span for a drive.
A few months ago I came across a Dell Dimension 2400 at no cost. Higher performance than the NEC. So I will go with that as the replacement. The idea is to load Ubuntu Server on it, no need for a desktop, I realized. I am comfortable enough with the Linux command line, been using it since 1997, to go without a “desktop”. In the meantime since the last server, I discovered ownCloud
OwnCloud
OwnCloud will let me set up a personal cloud, limited only by hard-drive space. I have not used it much yet, but it would be good for storage of photos and music, plus contacts, bookmark and calendar sync. It seems promising. I am reading the user manual and administrator manual. Two of the features that I am interested in are, making a photo gallery in it and being able to store music files and streaming them. Then I could have my personal “internet radio” station and listen to the music that I want to on any device, in theory, anywhere.
Samba
I finally got Samba working, which allows the Linux computer to interface correctly with Windows as far as file sharing. Now I can create a network folder on the Linux server to access with a Windows computer, which will be good for backups. It can be treated like another hard drive and files can be transferred easily. It was a lot of work, one small mistake that I made in providing a name was the problem. Windows did not like the use of special characters, slashes like / or \ in the name of the folder! It kept telling me, I don’t have permission for the folder and that the path did not exist. I thought I was being smart naming the network folder the same as it appears on the server computer, /files/erick, that was a big mistake! I went crazy checking the firewall, checking the DNS names & addresses. Reading things online. Then I added a new folder with a simple name, just files, and it worked, so I changed all of the folder names to something simple and it worked fine! I will use the Samba shares mounted as drives, for backup of the Windows computers, in one location.
I did learn a useful command in the process of troubleshooting, running…
smbclient -l //serveripaddress -u username
from the server CL lets you see all of the computers on the workgroup to make sure they show up and names are being resolved. If they look OK then you know you have that part working alright. As far as the firewall, it is off by default when Ubuntu Server installs. This can be confirmed by a dump of the iptables.
And of course, I installed the server with the SSH option turned on. So I can do all of this without having to be in front of the machine.
IP is set to static too. I learned that you can now set the DNS servers in the same config file as setting up static IP.