Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering Ubuntu Server
Mastering Ubuntu Server

Mastering Ubuntu Server: Upgrade your Ubuntu skills

eBook
€28.99 €32.99
Paperback
€41.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

Chapter 2. Managing Users

As an administrator of an Ubuntu Server, 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 file-system. 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 the /etc/passwd and /etc/shadow files
  • Distributing default configuration files with ...

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 regards 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 file-system? No problem. Want to use root to install software? Again, not a problem. The root account can even be...

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:

# useradd -d /home/jdoe -m jdoe

Note

As I mentioned in the front matter for this book, whenever I prefix commands with a pound symbol (#), I'm instructing you to execute the command as root. You can use the actual root account for these types of commands or you can simply prefix the command with sudo. In the latter case, the command would become:

# sudo useradd -d /home/jdoe -m jdoe

I won't remind you of this henceforth, so just keep in mind commands prefixed with # need to be executed as root or with...

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 and /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
# 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 is example output from this file on my test server. For brevity, I limited the output to the last seven lines...

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

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 file names begin with a period). I threw the -l parameter solely because I like it better (it shows a long list, which I think is easier...

Switching between 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 root 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. From this point on, you will be able to use the root account as any other account. You can log in as root,...

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 regards 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 file-system? No problem. Want to use root to install software? Again, not a problem. The root account can even be used...

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:

# useradd -d /home/jdoe -m jdoe

Note

As I mentioned in the front matter for this book, whenever I prefix commands with a pound symbol (#), I'm instructing you to execute the command as root. You can use the actual root account for these types of commands or you can simply prefix the command with sudo. In the latter case, the command would become:

# sudo useradd -d /home/jdoe -m jdoe

I won't remind you of this henceforth, so just keep in mind commands prefixed with # need to be executed as root or with the prefix sudo.

In this example...

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 and /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
# 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 is example output from this file on my test server. For brevity, I limited the output to the last seven lines:

testuser...

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

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 file names begin with a period). I threw the -l parameter solely because I like it better (it shows a long list, which I think is easier to read...

Switching between 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 root 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. From this point on, you will be able to use the root account as any other account. You can log in as root, switch to root...

Left arrow icon Right arrow icon

Key benefits

  • Get well-versed with newly-added features in Ubuntu 16.04
  • Master the art of installing, managing, and troubleshooting Ubuntu Server
  • A practical easy-to-understand book that will help you enhance your existing skills.

Description

Ubuntu is a Debian-based Linux operating system, and has various versions targeted at servers, desktops, phones, tablets and televisions. The Ubuntu Server Edition, also called Ubuntu Server, offers support for several common configurations, and also simplifies common Linux server deployment processes. With this book as their guide, readers will be able to configure and deploy Ubuntu Servers using Ubuntu Server 16.04, with all the skills necessary to manage real servers. The book begins with the concept of user management, group management, as well as file-system permissions. To manage your storage on Ubuntu Server systems, you will learn how to add and format storage and view disk usage. Later, you will also learn how to configure network interfaces, manage IP addresses, deploy Network Manager in order to connect to networks, and manage network interfaces. Furthermore, you will understand how to start and stop services so that you can manage running processes on Linux servers. The book will then demonstrate how to access and share files to or from Ubuntu Servers. You will learn how to create and manage databases using MariaDB and share web content with Apache. To virtualize hosts and applications, you will be shown how to set up KVM/Qemu and Docker and manage virtual machines with virt-manager. Lastly, you will explore best practices and troubleshooting techniques when working with Ubuntu Servers. By the end of the book, you will be an expert Ubuntu Server user 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

  • Learn how to manage users, groups, and permissions
  • Encrypt and decrypt disks with Linux Unified Key Setup /Luks
  • Setup SSH for remote access, and connect it to other nodes
  • Understand how to 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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 27, 2016
Length: 430 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287138
Vendor :
Canonical
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 : Jul 27, 2016
Length: 430 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287138
Vendor :
Canonical
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 120.97
Ubuntu Server Cookbook
€41.99
Mastering Ubuntu Server
€41.99
Practical Linux Security Cookbook
€36.99
Total 120.97 Stars icon

Table of Contents

15 Chapters
1. Deploying Ubuntu Server Chevron down icon Chevron up icon
2. Managing Users Chevron down icon Chevron up icon
3. Managing Storage Volumes Chevron down icon Chevron up icon
4. Connecting to Networks Chevron down icon Chevron up icon
5. Managing Software Packages Chevron down icon Chevron up icon
6. Controlling and Monitoring Processes Chevron down icon Chevron up icon
7. Managing Your Ubuntu Server Network Chevron down icon Chevron up icon
8. Accessing and Sharing Files Chevron down icon Chevron up icon
9. Managing Databases Chevron down icon Chevron up icon
10. Serving Web Content Chevron down icon Chevron up icon
11. Virtualizing Hosts and Applications Chevron down icon Chevron up icon
12. Securing Your Server Chevron down icon Chevron up icon
13. Troubleshooting Ubuntu Servers Chevron down icon Chevron up icon
14. Preventing and Recovering from Disasters Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(10 Ratings)
5 star 70%
4 star 10%
3 star 20%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Kinger Nov 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Really an excellent tutorial on setting up and managing Ubuntu servers. I've subscribed to many online courses (assorted Udemy, Linux Academy subscription, Linux Foundation...) and this book has gotten me working and understanding much more quickly than the rest. Examples are very clear and the writing style is engaging, not the typical dry delivery of a lot of books on this topic. Highly recommended!
Amazon Verified review Amazon
Amazon Customer Jul 16, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
One of the best Linux server books I have read. Very thorough and detailed.This book is never on the shelf in the ops room and is always on someone's desk with the pages opened or has taken it home or is sitting in the server room next to a keyboard.Covers new OS issues.I have also seen some of Jay's work on Kubernetes, Sonatype, security, and AWS and found it a guide to survival in DevOps/DevSecOps world. I hope Jay will publish something in these areas as well in the future. Even a short guide or how to.
Amazon Verified review Amazon
klikmaker Oct 09, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've never bought or read any of Jay LaCroix's books before, but based on the strength of his video tutorials I thought this would be a good buy. I mean, if a complete noob and dope like me can install Arch Linux from a guy's tutorials, a book by the same person should be good, right?The answer is: yup, right, definitely. I'm about 20% through the book and am certain I made a good choice. I have found everything to be clear, understandable, relevant, relatable, and jam-packed with good old common sense.It's an interesting experience in that his writing style is very much like his speaking style. I can practically hear his tutorial voice in my head as I read, and, as I intimated, that voice has been instrumental in me learning many Linux-esque things I otherwise would not have. (I wonder if he somehow "speaks" his books, then transcribes them?)So five stars from me. Thanks for writing this book, Jay.
Amazon Verified review Amazon
CCS4George Oct 20, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have been in the computer industry for over 20 years and I have always been a windows person. However, over the last 5-6 years I’ve started using Linux/Ubuntu as well. I purchased this book specifically to use as a handbook and as a reference for the many areas that I’m lacking. This book fills in knowledge gaps as well as help with best practices. There is a lot more I want to explore with Ubuntu and this book will help me with that.I highly recommend this book for anyone that is just starting out, just wants to understand the basics, or for the more advanced administrators that need to keep your skills well-polished.
Amazon Verified review Amazon
Mr. G. J. Sivill Dec 07, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good text book on Ubuntu.
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.