Linux Important
Linux Important
[Total Marks: 75
b. What are the network files to be changed when we setup or move the system?
Explain each in brief.
In addition to configuring the network cards on each of the computers in the network, three files
on each computer need to be modified. These files are all located in the /etc directory:
■■ /etc/nsswitch.conf
■■ /etc/hosts
■■ /etc/resolv.conf
■■ /etc/sysconfig/network
The /etc/nsswitch.conf file contains configuration information for the name resolver and should
contain the following line:hosts: files dns
This configuration tells the name resolver to check the /etc/hosts file before attempting to query
a name server and to return all valid addresses for a host found in the /etc/hosts file instead of
just the first. The /etc/hosts file could contain the names of all the computers on the local
network, or an outside network. For a small network, maintaining this file is not difficult, but for
a large network, like the Internet, keeping the file up to date is often impractical.
The /etc/resolv.conf file provides information about name servers employed to resolve
hostnames.
The /etc/sysconfig/network file contains two lines, as follows:
NETWORKING=yes
HOSTNAME=(host and domain name of your system)
The first line enables networking for your system. The second line displays the hostname of your
system and the name of the domain to which it belongs.
c. What are the tasks to be performed to setup Timeserver? Explain the steps to
configure NTP Server and NTP client.
Configuring the Time Server
Setting up your time server requires a small amount of preparation, implementation,
and verification. You’ll need to perform the following tasks:
1. Install the NTP software.
2. Locate suitable time servers to serve as reference clocks.
3. Configure your local time server.
4. Start the NTP daemon on the local time server.
5. Make sure that the NTP daemon responds to requests.
NTP Client
Configuring an NTP client requires fewer steps than configuring a server does. You select the
server to use as a reference clock, start the NTP daemon, ntpd, and you’re done. The GUI-
addicted can use the Date/Time Properties tool. Either start it from the menu (Red Hat ➪ System
Settings ➪ Date & Time) ortype system-config-date at a command prompt
d. What is caching proxy server? What are the steps in configuring squid? Explain
A caching proxy
server is software (and potentially hardware) that stores (caches) frequently requested Internet
objects such as Web pages, Java scripts, and downloaded files closer (in network terms) to the
clients that request those objects. When a new request is made for a cached object, the proxy
server provides the object from its cache instead of allowing the request to go to the source. That
is, the local cache serves the requested object as a proxy or substitute for the actual server. The
motivation for using a caching proxy server is two-fold: to provide accelerated Web browsing by
reducing access time for frequently requested objects and to reduce bandwidth consumption by
caching popular data locally, that is, on a server that exists between the requesting client and the
Internet. The HTTP acceleration feature speeds up Web browsing because cached pages need not
be re-retrieved unless the original page has been updated since it was last cached.
The Squid configuration file on Fedora Core and RHEL systems is /etc/squid/squid.conf. The
initialization script that controls Squid is /etc/rc.d/init.d/squid, which reads default values from
/etc /sysconfig/squid. For your initial experimentation with Squid, only modify the Squid
configuration file. It would easily consume several chapters to describe Squid’s configuration and
tuning adequately, so to get you up and running quickly, this section focuses on the bare
minimum. You definitely want to spend some quality time with the configuration file’s
comments, because they are complete, understandable, and do a fine job of telling you more than
you probably want to know about Squid’s care and feeding. Table lists the configuration settings
with which you concern yourself in the short term.
4. Attempt any two of the following: 10
a. Write a short note on SSH.
Secure Shell, also known as SSH, is a secure Telnet replacement that encrypts all traffic,
including passwords, using a public/private encryption key exchange protocol. It provides the
same functionality of Telnet, plus other useful functions, such as traffic tunneling.
This is what it looks like to SSH into a machine for the first time:
[vnavrat@buffy vnavrat$ ssh [email protected]
The authenticity of host ‘woolf.xena.edu (123.456.789.65)’
can’t be established.
RSA key fingerprint is
b2:60:c8:31:b7:6b:e3:58:3d:53:b9:af:bc:75:31:63.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘woolf.xena.edu,123.456.789.65’
(RSA) to the list of known hosts.
[email protected]’s password:
Welcome to woolf
Unauthorized usage prohibited. Please check your quotas.
vnavrat:~>
SSH asks you if you want to accept and trust the host key being sent to you as being the real key.
This question is asked only once when you log in to a machine for the first time. After this first
login, SSH behaves exactly like Telnet — you start SSH, it asks for your password, and then you
see a regular terminal screen.
In addition to providing terminal access, SSH tunnels almost any other protocol through it. So, it
is possible to tunnel POP, RCP, and other protocols through SSH to turn them into encrypted,
more secure protocols. With enough imagination and practice, you can make almost anything
more secure with SSH.
Following is an example of how to tunnel your mail through SSH to keep your password and mail
encrypted and secure during transit. In this example, you use POP3 to retrieve your mail from the
remote machine buffy.xena.edu. Normally you would tell your POP3 software to connect from
your localhost to port 110 (the POP port) of buffy.xena.edu. But in this example the first step is
to configure your POP mailer to connect to port 16510 of your own machine, and put in the
password for your account on buffy.xena.edu. The second step is to set up the SSH tunnel,
which encrypts and forwards the traffic over the network to terry.muhlenberg.edu’s
POP port. To set up the SSH tunnel, type the following at the command line:
ssh -N -L 16510:127.0.0.1:110 [email protected]
And voilà! You are now sending and receiving your mail through an encrypted SSH tunnel.
The last line of the xinetd.conf file shown in Listing 19-4 shows the directory location of the
individual configuration files for the services that use xinetd. Listing 19-5 shows the Krb5-telnet
configuration file that is located in the /etc/xinet.d directory.
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
disable = yes
}
c. What is BIND? Explain the files required to configure BIND server.
The number of files you will use depends on the type of BIND server you want to use. You need
five files to set up the named server. Three files are required regardless of the configuration as a
master, slave, or caching-only server, and two additional configuration files are used on the
master server. There is also the script that is used to start the servers after they are configured, for
a total of six possible files. The three required files are:
■■ named.conf — Found in the /etc directory, this file contains global properties and sources of
configuration files.
■■ named.ca — Found in /var/named, this file contains the names and addresses of root servers.
■■ named.local — Found in /var/named, this file provides information for resolving the loopback
address for the localhost. The two additional files required for the master domain server are:
■■ zone— This file contains the names and addresses of servers and workstations in the local
sample file is installed with the RPM from the Installation CDs.
d. Explain zone files and reverse zone files.
Zone files contain resource records (RR) about IP addresses. Atypical zone file
is shown.
@ IN SOA localhost root (
42 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
localhost IN A 127.0.0.1
A zone file can contain many types of RRs, which are listed in the order in
which they generally appear in the zone files.
SOA — Start of Authority
The start of authority (SOA) is the first line in the zone file. The SOA identifies the name server
as the authoritative source for information about that domain. Each zone file has only one SOA,
and it contains the following data:
@ IN SOA main.tactechnology.com. mail.tactechnology.com. (/
2000052101 ; Serial
8h ;Refresh
2h ;Retry
1w ;Expire
1d) ;Minimum TTL
The first character in the SOA line is a special symbol that means “to look at this domain.” IN
means Internet. SOA means Start of authority. In this example, the authoritative server for this
domain is main .tactechnology.com., and mail.tactechnology.com. is the e-mail
address of the administrator. Note the trailing period after the domain names. If these are not
included, the domain name is appended to the entry. The opening parenthesis enables the first line
to be extended so that anything between the opening and closing parenthesis is considered one
line. The information within the parenthesis is passed to other name servers, secondary masters
that use this information to update their records. The line containing 2000052101 ; Serial is the
serial number of the file. Secondary servers compare this number with their stored information. If
the numbers are the same, the information has not changed, and it is not necessary to download
this file. If the serial numbers are different, the file is downloaded to update the information in the
secondary server. The serial number can be any number desired as long as it can be incremented
to indicate a revision to the file. The semicolon indicates that what follows to the end of the line is
a comment.
■■ Refresh — The amount of time the server should wait before refreshing its data.
■■ Retry — The amount of time the server should wait before attempting to contact the primary
servers and tells them how long to hold the data in their cache.
All of the information contained by the SOA may be placed on one line, but it is usually written
as shown previously. The order of the items is significant in the SOA header. Following the SOA
header information are lines containing additional server information. Two of these lines,
containing the abbreviations NS and A are shown in Listing 20-2. These abbreviations are
explained here:
■■ NS — Name servers in this domain.
■■ MX — The mail exchange record. The MX record specifies the mail servers for the domain. If
more than one MX server is present priority is determined by the address with the lowest number
receiving the highest priority.
■■ TXT — Text information. You can enter descriptive information here.
across a network
■■ A mail delivery agent to deliver messages to users’ mailbox files
(optional)
■■ The SMTP protocols for packaging email and transferring email messages
between MTAs
c. What is vsftpd? What are its features? Explain its configuration files.
The default FTP server daemon on Fedora Core and RHEL systems is vsftpd, the Very Secure
FTP Daemon.
Depending on the type of installation you selected, the installer, might or might not have installed
vsftpd. To find out, execute the command rpmquery vsftpd.
By far, the most important (and potentially the longest) vsftpd configuration file is
/etc/vsftpd/vsftpd.conf. The configuration directives in this file enable you to exercise finely
grained control over vsftpd’s behavior. The configuration file itself has a pleasantly simple
format. Each line is either a comment, which begins with #, or a directive. Directives have the
form option=value. Most of the configuration options are Boolean, so they are either on or off,
or, rather, YES or NO. Asecond group of configuration options take numeric values, and a third,
considerably smaller set of configuration options accept string values. To organize the discussion
of /etc/vsftpd/vsftpd.conf, we start with the default configuration file provided in Fedora Core
and RHEL. It is shown in the following listing, with most of the comments removed to preserve
space and to make it easier to read. Like many configuration files, lines that begin with the hash
sign (#) denote comments that the program ignores.
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
#xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
#idle_session_timeout=600
#data_connection_timeout=120
#nopriv_user=ftpsecure
#async_abor_enable=YES
#ascii_upload_enable=YES
#ascii_download_enable=YES
#ftpd_banner=Welcome to blah FTP service.
#deny_email_enable=YES
#banned_email_file=/etc/vsftpd.banned_emails
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd.chroot_list
#ls_recurse_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
listen=YES
tcp_wrappers=YES
The first configuration option, anonymous_enable=YES, allows anonymous FTP access. You
can set this to NO if you do not want to enable anonymous FTP. The directive
local_enable=YES allows local users (users with accounts on the system on which vsftpd is
running) to access the system via FTP. Similarly, write_enable=YES enables all variations of
the FTP commands that allow FTP users to modify the file system, such as STOR (the FTP
put and mput commands for uploading files) and DELE (the FTP del command for deleting
files). As a rule, it is unwise to permit FTP users to modify the file system, so if security is a
concern, you might consider disabling write commands by setting write_enable to NO.
At first glance, it might seem reasonable to grant local users write access, or at least to be able to
log in. However, the reason local users should not be allowed to log in is that FTP is a clear-text
protocol; usernames and, more importantly, passwords, are transmitted in clear text. Anyone with
a packet sniffer monitoring IP traffic to and from your FTP server’s IP address can grab
the authentication information and use it to compromise your system. Where FTP is concerned,
one can argue that anonymous access is actually less of a security risk than normal, authenticated
access because anonymous FTP does not require transmitting sensitive passwords over the wire.
In fact, for local users, sftp sftp, part of the OpenSSH suite of programs, is vastly superior to
plain vanilla FTP because it encapsulates FTP inside a secure, encrypted communication session
(see “Using SFTP” at the end of this chapter).
The directives anon_upload_enable=YES and anon_mkdir_write_ enable=YES control
whether or not anonymous FTP users can upload files and create directories, respectively. These
two directives are commented out, so anonymous uploads are disabled. Hopefully, it is obvious
that allowing anonymous uploads is potentially dangerous. That said, should you decide to
permit anonymous uploads, you will want to investigate additional vsftpd configuration directives
that restrict this type of access. The various xferlog directives xferlog_enable, xferlog_file, and
xferlog_std_format, control t he location of the transfer log and the formatof entries in this log
file. If xferlog_enable is set to YES, file uploads (if permitted) and downloads are recorded in a
log file, widely referred to using the shorthand expression xferlog. The xferlog_file directive
specifies the name of the xferlog file. The default log file is /var/log/vsftpd.log, which
should be suitable for most purposes. If you want to capture file transfers in a more mnemonically
named file, you might use xferlog_file=/var/log /xfer.log, but this is only a suggestion.
If you want to change the log entry format from the standard format, set
xferlog_std_format=NO and add the directive log_ftp_protocol=YES, which will cause all
FTP protocol requests to be dumped into the log file. Again, the standard format should be fine.
Logging FTP at the protocol level is mostly valuable when trying to isolate server or network
problems or debugging vsftpd itself.
d. How can anonymous uploads and guest user accounts be enabled vsftpd? Explain.
Enabling anonymous uploads is also like teaching a pig to sing, but we’re not going to beat that
simile into the ground (but we will mangle a metaphor if we can get away with it). Seriously,
anonymous uploads pose all sorts of security risks. The two that come to mind are someone
uploading a virus or trojan to your server and having your FTP server become a warez server, that
is, a transfer point for illegal or cracked copies of software, music, and/or movies. Becoming
a warez server isn’t so much a security risk as it is a freedom risk, as in, the authorities might put
you in jail if they discover you’re running a warez server.
1. Edit /etc/vsftpd/vsftp.conf and change or add the entries
shown in Table 22-2.
2. Create a directory for anonymous uploads:
# mkdir /var/ftp/incoming
3. Change the permissions of /var/ftp/incoming:
# chmod 770 /var/ftp/incoming
# chmod g+s /var/ftp/incoming
The first chmod command give the user and group full access to
/var/ftp/incoming. The second command turns on the set-group
ID (colloquially known as setgid or sgid) bit on the directory, causing
any file created in this directory to have its group ownership set to the
group that owns the directory.
4. Make the ftp user the group owner of /var/ftp/incoming:
# chgrp ftp /var/ftp/incoming
5. Restart vsftpd:
# service vsftpd restart
These steps create a directory, /var/ftp/incoming, to which anonymous FTP users can upload
files but from which no one can retrieve files. Nor can anyone see a directory listing of the upload
directory during an FTP session. What is a guest FTP user? Why would you want to use this
feature? A guest user, referred to in vsftpd’s documentation as a virtual user, describes any
nonanonymous login that uses a login name that does not exist as a real login account on the FTP
server. The purpose of guest user accounts is to provide broader privileges to FTP users than
anonymous FTP provides without giving local users FTP access. Recall the discussion of why
local user FTP access is a dodgy proposition: it exposes local user’s authentication information to
packet sniffers because FTP is a clear-text protocol. Guest users provide a measure of security
because if the guest account is somehow compromised, it has access to only the FTP server, not
to the system as a whole. Guest users also serve as an administrative convenience because you
can create a guest user that has access to certain files that are not available to anonymous users.
You can create multiple guest users each with their own specific access rights and FTP
environments, too, although the guest user configuration presented in this section describes only a
single guest account. To create a guest user account, use the following procedure.
1. Create a guest user account:
# useradd -d /var/ftp/rhlnsa3 -s /sbin/nologin authors
This command created the user authors with a home directory of /var/ftp/rhlnsa3 and a login
shell of /sbin/nologin, which disableslocal logins for that account.
2. Add some content to this directory:
# echo ‘This is a test file.’ > /var/ftp/rhlnsa3/test.file
# chown authors:authors /var/ftp/rhlnsa3/test.file
The first command creates simple text file named /var/ftp/rhlnsa3
/test.file. The second command chang es the user and group ownership to authors.
3. Decide who will be permitted to access the authors account and then create a text file that with
pairs of lines that specify the login name and password.
bubba
grits
marysue
greens
In this example, the users are named bubba and marysue and their
passwords are grits and greens, respectively. They are stored in a
file named virtusers.txt.
4. Create a Berkeley database file from the text file you created in Step 3.
Use the following command:
# db_load -T -t hash -f virtusers.txt /etc/vsftpd/vsftpd_login.db
This command creates a database file with the contents of virtusers .txt and stores it in
/etc/vsftpd/vsftpd_login.db. For additional security, change the permissions on the generated
file so that only root owns it:
# chmod 600 /etc/vsftpd/vsftpd_login.db
5. Create a PAM (Pluggable Authentication Module) file in /etc/pam.d that contains the
following entries:
auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_
login
You can use the vsftpd.pam file in this chapter’s code directory on the included CD-ROM.
These directives tell the PAM user database module to use the vsftpd_login.db file (the .db
extension is assumed) for FTP logins.
6. Edit /etc/vsftpd/vsftpd.conf, adding the following entries or editing existing ones to match:
pam_service_name=ftp
guest_enable=YES
guest_username=authors
local_enable=YES
write_enable=NO
anon_world_readable_only=NO
chroot_local_users =YES
pam_service_name=ftp tells vsftpd to use the PAM file you created in Step 5.
guest_enable=YES enables guest user functionality. guest_username=authors maps all
guest logins to the authors account created in Step 1. local_enable=YES permits local users to
login, which is required for guest users. The anon_world_readable_ only=NO directive makes
the contents of the /var/ftp/rhlnsa3 directory readable by guest users. Finally,
chown_local_users=YES
causes vsftpd to chroot the authors user to /var/ftp/rhlnsa3.
7. Start, or restart, the vsftpd service:
# service vsftpd restart
8. Test it out, using one of the user/password combinations you created in
Step 3:
$ ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.0.1)
530 Please login with USER and PASS.
Name (localhost:bubba): marysue
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,253,85)
150 Here comes the directory listing.
-rw-r--r-- 1 503 504 8192 Mar 20 15:44 ch22.doc
226 Directory send OK.
ftp> quit
The password typed at the prompt was greens. For the record, the
user marysue does not have a local login account; she only exists in
vsftpd’s guest user database (/etc/vsftpd/vsftpd_login.db).
Samba password file. Be sure that you include this option/value pair in your smb.conf file.
■■ encryptpasswords = yes — Beginning with Windows NT service pack 3 and later, passwords
are encrypted. If you are connecting to any systems running these versions of Windows, you
should choose encrypted passwords.
■■ netbios name = RHL — This is the name by which the Samba server is known to the
Windows computer.
■■ server string = Samba Server — This is shown as a comment on the Windows PC in the
network browser.
■■ security = user — This is the level of security applied to server access. Other options are share,
domain, and server. Share is used to make it easier to create anonymous shares that do not require
authentication, and it is useful when the NetBIOS names of the Windows computers
are different from other names on the Linux computer. Server is used to specify the server to use
if the password file is on another server in the network. Domain is used if the clients are added to
a Windows NT domain using smbpasswd, and login requests are executed
by a Windows NT primary or backup domain controller.
■■ log file = /var/log/samba/log—This is the location of the log file.
■■ max log size = 50— This is the maximum size in kilobytes that the file can grow to.
enables the server to be tuned for better performance. TCP_NODELAY is a default value; the
BUF values set send andreceive buffers.
■■ dns proxy = No— This indicates that the NetBIOS name will not be treated like a DNS name
■■ browseable = yes — Means that the directory will appear in the Windows file browser.
■■ writeable = yes — Means that users can write to their directories.
■■ create mode = 0664—Sets the default file permissions for files created in the directory.
■■ directory mode = 0775 — Sets the default permissions for created directories.
■■max connections = 1 — The maximum number of simultaneous connections allowed. Setting
this number to 1 prevents a user from logging in to the server from more than one location.
Setting this number to 2 allows a user to log in from two locations and so on. Setting this number
to 0 allows an unlimited number of connections.
[printers]
This section sets the options for printing.
■■ path = /var/spool/samba — The location of the printer spool directory.
■■ printable = yes — Enables clients to send print jobs to the specified directory. This option
e. What are the features of Postfix Mail Server? Explain its primary configuration file.
Postfix’s primary configuration file is /etc/postfix/main.cf. You will need to check or edit at
least the following variables:
■■ The mydomain variable specifies your domain name:
mydomain = example.com
■■ The myhostname variable identifies the local machine’s fully qualified domain name:
myhostname = coondog.example.com
■■The myorigin variable identifies the domain name appended to unqualified addresses (that is,
usernames without the @example.com
goober attached):
myorigin = $mydomain
This causes all mail going out to have your domain name appended.
Thus, if the value of mydomain is possum_holler.com and your
username is bubba, then your outgoing mail will appear to come from
bubba@possum_holler.com.
■■ The mydestination variable tells Postfix what addresses it should
f. What is sudo? What are its features? How does sudoseesion work after the creation of
configuration file?
Considering root’s privileges, you can easily understand why root access on a Linux system is
carefully protected and the root password tightly guarded. Nevertheless, it is often desirable to
grant privileges to a nonroot user (humorously referred to as merely mortal user) that have
traditionally been solely root’s domain, such as printer management, user account administration,
system backups, or maintaining a particular Internet service. In other operating systems,
such users are often called wheel users or administrative users. Indeed, in many environments,
subdividing system administration responsibilities is a necessity because the responsibilities of
maintaining multiple servers in a large IT shop or ISP can quickly overwhelm a single individual.
The problem in such a situation is clear: How do you grant administrative privileges to
merely mortal users without providing unfettered root access? In many situations, Sudo, a
mnemonic for superuser do, is one solution. Sudo enables you to give specific users or groups of
users the ability to run some (or all) commands requiring root privileges. Sudo also logs all
commands executed, which allows you to maintain an audit trail of the commands executed, by
whom they were executed, when they were executed, and so on. As the README in the source
distribution states, Sudo’s “basic philosophy is to give as few privileges as
possible but still allow people to get their work done.” Sudo’s features include:
■■ Enabling the ability to restrict the commands a given user may run on a per-host basis.
■■ Maintaining a clear audit trail of who did what. The audit trail can use the system logger or
Sudo’s own log file. In fact, you can use Sudo in lieu of a root shell to take advantage of this
logging.
■■ Limiting root-equivalent activity to a short period of time using timestamp based “tickets,” thus
avoiding the potential of leaving an active root shell open in environments where others can
physically get to your keyboard.
■■ Allowing a single configuration file, /etc/sudoers, to be used on multiple machines, permitting
both centralized Sudo administration and the flexibility to define a user’s privileges on a per host
basis.
After the configuration file has been created, a typical Sudo session proceeds
as follows:
1. An authorized user prefixes the root command she wants to execute
with sudo followed by a space, for example:
$ sudo shutdown -h +5 “System shutting down for disk replacement”
2. Sudo prompts the user for her personal password (not the root password)
and then checks the configuration file (/etc/sudoers) to make
sure she has permission to run the given command on a given machine.
The password prompt can be overridden by specifying the NOPASSWD
flag in /etc/sudoers, but this poses as security risk, so we don’t
cover the NOPASSWD flag in this section.
3. If the user is permitted to use that command, Sudo runs the command
as root (or another user if specified), logs the details, and timestamps the Sudo session ticket.
many environments, subdividing system administration responsibilitie s is a necessity because the
responsibilities of maintaining multiple servers in a large IT shop or ISP can quickly overwhelm a
single individual. The problem in such a situation is clear: How do you grant administrative
privileges tomerely mortal users without providing unfettered root access? In many situations,
Sudo, a mnemonic for superuser do, is one solution. Sudo enables you to give specific users or
groups of users the ability to run some (or all) commands requiring root privileges. Sudo also logs
all commands executed, which allows you to maintain an audit trail of the commands executed,
by whom they were executed, when they were executed, and so on. As the README in the
source distribution states, Sudo’s “basic philosophy is to give as few privileges as
Possibl but still allow people to get their work done.” Sudo’s features include:
■■ Enabling the ability to restrict the commands a given user may run on a per-host basis.
■■ Maintaining a clear audit trail of who did what. The audit trail can use the system logger or
Sudo’s own log file. In fact, you can use Sudo in lieu of a root shell to take advantage of this
logging.
■■ Limiting root-equivalent activity to a short period of time using timestamp based “tickets,” thus
avoiding the potential of leaving an active root shell open in environments where others can
physically get to your keyboard.
■■ Allowing a single configuration file, /etc/sudoers, to be used on multiple machines, permitting
both centralized Sudo administration and the flexibility to define a user’s privileges on a per host
basis.
After the configuration file has been created, a typical Sudo session proceeds
as follows:
1. An authorized user prefixes the root command she wants to execute
with sudo followed by a space, for example:
$ sudo shutdown -h +5 “System shutting down for disk replacement”
2. Sudo prompts the user for her personal password (not the root password)
and then checks the configuration file (/etc/sudoers) to make
sure she has permission to run the given command on a given machine.
The password prompt can be overridden by specifying the NOPASSWD
flag in /etc/sudoers, but this poses as security risk, so we don’t
cover the NOPASSWD flag in this section.
3. If the user is permitted to use that command, Sudo runs the command
as root (or another user if specified), logs the details, and timestamps
the Sudo session ticket.