41
Guide to Linux Installation and Administration, 2e 1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Embed Size (px)

Citation preview

Page 1: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 1

Chapter 8

Basic Administration

Tasks

Page 2: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 2

Objectives

In this chapter, you will:

• Create and manage Linux user accounts

• Install and maintain types of Linux systems

• Manage processes on Linux using basic commands

Page 3: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 3

Managing User Accounts

• To complete any operation in Linux, a person must first log in using a valid user account name and password

• Setting up and maintaining these user accounts is an important part of the work of a system administrator

Page 4: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 4

Types of User Accounts

• Types of user accounts include:– root account

– Regular accounts

– Special accounts

Page 5: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 5

The root Account

• The administrative account (the superuser) on a Linux system is named root

• The root user can perform any operation on a Linux system

• The su utility (for substitute user) temporarily changes your access rights to those of another user

Page 6: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 6

Regular Users

• Regular user accounts are for users who log in at a keyboard and use the Linux system

• Regular user account names typically use a combination of first name or initial and last name or initial

Page 7: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 7

Special Users

• Special accounts cannot be used to log in• Special accounts are used by programs running

on Linux

Page 8: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 8

Linux Groups

• A group is a collection of user accounts that can be collectively granted access to files and directories

• A user can be a member of multiple groups, but can only have one primary group

• A User Private Group system creates a group with a single member for each new user account

Page 9: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 9

A User as a Member of Multiple Groups

Page 10: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 10

User and Group Files

• User account information is stored in the file /etc/passwd

• To edit the /etc/passwd file, use the special editing program vipw

• Groups on a Linux system are defined in /etc/group

• To edit the /etc/group file, use the command vigr

Page 11: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 11

Shadow Passwords

• Encrypted passwords are stored in /etc/shadow• Regular users cannot read encrypted passwords• Shadow Password Suite is a collection of

password-related programs that have been modified to recognize the /etc/shadow file

Page 12: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 12

Creating New User Accounts

• New user accounts can be created – With the useradd command

– With various graphical utilities

• Default settings apply when using the useradd command alone

• Default settings can be modified on the command line or by editing a configuration file for useradd

Page 13: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 13

Configuring Users Graphically in Red Hat Linux 7.3

Page 14: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 14

useradd Command Options

Page 15: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 15

Changing User Passwords

• A password is not defined by useradd when a new user account is created

• The passwd command is used to define or change a user’s password

• You must enter the new password twice

Page 16: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 16

Creating New Groups

• To create a new group, use the groupadd command

• To add a new group, include the group name as a parameter

Page 17: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 17

Modifying User and Group Accounts

• The usermod command allows you to modify user account parameters stored in /etc/passwd or /etc/shadow

• The groupmod command lets you modify membership of a group

Page 18: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 18

Automating Home Directory Creation

• Files contained in /etc/skel are automatically copied into each user’s home directory at the time you create the account

• You should place files in /etc/skel when you first install Linux

Page 19: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 19

Disabling User Accounts

• You can temporarily or permanently disable a user account

• Accounts can be deleted using the userdel command

• To temporarily disable a user’s account, change the password with the passwd command

Page 20: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 20

Maintaining File Systems

• File system refers to an organized set of data that can be accessed via the standard Linux directory structure

• To access a file system in Linux, it must first be mounted into the root directory structure

• A mount point is the path in the directory structure where you access the data in a file system

• Use the mount command to make a new file system accessible via a mount point

Page 21: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 21

Automatically Mounted File Systems

Page 22: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 22

File Systems Mounted in a Linux Directory Structure

Page 23: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 23

Checking File System Status

• The df command displays space usage information for each file system that is currently mounted

• The du utility lists the size of a directory and all its subdirectories

• You can use various graphical tools and system administration scripts to check the status of file systems

Page 24: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 24

Creating New File Systems

• You can install new file systems that are permanent or temporary

• File systems can be stored on a device with removable media or fixed media

• Once the hard disk or other device is installed, you can use the Linux fdisk command to examine its partitions, creating new Linux partitions

Page 25: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 25

Using the fdisk Utility

• To manage partitions in Linux after the operating system is installed, use the fdisk utility

• The fdisk utility can configure partition data on a hard disk

• Your modifications to the partition table are only effective when you write the changes to disk with the w command to exit fdisk

Page 26: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 26

fdisk Commands

Page 27: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 27

Sample Output of the p Command in fdisk

Page 28: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 28

Formatting File Systems

• File system journaling is a feature that protects against data corruption by tracking each “write” to the hard disk in a special way so that it will either be completely finished or left completely undone

• New partitions must be formatted using mke2fs or mkswap before they can be used

Page 29: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 29

Mounting File Systems

• After you have formatted a file system, you can mount it

• To access a file system, you use the mount command

• The floppy disk drive and CD-ROM drive are mounted to /mnt/floppy and /mnt/cdrom

Page 30: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 30

Unmounting File Systems

• To unmount a file system, use the umount command with the device name or mount point

• A file system cannot be in use when you unmount it

Page 31: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 31

Automating File System Mounting

• The new file systems that you create from additional hard disks or other devices can also be automatically mounted at boot time

• The key to automounting file systems is the /etc/fstab configuration file which contains one line for each file system that you want to have automounted when Linux boots

Page 32: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 32

Option Field Settings for the mount Command

Page 33: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 33

Managing Swap Space

• The swap space is a special partition type used by the Linux kernel for virtual memory

• You can use the mkswap command to format a swap partition

• Swap space is activated by the swapon command within the system initialization scripts

• The vmstat command displays current status details for how virtual memory is being used

Page 34: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 34

Setting Quotas on Disk Usage

• Limits on the amount of hard disk space that any user or group can use are called disk quotas

• Use the edquota command to establish a quota for one or more users or groups

• Activate the quota system using the quotaon command

Page 35: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 35

Simple Task Management

• To control processes running on Linux, you can use the following:– The ps command

– The bg command

– The fg command

Page 36: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 36

Job Control in the Shell

• When you start a program, that program takes control of the command line where you are working

• The jobs command lists all jobs or processes that are running from the current shell

• The fg command places processes in the foreground

• The bg command places processes in the background command

Page 37: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 37

Using Virtual Consoles

• A virtual console is a separate login screen that you access by pressing a combination of keys on your keyboard

• A virtual console allows you to start multiple text-based login sessions on the same computer

• The virtual consoles are assigned to the function keys

Page 38: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 38

Learning about Processes

• A simple ps command shows you only the commands that you have started in the current command-line environment

• Multiple processes can be started from a single shell

Page 39: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 39

Controlling Processes

• The kill command is used to kill, or end, processes

• Signals are messages that can be sent between processes

• The killall command sends a signal to all processes started by a given command

Page 40: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 40

Summary

• Types of user accounts include root, regular accounts, and special accounts

• New user accounts can be created with the useradd command or with various graphical utilities

• New groups can be created with the groupadd command

• File systems are accessed by using the mount command to specify a device and a mount point

• The df and du commands display status and size information about file systems

Page 41: Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks

Guide to Linux Installation and Administration, 2e 41

Summary

• The fdisk utility can configure partition data on a hard disk.

• The vmstat command displays how virtual memory is being used

• Within a shell, the jobs command manages these processes, placing them in the foreground or background

• Virtual consoles let you log in at multiple independent text-mode screens

• The kill command sends signals to processes or to the Linux kernel when necessary to end a process