Book Image

Linux Administration Cookbook

By : Adam K. Dean
Book Image

Linux Administration Cookbook

By: Adam K. Dean

Overview of this book

Linux is one of the most widely used operating systems among system administrators,and even modern application and server development is heavily reliant on the Linux platform. The Linux Administration Cookbook is your go-to guide to get started on your Linux journey. It will help you understand what that strange little server is doing in the corner of your office, what the mysterious virtual machine languishing in Azure is crunching through, what that circuit-board-like thing is doing under your office TV, and why the LEDs on it are blinking rapidly. This book will get you started with administering Linux, giving you the knowledge and tools you need to troubleshoot day-to-day problems, ranging from a Raspberry Pi to a server in Azure, while giving you a good understanding of the fundamentals of how GNU/Linux works. Through the course of the book, you’ll install and configure a system, while the author regales you with errors and anecdotes from his vast experience as a data center hardware engineer, systems administrator, and DevOps consultant. By the end of the book, you will have gained practical knowledge of Linux, which will serve as a bedrock for learning Linux administration and aid you in your Linux journey.
Table of Contents (15 chapters)

Quick sudo explanation

In the various commands that were given in the preceding recipe, we used sudo repeatedly. This was so that we didn't have to log in as the root user to perform various restricted actions.

sudo is a contraction of 'superuser do' because sudo used to be used for running commands as the "superuser" only, nowadays you can use it to run commands as various users.

Generally, if you attempt to run a command that you lack permissions to complete successfully, you'll be greeted with an error:

$ less /etc/sudoers 
/etc/sudoers: Permission denied

Here, I tried to have a look at the /etc/sudoers file, which also happens to be the file that determines a user's sudo privileges.

Running this command with sudo is a different story. Instead, it opens the file for me, dropping me into the less pager.

Toward the bottom of this file, we find the following block:

## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL

The wheel portion of this block is uncommented, and the text above that tells us what that means.

So, the obvious next question is, am I in the wheel group?

The term wheel has ancient origins in old-school UNIX installations. These, days it might be called admin or other. CentOS keeps it classic by using wheel.

Thankfully, this is very easy to check the file in question is always in the same place: /etc/group.

Here, we print the contents of the group file to our screen, and look specifically for wheel.

We see the following layout:

group_name:password:GID:user_list

We can see that the group_name is wheel, the password is a lower x, which means that shadow passwords are being used, the group ID is 10, and the only user in this group is myself:

$ sudo cat /etc/group | grep wheel
wheel:x:10:adam

We can even do this with a single word, that being the groups command, which prints the groups that your current user is a member of:

$ groups
adam wheel

Being granted the ability to run superuser commands with sudo isn't the immediate right of everyone on the system, and it's up to the individual company and administration team to decide how that power is distributed.

There are places where everyone in operations has the power of sudo, and places where one person has that power.