Monthly Archives: April 2014

Set A Static DNS Server Address In Ubuntu 14.04 Trusty Tahr

Gateway

It is not immediately obvious how to set a static DNS server address from the command line in Ubuntu 14.04 Trusty Tahr. In the Desktop version of Ubuntu, you can of course use the graphical Network Manager to assign a static DNS server. In the Server version, things are a little more complicated. This post will explain how to use the resolvconf utility to set a static address for the DNS server. (In this example, we will assume your DNS server has an address of 192.168.1.100.)

First, log into Ubuntu, and then navigate to this directory:

 /etc/resolvconf/resolv.conf.d

Once you are in the appropriate directory, use this command to launch the vi text editor:

 sudo vi /etc/resolvconf/resolv.conf.d/head

This will open up resolvconf’s head text file in vi. Once vi has launched, press the INSERT key to switch vi to edit mode, and then enter the following line:

 nameserver 192.168.1.100

Then hit the ESC key to switch vi back to command mode, and type this command to save the edited text file and then quit vi:

 :wq

Once vi exits, type this command:

 sudo resolvconf -u

The resolvconf utility will then read the head file and set the static DNS server address you entered.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Install WordPress In Ubuntu 14.04 Trusty Tahr

WordPress

WordPress is a content management system that powers quite a variety of websites, first developed in 2003. In WordPress’s early days, it tended to run only personal blogs and smaller sites. However, the software improved considerably with every version, and it’s adaptable enough to be used for a variety of different sites. WordPress’s big break came in 2009 when popular blogging platform Movable Type changed its licensing terms. Enough Movable Type users were annoyed with the change that they migrated to WordPress, and WordPress is the dominant open-source content management system on the Internet as of this writing.

It’s quite possible to install WordPress on a machine running either the desktop or the server version of Ubuntu 14.04 Trusty Tahr. This makes an excellent environment for testing and experimentation, since you can tweak and experiment to your heart’s desire without rendering your production blog inoperable. If you need to run an internal corporate blog of some kind, hosting WordPress on an Ubuntu box or virtual machine is a cheaper solution than more expensive blogging or collaboration software. Or, if you’re really ambitious (and you can afford the bandwidth), you can host an Internet-accessible WordPress blog out of your apartment.

Let’s begin!

(Note that the Ubuntu repositories now contain a fully automated WordPress installation. However, I believe that installing it by hand yourself has significant value – you’ll not only learn how to set up a LAMP server, but installing step-by-step gives you valuable troubleshooting knowledge later on in case something breaks.)

First, install Ubuntu into your machine of choice. Once Ubuntu is installed and updated, you will need to install five pieces of software: the Apache web server, the MySQL database server version 5.6, PHP version 5, the MySQL module for PHP, and finally the WordPress software itself.

First, install the Apache web server. To install Apache, go to a Terminal window or a command prompt and type this command:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1 . Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see a web page with only two words on it:

It works!

Apache is now operational.

The next step to install WordPress is to install the MySQL database server. Return to the Terminal and type this command:

sudo apt-get install mysql-server-5.6

(As of this writing, MySQL Server version 5.6 is the latest version available in the Ubuntu repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just like the root user in Linux, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line. You’ll then need to activate MySQL with the following command:

sudo mysql_install_db

This will set up MySQL Server for use with your Ubuntu system. Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system.

The next step to installing WordPress is to install PHP version 5:

sudo apt-get install php5

Then install the MySQL module for PHP:

sudo apt-get install php5-mysql

You may also want to install the GD library for PHP, since many WordPress plugins rely on it for graphical manipulation:

sudo apt-get install php5-gd

Finally, download the WordPress software to your Desktop. You can obtain it from this address:

http://wordpress.org/latest.tar.gz

If you’re working exclusively from the command line, you can use this command to download the WordPress software:

wget http://wordpress.org/latest.tar.gz

Use this command to unpack the WordPress files:

tar -xzvf latest.tar.gz

Make a directory in /var/www/html for the WordPress files:

sudo mkdir /var/www/html/wordpress

Finally, move the WordPress files over to the /var/www/html/wordpress directory. (In this command, I’ll assume you unpacked the WordPress files to your home directory; you will have to adjust the command if you unpacked them in a different directory.)

sudo cp -r ~/wordpress/* /var/www/html/wordpress

Now that we’ve got our software installed and downloaded, we’ll need to configure it. We’ll start with Apache.

First, it’s always a good idea to make a backup of a system configuration file before you alter it, so start by making a back of Apache’s configuration file. Use this command to back up Apache’s configuration file to your home directory:

cp /etc/apache2/apache2.conf ~

Next, you’ll need to add a line to your /etc/apache2/apache2.conf file, so Apache will properly interpret WordPress’s PHP files. (Note that this is only necessary if you install WordPress in a subdirectory of /var/www, as we are doing in this example. If you install WordPress in /var/www, you don’t need to add this line, but you do need to delete or move the original index.html file.) To edit apache2.conf, fire up the vi editor:

sudo vi /etc/apache2/apache2.conf

Once you are in vi, scroll to the end of the vile, switch to Insert mode, and add the following line:

AddType application/x-httpd-php .html

Return vi to Command mode, save the file, and then exit vi. Restart Apache with this command, so it re-reads its configuration file:

sudo /etc/init.d/apache2 restart

Now we’ll need to prepare MySQL for use with WordPress. WordPress requires a database and a database user, and full permission for its database user to access its database. To start the MySQL command-line client, use this command:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a WordPress database, create a user to access that database, and grant our new user all rights to the WordPress database.

(An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.)

To create a database for WordPress, use this command at the mysql> prompt:

CREATE DATABASE wordpress;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database:

CREATE USER wordpressuser;

You should get the “Query OK” message again. Once the new user is created, we’ll need to set a password for the user before we can assign any permissions. In this example, we’ll assign a password of “1234″. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.)  To create the password, use this command:

SET PASSWORD FOR wordpressuser = PASSWORD(“1234”);

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “wordpress” database to the “wordpressuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ‘1234′;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

Then type exit to quit the MySQL local command-line client. Now that we have MySQL prepared, we can now configure WordPress itself. Specifically, we’ll have to configure WordPress to talk to the database we just created. To do so, you must create a wp-config.php file in the WordPress directory. Fortunately, WordPress includes a handy wp-config-sample.php you can use as a template.

Type this command to create a wp-config file (assuming you installed WordPress in the /varwww/html/wordpress directory):

sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Next, use vi to edit the newly created wp-config file:

sudo vi /var/www/html/wordpress/wp-config.php

You’ll see that the wp-config.php file contains a number of variables. Change the following three variables:

-Change putyourdbnamehere to wordpress.

-Change usernamehere to wordpressuser.

-Change yourpassword here to 1234.

Once you have your changes made (after double-checking the spelling, of course), switch vi to Command mode, and save your changed file.

Everything should now be ready. Open up a web browser, and navigate to http://127.0.0.1/wordpress. (If you want to access it from a different machine, of course, use the IP address of the WordPress server, for instance – http://192.168.1.100/wordpress .)If you configured everything correctly, you should then be greeted by the WordPress configuration page. You’ll pick a username, and WordPress will assign you a password. Follow the prompts, and you will have a functional WordPress blog installed on a Ubuntu machine. Congratulations!

One final note: if you configure your blog from a local browser, it will probably set your blog’s address as http://127.0.0.1/wordpress. This is fine if you only want to view it from the host machine, but if you want to view it over the network, you’ll need to change it. Fortunately, you can do so quickly by going Options in the WordPress admin interface, and then to General, and changing the blog’s URL.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Ubuntu 14.10 Utopic Unicorn

I use Ubuntu Linux pretty extensively, and every version of Ubuntu has an alliterative codename based around an animal – Saucy Salamander, Breezy Badger, Dapper Drake, Feisty Fawn and so on. The latest version, which came out last week, is Trusty Tahr.

The next version will be Utopic Unicorn.

To be fair, there aren’t a lot of good animal names that start with the letter U.

But, alas, think of what could have been – the next version could have been named Ubuntu Unpleasant Urial! 🙂

-JM

Install And Configure MySQL Server On Ubuntu 14.04 Trusty Tahr

MySQL

To install MySQL Server 5.5 on Ubuntu 14.04 Trusty Tahr, make your way to a Terminal window or a command prompt, and type this command:

sudo apt-get install mysql-server-5.5

(As of this writing, MySQL Server version 5.5 is the latest version available in the repositories, though future versions of Ubuntu may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just like the root user in Linux, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line. You’ll then need to activate MySQL with the following command:

sudo mysql_install_db

This will set up MySQL Server for use with your Ubuntu system. Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Ubuntu system. In the next section, we’ll discuss using the MySQL command-line client to create databases and users.

The most common use for MySQL on a Ubuntu system is to provide a backend for a dynamic website of some kind, usually content management systems like WordPress or MediaWiki. To host these websites on a Ubuntu machine, you’ll need to create a database and a database user for the website. MySQL Server can support many different databases, limited by the amount of hardware and disk space available on the machine. (Hosting multiple active databases at the same time places a high level of demand upon a hard drive.)

Like Samba, MySQL has its own collection of user accounts, separate from the main system accounts, called “database users.” A database user is simply a MySQL user that has access to a particular database, or specific tables within a database. In this section, we’ll show you how to create database and users with the command-line client.

First, you’ll need to get to the MySQL client prompt. The MySQL command-line client, like the command-line clients for FTP and SFTP, has its own prompt. To access that prompt and start the client, use this command:

mysql

However, if you simply type the command, it will bounce back with an error message. To use the MySQL command-line client, you need to add the -u and the -p switches as well. The -u switch tells it what MySQL user you want to use to log into the client (similar to the -l switch with SSH). The -p switch tells it to ask for the password. So, to use the MySQL client as the MySQL root user, the command should look like this:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a database, create a user to access that database, and grant our new user all rights to that database. Generally, when you’re installing a web application like WordPress, you’ll give the database user you create for the WordPress application all rights to the database so it can function properly. Not giving the application user all rights to the database can cause the application to act erratically or even fail entirely (though some applications can work with limited access to its database).

An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.

To create a database, use this command at the mysql> prompt:

CREATE DATABASE newdatabase;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database:

CREATE USER newdatabaseruser;

You should get the “Query OK” message again. Once the new user is created, we’ll need to set a password for the user before we can assign any permissions. In this example, we’ll assign a password of “1234″. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.)  To create the password, use this command:

SET PASSWORD FOR newdatabaseuser= PASSWORD(“1234”);

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “newdatabase” database to the “newdatabaseuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON newdatabase.* TO newdatabaseuser IDENTIFIED BY ‘1234;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

You’ve now set up a database, created a database user, and given that user full control over that database.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Set Up Apache Virtual Hosts On Ubuntu 14.04 Trusty Tahr

ApacheVirtualHosts

It is quite easy to set up an Apache web server on a Ubuntu 14.04 Trusty Tahr system.However, you might need a more complex web server, one that can host multiple separate websites, rather than subdirectories within a larger website.

How do you do this?

Apache has a feature called “virtual hosts” that lets you run separate websites, with completely different domain names, on the same physical server. Fortunately, implementing virtual hosts for Apache on Ubuntu is actually quite simple to do. In this example, we’ll show you how to set up a new website called “examplename.com” on an Apache web server.

First, you’ll need to set a location for your new web site’s files. Apache, you might recall, by default stores the web files in /var/www. For this example, create a new folder for the website with this command:

sudo mkdir /var/w2

Next, you’ll need to create a configuration file for the new website in the /etc/apache2/sites-available directory. Fortunately, that directory contains a default file you can simply copy and use as a template with this command:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/examplename.conf

Note that any configure files you create MUST have a *.conf extension!

The next step is to edit the new configuration file with the correct settings. You can do this using the vi text editor:

sudo vi /etc/apache2/sites-available/examplename.conf

Once editing the file with vi, you’ll need to make a few changes.

Change the “Document Root” directive from /var/www to the proper location of your new website, in this case, /var/w2.

Also change the “Directory” directive from /var/www to /var/w2.

Finally, under the line that begins “ServerAdmin”, add a new line for the new website’s domain name. For our website named “examplename.com”, add a line like this:

ServerName examplename.com

Save changes to the configuration file, and then exit vi.

Now you’ll need to modify Apache to display the new domain names to web visitors. Fortunately, you can do this with the a2ensite command:

sudo a2ensite examplename.conf

(Note that “examplename” would change depending upon what you named your configuration file.)

One final step – restart Apache to force it to re-read its configuration files and start serving the new website:

sudo /etc/init/d apache2 reload

Make sure you have some sort of index.html file in /var/w2, and the examplename.com website should now be working.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Install And Configure Apache Web Server on Ubuntu

ApacheVirtualHosts

As installations go, installing Apache on Ubuntu 13.10 Saucy Salamander is a breeze. (Configuring it, of course, is substantially more difficult.) To install Apache, type this command at a Terminal window or a command prompt:

sudo apt-get install apache2

(Technically, you’ll be installing Apache 2, the latest version.)

Enter your password to authenticate, follow the default prompts, and apt will download and install the Apache web server for you.

And that’s it! Apache should now be working. To test it from the web server itself, go to a web browser and visit the address http://127.0.0.1 . You’ll remember that this is the “local loopback” address, basically the IP address the local computer uses to refer to itself. Alternatively, you could test it from another computer on the same subnet. For instance, if you installed Apache on a computer with an IP address of 192.168.1.100, you could test it by going to another computer on the same subnet and visiting http://192.168.100 from the web browser.

Regardless, if Apache is working properly, you should see a web page with only two words on it:

It works!

Apache is now operational.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Check Disk Space Usage In Ubuntu 14.04 Trusty Tahr

DiskSpace

Hard drives have gotten ever larger, but it’s still important to keep disk space usage under control. If you’re using a netbook with a small solid-state hard drive, then keeping disk usage under tight control is especially important. Fortunately, Ubuntu 14.04 Trusty Tahr has a number of easy Terminal commands for taking a quick look at your disk usage.

The first command is df, which will produce an output that will show you the various filesystems on your computer, along with the percentage currently used. However, the numbers shown are in 1k blocks, which may be difficult to read if you’re not used to it. Using df -h will produce an output that will have the sizes are sorted into gigabytes, megabytes, and kilobytes, making it much easier to read.

You can also use a Terminal command to check the size of an individual directory. For instance, if you wanted to check the size of your Documents directory, you would use this command:

du -hs Documents

This will give you the combined size of your Documents folder, along with any subfolders.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Install And Configure And FTP Server With vsftpd In Ubuntu 14.04 Trusty Tahr

UbuntuFTP

FTP stands for “file transfer protocol”, and it allows you to transfer files to a remote computer. FTP has been around forever, and it has a number of pros and cons. Since FTP is so old, it is supported on virtually every operating system, and most operating systems include an FTP client of some kind. Ubuntu 14.04 Trusty Tahr can act as an FTP server with a reasonable degree of security. In this post, we’ll show you how to set up Ubuntu as an FTP server.

The most common FTP server software for Ubuntu is the vsftpd package, which stands for “very secure FTP daemon.” It’s the default FTP package for Ubuntu, and most other Linux distributions as well. As an added bonus, vsftpd is pretty secure out of the box – to make it insecure, you have to go out of your way to mess up the configuration file.

As an added bonus, vsftpd is simple to install and configure on a Ubuntu machine. To install the vsftpd package, make your way to a command prompt and type this command:

sudo apt-get install vsftpd

Enter your password to authenticate and apt will download and install vsftpd for you.

Follow the default prompts, and the vsftpd server will be installed on your computer. Generally, the default configuration for vsftpd is pretty secure, and good enough for casual use. Anonymous users are allowed, but no one can write files to the server (or, in FTP terminology, no one can upload files to the server). However, this configuration isn’t very good if you want people to be able to write files to the server, so we’ll show you how to securely set that up by changing vsftpd’s settings.

If you want to change any settings, the configuration file for vsftpd is /etc/vsftpd.conf. Like any other configuration file, you can edit it with vi:

sudo vi /etc/vsftpd.conf

The vsftpd.conf file contains a large number of “directives” that govern how the server behaves and operates. If you want to change its configuration, you’ll need to alter the directives.

If you want people with local user accounts on the FTP server to be able to connect via FTP (you usually do), you will need to change this directive:

#local_enable=YES

To this:

local_enable=YES

If you do not change this directive, only anonymous users will be able to log into your FTP server, which is bad. (More on that below.)

If you want users to be able to write files to your FTP server, change this directive:

#write_enable=YES

To this:

write_enable=YES

With the write_enable directive set to YES, users will be able to upload files to your FTP server. Note, however, that they will only be able to do so if they have proper permissions to the directories in question. They’ll be able to upload files to their home directories, but not, for instance /var or /usr.

Anonymous access is controlled with this directive:

anonymous_enable=NO

Under no circumstances should you allow anonymous access to your FTP server, especially if it is accessible from the Internet! There are certain circumstances when you might find it useful, but you should only enable it if you know exactly what you are doing. Generally, it is almost always best to keep anonymous_enable set to NO. Especially if you allow users to write files to your FTP server, then it is very important to have anonymous_enable set to NO.

If you make any changes to the file, switch vi to command mode, save the changes, and then exit vi. Then restart the vsftpd server so it reads its new directives:

sudo service vsftpd restart

Your Ubuntu machine should now have a functional FTP server.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Set Up A SFTP Server On Ubuntu 14.04 Trusty Tahr

NautilusLaunch

SFTP (SSH File Transfer Protocol) is basically the File Transfer Protocol run over an SSH connection. Since it uses SSH’s encryption, it’s much more secure than traditional FTP. As an added bonus, there’s no need to set up a separate SFTP server – the OpenSSH Server package includes a built in SFTP server, which is also governed by the /etc/ssh/sshd_config file. Like with an FTP server, you need an SFTP client – but Ubuntu (and most Linux distributions) include one by default.

To create an SFTP server on your Ubuntu 14.04 Trusty Tahr machine, first install the OpenSSH server and configure it.

Once your new SSH server is installed and configured, you can access the SFTP server using the SFTP client from the command line by simply typing:

sftp

However, it’s far easier to use if you know the IP address of the SSH server you want to access. Let’s say you want to access a SSH server with an IP address of 192.168.1.100. To do so, you would append the IP address to the sftp client command:

sftp 192.168.1.100

The SSH client will then ask for your username. (Note that this will be your username and password on the SSH server, not the computer with the SFTP client.) Type it and hit enter. The client will ask for your password, which you should then enter. Once you do, you’ll be taken to the SFTP prompt, which looks like this:

sftp>

You can also specify a different username as part of the sftp command. If, for instance, you wanted to use an account called camalas to connect to the SSH server at 192.168.1.100, the command would look like this:

sftp camalas@192.168.1.100

If you set up the SSH server to listen on a different port than the default of port 22, you’ll need to tell the SFTP client to use a different port with the “-P” switch. Note that this is different than the SSH client, which uses the “-p” switch – remember that the Linux command line is case-sensitive. To make the SFTP client use the 5589 port, the command should look like this:

sftp –P 5589 192.168.1.100

Once at the sftp  prompt, you can use some of the common terminal commands. To see a listing of the remote directory, you can use the ls command:

ls

This will display the contents of the remote directory.

To find which remote directory you’re actually in, you can use the pwd command:

pwd

This command stands for “print working directory”, and will display the current working directory.

To download files from the SSH server, you will need to use the get command. For instance, to retrieve a file named “report.doc” from the current working directory:

get report.doc

This will download the file to your local home directory.

To upload files to the SSH server, you’ll need to use the put command. To put a file named “data.doc” on the remote server:

put data.doc

This will upload the file to the remote directory on the SSH server.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Install And Configure Samba For File Sharing On Ubuntu 14.04 Trusty Tahr

NautilusLaunch

One of the most common uses of a Ubuntu 14.04 Trusty Tahr machine – whether a server or a desktop – is to share files across the network. If you’re not familiar with the term, “file sharing” means to make a folder on your system available to clients on the network. From their own machines, users are able to access your shared folder from their computers, and depending upon how you’ve configured the security, they can copy the files for themselves, alter the files, add new files, or even delete files.

There are a number of different programs that offer file-sharing capabilities. Most Ubuntu systems use the “Samba” software, since it is can easily share files with Windows-based computers. It’s common to find organizations that have a number of users with Windows systems storing their data on a Linux server running Samba.

In this post we’ll show you how to set up a basic Samba server, and how to access those shares from client computers, on a Ubuntu machine.

Samba has a vast array of options and configuration settings, but here we’ll show you how to set up and configure a basic Samba server with one user.

First, you’ll need to install Samba. Make your way to a command prompt and type this command:

sudo apt-get install samba

Enter your password to authenticate, and apt will download and install Samba and its attendant utilities for you.

It’s important to realize about Samba is that it stores its own set of user accounts, separate from the main accounts, in the /etc/samba/smbpasswd file. That means you’ll need to create a separate Samba password for every user you want to access your file shares. You create this password using the smbpasswd command. For example, to create a command for a user named camalas, here’s how the command should look:

sudo smbpasswd -a camalas

Be sure to give camalas’s Samba account an appropriately strong password (make sure it includes uppercase, lowercase, punctuation, and numbers). Once camalas’s password is created, the next step is to create a directory for her to share. Begin by creating a folder named ‘test’ in camalas’s folder, which we’ll use for our first shared folder:

mkdir /home/camalas/test

(NOTE: DO NOT use sudo to create the folder, because then the owning user and group will be set as ‘root’, which means you won’t be able to access the folder using your Samba username and password.)

The next step is to edit the /etc/samba/smb.conf file, the main configuration file for Samba. As always, make a safe backup copy of the original smb.conf file to your home folder, in case you make an error:

sudo cp /etc/samba/smb.conf ~

Now use vi to edit the /etc/samba/smb.conf file:

sudo vi /etc/samba/smb.conf

The smb.conf file is long and rather complex, but for the purposes of this demonstration, you can ignore most of it. Key down to the very end of the file and insert this text:

[test]

path = /home/camalas/test

available = yes

valid users = camalas

read only = no

browsable = yes

public = yes

writable = yes

(There should be no spaces between the lines, and note also that there should be a single space both before and after each of the equal signs.)

Here’s what some of the more important configuration options mean.

-The “[test]” gives the name of the file share.

-The “path” option specifies the location of the folder to be shared.

-The “available” option specifies that the file share is available to clients on the network.

-The “valid users” option details the users that are allowed to access the file share. In this case, we’ve set it so that only the camalas account can access it. You can add additional accounts here, if you prefer.

-The “read only” options specifies whether nor not clients will be allowed to write to the file share.

-The “writable” option specifies that data can be written to the file share.

The settings specified above will share the test folder we created earlier, and give your username and your username alone permission to read and write to the folder. Once you have input the changes, save smb.conf, exit vi, and restart Samba with this command:

sudo restart smbd

(This will force Samba to restart, re-reading its configuration files and activating the share you just created.)

Once Samba has restarted, use this command to check your smb.conf for any syntax errors:

sudo testparm

If you pass the testparm command, Samba should be working. Try accessing the share from another client on your LAN.

-JM

ADDITIONAL READING:

Ubuntu: 101 Tips & Tricks

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide