CHAPTER 10
Ubuntu Server is an operating system created from the vision and the idea of Mark Shuttleworth, who gathered a bunch of people in April 2014 to ask them for a better operating system. These people named themselves the Warthogs and gave themselves a six-month deadline to build a proof-of-concept OS, and named that first release the Warty Warthog.
The Warty Warthog exceeded the group’s expectations and the most optimistic predictions, and became Ubuntu. The name “Ubuntu” was taken from a South African term that can be translated as “humanity toward others.”
In order to sustain the Ubuntu vision, and going beyond that vision, Mark Shuttleworth founded a company named Canonical Ltd. The primary goal of this company was the development and support of the Ubuntu distribution. Canonical ensures that Ubuntu’s bottom-line commitments are kept.
Ubuntu Server is available for the three major architectures: Intel X86, AMD64, and ARM. A computer with 512 MB of RAM and a 1 GHz processor can be used to install Ubuntu. The installation program can be downloaded from the Ubuntu website as an ISO image file.
To start the installation process, the ISO image file must be burned to a CD/DVD disc. Then, the CD/DVD disc must be placed in a CD/DVD drive in order to make the computer boot with the installation program.
The installation process takes a series of steps, starting with the language selection for the process and the user interface. During the installation, the user can configure the keyboard layout, the network parameters for the server, and the system clock.
To make the computer boot with Ubuntu, a hard disk must be used to store the operating system. A process called hard disk partitioning must be performed first. Disk partitioning is the creation of one or more regions on a hard disk or other kind of storage, so that an operating system can manage data in each region separately. Once the partitions are created, the disk stores the information about their locations and sizes in a special area known as the partition table.
To create partitions, Ubuntu needs to identify the hard disks attached to the computer. The naming convention for a hard drive starts with a slash and the dev abbreviation. This abbreviation stands for “device.” Then, dev is followed by another slash and the sd abbreviation, which stands for SCSI (Small Computer System Interface) device. An example for a hard disk identification would be /dev/sd and a letter at the end, starting with a. So, the first drive found in the computer would be /dev/sda, the second disk would be /dev/sdb, and so on.
Once a disk partition is created, it needs to be formatted before it can be used. This process includes stamping the partition with a file system, which is a way to name and place files logically. There are several file systems available for Ubuntu, such as Ext4, Ext3, and Ext2. Besides these, there’s another type called swap. Swap is a small section of unformatted hard disk that Ubuntu uses as virtual memory.
Ubuntu needs to create mount points in order to work properly. A mount point is a directory (typically empty) in the file system that is in the hard drive. The common mount points in Ubuntu are /boot, which stores the boot loader files; / (root), which is the root directory; and /home, which stores all users’ files and directories.
The user must enter a username and password, which will be used to work with the system before the installation process starts copying files to the hard disk. The installation program will ask for a confirmation to ensure that the password was entered correctly.
After the installation process ends, the user must provide a username and password to log in to the system. If this succeeds, the command prompt will be shown on the screen. The command prompt is the place where the user must type text commands in order to work with the server.
A command named sudo is the most important in Ubuntu, and is used to grant superuser and other privileges to any command that is executed along with it. This is the best option for doing administrative tasks, because every time sudo ends its execution, it revokes the elevated privileges and brings the system to a normal user state. In that way, fatal accidents can be avoided, the because sudo command always asks for the active user password. A file named sudoers can modify this behavior. The sudoers file tells the sudo command which users can gain superuser privileges, and in some cases, how certain commands must be executed, and by whom.
Every file or directory stored in the filesystem must have a name. This name must follow certain rules to be used, such as the name for a file or directory must be unique within the location where it is placed. Also, all names are case sensitive. This means that a file named Place is different from another named place.
There are commands available to navigate within the Ubuntu Server filesystem. The user can see the files and directories in the system with the ls command, and can move around using the cd command. Also, file viewing is allowed by using the ls command, which displays the content of a file on the screen. The mkdir command is used to create a new directory and the touch command creates a new empty file.
Ubuntu Server takes into account security issues as well. For this reason, it disables the root administrative account by default to prevent accidents and possible system malfunction. Adding and deleting users or groups is another important way to keep the system safe. To perform these actions, the commands adduser, useradd, deluser, userdel, addgroup, groupadd, delgroup, and gropupdel are available. It’s highly recommended to protect each user’s home directory using the chmod command to assign the value 750 to the directory’s permissions. Changing the value of the DIR_MODE variable located in the /etc/adduser.conf file to 750 will protect the home directory for each new user added to the system from other users’ access.
Password policies ensure that security breaches can be avoided. Establishing a minimum password length in the /etc/pam.d/common-password file and forcing users to change their passwords periodically by editing the /etc/login.defs file are good security practices.
Granting ownership and permissions to files and directories makes security complete. The chown and chmod commands are used to do this. Permissions can be identified with alphabetic notation, which uses the letters r, w, and x for read, write, and execute permissions. Octal notation also exists, and uses a series of values between 0 and 7 to represent the read (r = 4), write (w = 2), and execute (x = 1) permissions. A value of 0 signifies access restriction.
Networking is a substantial theme when installing and configuring a computer as a server. Ubuntu Server has a series of commands that allow you to configure the server in the network. A list of all available interfaces can be obtained with the ifconfig –a | grep –I eth command, and detailed information about a network adapter can be displayed with the sudo lshw –class network command. The ethtool command allows the user to view the adapter settings and gather statistics about it.
IP addressing is another important issue in networking. This means assigning an IP address to any device in the network. An IP address is a 32-bit numeric value defined under the Ipv4 protocol to identify and address a location for a device in the network. The Ipv4 protocol divides networks into five classes, A, B, C, D, and E. For private networks (built at a home or office), the classes A, B, and C are used. The ifconfig command allows you to manage IP addressing in Ubuntu Server. This kind of IP addressing is known as static IP addressing. Ubuntu Server also allows dynamic (automatic) IP addressing. In order to establish dynamic or static addressing by default, the /etc/network/interfaces file must be edited.
Dynamic IP addressing is possible because of the DHCP protocol. This protocol allows a device in the network to be in charge of assigning IP addresses to other connected devices. This device is known as a DHCP server. Ubuntu can be used as a DHCP server by installing the isc-dhcp-server service.
The networking process allows you to synchronize the system’s clock with a remote server’s time. To do this, the NTP (Network Time Protocol) must be used. Ubuntu manages NTP with the ntpdate command and the ntpd service.
In most scenarios, computer networks work with both Ubuntu Server or Ubuntu Desktop computers and Windows computers. It’s necessary to make them work in harmony. Ubuntu Server includes the Samba suite for Windows networking. It is necessary to configure Samba as a file server for sharing resources with Windows computers by using the sudo apt-get install samba command.
Samba can be used for customization by editing the /etc/samba/smb.conf file. This file consists of sections and parameters. Each section is identified with a name enclosed in brackets, and there are three of them that are special: global (which allows you to define the parameters for the whole Samba server operation), homes, and printers. Every additional section defines a share, which is a shared network resource. The file can have as many of those shares as needed.
Each section in the /etc/samba/smb.conf file contains parameters. A parameter is a value that tells Samba how to behave. An example of a parameter is workgroup, which indicates the name for the group of computers in the network, and it’s declared in the global section of the file.
The printers section of the /etc/samba/smb.conf file contains the parameters needed to browse and access all the printers installed in Ubuntu Server. The server must have a working CUPS (Common UNIX Printing System) installation to share printers.
Secure access to files and printers can be configured in Samba. There are two security levels: user-level and share-level. User-level security mode enforces every user to supply credentials (username and password). Share-level security mode allows you to define which users or groups of users are allowed to access shared resources.
A computer running Ubuntu Server can be a host for a DBMS (database management system) in order to store and process data over a network. Ubuntu Server provides two popular database systems: PostgreSQL and MySQL.
Both PostgreSQL and MySQL can be installed by using the sudo apt-get install command. The difference is the name of the package to be installed. For PostgreSQL, the package is named postgresql, and for MySQL, the name of the package is mysql-server.
In the MySQL installation process, a dialog box will be shown to provide a password for the root user. The root user is the one with all administrative privileges for managing the database server.
In PostgreSQL, the administrative user is called postgres. To assign a password for that user, a connection to the template1 database needs to be made. This connection can be done with the sudo –u postgres psql template1 command. This command will show the PostgreSQL command prompt. Then, using the ALTER USER postgres WITH ENCRYPTED PASSWORD '<user_password>' command, a new password for the postgres user will be assigned.
Ubuntu Server provides a GUI (graphical user interface) to replace the command line that is installed by default. This interface is called the desktop environment and can be deployed by using the sudo apt-get update and sudo apt-get installbuntuu-desktop commands.
Once installed, the Login screen replaces the text login prompt. The user needs to supply a username and password to access the system.
The main program of the desktop interface is Ubuntu Desktop, which provides a point of entry for all applications installed in the system, and for all system management programs available.
The main element for user interaction in the desktop environment is called a dialog. A dialog has a series of elements, each with a particular function. A dialog’s elements can be used by clicking on them using the pointer. Some of these elements allow the user to enter text when it is needed.
The desktop environment provides a set of graphical applications to mimic the behavior of text commands. One of these applications is the file explorer dialog (Files), which is the equivalent of the ls command.
The shutdown and reboot commands have a graphical equivalent, called the Shut Down dialog. This dialog can be launched by clicking the Shut Down option in the Settings menu. This menu is accessed by clicking the gear icon, located in the upper-right corner of the Ubuntu Desktop screen.
A user’s session can be locked by pressing the Super (Windows logo) key+L, bringing up the lock screen. To get back into the working session, the user must enter a password.
There are several tools in the desktop environment available for managing the system. The System Settings dialog is used to customize the interface, the hardware, and the global system settings. The Ubuntu Software Center is a tool provided to manage installed applications and to install new ones. The Dash is an interface used for searching for any content in the system or on the web. The type of content searched for can be files, directories, applications, music, images, or videos. Sometimes, typing a text command is a better choice instead of using the graphical interface. For doing this, Ubuntu provides an interface called Terminal. Any of the text commands explained in this book can be used in the Terminal interface.
Finally, the user can execute a series of commands at once by placing them in a text file called a shell script. This file can be created using a text editor. The interpreter for this script is called bash. There are others available as well, like dash or python. For the most part, commands that can be entered on the command line are suitable for a shell script.