Docker on Debian Linux – Getting a Canned Container for WordPress

The Setting for this article:


If there is no outside nonsense going on, this is the way that the whole open-source and Docker universe is supposed to work.  You grab a container that has your operating system in it from a repository and run it as needed.

That means you grab it from the cloud.  When you have it you can do with it what you want and then either save it or throw it away.

All that is great, but it does go against my own Project Management training.  You did not make it so how do you know it does not have any problems with it like viruses or worse.

So Warning:  Only run a container that you create or one that you know to be safe. 

I am assuming that the container I am working with is safe because it is listed as official.  To be honest, I can’t say I know enough about Docker and this particular container to say that assumption is true.

The benefits of running a container from a repository:

In the case of this particular one, it saves me a lot of time.

I do not have to create the container, I can just use it.

I can save it on my computer, or not – it is up to me.

I can modify it as I like.

Not a long list, I’m sure you can add other items to it.  It took me about 10 minutes to grab the container and save it to my hard drive.  It takes about 2 hours to install Debian, then another couple hours to install LAMP, and more time install WordPress… and configuration time.  Someone at Docker did it for me.  This is why containers got popular.  In a large organization, you will have a standard container that gets cloned dozens of times for the designed purpose.

Since we’re going to simply use it, here are the steps to get a “canned” container onto your computer for WordPress.

 

1) Get your environment ready

Start your Docker compatible computer and make sure Docker is up and running.  A simple command like docker images will tell you the list of images you have available and what they are called.

2) Search the repository for the image you were given

What you need is a list of containers.  These are “out there on the cloud” and available at Docker for you to grab.  They may also be on your own cloud server if you’re at a business.  Typically someone will tell you “what to use” to get your job done.

We need a WordPress image.  You want to search.  docker search wordpress  will give you a list of all images that have wordpress in the name field.  Remember that “case counts” in Linux – all things are Case Sensitive as a Standard.

The one I feel safest choosing is the first one.  “wordpress”.  It has an official tag, 1601 stars, and I honestly am simply guessing.  Like I said in my preamble, if you want bulletproof security – create one from scratch.

3) Download the image with the “docker pull” command

This is pleasantly easy.  The image itself is called “wordpress” and all you need to get the latest image is to enter on the command line “docker pull wordpress“.  Docker will go out to its repository and make it available to itself.

At this point, you have in your hot little computer’s hands a copy of Debian Linux with WordPress.  If all you want to do is poke around and destroy at the end, you can stop reading, you’re done.

4) Verify that you have the image available to Docker

You can easily do this with another docker image command:

Having the wordpress image show on the REPOSITORY list proves things worked.

5) Prove that the image runs in Docker

You have it. Now how do you run the beast? 

First, check that images list.  There is a field called “IMAGE ID” in the list.  That is what Docker knows the images are called.  The Name is just a friendly name that you can change if you have a mind to.
Second execute the container using that IMAGE ID.  You will also want to be able to do something inside, so run /bin/bash as well.  That will allow you to control the container.

For my copy of wordpress the number to run is f6ae044a5122.  The command to run is “docker run -i -t f6ae044a5122 /bin/bash”  Your IMAGE ID will vary based on your list.

Notice that the prompt changes from root@elk to root@f6ae044a5122.  This tells you your computer changed and you are now “inside” the container.  You can enter normal bash commands here.

I am purposely getting out of the container with an “exit” command.  When you exit the container, it stops.

Finally, I need to know what docker called that container when it downloaded it.  Its name in the “NAMES” field is the key.  For me it is 8bb814e82c48.  I will need this to re-start the container in the next step.

6) Starting your Docker container, getting the container up to date.

The last step was to get out of the container.  That puts you back onto “your” computer.  You’re “local” now.  That is important because you will want to go back into docker to make sure you can.  It is an extra step, but it allows you to be careful.  Following that you will want to update the container.

You first need to start the container.  That is done with the docker start command.  My container is called 8bb814e82c48, and that is used here.  I do this by starting it with “docker start 8bb814e82c48“.

It’s running but you have to attach  the container.  In this case, I was able to have it drop me into a /bin/bash shell, automatically.  I do this with a “docker attach 8bb814e82c48” command.

Now that I am in the container, I want to update the container to current Debian – get all the software inside the container up to date.  This is done in the traditional way with the following three commands:

  1. apt update
  2. apt upgrade
  3. apt dist-upgrade

Finally it is necessary to get out of the container by entering an “exit command at the command prompt.

All except the exit are in the next graphic.

7) Commit your docker container to your local hard drive and give it a friendly name

That’s all great.  You have gotten the container up to date.  You need to be able to shut down the computer and make the container available for you when you come back from what ever you are doing out in the real world.  Right?

This is done with a few steps.

First you need to commit the container and give it a name.  Then you can verify your actions with an image.

Your container is the one you have been working with.  In my case it is 8bb814e82c48.  You need to commit this to the hard drive within Docker on the local machine.  I enter the command “docker commit 8bb814e82c48 wordpress“.  This gives the container the NAME of “wordpress”.  Terribly generic.  If you are running a couple containers at once, you will want to give it something more specific and meaningful.

Verify that Docker knows that it exists in its own table by entering a “docker ps -a” command.

Finally you can do a “docker images” command to show the list of containers you have access to.

8) Running your local copy of the Docker Container

Now that you have returned to your computer, or have stopped Docker, you are going to want to go through the motions of restarting it again.

First, the “docker images” command will give you the information you need.  It will tell you docker is up and running, and give you a list of containers you will need to do your thing.  The container is 8bb814e82c48 for me, your number will vary.  This corresponds to the container we committed to disk earlier.

Second, you can run some commands to start the container, attach to it, and verify that it is responding.  To start the container, you enter a command of “docker run -i -t 8bb814e82c48 /bin/bash“.  Attach to the container This will also put you inside the container and allow you to enter bash commands.

Finally, you can exit out of the container and go back to your local machine.

This is all listed in the following graphic.

9) How to actually access this specific container from the Docker Repository

Here is where I end for now.

What you have achieved is to grab a container from Docker and get the thing up to date.  You were able to save it locally, hopefully.  Finally you proved that it is verifiable and repeatable by running it again.

That gives you a server that you don’t know how to use.
I’m in the same boat at this point.  There is a long list of things you can do with the container, if you know how to get into it.  This specific container is a Docker produced container.  They have documented the steps for you to get access to it.

I will be returning to this and producing a cheat sheet in time as I get more used to the whole process.  I’m used to Debian and LAMP and doing it all “live” on a “real” computer (bare metal for the VMWare crowd), but this is still a learning process for me.

So once I get more helpful information, I’ll be back.  After all I have been at blogging since 2007.

The link from docker is here:

https://hub.docker.com/_/wordpress/

Good luck!

Docker on Debian Linux – Why and The Install of it All

If you want just the instructions, Skip to the break.  This is here basically so that I can do this again later.

The setting:

For almost all of what I do, I run Linux.  Specifically Debian Linux.

It runs much faster, has most of the same programs you’re used to on a Mac or a Windows PC, and is about as stable as an operating system can be. It can run some Windows programs in Emulation (WINE) but that’s not the point. I’ve got what I need if I stay within Linux, natively.

Some Debian Linux computers have “uptime”, time since they were last restarted, in years – not days or weeks.

I update things when I want.  I make things how I want them.  I change things how I want.  If there is one thing about Linux that Mac and Windows users don’t get to do is customize things the way that they want.

The backstory:

My blog resides in two places.  On www.ramblingmoose.com and on a WordPress hosted site at ramblingmoose.wordpress.com as a backup.

I really don’t care for how my WordPress site looks, so I want to change it.  Being someone with more years in IT Software Development Project Management than I care to admit to, I will do it “offline” and not on the live site.

Furthermore, I have a client in Los Angeles.  His website was developed on WordPress by me, and I have a backup.  I’m finished with the site, but I thought it might be “fun” to see if I could get it to work here on my own computer.

The reasoning:

My own main computer running Debian I am happy with.  Actually that is an understatement.  I don’t want to slow it down by loading up server software, a LAMP stack, and things to slow it all down.   I could create a VMWare or Virtual Box virtual computer and do the LAMP stack there, I’ve done that a couple times before, but running a full VM for something like this felt “overkill” and “heavyweight”.

What Docker Does:

Docker will allow me to share some of my computer by running a pared down version of Linux inside what they call a Container.  It is not a full virtual computer, so it should run faster, and since it is not a full computer it will not effect my apparent speed – in case I forget to “turn the damn thing off at night”.

The Goal:

Get a Docker Container up and running.  The container will have a web server and WordPress software running configured for my use.


 

Installing Docker:

This is adapted from the official Docker instructions found at this link.

This will get the base Docker software installed on a Debian system.  Your system should be “up to date”.  It should be running fairly current software.  As I am writing this March 2017, Docker will run on Debian 7, 8, and 9.  9 being “Stretch” or “Testing” at this point, 8 being “Jessie”, and 7 is “Wheezy”.

My own personal thought is that if you aren’t running at least “Jessie”, get yourself upgraded to current software.  After all, within a month or three of this writing, Stretch will become “Stable” and the official up to date current software.  It’s easy.  I started with Wheezy, migrated to Jessie, and am currently running Stretch.

Open a terminal session and sign in as root with “su”.

Add transport module to allow Docker to grab what it needs via HTTPS:

Add the Docker GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add –
Verify that the key ID is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

Add the Docker repository:

add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable”

Update your apt repository lists:

apt update

 Install Docker:

apt install docker-ce

 

At this point, Docker is installed.  They set up a container that you can run to verify it called Hello World.

docker run hello-world

Docker is installed.  The software will run from the command line, as root.  It can be configured to start automatically by entering in a command:  

systemctl enable docker

However I have not yet done it because I am not convinced I want to run this every time I boot.  I am being conservative with my system resources, but to be honest I have not noticed it slowing me down in the slightest.   Since I will only be running this intermittently,  I probably will not be running it.

Since this tends to be my own mental scratch pad, the way to disable docker at boot is:

systemctl disable docker

This and more tweaks to how it runs are found at Docker’s own help file for post install.

Conclusion:

Obviously, this is something that is incomplete.  I will be returning with more when I go to get my container started.  I need a Container with Debian, a LAMP Stack, and WordPress.  A ready made version of this exists, and I will try that first – ready made from Docker itself!

On the other hand, my own normal IT Project Management curiosity tells me that I need to make one on my own.  So I’ll work on that later.

First step, getting it installed, worked.  Next I will get onto that other stuff… later.

Cloning a Hard Drive With Linux

Yeah well calling it Linux means I most likely lost 97% of the market.


Windows people don’t realize that there is a painless way to get their windows computer to do some of this stuff – a Live Linux Distribution like Ubuntu.  If you get a live disc working, you can copy this shell into it, then follow the instructions.  It should work.

Mac people may even be able to run this natively.

Maybe.  Depends if PV is Mac Friendly, if not, convert the PV line to a copy of your choice.


A Live Linux can be “burned” to a USB stick or to a DVD and your computer can be booted from that.


And now you know!


But none the less…

What this is basically is my own shell.  I use this to completely back up my computer.  All the drive specifications are found and known, and do not change.

I run fdisk -l as root and use the information in there to edit the shell script to change things as needed.

This assumes that you know what your drive devices are, are willing to edit a shell script to make your own changes as is, then have an external USB hard drive slightly larger than your boot device.  My boot device is /dev/sda and most likely yours is as well.

This assumes that you have a second drive sitting in your chip reader.  If not, you can comment out the line that copies it to the hard drive.

This assumes that you have room enough to do everything.

I am doing this on Debian Linux, however the commands here are so very generic that you should be able to run this on most “full” distributions of Linux.  Debian, Ubuntu, Linux Mint, Centos, Fedora and the like come to mind.

Standard Internet Warranty – I make no warranties and it is at your own risk.  If you lose data, it is on you.  I take zero responsibilities for any miscoding or changing or whether a magic dragon comes out of the skies and takes you onward to valhalla.  Really.  None at all.

I will say that I ran this exact shell this morning and it worked for me.  You WILL have to change the file specifications to fit.   

Finally:

  • My boot drive is a 240gb SSD with about 120gb free.
  • My chip has about 12 gb worth of data on it.
  • Debian thinks that the chip is called “128GB” and it typically comes up in the file manager (thunar) on /media/bill/128 GB/

Prerequisites:

Installed versions of

How it runs:

  • This must be run as Root in Terminal.
  • This will pause after each step with an OK message in the Dialog box.
  • For me, the entire shell runs in about 2 hours on my i7 laptop with a USB 2.0 external hard drive.

First the shell in its entirety through to the end comment:

#! /bin/bash


#backup.sh from http://www.ramblingmoose.com

dialog –no-lines –title ‘Run This As Root’ –msgbox ‘This shell will backup SDA to SDB\nYou must click OK after each step so watch this.\nYour Disaster Recovery will thank you!’ 10 70

dialog –no-lines –sleep 3 –title “update your sources” –prgbox “apt-get -y update” 10 70
dialog –no-lines –sleep 3 –title “update your software” –prgbox “apt-get -y upgrade” 10 70
dialog –no-lines –sleep 3 –title “update your distribution” –prgbox “apt-get -y dist-upgrade” 10 70

arg1=”‘/media/bill/128 GB'”

dialog –title “copying the chip to the drive” –prgbox “cp -avr $arg1 /home/bill/128GB” 10 70

(pv -n -i 2 /dev/sda &gt; /dev/sdb) 2&gt;&amp;1 | dialog –title “Backup SDA to SDB” –gauge ‘Progress…’ 7 70

dialog –title ‘Message’ –msgbox ‘Cloning is done, click ok to clean up and end’ 5 70

dialog –no-lines –sleep 3 –title “Removing the copy of the chip” –prgbox “rm -r /home/bill/128GB” 10 70 

dialog –no-lines –sleep 3 –title “Synchronize your drives” –prgbox “sync” 10 70
#end backup.sh

To actually use that mess…

  • Copy the entire text and paste it into your favorite text editor.
  • Save the file with a “.sh” extension somewhere you will be able to get to it – in your path.
  • Change the mode to executable – chmod 0770 backup.sh
  • Change the owner to root.  You never want to use this as a regular user – chown root backup.sh
  • Change the group to root.  chgrp root backup.sh
  • Run the shell as root: sudo ./backup.sh

Now, each line in excruciating detail!

—- Run the programs using bash interpreter

#! /bin/bash

—- I’m signing my work here

#backup.sh from http://www.ramblingmoose.com

—- This puts up a message box

dialog –no-lines –title ‘Run This As Root’ –msgbox ‘This shell will backup SDA to SDB\nYou must click OK after each step so watch this.\nYour Disaster Recovery will thank you!’ 10 70

—- The next three steps gets your distribution to date.  Don’t want this, comment it out

dialog –no-lines –sleep 3 –title “update your sources” –prgbox “apt-get -y update” 10 70
dialog –no-lines –sleep 3 –title “update your software” –prgbox “apt-get -y upgrade” 10 70
dialog –no-lines –sleep 3 –title “update your distribution” –prgbox “apt-get -y dist-upgrade” 10 70

—- Store the directory that Linux mounts the chip to in “arg1”  If no chip to backup you can comment this.

arg1=”‘/media/bill/128 GB'”

—- Wrap the actual work of copying the chip out to a dialog box.  The flags “-avr” say copy the whole drive in $arg1 recursively to the destination.  If no chip to copy, comment this line.

dialog –title “copying the chip to the drive” –prgbox “cp -avr $arg1 /home/bill/128GB” 10 70

—- This line does the real work.  Now that you copied your chip out to the hard drive, clone the actual hard drive.  The flags on pv tell it to report to stdout the percentage of work done so that dialog can show a pretty gauge.  Ahh, so pretty!

(pv -n -i 2 /dev/sda &gt; /dev/sdb) 2&gt;&amp;1 | dialog –title “Backup SDA to SDB” –gauge ‘Progress…’ 7 70

—- Copy is done, it is time to clean up message

dialog –title ‘Message’ –msgbox ‘Cloning is done, click ok to clean up and end’ 5 70

—- remove the data that you copied from the chip from the hard drive to be neat. if no chip, comment this out.

dialog –no-lines –sleep 3 –title “Removing the copy of the chip” –prgbox “rm -r /home/bill/128GB” 10 70 

—- Your work is done, make sure you flush your cache by doing a “sync”.

dialog –no-lines –sleep 3 –title “Synchronize your drives” –prgbox “sync” 10 70  

#end backup.sh

Netbook Server – Sharing An External Hard Drive In Linux

So if you have followed my instructions, you now have a:

Computer that runs Debian Linux
http://www.ramblingmoose.com/2016/02/the-netbook-server-installing-debian-or.html
Computer that you can look into using Remote Desktop
http://www.ramblingmoose.com/2016/02/the-netbook-server-you-need-to-be-able.html
Computer that you can share part of the local hard drive
http://www.ramblingmoose.com/2016/02/the-netbook-server-how-to-actually.html
Congratulations.  You now have a file server!

If you followed those directions, it also installed a bunch of other programs that will let you do other things.  I noticed that something called “CUPS” was installed, and that will let you plug a printer into the same machine and act as a “Print Server” or a “Network Printer” – if you can find the instructions on how to configure it.

Debian and Raspbian both come with enough that you could use that machine as your one and only daily driver computer.  The browser is called “Iceweasel” and is Firefox, rebranded.  You have Libre Office to write letters, work with spreadsheets, and make presentations that are all compatible with Microsoft Office.

Yes, it really is, I use it every day.  No, you don’t have to pay for it.  Ever.

There are more apps, and I would suggest looking into some of the software that is out there, all free.  If you start “synaptic” from your terminal as root or “sudo synaptic &” you will find so much free software that your mind will fog up and get tired before you find everything you want.

But that all is just the preamble to this discussion.  You came here to share an external drive.  This is like any other shared drive on the network, you have to have it plugged into the server (USB Port on your netbook), you have to tell the computer where it is, and you have to tell it how it is to be shared.

Remember, I am trying to write this for a Windows audience so I’ll go as basic as I can.  You Windows folks are in a new world, and you will want to have this go well.  If you are a Linux expert or even intermediate, you may find this needlessly wordy.   Not to worry, you’ll be right.

One Step At A Time.  Divide and Conquer.

First step – Make sure you can read the drive from Linux.


Before you get anywhere, start the computer.  Log in.  Get to your desktop.  Then plug in the drive.

Start your terminal session by clicking on the (start) “Applications Menu”, then click on Terminal.  Sign in as root by entering “su” and your root password.  You will eventually need this

Now, launch the file manager by clicking on the (start) “Applications Menu”, then click on “File Manager”.

In the left pane of the file manager you will see Devices, Places and Network.  In “Places” your external drive will come up with a little eject arrow to the right of it.  Click on the icon for the drive.  A little wait icon will start to rotate.  When it is through it will do one of two things:

Success is if you are dropped into a view of whatever files are on the disc.  It means that all the drivers are in place.  Most likely this drive is something called “vfat” or “fat32”.  Remember this for later.

Failure is if you get a big ugly warning message up.  That means that you don’t have the drivers for the format that the drive has on it.  Most likely you will have to install the set of drivers called “ntfs-3g”.  This would be where your external is a really big drive and you did it to make things faster.  To install that do the following steps:

  1. apt-get update
  2. apt-get upgrade
  3. apt-get install ntfs-3g
  4. shut down the server
  5. unplug the drive (It isn’t shared yet and you don’t want to wait for the computer to release it)
  6. start the server
  7. and plug in your drive when you have logged back in to the desktop, terminal, and file manager.

No matter what, at this point, you should be able to read your external drive.

You also need information.  When you worked with the server software “samba” you created a user and a password, and you will need that later.
 

Next step – finding where Linux thinks that drive actually is.

Here is where Linux people will be saying “gparted“.  If you know how, go for it, this is the slower but less risky method.

To determine what is plugged into your machine type into the terminal:

  • dmesg | tail -30

Linux keeps a log of whatever is important to the system.  Since you “just” plugged that external drive into the computer, the last thing on that very long stream of text will be what was reported when the computer detected the hardware.  The “tail” bit will tell terminal to just show the last 30 lines of what are in the display of messages (dmesg).

The clue there are the lines that say “usb 1-2” and “sdb”.  When I plugged in the drive, it said “new high-speed USB device number 2”.  So what we’re going to tell the system is that the drive is sitting on a device called sdb.  The partition we will be using will be the first one, so it is officially “/dev/sdb1”.  In windows, it would come up as your D drive if there is no DVD/CD drive present, E Drive if it is, this is the same thing.

Since my stick is formatted to be removable on Windows, it is a format that Linux calls “vfat“.    My big 4 TB drive is formatted NTFS, so I would have to mount it as “ntfs-3g

Create a place to store the data in.  In my case, it is “/home/bill/external“.  You should change “bill” to the name of your user that you logged into when you started this exercise.  To make the directory, open terminal again as a regular user and enter this command:

  • mkdir /home/bill/external
  • chmod 0770 /home/bill/external

You just created the directory and set it up so that you and root can use it.

There is one file that you need to edit in Terminal with the following command:

  • nano /etc/fstab

This file tells linux where all of your disc drives sit, so be careful and don’t delete anything.  You will be adding a line, as below:

  • /dev/sdb1 /home/bill/external vfat defaults 0 0″

That says – put the external drive’s first partition “in” the /home/bill/external directory.  It also says that it is “vfat” format so change that if it is an ntfs-3g format.  The defaults are lengthy and you can go into them in great detail on the Wikipedia Article.

If you wanted to go further and add multiple partitions for other people, you could do it in /etc/fstab by adding multiple entries.

Once you restart the computer, you should be able to find the drive on Windows, and you are on your way.  Just find the drive in Windows File Manager, enter in your login from Linux, and you’re good to go.

One final wrinkle

What this does is to “bind” the external hard drive or memory stick to the server.  It is now set to automatically mount and share the drive whenever the power comes back on.  If you do not have a drive plugged in, Linux will boot, but put you into a terminal session as root into what is called “Single User Mode”.  You can do the following edit at that point with the commands below.

To remove the hard drive so that the server is no longer looking for the drive at boot, in terminal as root:

  • nano /etc/fstab
  • find the line with the external drive and enter a # as the first character in the line
  • save the file and restart the computer

This now turns your server into a machine that only serves the local hard drive.

The Netbook Server – How to Actually Share Part Of The Hard Drive

First, you installed Linux to a RaspberryPi or a Netbook, or whatever you had on hand.

Second, you made it so you could look into that machine from anywhere on your network.

If all you wanted was a taste of how to run Linux and have fun with all those free goodies there, you could have stopped.  Now I’m going to show you how to take a part of the hard drive (a folder) and share it out to the network.

Why?

So you can copy your pictures/recipes/important crap somewhere else.

So you can back up your computer across the network.

So you can brag to the co-workers that you have a proper Linux Home Server and sound like you know what you’re doing.

Well the deal is that it took me a half hour to do this last night.  I was distracted by what was on the TV so it would have taken less time.

I did this on a RaspberryPi first.

 

Since my instructions were written there I then repeated the steps on my Netbook running Debian, so the instructions work.  It also works on anything derived from Debian Linux, so that if you have found this article using Linux Mint, Ubuntu, or any of the other derivatives from the Debian Family, you SHOULD be able to get this working with very little fuss.

If you are familiar with Linux and the way things work, you’re used to finding instructions that promise to do something, get totally frustrated that the instructions are geeked out, and then realize that while it’s working you don’t actually understand WHY things are done this way.

I’m going to attempt to do it differently.  This way when I have to look at it later, I can look at my own B.S. here and say “Oh yeah, I remember this”.

The information you need:

1) Your sign on name – this will be written assuming you are “bill”.  Just change that to your own name from when you created the machine.

2) Your “root” and regular user (bill) Passwords.  

3) The name you gave the computer when you installed Linux.  It could be pi or rudolph or any other name you came up with.  

I will make assumptions and try to explain it all away.  Don’t worry, I followed these same steps last night and the server now “serves” files out to the network.  As long as your network has a firewall, your stuff is safe.

Get the machine “up to date”:

  1. Start your Terminal from the start menu.
  2. su and hit enter – Get “root” by giving it the root password.
  3. apt-get update – pull down all the headers of new stuff since the last time you got on the machine
  4. apt-get upgrade  – actually get all the upgraded software

Answer yes or Y to the prompt asking if you really want to update things, go make yourself something from the kitchen and come back in a bit.  It may take time.  There are always updates.  But if you never make changes to your “Repositories” on Debian or Raspbian, you are safe and free from any nasty viruses.

 

 

Get the Server Software Installed:

You’ll be shocked how little has to be done here.   The server software is called SAMBA.  You know, like the great music from Brazil?   The current name has been made less fun – CIFS.  People tend to say it as “Siffs”.

Geeks.

One line gets the software.  In terminal from the last part, as root enter the next line:

apt-get install samba samba-common-bin

Configure the Server Software:

You have to roll up your sleeves here.  You are actually going to change a text file, but I’m going to give you the information.  Remember – I am entering it as “bill”.  If you are on RaspberryPi, your regular user will most likely be “pi”.    Change “bill” to what you need it to be.

 

Second, a comment starts with a hash tag.  #

 

1) In terminal where you are signed on as “root”, enter the following line to get into the “Nano” editor:

 

nano /etc/samba/smb.conf  

2) Find the line with “wins support” and change the line to read:

wins support = yes

3) Find “Share Definitions”.  You are going to enter in a block of text.  Remember to change the path from “bill” to match your login name.

 

[Downloads]
comment = Downloads Directory
path = /home/bill/Downloads
browseable = no

    writeable = yes
only guest = no
create mask = 0770
directory mask = 0770
public = no

 

#browseable limits logins to only see this directory and what is created there.  “yes” shares everything.

 

4) ctrl+x to exit, type y to save the file, then enter to get yourself back out to the root terminal prompt.

5) add a Samba user to be able to share that directory.  In terminal enter the following:

smbpasswd -a bill

Enter in a password, then enter it in again.  This is the password you will need to have to be able to get at the files from out on the network on another machine.  You will log in as (bill) and (password) from that other machine when you try to get there using File Manager.  Same thing with Mac or Linux.  They all need that password.

Write down your password.  I recommend using the same as your regular user password.  If you made them all the same as the Root password, well that may be easier.  You can also leave it blank, but I do not recommend that.  In fact, forget I mentioned it (or not…).

6) restart the computer


At this point, the netbook server is now visible on the network.  It is sharing the default login’s “Downloads” directory.

If you go into File Manager in Windows, you will be able to get to the files that are stored in the netbook’s /home/bill/Downloads directory from any other machine on the network as long as you know the default user’s login.  It will ask you for user and password.

If you have followed this, you can use the computer’s name from when you created it.  I now have two servers “rudolph” for the netbook and the raspberryPi.  If computer names aren’t your thing, you can also find them via IP addresses.

But at this point you have a functioning File Server.

You’re done.  Next time it’s getting this machine to serve out files from an external drive that you plugged in.

The Netbook Server – You Need to be Able To Look In Remotely With XRDP

Blogs have many purposes.  One that is not often stated is that it serves as a place to put things that the writers feel they need to remember.  I have a habit of creating Linux computers for my own personal desktop use or as a server from time to time.  It isn’t often enough for me to memorize everything, and you do forget things.

So to make it easier, I’m going to do this in a couple of steps.  Last time I wrote, I talked long and hard about setting up either a RaspberryPi or a Netbook as a server.  The reality is that these instructions work with pretty much anything that takes a version of Debian as the operating system.  Since Debian has been copied and serves as one of the main “seeds” of the trees of distributions, the instructions can be used elsewhere.

If you followed those instructions, at this point you now have a computer that has Debian.  It’s time to get it Up To Date, and set up so that it can be seen from other computers on your network.  The reality is that this is pretty simple and if I cut out the editorializing, it could be written in about three well crafted paragraphs.

Most Linux distributions take a “You’re the boss” attitude.  If you break it, you can fix it, but it will allow you to break it if you know the right commands.  Most also take the attitude that it will only install what you need to be a “role” of a desktop/laptop or a server.  Debian Linux is an excellent desktop or laptop for general home or office uses.  I use it for 95% of my own computing needs, but there are some things that need to be added.

—-

Firstly, start the computer, and log in.

Second, get your terminal started up.  Terminal will look like the old style DOS computers.  It’s a command line interface – you type stuff in.  Not to worry, all the commands I type in can be copied from this blog article and pasted directly into your terminal session.

Third, you have to be “Root”.  Root is the administrator of the computer.  When you created your computer you gave it two passwords.  They may be the same one, but the one that you need is your root password.  In Terminal type in: su .  Enter in your root password.

The result is that everything that you do in the terminal window has full control over your computer.  It will allow you to completely remove everything, so be careful.  It is after all, at your own risk.

Fourth – get the computer up to date.  In terminal you need to enter in three commands, one after another.  Each time, if there are changes, it will ask you to enter a “y” or “n” depending if you want to continue.  If you simply hit enter under Debian 8, it will assume you want to continue.

  • apt-get update
  • apt-get upgrade
  • apt-get dist-upgrade

What that says is update the list of programs that you know about.  Then find out if there are any upgrades and give you the option to upgrade or not.  Then if there is a distribution upgrade, give you the option to upgrade or not.  Distribution upgrades are rare.  Sometimes there are updates that require you to enter in some information.  In this case, you will need to consult the internet for what is going on.  Mine was asking for a “Root Certificate” update and put up a list of changes. I read it, typed q to quit, and it went back to installing “stuff”.  Major changes could be much more involved.

Depending on what is installed, you may want to restart your computer.  Linux does not require this, but sometimes you should.  It’s up to you, I did, and all that took me a good half hour to get to this point.  Get something to drink and settle in.  When you get back, get yourself back to a terminal and log in as root.

I’ll wait.

Next step.  Remote Desktop.  Why you need this is that if you get this beast up and running you may decide to put it in a closet somewhere.  Inconvenient.  You might want to do work on it directly.  So why not be able to start a window up and actually look at the desktop.  Windows has the software available to look at it installed on the newer versions – RDP.

It also makes it easier for me to sit at one computer and work on two at the same time.  Keyboard in lap is easier than two keyboards on a desk.  I can relax!

To install type:  apt-get install xrdp

To get it to work, you simply open up a remote desktop client to the computer name and you will get a windowed representation of the other computer.   This can be adjusted to size in the configuration files.  Without any tweaks, it worked on my Linux machine using Remmina.

What it is actually doing is getting you to log into another session on the remote Linux machine.  If this were windows, it would take over the existing session.  Linux gives you the option to do it that way as well, but you would need to reconfigure it.

It is a little odd to see the default behavior.  I had the computer up under remote desktop, and it was sitting on my desk near me.  Screensaver came on on the table, but not on the remote desktop.  Then when remote desktop went to screensaver, it was different from the table.  Shows that you’re under a completely different session by the default behavior.

 

To actually use the machine remotely:
You need to know what IP Address the remote computer is “at”.   Most times the machine name you gave it when you installed the operating system will be visible to the world.  I find that usually shows up when the network is set up with sharing via something called Samba.  Installing Samba can be an annoying process.

ifconfig –  the old school way of doing things.

open that terminal prompt on the computer and log in with su as root.  Once there, type in ifconfig.  You will get a bunch of text.  If the computer is connected with an “ethernet” wire to the network, you need to look at the “eth0” otherwise, “wlan0” is most likely how you are connected with Wifi.

The line you are looking for will be the second one in the group for wlan0 or eth0.  Look for “inet addr:” and you will find your internet address.   In the case of the picture below, I am on wlan0 (wifi), and my internet address is 192.168.1.208 .

Open your remote desktop program.  You may have to actually install one in windows.  Since I use mine so heavily I might have done that literally years ago.  Mine was found by clicking:

 

  • start
  • all programs
  • windows accessories
  • remote desktop connection

For me to connect to my server, I enter the IP address 192.168.1.206 in the computer box, then click connect.

There you will have to enter in the log in information to log into xrdp.

  • sesman-Xvnc
  • your login will be your username on the computer
  • your password for the computer

Hopefully you will get there and you will see a desktop – here’s mine!

The Netbook Server – Installing Debian or Raspbian

Funny how writing a blog can be.  I have been thinking how to write this bit for a couple weeks now.  I came to the decision that the easiest way is to step back and let someone else do some of the “heavy lifting”.

If all this information is a big much, I will make the links you really need to follow in bold.  So if you trust my blog, just jump to the link and click.  If it is “later” and the link is broken, you can click an earlier link.

Remember, if you are installing an operating system onto a computer you WILL lose everything that was previously on the hard drive.  Back it up before proceeding.

Also, standard internet weasel words – This is obviously at your own discretion.  I have done these instructions as I wrote them down, they worked for me.  So at your own risk, I’m not responsible for any damage or time wasted, extra electricity burned, or whether your netbook sprouts wings and demands to be fed an offering periodically.  Lawyers are respectfully welcome to take their lawsuits, roll them into a little ball and file them where they will not effect (or affect?) me.

I have done both processes successfully more than once.  With Debian, all but one of my computers run that operating system.  I wrote this guide while doing the steps for Debian, so it should be pretty close.

Finally – take your time.  If you’ve only ever used Windows, Linux is a completely different philosophy.  Everything is free, but you pay for support.  So if you have a question, look to your favorite search engine, and see if you can find it yourself.  You would be shocked at how much information is out there for Linux, and the quality of the write ups are usually much better than I find for windows.

RaspberryPI

If you have one of these beasts, I am assuming you have already looked into and installed the operating system once.  That simplifies my own tasks.

Get yourself an unused memory chip, I strongly recommend larger than 8GB.  16 is acceptable.  Why is because I found that Raspbian has a quirk or a bug in it.

If you want to copy a lot of files to a shared drive on Raspbian, it looks at the empty space on your chip and says that is the maximum you are going to be able to copy to it.  When you install Raspbian, go back in to the preferences and make sure that Noobs releases the entire chip to be used.  Typically, it will be set for 2GB, noobs will let you reclaim your entire 16GB plus.

Why Raspbian?  Because it is based on Debian, and because it has “official images for recommended Operating Systems”.  That and since Debian is so stable and well known, it works for my own knowledge – I can do it in two places but only write one set of instructions once you’re “there”.

RaspberryPi’s instructions really are simple, and you can follow them on this page.

https://www.raspberrypi.org/documentation/installation/installing-images/

 
Debian – You want this.

There are other Linux distributions that are more “user friendly” but few are anywhere near as stable as Debian.  You could put a computer inside a wall running Debian and as long as it gets power, you can ignore it and let it happily run.

Since this is Netbook oriented, I am pointing you to a 32 bit copy of Debian.  If you discovered this blog posting elsewhere, consider for yourself whether a 64 bit copy is right for you.  It will not work on a netbook, but on a Core 2 Duo or newer, it may be right for you.

One other decision to make.  Debian has another quirk.  Debian’s maintainers are very adamant about not having any software on their operating system that is owned by other companies.  It is called “Non-Free”.  To you and I, that can get in the way of having what you need on your computer.  In the case of my Lenovo S10-2 netbook that I will use for this project, I need the Non-Free version of the wifi drivers.

Thankfully someone else has put all that together for you.  If you don’t need the Non Free version of Debian, or you want to see what on earth I am talking about, go and download the other version.

In my case, the Non-Free saves me the step of waiting on the network cards.

I know, it all sounds very odd because Windows has all that stuff “on the DVD”.  In reality, since Windows is 95% of the market, they make sure that Microsoft has the drivers needed.

For most this is all you will need.  There still was a file it wanted during the install.  Broadcom Wifi Drivers are a BEAR.  So I stopped the install after I found the ones I needed online.  It was looking for b43/ucode15.fw series of drivers.  The solution is actually to install Non-Free Debian with an ethernet cable plugged in to the Netbook for the network.

While Servers should be connected to the network with ethernet for speed, this is just a sloppy omission – Non-Free or Not.  Since this bothers me and other owners of the Lenovo S10-2, I’ll solve it by restarting the install with ethernet plugged in.  Weirdly enough, after all of that on my first boot, it came up without a problem.  It must have found what it needed “magically” on the install disk or the internet.

For Debian, the DVD you want is on this link:
http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/current-live/i386/iso-hybrid/

To explain what that file name means:

  • That “Including Firmware” is what you really need.
  • That “i386” says 32 bit operating system – for netbooks.
  • That “current-live” says I want to be able to test this on my computer and run it from the DVD without ever touching the hard drive because I don’t trust anything.

When you click on that link, it puts you with a bewildering list of weird scribbles and file names.  The one you want is the one with “xfce” and “iso” in the name.

Why?  Because the “place” in the file name tells you which desktop you are going to get.  That desktop is called xfce.
Why XFCE?  Because it has a balance of looking like Windows 7, is highly configurable, and is relatively lightweight so it will run well on older computers.  I trained a 69 year old little old lady how to use Linux as a daily driver using XFCE and her son uses it to this day after she passed on.  It really does look that familiar.

The direct link for the file, as of today, is:
http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/current-live/i386/iso-hybrid/debian-live-8.2.0-i386-xfce-desktop+nonfree.iso

Click on the link, and save the file somewhere meaningful to you.

When this is finished, you need to make a copy of the operating system on a 2GB or larger USB Memory stick.  Remember, your Netbook will almost certainly not have a DVD drive on it, so you’re doing this most likely on your windows system.

The instructions for Linux and Windows are on the following link.  What they are telling you to do on Windows is download a program, install and run it, then tell the program where you put your copy of Debian.

http://crunchbang.org/forums/viewtopic.php?id=23267

When you go to run Win 32 Disk Imager You need to run it as an administrator.  Right click on the icon in the start screen/menu and select “Run As Administrator” and follow the instructions on how to create the disc by selecting the ISO Image File, and the correct Device, then click Write.

Now that you have all that on the USB Stick, you can test it in the Netbook by plugging it in to the USB port.  Then turn on the Netbook, but hit the key that you use to get into the temporary boot menu – typically F12 when you are booting.  To get to see what Debian looks like, select “Live (586)” and hit enter.

When your computer is up completely under Debian, check to make sure that you have Wifi connectivity, Ethernet connectivity, and that there isn’t anything missing.  Basically a Netbook is an old laptop these days and with the Live DVD or USB stick you just made, It would be pretty rare if you are missing anything on it, so just sniff around and make sure it found all your hardware.  When through you can shut everything down and take a breather.

Installing Debian from the Live USB Stick onto the Netbook.

It’s surprisingly easy.  The video at the end will help if you get worried or lost but it boils down to you need to enter just a few things in.

Start by selecting “Graphical Install” at the “Boot Menu”.

Language (English)
Location (United States)
Keyboard (American English)

Computer Name:  It will spend a bit gathering itself together then ask you for a name of the computer.   My own habit is to name it after large Moose, Reindeer, Elk and that sort of thing.  Really, It doesn’t have to be anything meaningful, so have fun with it.  My test installs were Rudolph and Blitzen.  Or be bland and call it “server”.  The default is “debian”.  But it has to be unique to the network.  Two computers with the same name cause confusion, just like the year I had five Karen’s in my classes.

Karen.  Should I call it Karen?… Naaaah!

Domain Name – if you know of one use it, but I leave this blank.

Setting up users and passwords.  

First there is the Root Password.  This is the Administrator on Windows but it is password controlled.  It’s one of the many reasons why Linux security is stronger than most.  If you have someone trying to install something on your linux computer, a window will come up and ask the user to enter in this password.  It should be meaningful, and ideally it should be complex.  Write it down because a Linux computer without a root password is useless.

Second, there is the Regular User Name.  This is the “Non-Root” user who gets to sign onto to the machine.  It is you, but it could be anything.  Just write this down or else you won’t be able to log onto the computer, and no you may not use Root.

Third,  you will need a password for the regular user.  It can be the same as the Root password, but if it is, don’t tell anyone because they will have full control over your computer.  Can’t have that can we?

Fourth, you need to enter in your time zone.  If you don’t know it, you are probably lost.

Partition Disks:

Here is where you end up losing everything on your hard drive to give the netbook a new life as a Linux Server.  If you did not back up your computer, proceeding will delete the old data.  That may be what you want, it may not be.  Now is the time to pause and backup the data, unless you want to delete it all.  It is a One Way Trip!

Partitioning disks is something I have always found easiest to simply take what they give me here.  The “Guided  – Use Entire Disk” prompt is what I select.

The Disk naming is different on Linux than Windows.  They call things HDA and HDB, and each partition on the disk gets their own number.  Typically what you will want to do is look for a disk that has the same size as your netbook.  Many netbooks have a 160gb or less drive in it.  The install stick may also be spotted – but you should be able to determine that logically.  Most likely it will be called sda…  Select that hard drive, tell it to create a new partition table, and if it looks right, click continue.  Mine actually had a string saying “SCSI3 (0,0,0) SDA – 60GB Hard Drive” and a second one on “SDB” that was the 2GB Generic Disk

When you are done setting up the disk with “All Files In One Partition“, you highlight “finish partitioning and write changes to disk“, and let the computer create your partitions.  It gives you a warning at the end to write changes where you have to select “Yes” and continue.

At this point, Debian will write the data out to the base system – your hard drive.  You are on the way to getting a new operating system.  Go make a sandwich or a cup of coffee and come back later…

Now that it is later…

Package Manager:

It will come back and ask you to configure a Package Manager.  Linux is free.  There isn’t one central place that all is kept.  You will be asked if you have a network mirror – and that is the location of the place that that software is kept.

Yes. (Always.)
Country:   United States.
Please Select the Debian Archive Mirror:  debian.gtisc.gatech.edu or a closer one
Proxy – leave blank unless you know otherwise.

All the software is spread around the world on different archive mirrors.  So Debian, and most other Linux distributions, share the burden of putting the free software out there by creating a place for it to reside.  Here in Florida, my nearest place is at Georgia Tech in Atlanta, but you could be using a server anywhere.  Pick one, nearest is best and you can change them later.

Here is where you can get your second mug of coffee and comeback later.

When it finishes installing all those packages, it asks you if you want to “Install Grub To Hard Drive”.  Yes.  Continue.  Why is so the computer will boot from the hard drive, so you really do not have a choice.

It will ask  you what drive to write it to.  /dev/sda is your main hard drive and that is your choice.  My generic USB stick was in /dev/sdb at that time and obviously you do not want that.

It will write out that GRUB which is a boot menu, then bring up a page saying to “Finish The Installation“.  Make sure you remove the memory stick, and click continue.

On the first boot:  “Welcome to the first start of the Panel

When you log into the computer the first time, XFCE will put up a message asking you to configure panels – you want to “Use Default Config“.  That gives you a control strip at the top, and a launcher at the bottom.  Both are completely configurable from your system settings.

Now you are running Linux on your netbook.   Have fun!

Video is at https://www.youtube.com/watch?v=TIuOFqQ-XTk