Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Mastering Ubuntu Server
Mastering Ubuntu Server

Mastering Ubuntu Server: Master the art of deploying, configuring, managing, and troubleshooting Ubuntu Server 18.04 , Second Edition

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering Ubuntu Server

Managing Users

As an administrator of Ubuntu-based servers, users can be your greatest asset and also your biggest headache. During your career, you'll add countless new users, manage their passwords, remove their accounts when they leave the company, and grant or remove access to resources across the filesystem. Even on servers on which you're the only user, you'll still find yourself managing user accounts since even system processes run as users. To be successful at managing Linux servers, you'll also need to know how to manage permissions, create password policies, and limit who can execute administrative commands on the machine. In this chapter, we'll work through these concepts so that you'll have a clear idea of how to manage users and their resources.

In particular, we will cover:

  • Understanding when to use root
  • Creating and removing users...

Understanding when to use root

In the last chapter, we set up our very own Ubuntu Server installation. During the installation process, we were instructed to create a user account as an administrator of the system. So, at this point, we should have two users on our server. We have the aforementioned administrative user, as well as root. We can certainly create additional user accounts with varying levels of access (and we will do so in this chapter), but before we get to that, some discussion is in order regarding the administrator account you created, as well as the root user that was created for you.

In regard to root, the root user account exists on all Linux distributions and is the most powerful user account on the planet. The root user account can be used to do anything, and I do mean anything. Want to use root to create files and directories virtually anywhere on the filesystem...

Creating and removing users

Creating users in Ubuntu can be done with one of either of two commands: adduser and useradd. This can be a little confusing at first, because both of these commands do the same thing (in different ways) and are named very similarly. I'll go over the useradd command first and then I'll explain how adduser differs. You may even prefer the latter, but we'll get to that in a moment.

First, here's an example of the useradd command in action:

sudo useradd -d /home/jdoe -m jdoe
As we go along in this book, there will be commands that require root privileges in order to execute. The preceding command was an example of this. For commands that require such permissions, I'll prefix the commands with sudo. When you see these, it just means that root privileges are required to run the command. For these, you can also log in as root (if...

Understanding the /etc/passwd and /etc/shadow files

Now that we know how to create (and delete) user accounts on our server, we are well on our way to being able to manage our users. But where exactly is this information stored? We know that users store their personal files in /home, but is there some kind of database somewhere that keeps track of which user accounts are on our system? Actually, user account information is stored in two special text files:

  • /etc/passwd
  • /etc/shadow

You can display the contents of each of those two files with the following commands. Take note that any user can look at the contents of /etc/passwd, while only root has access to /etc/shadow:

cat /etc/passwd 
sudo cat /etc/shadow

Go ahead and take a look at these two files (just don't make any changes), and I will help you understand them. First, let's go over the /etc/passwd file. What follows...

Distributing default configuration files with /etc/skel

In a typical organization, there are usually some defaults that are recommended for users in terms of files and configuration. For example, in a company that performs software development, there are likely recommended settings for text editors and version control systems. Files that are contained within /etc/skel are copied into the home directory for all new users when you create them (assuming you've chosen to create a home directory while setting up the user).

In fact, you can see this for yourself right now. If you execute the following command, you can view the contents of the /etc/skel directory:

ls -la /etc/skel 
Default /etc/skel files

You probably already know how to list files within a directory, but I specifically called out the -a parameter because the files included in /etc/skel by default are hidden (their...

Switching users

Now that we have several users on our system, we need to know how to switch between them. Of course, you can always just log in to the server as one of the users, but you can actually switch to any user account at any time providing you either know that user's password or have sudo access.

The command you will use to switch from one user to another is the su command. If you enter su with no options, it will assume that you want to switch to root and will ask you for your root password. As I mentioned earlier, Ubuntu locks out the root account by default, so you really don't have a root password. Unlocking the root account is actually really simple; all you have to do is create a root password. To do that, you can execute the following command as any user with sudo access:

sudo passwd 

The command will ask you to create and confirm your root password....

Managing groups

Now that we understand how to create, manage, and switch between user accounts, we'll need to understand how to manage groups as well. The concept of groups in Linux is not very different from other platforms and pretty much serves the exact same purpose. With groups, you can more efficiently control a user's access to resources on your server. By assigning a group to a resource (a file, directory, and so on), you can allow and disallow access to users by simply adding them or removing them from the group.

The way this works in Linux is that every file or directory has both a user and a group that takes ownership of it. This is contrary to platforms such as Windows, which can have multiple groups assigned to a single resource. With Linux, it's just a one-to-one ownership: just one user and just one group assigned to each file or directory. If you...

Managing passwords and password policies

In this chapter, we've already covered a bit of password management, since I've given you a few examples of the passwd command. If you recall, the passwd command allows us to change the password of the currently logged-in user. In addition, using passwd as root (and supplying a user name) allows us to change the password for any user account on our system. But that's not all this command can do.

One thing I've neglected to mention regarding the passwd command is the fact that you can use it to lock and unlock a user's account. There are many reasons why you may want to do this. For instance, if a user is going on vacation or extended leave, perhaps you'd want to lock their account so that it cannot be used while they are away. After all, the fewer active accounts, the lower your attack surface. To lock an account...

Configuring administrator access with sudo

By now, we've already used sudo quite a few times in this book. At this point, you should already be aware of the fact that sudo allows you to execute commands as if you were logged in as root. However, we haven't had any formal discussion about it yet, nor have we discussed how to actually modify which of your user accounts are able to utilize sudo.

On all Linux systems, you should protect your root account with a strong password and limit it to be used by as few people as possible. On Ubuntu, the root account is locked anyway, so unless you unlocked it by setting a password, it cannot be used to log into the system. Using sudo is an alternative to using root, so you can give your administrators access to perform root tasks with sudo without actually giving them your root password or unlocking the root account. In fact, sudo...

Setting permissions on files and directories

In this section, all the user management we've done in this chapter so far all comes together. We've learned how to add accounts, manage accounts, and secure them but we haven't actually done any work regarding managing the resources as far as who is able to access them. In this section, I'll give you a brief overview of how permissions work in Ubuntu Server and then I'll provide some examples for customizing them.

I'm sure by now that you understand how to list the contents of a directory with the ls command. When it comes to viewing permissions, the -l flag is especially handy, as the output that the long listing provides allows us to view the permissions of an object:

ls -l 

The following are some example, hypothetical file listings:

-rw-rw-rw- 1 doctor doctor   5          Jan 11   12:52 welcome 
-rw...

Summary

In the field, managing users and permissions is something you'll find yourself doing quite a bit. New users will join your organization, while others will leave, so this is something that will become ingrained in your mental toolset. Even if you're the only person using your servers, you'll find yourself managing permissions for applications as well, given the fact that processes cannot function if they don't have access to their required resources. In this chapter, we took a lengthy dive into managing users, groups, and permissions. We worked through creating and removing users, assigning permissions, and managing administrative access with sudo. Practice these concepts on your server. When you get the hang of it, I'll see you in our next chapter, where we'll discuss all things related to storage. It's going to be awesome.

...

Questions

  1. Which command should you place in front of commands that require root privileges?
  2. Name at least one of the two commands you can use to create a new user on Ubuntu Server.
  3. Which command can you use to remove a user?
  4. Which two files on the Linux filesystem store information regarding user accounts?
  5. What is the name of the directory that stores default configuration files for users?
  6. Assuming you have a user named jdoe, what command would you type to switch to that user?
  7. Assuming you want to create a group named accounting what command would you use to accomplish that?
  8. To add an expiration date to a password, you would use the ____ command.
  9. You should use the _____ command to give a user access to sudo.
  10. The ______ command allows you to change permissions of a file or directory, and the ______ command allows you to change its ownership.
...

Further reading

Left arrow icon Right arrow icon

Key benefits

  • • A practical easy-to-understand book that will teach you how to deploy, maintain and troubleshoot Ubuntu Server
  • • Get well-versed with newly-added features in Ubuntu 18.04.
  • • Learn to manage cutting-edge technologies such as virtualization, containers, Nextcloud and more

Description

Ubuntu Server has taken the data centers by storm. Whether you're deploying Ubuntu for a large-scale project or for a small office, it is a stable, customizable, and powerful Linux distribution that leads the way with innovative and cutting-edge features. For both simple and complex server deployments, Ubuntu's flexible nature can be easily adapted to meet to the needs of your organization. With this book as your guide, you will learn all about Ubuntu Server, from initial deployment to creating production-ready resources for your network. The book begins with the concept of user management, group management, and filesystem permissions. Continuing into managing storage volumes, you will learn how to format storage devices, utilize logical volume management, and monitor disk usage. Later, you will learn how to virtualize hosts and applications, which will cover setting up KVM/QEMU, as well as containerization with both Docker and LXD. As the book continues, you will learn how to automate configuration with Ansible, as well as take a look at writing scripts. Lastly, you will explore best practices and troubleshooting techniques when working with Ubuntu Server that are applicable to real-world scenarios. By the end of the book, you will be an expert Ubuntu Server administrator who is well-versed in its advanced concepts.

Who is this book for?

This book is intended for readers with intermediate or advanced-beginner skills with Linux, who would like to learn all about setting up servers with Ubuntu Server. This book assumes that the reader knows the basics of Linux, such as editing configuration files and running basic commands.

What you will learn

  • • Manage users, groups, and permissions
  • • Encrypt and decrypt disks with Linux Unified Key Setup (LUKS)
  • • Set up SSH for remote access, and connect it to other nodes
  • • Add, remove, and search for packages
  • • Use NFS and Samba to share directories with other users
  • • Get to know techniques for managing Apache and MariaDB
  • • Explore best practices and troubleshooting techniques
  • • Get familiar with scripting
  • • Automate server deployments with Ansible

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 30, 2018
Length: 552 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788997560
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : May 30, 2018
Length: 552 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788997560
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 168.97
Linux: Powerful Server Administration
€94.99
Mastering Ubuntu Server
€36.99
Linux Administration Cookbook
€36.99
Total 168.97 Stars icon
Banner background image

Table of Contents

20 Chapters
Deploying Ubuntu Server Chevron down icon Chevron up icon
Managing Users Chevron down icon Chevron up icon
Managing Storage Volumes Chevron down icon Chevron up icon
Connecting to Networks Chevron down icon Chevron up icon
Managing Software Packages Chevron down icon Chevron up icon
Controlling and Monitoring Processes Chevron down icon Chevron up icon
Setting Up Network Services Chevron down icon Chevron up icon
Sharing and Transferring Files Chevron down icon Chevron up icon
Managing Databases Chevron down icon Chevron up icon
Serving Web Content Chevron down icon Chevron up icon
Learning Advanced Shell Techniques Chevron down icon Chevron up icon
Virtualization Chevron down icon Chevron up icon
Running Containers Chevron down icon Chevron up icon
Automating Server Configuration with Ansible Chevron down icon Chevron up icon
Securing Your Server Chevron down icon Chevron up icon
Troubleshooting Ubuntu Servers Chevron down icon Chevron up icon
Preventing and Recovering from Disasters Chevron down icon Chevron up icon
Using the Alternate Installer Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(20 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




klempk Apr 07, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It seems strange buying a paper technical book in this e-age, but it has proven useful in this case. Having a copy of _Mastering Ubuntu Server_ handy to flip through while working is a nice break from the usual constant web searches for information. And this book encapsulates a surprisingly dense and varied amount of info on myriad topics considering its relative compactness.LaCroix's book cleared up confusion on a number of topics, even ones I'd spent time researching online (where info can be unreliable at best). I've certainly received 5 stars worth of value from it already.The only negatives I can list are the lack of some topics and the slim coverage of others, but that's inevitable in a comprehensive technical manual. The other is the weak index, which has failed to point me to the right location many times. If you are looking for info on a specific command, you will likely have to just browse the chapter related to that command's topic. Neither of these is worth a star deduction (maybe 1/2 star but I'll err on the side of generosity).Overall, a great resource for anyone beyond beginners who want a handy, well organized reference in paper form that won't break the bank or your back.
Amazon Verified review Amazon
Luis Usquiano Apr 22, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Después de terminar ASIR este libro viene de perlas para profundizar en Linux y servicios de red e Internet.
Amazon Verified review Amazon
JPaz Aug 17, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very readable and plenty of valuable information. Concepts and tools are clearly explained and it is a good starting point for Ubuntu administration.
Amazon Verified review Amazon
Michael Doerfler Apr 13, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This has been a great book for me to learn what I have found through google. I am a software developer that has to help administer windows based networks. More of these are adding Linux servers to them and I’ve been learning Linux through google for a very specific task. This book has brought what I’ve encountered into a single resource that has really reinforced and clarified Linux and Ubuntu admin activities I have had to do.
Amazon Verified review Amazon
J McDougal Jan 28, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm not a Linux newbie, but I'm a refugee from Red Hat Linux, so I have a lot to learn about Ubuntu Server 18.04. I love its command line environment, and this book provides all that is required to master it.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.