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
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781788997089
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 197.97
Linux: Powerful Server Administration
$99.99
Mastering Ubuntu Server
$48.99
Linux Administration Cookbook
$48.99
Total $ 197.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.