Friday, July 12, 2013

Protecting Your Children on the Internet with Linux or How to be a Sneaky Parent Part 2 Samba

For extra credit install and configure Samba.   Samba is a system that creates Network Drives.  There are some very good reasons to do this:

1. At some point one of your kids (or all) are going to accidentally delete an important file.  Probably an important school paper.  If instead of saving files to the local hard disk, they are saved to each child's private network drive and there are periodic backups made of the network drive, all that you would have to do is restore from the backup.

2. Your children won't be depleting their local hard disk (which is probably going to be small anyway.)

3. You can set it up a common common drive that everyone has access to, making file sharing easy.

 4. Your Children's Documents will be stored on the Desktop in your kids Samba Directories, making easy for you the parent to monitor them for quality.  If their is an Educational Issue, you could possibly catch it before it is turned in.  You may also get a heads up to a looming educational issue and perhaps be able to take corrective actions.

The following web page describes a very basic and easy way to configure Samba:

Sign on to each laptop as your child and issue the following commands from within their home directory:

    mkdir bin
    mkdir PrivDir
    mkdir ShareDir

Now on each laptop start the text editor  with “leafpad” and create the following file and save it to bin/AttachSamba

mount -t cifs // [IP Address]/[Samba Share] /home/charles/PrivDir -o     rw,username=[Samba User Name],password=[Samba Password],uid=nnnn,gid=nnnn
mount -t cifs //[IP Address]/[Samba Share] /home/charles/ShareDir -o     rw,username=[Samba User Name],password=[Samba Password],uid=nnnn,gid=nnnn

Note the above file is only three lines long.  The mount command is one line long from the word "mount" to "gid=nnnn".  It won't fit in one line in this blog, but it is just one line.  If you break it up, the script will fail.

Now the explination of this is kind of messy.  The [IP Address] needs to be the IP Address of the Desktop.  The [Samba Share] is probably going to be the child's name.  The Samba User Name and Password would be this child's Samba User Name and Password. This is the share name that you set up with the Samba GUI Tool.

There is a GUI User Add utility that you can just use to display your child's User info with and it will display the gid and uid numbers or you can type the following command into a terminal:

    cat /etc/passwd | grep charles

There will be two 4 digit numbers displayed, they will probably be identical.  These are the uid and gid.

With charles being your child's name.  Finally from a terminal type the following command:

    sudo chmod +x /bin/AttachSamba

If you only set up a Private Directory for your child, delete the 2nd mount command.  But really, a common directory for files the whole family needs access to is going to be really useful.

Now create the following file in the Desktop Directory on your Child's computer.

    gksudo /home/charles/bin/AttachSamba

And save it as  Then issue a chmod to make it executable:
    chmod +x Desktop/

Now your child will have an icon to connect to his/her private network drive and the common drive.   

There is one last thing that has to be done, right now your child can't run this command because he or she doesn't have super user rights.  You can give them the rights to just mount and unmount file systems though.  This can't be done from your child's account.  The easiest thing to do, since you are already logged into your childs account is issue the following command from a terminal:

    su - [Parent Account]

It will prompt you for your password and then issue the following command:

    sudo visudo

and then find the line that has “root    ALL=(ALL:ALL) ALL” and add the following line below it:
charles ALL=(ALL) /bin/mount, /bin/umount, /sbin/halt

Press F3 to save and F2 to exit.
Here is a webpage that discusses how to set up backups on a Linux System.

 For backup media I recomend using usb hard drives.  I have tried in the past to use cd and then dvd, but their storage capacity is just inadequate.

This whole Samba setup is probably the most difficult thing I have talked about to set up.  If you are having trouble contact a local Linux User or ask question someplace like  There are also books, which is how I originally did it.

No comments: