Nothing Special   »   [go: up one dir, main page]

Linux Fundamentals Student Workbook: Unauthorized

Download as pdf or txt
Download as pdf or txt
You are on page 1of 65

Fundamentals

Workbook PY
Student
Linux

O
d
ite
ib
C Pr
oh
N
n
io
ut
I O is
trib
AT
D
or
n
ctio
U du
AL
ro
ep
R
ed
EV
riz
ho
ut
na
U
EV U
na

AL
ut
ho
riz

U
ed
GL120

R
LINUX

AT
ep FUNDAMENTALS
ro RHEL7 SLES12 U16.04

du

I
c tio

O
n
or

N
D
The contents of this course and all its modules and related materials, including handouts to

is
audience members, are copyright ©2017 Guru Labs L.C.

t rib
No part of this publication may be stored in a retrieval system, transmitted or reproduced in any

C
way, including, but not limited to, photocopy, photograph, magnetic, electronic or other record,
without the prior written permission of Guru Labs.

ut
This curriculum contains proprietary information which is for the exclusive use of customers of Guru

io
Labs L.C., and is not to be shared with personnel other than those in attendance at this course.

O
n
This instructional program, including all material provided herein, is supplied without any guarantees
from Guru Labs L.C. Guru Labs L.C. assumes no liability for damages or legal action arising from

Pr
the use or misuse of contents or details contained herein.

PY
Photocopying any part of this manual without prior written consent of Guru Labs L.C. is a violation

oh
of federal law. This manual should not appear to be a photocopy. If you believe that Guru Labs
training materials are being photocopied without permission, please email Alert@gurulabs.com or

ib
call 1-801-298-5227.
Guru Labs L.C. accepts no liability for any claims, demands, losses, damages, costs or expenses

ite
suffered or incurred howsoever arising from or in connection with the use of this courseware. All
trademarks are the property of their respective owners.

d
Version: GL120S-R7S12U1604-T03
PY
O
d
ite
ib
C Pr
oh
N
n
io
ut
I O is
trib
AT
D
or
n
ctio
U du
AL
ro
ep
R
ed
EV
riz
ho
ut
na
U
Table of Contents
Chapter 1

EV
Unix/Linux Filesystem Features 3
WHAT IS LINUX? 1 Filesystem Hierarchy Standard 4
Unix and its Design Principles 2 Navigating the Filesystem 6
FSF and GNU 4 Displaying Directory Contents 7
GPL – General Public License 5

U
Filesystem Structures 9
The Linux Kernel 6

na
Determining Disk Usage With df and du 10

AL
Linux Kernel and Versioning 7 Determining Disk Usage (GUI) 11

ut
Components of a Distribution 9 Disk Usage with Quotas 13

ho
Slackware 10 File Ownership 14
SUSE Linux Products 11 Default Group Ownership 15

riz
Debian 12 File and Directory Permissions 16

U
Ubuntu 13

ed
File Creation Permissions with umask 18
Red Hat Linux Products 14 SUID and SGID on files 20
Oracle Linux 16

R
SGID and Sticky Bit on Directories 21

AT
ep
Changing File Permissions 22
Chapter 2 User Private Group Scheme 24

ro
LOGIN AND EXPLORATION 1 Lab Tasks 26
Logging In 2

du
1. Navigating Directories and Listing Files 27
Running Programs 3 2. Disk and Filesystem Usage 29

I
c
Interacting with Command Line 4 3. File and Directory Ownership and Permissions 31

tio

O
Desktop Environments 6 4. Introduction to Troubleshooting Labs [R7 S12] 36

n
GNOME 7 5. Troubleshooting Practice: Filesystem [R7 S12] 41
Starting X 9

or

N
Gathering Login Session Info 11 Chapter 4

D
Gathering System Info 12 MANIPULATING FILES 1

is
uptime & w 14 Directory Manipulation 2

t
got root? 15 File Manipulation 3

rib

C
Switching User Contexts 16 Deleting and Creating Files 4

ut
sudo 17 Managing Files Graphically 5
Help from Commands and Documentation 19

io
Drag and drop with Nautilus 6

O
whereis 20 Physical Unix File Structure 7

n
Getting Help Within the Graphical Desktop 21 Filesystem Links 8

Pr
Getting Help with man & info 22 File Extensions and Content 9

PY
oh
Lab Tasks 24 Displaying Files 10
1. Login and Discovery 25 Previewing Files 12

ib
2. Help with Commands 30 Producing File Statistics 13

ite
3. Switching Users With su 34 Displaying Binary Files 14
Searching the Filesystem 16

d
Chapter 3 Alternate Search Method 17
THE LINUX FILESYSTEM 1 Lab Tasks 18
Filesystem Support 2 1. Manipulating Files and Directories 19
ii
2. File Examination & Search Commands 23 Extracting Columns of Text 9
Combining Files and Merging Text 10

EV
Chapter 5 Comparing File Changes 12
SHELL BASICS 1 Lab Tasks 14
Role of Command Shell 2 1. Processing Text Streams 15
Communication Channels 3 2. Text Processing 17

U
File Redirection 4

na
Piping Commands Together 5 Chapter 8

AL
Filename Matching 6 REGULAR EXPRESSIONS 1

ut
File Globbing and Wildcard Patterns 7 Regular Expression Overview 2

ho
Brace Expansion 8 Regular Expressions 3
Shell and Environment Variables 9 RE Character Classes 4

riz

U
Key Environment Variables 10 Regex Quantifiers 5

ed
Which and Type 12 RE Parenthesis 6
General Quoting Rules 14 Lab Tasks 7

AT
Nesting Commands 16 1. Pattern Matching with Regular Expressions 8

ep
Lab Tasks 17 2. Extended Regular Expressions 10
1. Redirection and Pipes 18 3. Using Regular Expressions With sed 14

ro
2. Wildcard File Matching 25

du
3. Shell Variables 27 Chapter 9
4. Shell Meta-Characters 30 TEXT EDITING 1

I
c
tio
5. Command Substitution 33 Text Editing 2

O
Pico/GNU Nano 3

n
Chapter 6 Pico/Nano Interface 4

or
ARCHIVING AND COMPRESSION 1 Nano configuration 5

N
Archives with tar 2 Pico/Nano Shortcuts 6

D
Archives with cpio 3 vi and Vim 7

is
The gzip Compression Utility 4 Learning Vim 8

trib
The bzip2 Compression Utility 5 Basic vi 9

C
The XZ Compression Utility 6 Intermediate vi 10

ut
The PKZIP Archiving/Compression format 7 Lab Tasks 13

io
GNOME File Roller 8 1. Text Editing with Nano 14

O
n
Lab Tasks 9 2. Text Editing with Vim 17
1. Archiving and Compression 10

Pr
Chapter 10

PY
oh
Chapter 7 MESSAGING 1
TEXT PROCESSING 1 System Messaging Commands 2

ib
Searching Inside Files 2 Controlling System Messaging 3

ite
The Streaming Editor 3 Internet Relay Chat 4

d
Text Processing with Awk 4 Instant Messenger Clients 5
Replacing Text Characters 6 Electronic Mail 6
Text Sorting 7 Sending Email with sendmail 7
Duplicate Removal Utility 8 Sending and Receiving Email with mailx 8
iii
Sending and Receiving Email with mutt 10 The borne for-Loop 13
Sending Email with Pine 11 The while and until Loops 14

EV
Evolution 13 Lab Tasks 15
Lab Tasks 14 1. Writing a Shell Script 16
1. Command Line Messaging 15
2. Messaging with talkd 17 Chapter 13

U
3. Command Line Email 20 PROCESS MANAGEMENT AND JOB CONTROL 1

na
4. Alpine 22 What is a Process? 2

AL
Process Lifecycle 3

ut
Chapter 11 Process States 4

ho
COMMAND SHELLS 1 Viewing Processes 5
Shells 2 Signals 7

riz

U
Identifying the Shell 4 Tools to Send Signals 8

ed
Changing the Shell 5 nohup and disown 9
Configuration Files 6 Managing Processes 10

AT
Script Execution 7 Tuning Process Scheduling 11

ep
Shell Prompts 8 Job Control Overview 13
Bash: Bourne-Again Shell 9 Job Control Commands 14

ro
Bash: Configuration Files 10 Persistent Shell Sessions with Screen 15

du
Bash: Command Line History 11 Using screen 16
Bash: Command Editing 13 Advanced Screen 18

I
c
tio
Bash: Command Completion 15 Lab Tasks 19

O
Bash: "shortcuts" 16 1. Job Control Basics 20

n
Bash: prompt 17 2. Process Management Basics 25

or
Setting Resource Limits via ulimit 18 3. Screen Basics 28

N
Lab Tasks 19 4. Using Screen Regions 31

D
1. Linux Shells 20 5. Troubleshooting Practice: Process Management [R7 S12] 34

is
2. Bash History 24

t
rib
3. Aliases 27 Chapter 14

C
4. Bash Login Scripts 29 AT AND CRON 1

ut
5. The Z Shell 31 Automating Tasks 2

io
at/batch 3

O
n
Chapter 12 cron 5
INTRODUCTION TO SHELL SCRIPTING 1 The crontab Command 6

Pr
Shell Script Strengths and Weaknesses 2 crontab Format 7

PY
oh
Example Shell Script 3 /etc/cron.*/ Directories 8
Positional Parameters 4 Anacron 10

ib
Input & Output 5 Lab Tasks 12

ite
Doing Math 7 1. Creating and Managing User Cron Jobs 13

d
Exit Status 8 2. Adding System cron Jobs 16
Comparisons with test 9 3. Troubleshooting Practice: Automating Tasks [R7 S12] 18
Conditional Statements 10
Flow Control: case 11
iv
Chapter 15 Chapter 17
MANAGING SOFTWARE 1 MOUNTING FILESYSTEMS & MANAGING REMOVABLE MEDIA 1

EV
Downloading with FTP 2 Filesystems Concept Review 2
FTP 3 Mounting Filesystems 3
lftp 5 NFS 4
Command Line Internet – Non-interactive 6 SMB 5

U
Command Line Internet – Interactive 8 Filesystem Table (/etc/fstab) 6

na
Managing Software Dependencies 9 AutoFS 7

AL
Using the Yum command 11 Removable Media 8

ut
Using Yum history 14 Lab Tasks 9

ho
YUM package groups 17 1. Accessing NFS Shares 10
Configuring Yum 18 2. On-demand filesystem mounting with AutoFS 12

riz
yumdownloader 20

U
ed
Popular Yum Repositories 21 Chapter 18
Using the Zypper command 22 PRINTING 1

R
Zypper Services and Catalogs 24 Legacy Print Systems 2

AT
ep
The dselect & APT Frontends to dpkg 26 Common UNIX Printing System 3
Aptitude 27 Defining a Printer 4

ro
Configuring APT 28 Standard Print Commands 6

du
Lab Tasks 30 Format Conversion Utilities 8
1. Command Line File Transfers 31 enscript and mpage 9

I
c
2. Using Yum [R7] 35 Lab Tasks 11

tio

O
3. Using Zypper [S12] 42 1. Printing 12

n
4. Managing Yum Repositories [R7] 47 2. Configuring Print Queues 16

or
5. Managing Zypper Repositories [S12] 50

N
6. Using APT [U1604] 53 Appendix A

D
7. Adding an APT repository [U1604] 55 THE X WINDOW SYSTEM 1

is
The X Window System 2

t
Chapter 16 X Modularity 3

rib

C
THE SECURE SHELL (SSH) 1 X.Org Drivers 4

ut
Secure Shell 2 Configuring X Manually 5

io
OpenSSH Client & Server Configuration 3 Automatic X Configuration 7

O
Accessing Remote Shells 4 Xorg and Fonts 8

n
Transferring Files 5 Installing Fonts for Modern Applications 10

Pr
Alternative sftp Clients 6 Installing Fonts for Legacy Applications 12

PY
oh
SSH Key Management 8 The X11 Protocol and Display Names 13
ssh-agent 9 Display Managers and Graphical Login 14

ib
Lab Tasks 10 Starting X Apps Automatically 16

ite
1. Introduction to ssh and scp 11 X Access Control 18

d
2. SSH Key-based User Authentication 13 Remote X Access (historical/insecure) 20
3. Using ssh-agent 15 Remote X Access (modern/secure) 22
XDMCP 24
Remote Graphical Access With VNC and RDP 26
v
Specialized X Servers 27
Lab Tasks 28

EV
1. Remote X with XDMCP 29
2. Configure X Security 36
3. Configure a VNC Server [R7] 42
4. Configure a VNC Server [S12] 47

U
5. Configure a VNC Server [U1604] 52

na
6. Launching X Apps Automatically 54

AL
7. Secure X 62

ut
ho
Appendix B
EMACS 1

riz

U
Emacs 2

ed
The Emacs Interface 3
Basic Emacs 4

AT
More Emacs Commands 6

ep
Lab Tasks 8
1. Text Editing with Emacs 9

ro
du

I
c
tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
vi
Typographic Conventions

EV 0O
The fonts, layout, and typographic conventions of this book have been
carefully chosen to increase readability. Please take a moment to
familiarize yourself with them.

U
A Warning and Solution

na

AL
ut
A common problem with computer training and reference materials is
the confusion of the numbers "zero" and "one" with the letters "oh" and The number The letter

ho
"ell". To avoid this confusion, this book uses a fixed-width font that makes "zero". "oh".

riz
each letter and number distinct.

Typefaces Used and Their Meanings


ed
R
U
AT
The following typeface conventions have been followed in this book:

ep
fixed-width normal ⇒ Used to denote file names and directories. For

ro
example, the /etc/passwd file or /etc/sysconfig/directory. Also

du
used for computer text, particularily command line output.
1l
The number
"one".
The letter
"ell".

I
c
fixed-width italic ⇒ Indicates that a substitution is required. For

tio

O
example, the string stationX is commonly used to indicate that the

n
student is expected to replace X with his or her own station number,

or
such as station3.

N
D
fixed-width bold ⇒ Used to set apart commands. For example, the

is
sed command. Also used to indicate input a user might type on the

t
command line. For example, ssh -X station3.

rib

C
fixed-width bold italic ⇒ Used when a substitution is required

ut
within a command or user input. For example, ssh -X stationX.

io

O
n
fixed-width underlined ⇒ Used to denote URLs. For example,

Pr
http://www.gurulabs.com/.

PY
oh
variable-width bold ⇒ Used within labs to indicate a required student
action that is not typed on the command line.

ib
ite
Occasional variations from these conventions occur to increase clarity.
This is most apparent in the labs where bold text is only used to indicate

d
commands the student must enter or actions the student must perform.

vii
Typographic Conventions

EV
Terms and Definitions Line Wrapping

The following format is used to introduce and define a series of terms: Occasionally content that should be on a single line, such as command
line input or URLs, must be broken across multiple lines in order to fit

U
deprecate ⇒ To indicate that something is considered obsolete, with on the page. When this is the case, a special symbol is used to indicate

na

AL
the intent of future removal. to the reader what has happened. When copying the content, the line

ut
frob ⇒ To manipulate or adjust, typically for fun, as opposed to tweak. breaks should not be included. For example, the following hypothetical
grok ⇒ To understand. Connotes intimate and exhaustive knowledge. PAM configuration should only take two actual lines:

ho
hork ⇒ To break, generally beyond hope of repair.

riz
hosed ⇒ A metaphor referring to a Cray that crashed after the password required /lib/security/pam_cracklib.so retry=3a

U
disconnection of coolant hoses. Upon correction, users were assured type= minlen=12 dcredit=2 ucredit=2 lcredit=0 ocredit=2

ed
the system was rehosed. password required /lib/security/pam_unix.so use_authtok
mung (or munge) ⇒ Mash Until No Good: to modify a file, often

AT
Representing File Edits
irreversibly.

ep
troll ⇒ To bait, or provoke, an argument, often targeted towards the
File edits are represented using a consistent layout similar to the unified

ro
newbie. Also used to refer to a person that regularly trolls.
diff format. When a line should be added, it is shown in bold with a
twiddle ⇒ To make small, often aimless, changes. Similar to frob.

du
plus sign to the left. When a line should be deleted, it is shown struck
out with a minus sign to the left. When a line should be modified, it

I
c
When discussing a command, this same format is also used to show and
is shown twice. The old version of the line is shown struck out with a

tio

O
describe a list of common or important command options. For example,
minus sign to the left. The new version of the line is shown below the
the following ssh options:

n
old version, bold and with a plus sign to the left. Unmodified lines are

or
often included to provide context for the edit. For example, the following

N
-X ⇒ Enables X11 forwarding. In older versions of OpenSSH that do
describes modification of an existing line and addition of a new line to

D
not include -Y, this enables trusted X11 forwarding. In newer versions
the OpenSSH server configuration file:
of OpenSSH, this enables a more secure, limited type of forwarding.

is
-Y ⇒ Enables trusted X11 forwarding. Although less secure, trusted

t rib
File: /etc/ssh/sshd_config

C
forwarding may be required for compatibility with certain programs.
#LoginGraceTime 2m

ut
Representing Keyboard Keystrokes - #PermitRootLogin yes

io

O
+ PermitRootLogin no

n
When it is necessary to press a series of keys, the series of keystrokes + AllowUsers sjansen

Pr
will be represented without a space between each key. For example, the #StrictModes yes

PY
following means to press the "j" key three times: jjj

oh
Note that the standard file edit representation may not be used when it

ib
When it is necessary to press keys at the same time, the combination will is important that the edit be performed using a specific editor or method.

ite
be represented with a plus between each key. For example, the following In these rare cases, the editor specific actions will be given instead.
means to press the "ctrl," "alt," and "backspace" keys at the same time:

d
Ó¿Ô¿×. Uppercase letters are treated the same: Ò¿A

viii
Lab Conventions

EV
Lab Task Headers Variable Data Substitutions

Every lab task begins with three standard informational headers: In some lab tasks, students are required to replace portions of commands
"Objectives," "Requirements," and "Relevance". Some tasks also include a with variable data. Variable substitution are represented using italic fonts.

U
"Notices" section. Each section has a distinct purpose. For example, X and Y.

na

AL
Objectives ⇒ An outline of what will be accomplished in the lab task. Substitutions are used most often in lab tasks requiring more than one

ut
Requirements ⇒ A list of requirements for the task. For example, computer. For example, if a student on station4 were working with a

ho
whether it must be performed in the graphical environment, or student on station2, the lab task would refer to stationX and stationY

riz
whether multiple computers are needed for the lab task.

U
Relevance ⇒ A brief example of how concepts presented in the lab stationX$ ssh root@stationY

ed
task might be applied in the real world.
and each would be responsible for interpreting the X and Y as 4 and 2.
Notices ⇒ Special information or warnings needed to successfully

AT
complete the lab task. For example, unusual prerequisites or common station4$ ssh root@station2

ep
sources of difficulty.

ro
Command Prompts Truncated Command Examples

du

I
Though different shells, and distributions, have different prompt Command output is occasionally omitted or truncated in examples. There

c tio

O
characters, examples will use a $ prompt for commands to be run as are two type of omissions: complete or partial.
a normal user (like guru or visitor), and commands with a # prompt

n
should be run as the root user. For example: Sometimes the existence of a command’s output, and not its content, is

or
all that matters. Other times, a command’s output is too variable to

N
$ whoami reliably represent. In both cases, when a command should produce

D
guru output, but an example of that output is not provided, the following

is
$ su - format is used:

trib
Password: password

C
# whoami $ cat /etc/passwd

ut
root . . . output omitted . . .

io

O
Occasionally the prompt will contain additional information. For example, In general, at least a partial output example is included after commands.

n
when portions of a lab task should be performed on two different stations When example output has been trimmed to include only certain lines,

Pr
(always of the same distribution), the prompt will be expanded to: the following format is used:

PY
oh
stationX$ whoami $ cat /etc/passwd

ib
guru root:x:0:0:root:/root:/bin/bash

ite
stationX$ ssh root@stationY . . . snip . . .
root@stationY's password: password clints:x:500:500:Clint Savage:/home/clints:/bin/zsh

d
stationY# whoami . . . snip . . .
root

ix
Lab Conventions

EV
Distribution Specific Information Action Lists

This courseware is designed to support multiple Linux distributions. Some lab steps consist of a list of conceptually related actions. A
When there are differences between supported distributions, each description of each action and its effect is shown to the right or under

U
version is labeled with the appropriate base strings: the action. Alternating actions are shaded to aid readability. For example,

na

AL
the following action list describes one possible way to launch and use

ut
R ⇒ Red Hat Enterprise Linux (RHEL) xkill to kill a graphical application:
S ⇒ SUSE Linux Enterprise Server (SLES)

ho
U ⇒ Ubuntu Ô¿Å Open the "Run Application" dialog.

riz

U
The specific supported version is appended to the base distribution xkillÕ Launch xkill. The cursor should change,

ed
strings, so for Red Hat Enterprise Linux version 6 the complete string usually to a skull and crossbones.
is: R6.

R
Click on a window of the application to kill.

AT
ep
Indicate which process to kill by clicking on
Certain lab tasks are designed to be completed on only a sub-set of
it. All of the application’s windows should

ro
the supported Linux distributions. If the distribution you are using is not
disappear.
shown in the list of supported distributions for the lab task, then you

du
should skip that task.

I
Callouts

c
tio

O
Certain lab steps are only to be performed on a sub-set of the supported
Linux distributions. In this case, the step will start with a standardized Occasionally lab steps will feature a shaded line that extends to a note

n
string that indicates which distributions the step should be performed on. in the right margin. This note, referred to as a "callout," is used to provide

or
additional commentary. This commentary is never necessary to complete

N
When completing lab tasks, skip any steps that do not list your chosen
the lab succesfully and could in theory be ignored. However, callouts

D
distribution. For example:
do provide valuable information such as insight into why a particular

is
1) [R4] This step should only be performed on RHEL4. command or option is being used, the meaning of less obvious command

t rib
output, and tips or tricks such as alternate ways of accomplishing the task

C
Because of a bug in RHEL4's Japanese fonts...
at hand.

ut
Sometimes commands or command output is distribution specific. In On SLES10, the sux command

io
[S10] $ sux -

O
these cases, the matching distribution string will be shown to the left of Password: password copies the MIT-MAGIC-COOKIE-1

n
the command or output. For example: # xclock so that graphical applications

Pr
can be run after switching
$ grep -i linux /etc/*-release | cut -d: -f2

PY
oh
to another user account. The
[R6] Red Hat Enterprise Linux Server release 6.0 (Santiago) SLES10 su command did not

ib
[S11] SUSE Linux Enterprise Server 11 (i586) do this.

ite
d
x
EV
Content
Unix and its Design Principles . . . . . . . . . . . . . . . . . . . . . . . . 2
FSF and GNU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
GPL – General Public License . . . . . . . . . . . . . . . . . . . . . . . . 5

U
The Linux Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

na
Linux Kernel and Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . 7

AL
Components of a Distribution . . . . . . . . . . . . . . . . . . . . . . . . 9

ut
Slackware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

ho
SUSE Linux Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

riz
Ubuntu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

U
ed
Red Hat Linux Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Oracle Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter
R

AT 1
ep
ro
du

I
c tio

O
n
or

N
WHAT IS LINUX?
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
Unix and its Design Principles

EV
Inherits features from Multics such as the hierarchical filesystem
Everything is a file
Small single-purpose programs
Ability to pipe small programs together to accomplish more complex

U
tasks

na
The kernel makes minimum policy decisions, leaving things up to

AL
easily modifiable userland programs

ut
All configuration data stored as text, (e.g. ASCII, UTF-8)

ho
riz

U
Unix Origins ed another, as yet unknown, program. Don't clutter output with

AT
extraneous information. Avoid stringently columnar or binary

ep
The original batch processing systems of the 1950s were limited to input formats. Don't insist on interactive input.
processing only one job at a time. Batch processing systems were

ro
3. Design and build software, even operating systems, to be tried
replaced with time sharing systems, such as the Compatible Time early, ideally within weeks. Don't hesitate to throw away the

du
Sharing System. In 1964, AT&T began discussions with MIT and GE to clumsy parts and rebuild them.

I
create a second generation time sharing system, Multics. Work

c
4. Use tools in preference to unskilled help to lighten a

tio

O
started at BTL in 1965. Over the next four years, cutting-edge programming task, even if you have to detour to build the tools
research was done by the academics at MIT, and the computer

n
and expect to throw some of them out after you've finished
scientists at GE and AT&T, changing the mind set of how computers using them.

or
should operate, such as the view that computing should be an

N
interactive and multi-user experience. (From M.D. McIlroy, E.N.Pinson, and B.A. Tague, Unix Time-Sharing

D
System Forward, The Bell System Technical Journal, July -Aug. 1978

is
AT&T pulled out of the Multics project in 1969. The Multics project
vol 57, number 6 part 2, pg. 1902.)

t
had been ambitious, and each party had differing visions that were

rib

C
hard to reconcile. Bell Labs researcher Ken Thompson started Small programs and pipes are flexible, and build simple, fast solutions

ut
working on an alternative to Multics, later nick named Unics by Brian to otherwise complex tasks.

io
Kernighan, to distinguish it from the complexity of Multics. It was

O
originally written in machine language for the DEC PDP-7 and 9, but Plain text config data facilitates remote administration. The ANSI text

n
ran primarily on the PDP-11 through Edition 7. originally used is limited by the 127 characters available on US

Pr
keyboards. UTF-8 (Unicode), the Plan 9 character set developed by

PY
Unix Design Principles

oh
Thompson, is now used by many Unix systems, offering an
international character set while remaining backwards compatible to
The researchers, led by Doug McIlroy, developed a set of principles

ib
ANSI text. The file command (covered later) will report most text
to guide their work. Among these principles were:

ite
files as ASCII text, as it is rare to see characters used outside Latin-1
1. Make each program do one thing well. To do a new job, build (extended ASCII), though not as rare as it used to be.

d
afresh rather than complicate old programs by adding new
features.
2. Expect the output of every program to become the input to
1-2
The Unix family Growth of Unix
In February 1973, the third edition of Unix was released. The preface As the DEC series systems gave way to Sun workstations, mail order

EV
of the UNIX PROGRAMMER'S MANUAL claimed an increase from 10 computer kits, and the PC era of home computers, it was realized by
installations to 16, but what was more important was reflected in this Thompson, Pike, and others that a redesign was needed to take
statement under "Writing a program": "The three principal languages advantage of these new, cheaper technologies. Plan 9 succeeded
in Unix are assembly language (see as(1)), FORTRAN (see fc(1)), Unix as a from scratch rewrite, incorporating a distributed filesystem

U
and C (see cc(1)) . . . " The new C language was a modification of and applications, and rethinking computing in terms of multiple

na

AL
Thompson's B interpreter, adding types, and a compiler. C's simplicity systems, not single time-sharing systems communicating with each

ut
led to the fourth edition Unix being rewritten in C, and to its dominant other. Though Plan 9 brings along many tools from later editions of

ho
use in the Unix family of operating systems. Unix (especially 8-10), it is a new system. Plan 9 is an open-source
operating system carrying the Unix philosophy to its pinacle.

riz
Starting with the sixth edition of Unix, AT&T licensed the source code

U
at low cost; however, Bell Labs kept the UNIX name trademarked, Plan 9's most significant influence on Linux was UTF-8. Though Linux

ed
and closely held. After AT&T sold UNIX to Novell, the UNIX trademark was intended as a free System V replacement, it has become a
was sold to the Open Group, and the source code licensed to the bridge system, incorporating ideas from Unix and Plan 9, and

AT
Santa Cruz Operation. Each licensee had to come up with their own interoperating with other systems, such as Microsoft Windows.

ep
name, (hence groups that used names like USENIX). Though UNIX is
a trademark, in common usage the capitalization "Unix" is used. See

ro
the preface to A Quarter Century of UNIX (Peter H. Salus – ISBN-13:

du
9780201547771) and

I
http://www.opengroup.org/tm-guidelines.htm.

c tio

O
There are two main branches in the Unix family tree, the System V

n
branch and the BSD branch. The System V branch was maintained by

or
AT&T and the BSD branch by the University of California at Berkeley,

N
and enhancement of the research system. There was lots of

D
cross-pollination of features between the two branches, especially in

is
later editions of research Unix. System V Release 4 is essentially a

t
merger of these two branches. Today, the BSD branch continues in

rib

C
several open-source projects, but System V exists primarily in

ut
commercial off-shoots, such as Oracle Solaris. Several clones are

io
available including Minix and Linux. See http://levenez.com/unix/

O
for a graphical chart of Unix and its derivatives.

n
Pr

PY
oh
ib
ite
d
1-3
FSF and GNU

EV
Richard Stallman – founder of GNU and the FSF
1983 – GNU (GNU's not Unix)
• goal: create the free GNU Operating System
• first programs: emacs and gcc

U
1985 – Free Software Foundation

na
• nonprofit organization for promotion of free software

AL
• manages the GNU project

ut
By 1991 the GNU system was almost complete
• only crucial component missing was a kernel

ho
riz

U
FSF and GNU ed
R

AT
ep
The GNU project was announced in September 1983 by Richard
Stallman with the goal of creating a free software operating system:

ro
GNU. In addition to defining the guiding philosophy for the GNU

du
project, Richard Stallman contributed code, and is the principal author

I
of several important software components such as GCC (the GNU

c tio

O
Compiler Collection), GDB (the GNU Symbolic Debugger), and the
popular GNU Emacs text editor.

n
or
Stallman graduated from Harvard with a degree in Physics. For

N
several years, he worked in the Artificial Intelligence lab at MIT,

D
resigning to work on GNU. He has been granted honorary PhDs from

is
several universities, and won numerous prestigious awards for his

t
continuing efforts to advance the ideals of free software as

rib

C
advocated by the FSF.

ut
The GNU project started work on the Alix kernel in 1990. The kernel is

io

O
now called the Hurd, and runs on top of GNU Mach, a Mach 4

n
micro-kernel. Although a micro-kernel architecture is theoretically a

Pr
superior kernel design, in practice the Mach design has proven

PY
cumbersome. The Debian project provides the official release of

oh
GNU/Hurd.

ib
ite
d
1-4
GPL – General Public License

EV
Guarantees that free software remains free (as in freedom)
All software under the GPL makes source available to the end user
Changes to a GPL licensed software package must also be licensed
under the GPL

U
Source code from GPL licensed software can be incorporated into

na
other GPL licensed software

AL
Other Licenses:

ut
• http://www.gnu.org/licenses/license-list.html
• http://www.opensource.org/licenses/index.html

ho
In 1992, Linus Torvalds released 0.12 of the Linux kernel under the

riz
GPL.

U
Free Software ed Copyleft

AT
ep
In the Linux community you will often hear the term "free software." To help guarantee that all software remains free, with the first GNU
What is meant by this term? What follows is an excerpt from the release of Emacs, Stallman wrote a copyright license so that GNU

ro
GNU website: http://www.gnu.org/philosophy/free-sw.html. "'Free software cannot be hidden in proprietary, "non-free" code. He called

du
software' is a matter of liberty, not price. To understand the concept, this copyleft. See

I
you should think of 'free speech', not 'free beer'." http://www.gnu.org/licenses/licenses.html#WhatIsCopyleft

c tio

O
'Free software' refers to the users' freedom to run, copy, distribute, "Copyleft is a general method for making a program free software

n
study, change and improve the software. More precisely, it refers and requiring all modified and extended versions of the program

or
to four kinds of freedom, for the users of the software: to be free software as well...To copyleft a program, we first state

N
that it is copyrighted; then we add distribution terms, which are a

D
The freedom to run the program, for any purpose (freedom 0). legal instrument that gives everyone the rights to use, modify, and

is
The freedom to study how the program works, and adapt it to your redistribute the program's code or any program derived from it but

t
only if the distribution terms are unchanged. Thus, the code and

rib
needs (freedom 1). Access to the source code is a precondition

C
for this. the freedoms become legally inseparable. Proprietary software

ut
developers use copyright to take away the users' freedom; we
The freedom to redistribute copies so you can help your neighbor

io
use copyright to guarantee their freedom. That's why we reverse

O
(freedom 2). the name, changing 'copyright' into 'copyleft'."

n
Pr
The freedom to improve the program, and release your Licenses

PY
improvements to the public, so that the whole community

oh
benefits. (freedom 3). Access to the source code is a precondition While the GPL license is arguably the most important of the free
software licenses, many other licenses exist.

ib
for this.

ite
A program is free software if users have all of these freedoms. Thus,

d
you should be free to redistribute copies, either with or without
modifications, either gratis, or charging a fee for distribution to
anyone, anywhere.

1-5
The Linux Kernel

EV
Linus Torvalds – Finnish college student
• wanted to replace Minix, a UNIX-like feature-limited teaching OS
The Linux kernel
• fresh re-implementation of the UNIX APIs

U
• under the GPL license

na
The Linux kernel together with GNU and other programs forms a

AL
complete free operating system

ut
ho
riz

U
The Linux Kernel ed PS. Yes - it•s free of any minix code, and it has a

AT
multi-threaded fs. It is NOT portable (uses 386 task switching

ep
Linus Torvalds made the now famous first post about Linux in the etc.), and it probably never will support anything other
comp.os.minix newsgroup in August of 1991. It is reproduced here:

ro
than AT-harddisks, as that•s all I have :-(.

du
From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroups: comp.os.minix

I
c
Subject: What would you like to see most in minix?

tio

O
Summary: small poll for my new operating system

n
Message-ID: <1991Aug25.205708.9541@klaava.Helsinki.FI>

or
Date: 25 Aug. 91 20:57:08 GMT

N
Organization: University of Helsinki

D
Hello everybody out there using minix -

is
t
I•m doing a (free) operating system (just a hobby, won•t

rib

C
be big and professional like gnu) for 386(486) AT clones.

ut
This has been brewing since april, and is starting to get
ready. I•d like any feedback on things people like/dislike

io

O
in minix, as my OS resembles it somewhat (same physical

n
layout of the file-system (due to practical reasons) among

Pr
other things).

PY
oh
I•ve currently ported bash(1.08) and gcc(1.40), and things

ib
seem to work. This implies that I•ll get something practical
within a few months, and I•d like to know what features most

ite
people would want. Any suggestions are welcome, but I won•t

d
promise I•ll implement them :-)
Linus (torvalds@kruuna.helsinki.fi)

1-6
Linux Kernel and Versioning

EV
1994 – Linux kernel 1.0 released
1996 – Linux kernel 2.0 released, based on 1.3 development branch
2003 – Linux kernel 2.6 released, based on 2.5 development branch
2004 – Linux kernel 2.6.8 released, based on Linus' post 2.6.7

U
development branch

na
2004 – Linux kernel 2.6.8.1 released to fix a NFS code problem

AL
2005 – Linux kernel 2.6.11.1 released making stability patches to the

ut
mainline release kernel official
2006 – Linux kernel 2.6.16 was released, becoming the first of several

ho
longterm release kernels

riz
2011 – 3.0 kernel released (after 2.6.39), patched as 3.0.1

U
2015 – 4.0 kernel released (after 3.19)

Linux Kernel Versioning ed Originally, Linux kernels with an even minor number (e.g. 1.2.x, 2.0.x,

AT
2.2.x, 2.4.x) were considered stable production kernels. Only bug

ep
The Linux kernel is maintained by a large group of developers headed fixes and isolated features, such as new drivers, were added to the
by Linus Torvalds. Linus acts as a "benevolent dictator" and has final

ro
stable kernel tree, indicated by a third number, the patch level. Linux
say over what changes are introduced into the official kernel. Linus is kernels with an odd minor number (e.g. 1.1.x, 2.1.x, 2.3.x) were

du
sponsored by the Linux Foundation, a merger of the Open Source development kernels, not to be used on production systems.

I
Development Labs (OSDL) and the Free Standards Group. See

c tio

O
http://www.linux-foundation.org/en/FAQ. The odd-numbered development kernel was where new features
were introduced. When all the slated features were added, then the

n
The Linux kernel version is designated by a major number, a minor development kernel went into a feature freeze where only bug fixes

or
release number, and optionally a patch level. Linux distributors may were allowed. After the development kernels became stable, the

N
add an additional component, the EXTRAVERSION. For example, an version number was bumped so that the minor number was even. If

D
errata kernel might be 3.13.0-42. the number or importance of features was large enough, the major

is
number was incremented.

t
rib

C
In 2004, Linus Torvalds decided that it was not necessary to create a

ut
2.7 development branch, as the overall structure and key components

io
of the 2.6 kernel were sufficient for future development. Instead,

O
further development kernels would be built within the 2.6 tree. Stable

n
kernels then used a fourth version number. The first such release was

Pr
2.6.8.1. Kernels with such a fourth digit were stable patch versions.

PY
oh
Newly incremented third digit versions were made to signify the
completion of sets of new and revised features. See the

ib
Documentation/HOWTO file in the kernel source documentation for

ite
current information.

d
1-7
Kernels now have long term service releases. The first such release depending on the willingness of individuals to keep supporting a
was 2.6.16, released 20 March 2006, and last patched 21 July 2008 release. The mainline kernel is the current release kernel, and the

EV
with release 2.6.16.62. Even though a kernel is declared end-of-life (it kernel in development for the next release, e.g. 3.13-rc7. See
will not receive further updates), kernels are considered stable for 6 https://www.kernel.org/category/releases.html for current
months from release. Other longterm supported kernels include 3.10. information.
Longterm kernel support is usually about two years, plus another 2

U
na

AL
ut
ho
riz

U
ed
R

AT
ep
ro
du

I
c tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
1-8
Components of a Distribution

EV
Typical Linux distributions provide
• collection of applications along with the Linux kernel
• installation program
• documentation

U
• support

na
• some are very specialized (e.g. Linux Router Project)

AL
• POSIX and Single Unix Specification compliance

ut
Most Linux distributions provide the same basic software:
• GNU software

ho
GNU Coding Standards

riz
• BSD and Linux utilities

U
• X.Org, GNOME, KDE, and other GUI components

Linux Distributions ed realize that, in spite of their brand differences, all main-stream Linux

AT
distributions are compatible with each other at the API and binary

ep
Most Linux companies producing distributions have teams of levels, because they all consist of the same core software: GNU and
developers working full time to produce free software. The

ro
BSD libraries and utilities, the X Window System as implemented by
companies earn money from services related to their distribution the X.Org Project, the GNOME and KDE desktops, etc.

du
including support, consulting, and selling boxed copies.

I
In spite of this basic compatibility, distributions are still

c
Most distributions are available for download off of the Internet.

tio

O
distinguishable because their developers tailor them for various
Since 1999, most distributions have also made ISO CD-ROM images markets. For example, some will include advanced software

n
available for download. If you have a fast Internet connection and a packaging functions, or commercial support, or automatic updating

or
CD/DVD writer, you can download an ISO image and create your own capabilities, while others may include features like commercial

N
installation media. Also, the use of bootable USB is typically offered, word-processing software, or additional free software targeted for

D
and is beginning to replace optical media. more specialized audiences.

is
Linux Standards

t
Locating Linux Software

rib

C
There are hundreds of different Linux distributions. At the API/ABI Software for Linux is available for download all over the Internet.

ut
level, all Linux distributions share a common kernel, which conforms Most software projects have their own sites. In addition, there are

io
to the POSIX/IEEE interface specifications and the Single Unix

O
several sites that maintain listings of many programs with links for

n
Specification. The GNU Project follows the design standards of the downloading and more information.
GNU Operating System, which influence the userland, and other

Pr
tools, provided by the GNU Project. This is documented in the Starting places when looking for Linux software include:

PY
oh
standards info manual, found at http://kernel.org/pub/linux
http://www.gnu.org/prep/standards/ http://www.rpmfind.net

ib
http://directory.fsf.org

ite
Components of Distributions

d
With the plethora of Linux distributions on the market, it might at first
seem that Linux is repeating the same Balkanization that has
hampered the Unix world for the past two decades. It's important to

1-9
Slackware

EV
Oldest active distribution
Fork of Softlanding Linux System (SLS)
Added simple package management
• Uses compressed tarballs

U
Added an automated installer

na
Became extremely popular and continues to have a wide following

AL
ut
ho
riz

U
SLS ed
R

AT
ep
The SLS distribution was an early distribution, making it possible for
non-überhackers to install a Linux system on their computer. Before

ro
Linux distributions, if you wanted to install Linux, you would first

du
download and install Minix, Xenix, SysV, or a 386BSD derivative, then

I
after building the GNU toolkit (binutils, glibc, and perhaps gcc),

c tio

O
you could begin the process of downloading, configuring, and
compiling the Linux kernel, and a boot loader (e.g. LILO). This gave

n
you a kernel, but no commands. Now you could begin downloading

or
the GNU userland, and other source code.

N
D
Slackware

is
First released in April 1993, and a derivative of SLS, Slackware has

t
rib

C
long sought to be the most Unix-like of all the Linux distributions. In
addition, Slackware primarily targets Intel-compatible architectures;

ut
few ports to other architectures have been completed and released.

io

O
Slackware tends to be popular among those who prefer a

n
minimalistic approach to Linux installation and configuration.

Pr
The first commercial Linux was S.u.S.E., which originally distributed

PY
oh
Slackware. Pat Volkerding assisted in the development of the early
S.u.S.E. releases, until it switched to RPM and forked as its own

ib
distribution. SUSE still has many underlying similarities to Slackware.
Additional information about how to Get Slack can be found at
ite
d
http://slackware.com. The name Slackware is derived from the
teachings of the Church of the SubGenius, http://subgenius.com.

1-10
SUSE Linux Products

EV
SUSE Linux Enterprise Family <http://www.suse.com>
• Server and Desktop releases
• 10-13 year maintenance life cycle
• Highly scalable, mature technology

U
• Three platforms: AMD64/Intel64, ppc64le (Power 8), IBM s/390x

na
(z196 and z114)

AL
• ISV certifications

ut
The openSUSE Project <http://www.opensuse.org>
• Tumbleweed: cutting edge

ho
• Future stable releases are based on SLE

riz

U
SUSE Linux Enterprise Family ed See https://www.suse.com/lifecycle/ for details.

AT
ep
There are two SUSE Linux Enterprise products available from SUSE: Some of the features included in SUSE Linux Enterprise Server are as
SUSE Linux Enterprise Server (SLES) and SUSE Linux Enterprise follows. (For a full list of features, see http://www.suse.com/).

ro
Desktop (SLED). SUSE Linux Enterprise has a 10 year life cycle.

du
Customers can deploy SLES and SLED and have security and bug y Scalability
y Scales up to 8192 CPUs

I
fixes available for the entire duration. The extended 18-24 month

c
y Certified to at least 64 TiB of RAM (1-4 TiB theoretically,

tio

O
release cycle coupled with the 10 year life cycle allows ISVs time to
certify their products on a stable Linux platform. depending on architecture)

n
y Clustering and High Availability (HA)

or
Life Cycle Considerations y Support for load balance clustering and HA configurations

N
y Platform Availability

D
The SUSE Linux Enterprise family has three stages of support:
y AMD64/Intel64, ppc64le (POWER8 only), IBM zSeries s/390x
general support, extended support, and self-support. The general

is
(z196 and z114)
support period is for the first 10 years of life, and is supported within

trib

C
periodic service pack releases. Each service pack has the option for The openSUSE Project
long term service pack support after a 6 month grace period in

ut
between service pack releases, and often will have extended support. The openSUSE project was founded by Novell as the community

io

O
Feature additions are only within the first 5 years of the general supported successor to SUSE Linux Professional. Focused on the

n
support life cycle. The extended support period provides 3 years of most current and cutting edge open-source technologies, openSUSE's

Pr
extended (long term service pack support) for server editions, and Tumbleweed provides builds of the newest open-source packages for

PY
with SLED11 for desktop editions, with critical bug maintenance openSUSE. openSUSE 13.1 is currently maintained by Project

oh
(such as security patches) for a subset of packages. Self-support is Evergreen until November 2016. openSUSE 13.2 is the currently

ib
available throughout the 13 year life cycle. End-of-life, the end of the supported release. Releases beyond 13.2 are planned to based on

ite
extended support cycle, is as follows: SLE, currently called Leap, with its first release in November 2015.

d
y SLES10: 31 July 2016. (Extended and self support only.)
y SLES11: 31 March 2019/2022.
y SLES12: 31 October 2024/2027.

1-11
Debian

EV
Second oldest active distribution
Initially sponsored by the FSF
Authored and Controlled by the Debian community
Very committed to free software

U
Uses own package management, dpkg

na
Innovated with in-place, no reboot upgradability

AL
Easy to keep your system current

ut
• apt-get update
• apt-get upgrade

ho
riz

U
Debian ed
R

AT
ep
Begun the same year, shortly before Red Hat Linux, the
non-commercial Debian project sought to develop a package-based

ro
approach to GNU/Linux installation. Since that time, Debian has

du
become popular for its dedication to free software principles and for

I
its huge variety of packaged software. It is also the most widely

c tio

O
ported GNU/Linux distribution, with ports to over a dozen
architectures, completed or in progress. It has even begun to support

n
non-Linux kernels, including the Hurd and various BSD project

or
kernels.

N
D
Much like Linux itself, Debian is developed and maintained by a cadre

is
of thousands of volunteers from all over the world, working together

t
over the Internet.

rib

C
Additional information about Debian can be found at

ut
http://www.debian.org/.

io

O
n
Pr

PY
oh
ib
ite
d
1-12
Ubuntu

EV
Founded by Mark Shuttleworth
Licensed by Canonical
Based closely on Debian
Uses Debian's package management, dpkg

U
Easy to keep your system current

na
• aptitude update

AL
• aptitude upgrade

ut
Package Update Availability
• Nine months

ho
• LTS: Five years

riz

U
Ubuntu ed
R

AT
ep
Ubuntu was first released in October 2004 with the 4.10 release.
Since that time Ubuntu has stuck to a strict six-month release cycle

ro
using a "Year.Month" versioning scheme.

du
Ubuntu supports each six month released version with security and

I
c
errata updates for 9 months. Beginning with 6.06, Ubuntu marked

tio

O
releases as LTS every two years, which were given additional

n
preparation and support. LTS releases are currently supported for five

or
years. Ubuntu also promises that they will never have an "Enterprise"

N
release, meaning that the entire community—business or

D
personal—will benefit from the same product.

is
A few of the key things that separate Ubuntu from other distributions

t
rib

C
are:

ut
y Community first

io
y Ubuntu Code of Conduct

O
n
y No "Enterprise" release
y Ubuntu will always be free of charge

Pr

PY
oh
ib
ite
d
1-13
Red Hat Linux Products

EV
Invented the RPM Package Manager
Easy-to-use installer integrates partitioning and leverages RPM
Loyal to free software ideals: only ships open-source software with
few exceptions that restrict modification and redistribution.

U
Fedora

na
• Cutting edge, community oriented project

AL
• Provides new technology for future RHEL releases

ut
Red Hat Enterprise Linux (RHEL)
• Enterprise targeted distribution with commercial support

ho
CentOS

riz
• Community edition of Red Hat Enterprise Linux

U
Red Hat Enterprise Linux ed Red Hat Enterprise Linux for SAP Business Applications ⇒ Ships

AT
with the Server component, plus SAP Business Applications

ep
First released in 1994, Red Hat Linux (RHL) quickly became the most Red Hat Enterprise Linux for SAP HANA ⇒ Provides in-memory
popular Linux distribution in the United States. Red Hat introduced a

ro
database management with SAP HANA.
variety of tools which simplify system management, such as RPM Red Hat Enterprise Linux Client ⇒ Desktop oriented, with more

du
and Kickstart, and has been ported to several architectures. The fast add-ons, but less server, software.

I
pace of RHL releases lead ISVs to ask Red Hat for a long-term option

c
Red Hat Enterprise Linux Workstation ⇒ The same as Client, but

tio

O
to allow product certification on a stable platform. The result was the with development add-ons.
introduction of what became Red Hat Enterprise Linux (RHEL), a

n
Red Hat Cloud Infrastructure ⇒ Includes Red Hat Enterprise Linux
stability branch of RHL/Fedora. See http://www.redhat.com/. OpenStack Platform, Red Hat Enterprise Virtualization, and Red

or

N
y RPMs bundled with purchased support contract Hat CloudForms.

D
y Source RPMs freely available and accessible For a complete breakdown of the differences between RHEL variants,

is
y Ten year life cycle for feature additions and bug/security fixes and other options, such as support for IBM System Z and POWER

t
y Per-year extensions after end-of-life (existing clients)

rib
systems, see http://www.redhat.com/rhel/compare/.

C
Red Hat Enterprise Linux comes in several variants, including:

ut
Fedora

io
Red Hat Enterprise Linux for Server ⇒ The primary Enterprise Linux

O
With the release of RHEL3, Red Hat decided to rename RHL to

n
release, but requires a key to unlock add-on software (at install), eliminate confusion with RHEL. What would have been called Red
and in some cases extra media. Not all packages built from

Pr
Hat Linux 10 became Fedora Core 1. The name change to Fedora
source RPMs are included on the installation media, but instead

PY
Core wasn't only about the name. Fedora is a community project,

oh
are only available from RHN. These packages are labeled optional, open to the public. The Fedora Core and Fedora Extras repositories
and are not covered by the ABI compatibility guarantees, or errata

ib
were merged for the release of Fedora 7. The word "Core" has,
support (though errata may extend from related updates), similar

ite
therefore, been dropped.
to supplementary packages

d
Red Hat Enterprise Linux for High-Performance Computing ⇒ Increased y Release cycle of 6 months
RHEL Server support options (e.g. more CPUs, SAN) intended for y 13 month life cycle for bug/security fixes
High Performance Computing y Commercial support is not available from Red Hat

1-14
CentOS
CentOS is a Red Hat sponsored community release of Red Hat

EV
Enterprise Linux. It removes trademarked components to allow legal
redistribution of Red Hat Enterprise Linux, and to provide access to
RHEL for testing and development without a Red Hat Network
subscription. See http://centos.org.

U
na

AL
ut
ho
riz

U
ed
R

AT
ep
ro
du

I
c tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
1-15
Oracle Linux

EV
Oracle Linux
• Matched release cycles with RHEL
• Binary and Source compatible with RHEL
• Highly scalable, mature technology

U
• AMD64/Intel64

na
• ISV certifications

AL
ut
ho
riz

U
Oracle Linux ed
R

AT
ep
Oracle Linux is an Oracle provided Linux distribution that is source
and binary compatible to Red Hat Enterprise Linux. Oracle uses the

ro
publicly available source code from Red Hat Enterprise Linux for the

du
core of its distribution. While Oracle does incorporate additional

I
patches and updates, they maintain compatibility with both Red Hat

c tio

O
Enterprise Linux, and the certified ISV products which run on it.

n
Patches and modifications to Oracle Linux are released to the Linux

or
community under the GPL license and are available for anyone,

N
including Red Hat, to use and incorporate into their products.

D
Oracle Linux (7.0) features include:

is
t
rib
CPU ⇒ up to 240 cores

C
Physical memory ⇒ up to 3TB

ut
ext4 ⇒ up to 16TB filesystems

io
XFS ⇒ up to 500TB filesystems

O
n
Btrfs ⇒ up to 16EB filesystems
ocfs2 ⇒ up to 16TB filesystems

Pr
Kernel base version ⇒ Compatible: 3.10

PY
For a complete list of features refer to:
oh
ib
http://www.oracle.com/linux/

ite
Oracle Linux is available free of charge from

d
http://linux.oracle.com.

1-16
EV
Content
Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Running Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Interacting with Command Line . . . . . . . . . . . . . . . . . . . . . . 4

U
Desktop Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

na
GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

AL
Starting X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

ut
Gathering Login Session Info . . . . . . . . . . . . . . . . . . . . . . . 11

ho
Gathering System Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
uptime & w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

riz
got root? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

U
ed
Switching User Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Chapter
R
Help from Commands and Documentation . . . . . . . . . . . 19

AT 2
ep
whereis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Getting Help Within the Graphical Desktop . . . . . . . . . . . 21

ro
Getting Help with man & info . . . . . . . . . . . . . . . . . . . . . . . . 22

du
Lab Tasks 24
1. Login and Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

I
c
2. Help with Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

tio

O
3. Switching Users With su . . . . . . . . . . . . . . . . . . . . . . . . . 34

n
or

N
LOGIN AND
D
is
EXPLORATION
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
Logging In

EV
Serial terminals — Text mode login via serial port
• mgetty+login — Handles modems
• agetty+login — Handles VT100/VT220 dumb terminals
Virtual terminals — Text mode login(s) on local console

U
• agetty+login

na
• mingetty+login

AL
Graphical — GUI login on local console

ut
• xdm, gdm, kdm, etc.
• Terminal Emulator

ho
xterm, rxvt, gnome-terminal, konsole

riz
Network logins — Remote text mode login

U
• in.telnetd+login, in.rlogind, sshd, etc.

Logging In ed used on modern systems). In the case of modems, the

AT
process started is usually /sbin/mgetty. In the case of virtual

ep
On a multi-user operating system, user identification is essential. This terminals, where no serial port management code is needed,
can be accomplished with hardware-based passkeys, biometrics (e.g.

ro
the light-weight /sbin/mingetty may be used instead, if
fingerprints, voiceprints, retina scans), and other authentication available.

du
tokens. The most common method is to prompt the user to enter a 5. The getty process is the second of the three programs (init,

I
username and corresponding password.

c
getty, and login) used by the system to allow users to log in.

tio

O
To provide authentication services and permit access to the system, mgetty, agetty, or mingetty is invoked by init to:

n
Linux will run special processes that are designed to gather a user's y Open tty lines and set their modes.
y Print the login banner, usually the contents of the

or
username and authentication token(s) (such as a password). To

N
understand the processes involved, you must examine some basics /etc/issue file.

D
of the boot process: y Spawn a login process for the user, usually /bin/login.

is
6. The login program is what actually prompts the user to input
1. When a Linux system boots, it must first locate and load the

t
their password. login will then validate the user's credentials

rib

C
kernel. and start the shell defined in the user's corresponding
2. When the kernel finishes its loading process, it loads and

ut
/etc/passwd entry.
passes control to some initial process, usually the program

io
If configured, graphical logins are provided by one of the graphical

O
init.

n
3. The init process goes through its initialization procedures, display managers, commonly: xdm, gdm, or kdm. After logging in
graphically, a terminal emulator can be run (such as the

Pr
part of which is to enter the currently defined run-level.
gnome-terminal command) to get a command shell, or from within

PY
Run-levels (among other things) determine if the system will

oh
display a text or graphical login prompt at the console. GNOME or KDE, the key combination Ô¿Å can be used.

ib
4. For a text mode login, init spawns one or more getty Network login access is provided by daemons such as in.telnetd,

ite
processes and associates them with the appropriate terminals. in.rlogind, or sshd which are launched as stand alone services, or
getty is the program responsible for configuring the terminal from a super-server such as xinetd. These programs take the place

d
hardware settings. agetty is the typical package used for of mgetty, and in some cases login as well. For security reasons,
providing getty (sometimes named agetty), and is especially SSH has replaced rlogin and telnet in most environments and
suitable for directly attached serial terminals (though rarely provides both strong authentication and encryption.
2-2
Running Programs

EV
Graphical environment (e.g. X+GNOME)
Command line (e.g. Bash)

U
na

AL
ut
ho
riz

U
Running Programs Within the GUI ed Running Programs From the Command Line (Text Interface)

AT
ep
Linux includes a graphical server called X and several full-featured Linux includes special programs called shells that provide a command
desktop environments such as GNOME and KDE. Most Linux line interface to the system. Modern shell programs such as Bash

ro
workstations boot automatically to a graphical login. Server systems (the default shell) are highly configurable and feature rich. When

du
may have the graphical interface installed, but more commonly boot launched, shells present a text interface with a string called a prompt

I
directly to a text login. being displayed. Typing the name of a program at this prompt and

c tio

O
then pressing Õ will launch the program.
Most graphical desktops provide an intuitive interface for launching

n
programs such as a simple menu. If the name of the program is Advantages of the command line include:

or
known, an alternative is to type that name from a terminal command

N
prompt and press Õ. In the GNOME and KDE desktop, pressing y Most tasks can be accomplished more quickly verses the

D
Ô¿Å opens a dialog where programs can be launched by typing the equivalent option performed within the GUI.

is
command name. If running commands from a terminal emulator, y The ability to pass options and arguments to programs provides
finer grained control than most GUI interfaces.

t
graphical programs may need to have the & character appended to

rib

C
ensure the command does not tie up the terminal. Graphical y Lower overhead: most command line programs use less
memory and CPU than equivalent GUI programs.

ut
programs requiring administrative privileges typically should be run as
y Ease of automation due to shell scripting features and

io
a regular user; the program will prompt for the root user's (or other

O
administrative) password. non-captive program interfaces. Once packaged into a script, a

n
sequence of commands can be run on hundreds of systems

Pr
Advantages of the GUI include: nearly as easily as a single system.

PY
y Easily accommodates remote access and interaction. Programs

oh
y Aesthetically compelling and inviting to new users.
such as SSH can allow secure interaction with a command shell
y Ease of multitasking (click and drag to move and resize program

ib
on a remote system, even over low bandwidth links.
windows, click on a program to bring it to focus and interact

ite
y The shell provides powerful ways to connect programs together
with it, etc.)
to accomplish more complex tasks. Almost any command line

d
y Graphical display can convey, and allow interaction with, certain
program can be connected to any other, (although not all
types of information very efficiently.
combinations are useful or make sense).
y Some advanced applications require the GUI (e.g. The Gimp)

2-3
Interacting with Command Line

EV
What happens when I press Õ at the command prompt?
• expansion, substitution, and splitting performed
• redirection setup
• execution

U
Command options

na
Command arguments

AL
Common errors

ut
Tips and Tricks

ho
riz

U
Processing of the Command Line ed Command Options

AT
ep
The shell command prompt provides an interactive text interface for Depending on how they are run, most commands can change their
running programs. Under normal usage, you type the name of the behavior. These extra command features are accessed by passing the

ro
program you want to run and hit Õ. The shell executes the program corresponding "option" when running the program. To help the shell

du
and it may return results which are printed to the same text window. and command recognize options, they are almost always preceded

I
This process is then repeated as needed, (running commands and with either a single dash "-" or two dashes "--".

c tio

O
analyzing the results).
Letters that follow a single dash are called short options and will

n
With a modern shell, several types of pre-processing are performed activate the corresponding feature of the program when it runs.

or
on the command line before a program is run. For example, many Generally, the order of options does not matter. For example, each of

N
characters have special meaning to the shell and cause it to perform the following would be operationally identical (causing the command

D
expansion or substitution, replacing these special characters with to run with the a, b, and c options selected:

is
other values. The shell must also break the input into logical pieces,
$ command -abc

t
an operation called word splitting, with whitespace acting as the

rib

C
$ command -cba
primary delimiter between words.
$ command -a -b -c

ut
By default, commands run from the shell can continue to accept $ command -c -b -a

io

O
input typed into the same terminal while they execute. Output or Short options are quick to type and generally have some mnemonic

n
errors generated by the program will be displayed on the same significance. Some commands support long options as a more

Pr
terminal. Alternatively, you can tell the shell to redirect input and descriptive alternative. These are specified with a preceding double

PY
output to another place. For example, input might be read from a file,

oh
dash:
or output sent to a file or another program.

ib
$ command --alpha --beta --charlie
Finally, the shell will attempt to run the specified program. If the shell

ite
can't locate the program then an error is displayed. When run, some Often commands support both short (Unix) and long (GNU) options
for the same feature. Other times, a feature will be accessible via

d
programs will exit quickly returning you to a command prompt. Other
programs may continue accepting input from the terminal effectively only one type or the other. A mix of option types can be used:
preventing you from running other programs from that shell. $ command -a --beta -c --delta
2-4
Command Arguments Multiple Commands on One Command Line
Many commands are designed to operate on one or more objects Sometimes, it is desirable to enter several commands at once and

EV
(often files). This list of objects are called "arguments" and are then have the system execute them one by one. This can be
generally listed after the command name options. When the shell accomplished using a semi-colon to separate commands. For
runs a command, it passes the list of arguments to the command as example:
an array. Arguments not preceded by a dash are normally delimited

U
by whitespace. For example: $ command_1; command_2

na

AL
Commands are run in a serial fashion only after the preceding

ut
$ command --option1 arg1 arg2
command finishes and exits. If separate commands need to share a

ho
Common Errors shell variable, or avoid permanent settings (e.g. umask), the
commands can be grouped together in parentheses:

riz
The shell searches a configurable list of locations for programs. If the

U
ed
program you want to run is not installed into one of the configured $ (foo=bar; echo $foo)
directories, or if you make a typo in specifying the name of the bar

R
program then an error is returned:

AT
$ echo $foo

ep
$ command $

ro
bash: command: command not found
Command Line Tips and Tricks

du
If the file containing the program does not grant you execute
Modern command shells have a large number of features designed to

I
permissions then attempts to run it result in an error:

c tio
make command line access more efficient and increase productivity.

O
$ command The following is a brief list of features. More extensive coverage of

n
bash: command: Permission denied each of these features is found in later chapters.

or

N
If an invalid (unknown) option is specified, then an error is displayed. History ⇒ The shell keeps a record of commands run in each

D
Often some basic usage information, or help, for the command is session. Use the arrow keys to bring back previously run

is
also displayed: commands to save typing.

t
Completion ⇒ Context sensitive auto-completion functions can save

rib

C
$ command -a huge amounts of typing. With default settings, press the Ð key
command: invalid option -- a

ut
to attempt completion.
Try command --help• for more information. Aliases ⇒ Give your own names to commands by defining aliases.

io

O
For example, after running alias p="cd ..", typing pÕ at the

n
If an invalid argument is specified (such as a file that doesn't exist),
then a command specific error is generated. The following is a prompt would change to the parent directory.

Pr
common example: Clear screen ⇒ Pressing Ó¿l will clear the screen, (Bash specific).

PY
oh
Copy & Paste ⇒ The act of highlighting text with the mouse (by left
$ command file1 clicking and dragging to select it) automatically places a copy of

ib
command: cannot stat file1•: No such file or directory that text into a copy buffer. Clicking the middle mouse button will

ite
paste from that buffer.

d
2-5
Desktop Environments

EV
Complete interface
• Consistent look and feel
Standardized working environment
• Window manager (window placement, behavior, and virtual

U
desktops

na
File manager, applications and utilities

AL
• Display Manager

ut
Originally handled terminal hangups and log in
graphical directory of available logins

ho
remote display connection/browsing

riz
Look and feel of X actually a function of the window manager

U
• Tom's Window Manager (TWM, officially maintained by X.Org)

Desktop Environments ed on providing a clean, simple interface, with full EWMH support; and

AT
FVWM, based on TWM: historically one of the first window

ep
As with Unix, the X Window System consists of many small, discrete managers, and still quite popular. More information, including screen
applications, rather than one huge monolithic application. As a result,

ro
shots, about these and other window managers can be found at
the X server application itself only provides a screen on which http://www.xwinman.org/.

du
applications can be displayed. The task of actually managing those

I
applications, and providing the user with a way to manipulate those X Display Managers

c tio

O
applications (iconify them, move them on the screen, and so forth) is
handled by a separate program, the aptly named window manager. Display managers provide graphical logins for Linux. In addition to

n
basic user authentication (much like the login program offers),

or
Historically, X has long had a variety of window managers which display managers also take care of setting up the initial user

N
provide basic windowing functionality—manipulating window environment; typically, they offer a choice of several different

D
placement, modifying window size, and so forth. In the early 1990s, graphical setups which the user can select when they log into the

is
window managers began acquiring additional functionality, such as system. Many display managers offer more advanced services as

t
toolbars for launching commonly used applications. By the well, such as a graphical browser of available logins, or a graphical

rib

C
mid-1990s, developers began extending window managers even browser of remote systems which can be accessed using the display

ut
further, creating desktop environments. Desktop environments manager.

io
implement all the functionality provided by window managers, either

O
as a separate window manager or as an integral part of the desktop Linux offers a variety of different display managers which can be

n
environment, but they also provide other features: end-user applets, selected, depending up on the feature set and appearance desired by

Pr
such as text editors and games; utilities, like desktop clocks; an the system administrator. Through the display manager, the X

PY
Window System also provides remote access to the graphical display,

oh
application launcher; and file managers. The two leading desktop
environments these days are GNOME and KDE. Xfce and LXDE are or its programs. X Window system security is provided through a

ib
popular, lighter weight alternatives. trusted host, by host name.

Popular window managers include Window Maker, which provides an


ite
d
interface similar to the old NeXT environment; Enlightenment, a
full-featured window manager which strives to provide maximal
amounts of eye candy; Blackbox, a window manager which focuses

2-6
GNOME

EV
GNOME – consistent desktop environment
• all GNOME applications have a common look
Uses the GTK library
• programmable in many different programming languages

U
Theme-able

na
GNOME 3 use Mutter by default

AL
• Originally used the Enlightenment window manager, then

ut
Sawfish
• GNOME 2 used Metacity

ho
gnome-control-center

riz

U
GNOME ed
R

AT
ep
The GNOME project, begun by the FSF to provide a free software
alternative to KDE (KDE was originally built on the non-free Qt library),

ro
has built a complete free and easy-to-use desktop environment for

du
the user, as well as a powerful application framework for the

I
software developer. All GNOME applications look and feel the same,

c tio

O
and can be configured through the GNOME Control Center.

n
One powerful feature of GNOME is its support for themes. By

or
configuring themes, the end user can easily modify GNOME (and

N
consequently all GNOME applications) to look and feel how they

D
would like.

is
Additional information about GNOME, as well as a large catalog of

trib

C
GNOME applications, can be found at the GNOME website:
http://www.gnome.org/.

ut
io
The following shows a simple GNOME 3 desktop, in Classic Mode,

O
n
with open programs:

Pr

PY
oh
ib
ite
d
2-7
GNOME Settings
The GNOME Settings is the central location for modifying all things

EV
related to GNOME. You can modify screensaver settings, keyboard
settings, themes and background wallpaper, among other items. All
changed settings take effect immediately. For ease of use, there are
no "Apply" buttons.

U
na

AL
Accessing the GNOME Settings can be done by selecting Places →
System Tools → Settings. This launches the gnome-control-center

ut
command. From the command-line, type gnome-control-center -l

ho
to get a list of available panels.

riz

U
ed
R

AT
ep
ro
du

I
c tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
2-8
Starting X

EV
X already running with a graphical login
• On Red Hat Enterprise Linux and SUSE Linux Enterprise Server,
the systemd graphical.target
See the /etc/systemd/system/default.target symlink

U
• On Ubuntu, runlevels 2-5 by default

na
From a text virtual terminal login, use startx

AL
• startx is a shell script that eventually runs xinit

ut
• can run xinit manually, but by default only starts the X server

ho
riz

U
Starting X ed Changing runlevels on the fly

AT
ep
X can be started in a variety of ways. Often, X will already be started To change the current runlevel, the following is the equivalent to
for you; Linux systems can be configured to boot either to a graphical changing to runlevel 5 with the telinit command:

ro
login screen, or a text login prompt.

du
# systemctl isolate graphical.target
Starting X on boot on RHEL7/SLES12

I
c
The following is the equivalent to changing to runlevel 3 with the

tio

O
Whether Red Hat Enterprise Linux and SUSE Linux Enterprise Server telinit command:
boots by default to a text-based login, or to a graphical login, is

n
controlled by the systemd graphical target. To configure the system # systemctl isolate multi-user.target

or

N
to start with a graphical login, and be presented with a display
Starting X at boot on Ubuntu

D
manager login prompt, the following will provide the equivalent of
setting runlevel 5 and setting it as the default:

is
Whether Ubuntu boots to a text-based login, or graphical login, by

t
default is controlled by whether or not the graphical login manager is

rib
[R7] The following applies to RHEL7 only:

C
installed. To configure the system to no longer boot to a graphical

ut
# systemctl enable graphical.target -f login, while leaving the display manager installed, requires a

io
modification to the GRUB boot loader:

O
[S12] The following applies to SLES12 only:

n
File: /etc/default/grub

Pr
# systemctl set-default graphical.target -f → GRUB_CMDLINE_LINUX="text"

PY
oh
To configure the system boot to a text login prompt, do the
following: To complete this change, run the update-grub command.

ib
ite
[R7] The following applies to RHEL7 only: $ sudo update-grub

d
# systemctl enable multi-user.target -f The display manager can be manually started from its init script (in
the /etc/init.d/ directory), controlled by the initctl (or the
[S12] The following applies to SLES12 only: service or start) command.
# systemctl set-default multi-user.target -f 2-9
To reenable the display manager, revert the change made to
/etc/default/grub.

EV
$ sudo sed -i •s/text//• /etc/default/grub
$ sudo update-grub
Starting X manually

U
na
If X is not started automatically, you can start it manually or by

AL
running the xinit command to start the X server. Usually, this

ut
requires custom configuration (in /etc/X11/ or ž/.xinitrc), so the

ho
startx command starts a more usable, pre-configured graphical
environment. Since X is modular, you can control exactly how much

riz
of it you start.

U
ed
Accessing Virtual Terminal

AT
Running one or more X graphical servers on a system does not

ep
preclude having simultaneous text login sessions. Each graphical or
text session will be associated with a virtual terminal. The first twelve

ro
virtual terminals can be accessed by pressing Ô¿Ä through Ô¿Ï

du
respectively (when in X, Ó is also necessary). Optionally, using

I
Ô¿¡ or Ô¿¤ works when not in X and can be used to access

c tio
high numbered terminals (moving sequentially from one terminal to

O
the next).

n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
2-10
Gathering Login Session Info

EV
Who are you really?
• UID – user id
• GID – group id
• terminal: tty, pts

U
Commands for gathering information:

na
• id

AL
id -un|whoami

ut
id -Gn|groups
• tty

ho
riz

U
ed
Identifying Users, Groups, and Terminals

AT
ep
Although it is common to identify users by their username, at a lower
level the system uses simple numbers to identify the various users

ro
on the system. Each user account on the system is associated with a

du
user identification number called the UID. This UID identifies the user,

I
and is used to track processes and files created by that user.

c tio

O
For ease of administration and use, Linux makes use of a group

n
scheme. Each group defined on the system has both a name and a

or
unique identification number called a GID. Although a user may be a

N
member of several groups on the system, they can only have one

D
group active at any given instant.

is
When you are interacting with the system, some type of terminal will

t
rib

C
be associated with your session. Following the Unix design
philosophy mentioned earlier, terminals are represented on the

ut
system as files. The following list shows several types of logins, and

io

O
the ttys used by each:
/dev/ttyS0, /dev/ttyS1 . . . ⇒ Serial terminals
n
Pr
/dev/tty0, /dev/tty1 . . . ⇒ Virtual terminal

PY
oh
/dev/pts/x ⇒ Network connected terminals (i.e. via ssh)
/dev/pts/x ⇒ Text terminals in an X Window System terminal

ib
emulator

ite
d
2-11
Gathering System Info

EV
Who else is logged into the system?
• users, who, w, last
What type of system is this?
• cat /etc/os-release

U
• uname -a

na
• hostnamectl

AL
• free

ut
What is the system's network name
• uname -n and hostname and cat /etc/hostname

ho
• ip and ifconfig

riz

U
Determining Who is Using the System ed to which you are currently connected. If your terminal prompt does

AT
not list the host name of the system, it is very easy to forget on

ep
On a multi-user system, sometimes it is helpful to see which other which system that terminal is connected. This is further complicated
users are currently logged onto the system. Maybe you just want to

ro
by the fact that it is not at all uncommon to have multiple terminals
send a quick message to the console of a friend, or perhaps you open simultaneously, connected to different machines.

du
want to run a process that you know will largely monopolize a certain

I
resource on the system, and you want to wait for a time when The hostnamectl command can be used to query and change the

c tio

O
system usage is low. Even more likely, you notice that some resource system hostname and related settings. Details and information
is being largely consumed (memory, CPU, disk, etc.) and you want to presented by the hostnamectl command includes the Static

n
see who is using it so you can go complain. hostname, system Chassis information, Machine ID and Boot ID, as

or
well as OS, Kernel version, and Architecture. The information and

N
Linux provides several commands such as users, who, w and last details presented by the hostnamectl command varies depending on

D
that allow you to query the system and determine who is currently your system. The command also provides a number of options which

is
logged on, as well as gain other useful information such as: can be used to operate on a remote host and change many of the

t
rib
system details listed above. To query information about the local

C
y when they logged on
y how long they have been idle host, type:

ut
y what process they are currently running

io
$ hostnamectl status

O
y what tty they are attached to

n
To operate on a remote host, type:
Many of the commands mentioned above return largely the same

Pr
information, differing only in supported options, how they obtain the $ hostnamectl -H user@host

PY
oh
information, or in the formatting of the output.
To set a new hostname on the local host, type:

ib
Gathering and Changing System Details

ite
$ hostnamectl set-hostname NAME
The amount of physical memory in the system and usage can be

d
obtained by running the free command. Numerous more commands are available for hostnamectl. To veiw a
full comprehensive list of commands and correct usage details, check
The uname command can be used to list information about the host out the man page.

2-12
Networking Details
The uname -n or the hostname command can be used to determine

EV
the host name as well as the domain name. To only view the
hostname, type:
$ hostname -s

U
na
To view the domain name run:

AL
ut
$ hostname -d

ho
To view IP settings run the command ip addr. To see what DNS

riz
servers are configured look in the file /etc/resolv.conf.

U
ed
R

AT
ep
ro
du

I
c tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
2-13
uptime & w

EV
uptime
• Shows the following information:
Current time
How long the system has been running

U
The number of users logged in to the system
The system load average.

na

AL
• Reads data from /proc/ and /var/log/wtmp

ut
w
• Same ouput as update plus list of logged in users

ho
• Use -i to display remote IP address instead of hostname

riz

U
uptime ed w

AT
ep
The uptime command provides a quick and easy way of viewing The w command provides the same information as the uptime with
information about the running system. the addition of displaying all the logged in users. For example:

ro
du
The first entry shows the current time and how long the system has $ w
been booted. The second entry indicates the number of users 17:56:10 up 3 days, 15:11, 25 users, load average:a

I
c
currently logged in, as logged by /var/log/wtmp. The final entry 0.16, 0.16, 0.15

tio

O
provides an indication of how busy the system is over 1, 5 and 15 USER TTY FROM LOGIN@ IDLE WHAT

n
minute averages. gurulabs pts/3 40.141.117.2 17:56 1.00s w

or
ddmayne pts/8 ddmayne.dsl.xmis 07:58 17:54 -bash

N
CPU load averages show the CPU capacity available, and the average
amipjs pts/11 ip98-163-88-193. Mon06 9:43m pine

D
processes using them. Systems that have multiple cores will report
jjanney pts/12 216:S.0 Sat07 3days emacs -nw
one CPU per core. The number will be doubled if hyperthreading is

is
jjanney pts/13 216:S.1 Sat07 2:05m w3m
enabled. The following example shows a single processor (one core,

trib
bmwright pts/14 179.5.103.122 17:32 23:42 -ksh

C
no hyperthreading) with 0.42 processes that had to wait their turn in
the previous minute of CPU cycle, but which otherwise were not

ut
overloaded:

io

O
n
$ uptime
14:37:56 up 5:34, 5 users, load average: 1.42, 0.27, 0.12

Pr

PY
oh
ib
ite
d
2-14
got root?

EV
Many operating systems have the concept of a super user
This super, or privileged, user has special access rights and privileges
on the system
The root user is the privileged user on most Unix systems

U
Has the user ID (UID) of zero (0)

na

AL
ut
ho
riz

U
root ed
R

AT
ep
Many network operating systems support the concept of a privileged
user. On Linux (as on most Unix systems), this user is called the root

ro
user. The root user is in many respects all-powerful on the system.

du
Below is a short list of some of the things that the root user can do:

I
c
y Change to any directory and read and write to files regardless of

tio

O
the permissions set on those files

n
y Install software and make it available system wide (because

or
root can create/modify/delete files anywhere)

N
y Modify device settings

D
y Modify the network configuration

is
y Change the time on the system

t
y Add/modify/remove users on the system

rib

C
y Assume the identity of any user on the system

ut
Although the name of the all-powerful, privileged user is normally

io

O
root, the name assigned to the user is not actually important. The

n
system identifies users by assigning a number to each called the user

Pr
identifier or UID. The privileged user is identified by the UID of 0.

PY
However, it is recommended that the root user name not be

oh
changed, as there are some user-space pieces that actually look at

ib
the username rather than the UID.

ite
[U1604] The following applies to U16.04 only:

d
On Ubuntu the root account password is locked by default.

2-15
Switching User Contexts

EV
su: launch a new shell as another user (using the target user's
credentials)
• Use - | -l | --login to inherit login profile
• Default user is root

U
sudo: run a single command with another user's privilege

na
• Remembers authentication per-terminal (typically five minutes)

AL
• Configuration affects authentication and available privilege

ut
(/etc/sudoers)

ho
riz

U
Switching User Contexts ed configuration), type sudo -i.

AT
y To run a single command using another user's privilege, type

ep
On a multi-user system, an individual may have more than one sudo command_name.
account. Logged in from one account, there may be a need to do

ro
something using another account. This would require the following In both cases, the sudo command will ask for the user's password,

du
procedure: and based on the configuration in the file /etc/sudoers, will allow

I
c
the user to execute an administrative command.
1. log out

tio

O
2. log in using the new account sudo remembers authentication by username and terminal, typically

n
3. execute the needed commands for five minutes. To extend the time out, run sudo -v. To cancel the

or
4. log out of the new account time out, run sudo -k.

N
5. log back in using the old account

D
[S12] The following applies to SLES12 only:

is
To avoid the above, use the substitute user command (su) to
By default, the sudo command on SUSE Linux Enterprise Server will

t
temporarily use the other account. For example:

rib
ask for the root user's password, the default target user.

C
1. type su - new_username

ut
[U1604] The following applies to U16.04 only:
2. execute the needed commands

io

O
3. type exit to return to the old user account Ubuntu has locked the root password by default, requiring

n
administrators to rely solely on sudo. See the sudo_root(8) man
The original purpose of the su command was to perform system

Pr
page for details.
administration tasks as the root user. This remains its most common

PY
oh
use. Unfortunately, in an attempt to avoid being forced to switch
between accounts, new users are often tempted to log in initially as

ib
root. Using the root account to perform routine tasks is a bad idea!
The sudo command provides administrative access using user
ite
d
authorization. For example:
y To switch to a login shell (typically root's, depending on

2-16
sudo

EV
sudo – a more powerful su
• more fine-grained security
• able to log commands
sudoedit – a safer way to edit files

U
• sudo -e

na
visudo – a safer way to manage sudo

AL
• /etc/sudoers

ut
Replacing su with sudo
• sudo -i

ho
Using sudo with ssh

riz
• ssh -t hostname "sudo reboot"

U
Delegating Privileges ed target user's password is required. This is done so that all users can

AT
be safely allowed to use sudo without first being granted permission

ep
sudo makes it possible to run commands as a different user. It can by an administrator.
be used to replace or complement su. In most situations, sudo is

ro
superior because it supports more fine-grained configuration. $ sudo reboot

du
root•s password: makeitso Õ
When evaluating security rules, sudo considers many variables

I
c
. . . output omitted . . .
including:

tio

O
Editing Files with sudo
y The command being run

n
y Arguments being passed to the command Failure to consider edge conditions when configuring sudo can

or

N
y The user launching the command compromise system security. For example, a user permitted to run

D
y The user the command will run as "sudo vi some_file" can get complete root access by typing

is
y The host the command will run on ":!/bin/bash" within vi.

t
rib
By default, sudo logs all commands to syslog. It can also be

C
When granting a user permission to edit files, using the sudoedit
configured to log to another file. command may be safer. When launched as either sudoedit or sudo

ut
-e, sudo will make a temporary copy of the file to be edited then

io
Unless a different user is requested, sudo runs commands as root.

O
launch an editor running with normal user privileges. When the user
Unlike su, by default sudo does not prompt for the target user's

n
finishes editing, the contents of the file will be copied back. However,
password. Instead, the user is required to re-authenticate using his or

Pr
creating temporary copies may not be appropriate for sensitive files.
her own password. For example:

PY
oh
Configuring sudo
$ sudo reboot

ib
[sudo] password for guru: work Õ sudo security rules are defined in /etc/sudoers. The visudo

ite
. . . output omitted . . . command should be used when editing /etc/sudoers because it
prevents simultaneous modifications, and it verifies syntax to prevent

d
[S12] The following applies to SLES12 only:
typos or other mistakes in the configuration file.
SLES12 changes the default behavior of sudo by enabling the
targetpw option. Instead of requiring the user's own password, the
2-17
File: /etc/sudoers
%wheel ALL = (ALL) NOPASSWD: ALL

EV
%operator ALL = /usr/local/bin/backup,a
/usr/sbin/lpc, /usr/sbin/lprm
guru www.example.com = sudoedit /etc/hosts.allow

U
In this example, members of group wheel can run any command on

na

AL
any host without entering a password. Members of group operator

ut
can run backup and printing commands on any host. And guru can
edit /etc/hosts.allow using sudoedit only on a host named

ho
www.example.com. The implication is the inherent assumption of a

riz
distributed (e.g. NFS, LDAP) /etc/sudoers file, delimiting the

U
capabilities of users and groups on specific hosts.
Replacing su with sudo
ed
R

AT
To launch an interactive shell, similar to default behavior of the su

ep
command, use the -i option. For example:

ro
$ sudo -i

du
[sudo] password for guru: work Õ

I
c
# whoami

tio

O
root

n
Using sudo with ssh

or

N
When the requiretty option is enabled in /etc/sudoers, sudo can

D
not be used as part of an ssh command unless the -t option is used.

is
For example:

trib
$ ssh station1.example.com "sudo service cups restart"

C
sudo: sorry, you must have a tty to run sudo

ut
$ ssh -t station1.example.com "sudo service cups restart"

io

O
. . . output omitted (cups is restarted) . . .

n
Pr

PY
oh
ib
ite
d
2-18
Help from Commands and Documentation

EV
command --help
Documentation for installed packages
• RHEL7 /usr/share/doc/package_name-version
• SLES12 /usr/share/doc/packages/package_name

U
• U16.04 /usr/share/doc/package_name

na
Shipped or online distribution documentation

AL
Linux Documentation Project - TLDP

ut
Online help:
• web sites, FAQs, Howtos, newsgroups, mailing lists

ho
Linux User Group(s) (LUGs)

riz
• membership typically by mailing list subscription (no dues)

U
• monthly presentations/meetings

Getting Help ed Online Help

AT
ep
Most Unix commands will print a usage summary if an incorrect In addition to documentation installed, or available for installation, to
option or argument is used. Some commands have a dedicated the system, most open-source projects will have a website or email

ro
option (e.g. -?) to print a usage summary, which in some cases list (typically both), sometimes a Usenet group or IRC channel,

du
includes descriptions of the options and arguments printed. dedicated to both users and developers of the software. Common

I
files or web pages include a frequently asked questions (FAQ), a

c
Supplementary documentation may be included in the /usr/share/

tio

O
HOWTO guide, and sometimes the user's manual available for
filesystem, either directly (e.g. /usr/share/emacs), or under the download or as a web page.

n
/usr/share/doc/ directory. Linux distributions will often include

or
source code documentation to supplement incomplete man pages. The Linux community has produced lots of documentation to assist

N
users. One of the most organized and ambitious projects of this

D
Help Syntax nature is The Linux Documentation Project (TLDP). This goal is stated

is
When invoking a command with the GNU --help option, a usage in their manifesto:

trib
summary with option and argument descriptions will be printed to the

C
The Linux Documentation Project is working on developing free,
screen. This uses syntax which may not be readily identifiable: high quality documentation for the GNU/Linux operating system.

ut
$ date --help | head -n 2 The overall goal of the TLDP is to collaborate in all of the issues

io

O
Usage: date [OPTION]... [+FORMAT] of Linux documentation. This includes the creation of HOWTOs

n
or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] and Guides. We hope to establish a system of documentation

Pr
for Linux that will be easy to use and search. This includes the
For instance, capital letters (angle brackets < > are sometimes used)

PY
integration of the manual pages, info docs, HOWTOs, and other

oh
specify a variable: OPTION. This variable is enclosed in square documents. TLDP's goal is to create the canonical set of free Linux

ib
brackets, indicating an optional argument. Also, a vertical bar (|) documentation. While online (and downloadable) documentation
separates arguments where only one in a list can be chosen:

ite
can be frequently updated in order to stay on top of the many
[-u|--utc|--universal]. Ellipses ( . . . ) are used to specify that more changes in the Linux world, we also like to see the same docs

d
than one argument may follow. Finally, notice the difference in types included on CDs and printed in books.
of optional arguments: GNU long (--universal), POSIX (-u) flags, and — http://tldp.org/
keys (BSD style, e.g. ps ax, tar tf).

2-19
whereis

EV
whereis
• Used to identify the location of a command, related source
code, and related man pages
-m | -M: restricts results to manual page(s)

U
-b | -B: restricts results to executable files

na

AL
ut
ho
riz

U
whereis ed
R

AT
ep
The whereis command is useful for identifying the path(s) of a
command, and its associated man pages.

ro
du
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz

I
c tio

O
To retrieve only one of these, use -b or -m. Other options exist, such

n
as -s (which will look for the source files of a command).

or

N
$ whereis -m ls
ls: /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

D
is
Constraining the search locations

t
rib

C
The -B, -M, and -S options do the same as their lower case

ut
counterparts, but provides results restricted to a specific directory.
The directory is provided as an argument to the respective option,

io

O
and must be an absolute path. The use of -f is required to identify

n
the file in question.

Pr

PY
$ whereis -b -B /usr/bin -f zgrep

oh
zgrep: /usr/bin/zgrep

ib
ite
d
2-20
Getting Help Within the Graphical Desktop

EV
Graphical Help begins with Ä
• Gives a help manual for the active window
yelp
khelpcenter

U
na

AL
ut
ho
riz

U
Graphical Help ed
R

AT
ep
The Linux Programmer's Manual and GNU info manuals can be
viewed graphically with the GNOME yelp command, or the KDE Help

ro
Center (the khelpcenter command). Yelp can also be used with

du
GNOME applications. The KDE Help Center can also be used with

I
any KDE application. In GNOME, typing Ä will bring up an active

c tio

O
program's documentation. In KDE, individual application handbooks
can be located from the Help menu.

n
or

N
D
is
t
rib

C
ut
[U1604] The following applies to U16.04 only:

io

O
The xman command can also be used to browse man pages.

n
Pr

PY
oh
ib
ite
d
2-21
Getting Help with man & info

EV
It may seem cryptic, but at least it's well-documented
• man [section] name
man sections
useful options

U
• info

na
created by the GNU project

AL
meant as a "superior" replacement for man

ut
uses HTML like navigation with links
if info pages exist, they usually provide more complete

ho
and up-to-date documentation than the corresponding man

riz
page

U
use pinfo to view pages

Getting Help ed man Sections:

AT
ep
If you are new to Linux, and especially if you have no previous (1) ⇒ User Commands
experience using the system from the command line, you may feel (2) ⇒ System Calls

ro
intimidated or even confused by the commands. Some commands (3) ⇒ Subroutines

du
have what seem to be countless different options, each causing the (4) ⇒ Devices

I
command to behave in a slightly different manner. Often, even the (5) ⇒ File Formats

c tio

O
names of the commands can seem non-intuitive and confusing. (6) ⇒ Games
(7) ⇒ Miscellaneous

n
Fear not! What at first may seem like an insurmountable task is (8) ⇒ System Administration

or
actually far easier than you may think. Linux has excellent online (n) ⇒ new (used for writing and testing new and/or updated man

N
documentation for the commands and programs found on the pages for other sections)

D
system. After learning the help systems, and practicing with the

is
commands, soon what you once found short and cryptic you may The man command will search the sections in the following order:

t
consider efficient and elegant. Commands that you thought had far 1,8,2,3,4,5,6,7,n. Usually this will not be a problem, but occasionally

rib

C
too many options you will soon describe as flexible or versatile. you will be looking for help on a command that is found in several

ut
sections. In this case, man will return the page for the first instance it
The mainstays for command line help are the electronic manual

io
finds. For example, suppose you are adding a new task to the system

O
pages commonly called "man pages." Almost all of the commands on crontab and need to check syntax for the file. You type man crontab

n
the system have corresponding man pages, and when new software and get this output:

Pr
is installed it usually comes with additional man pages. Man pages

PY
are organized into sections or books that group similar things

oh
together. Although additional sections can be added, the following

ib
sections are defined by default:

ite
d
2-22
CRONTAB(1) CRONTAB(1)
NAME

EV
crontab - maintain crontab files for individual users (V3)
SYNOPSIS
crontab [ -u user ] file
crontab [ -u user ] [ -l | -r | -e ]

U
DESCRIPTION

na
Crontab is the program used to install, deinstall or list the

AL
. . . snip . . .

ut
ho
This is not what you were after, and you notice that the very first line
of output starts with CRONTAB(1) indicating that this page is from

riz
section one. To override the normal search order of the man

U
command, type man 5 crontab to get the output you were after:
CRONTAB(5) ed CRONTAB(5)

AT
NAME

ep
crontab - tables for driving cron
DESCRIPTION

ro
A crontab file contains instructions to the cron(8) daemon

du
of the general form: run this command at this time on this date•

I
c
. . . snip . . .

tio

O
Notice the CRONTAB(5) convention of referring to the manual and its

n
chapter. This was a convention started in the first Unix Programmer's

or
Manual, which was broke up alphabetically into chapters. When

N
looking at the manual online (on the system, not the Internet), it

D
means type man 5 crontab. It is therefore common to see 'crontab(5)'

is
as a way to reference the crontab entry in chapter 5 of the manual.

t
rib

C
Another command for getting help is the info command. info is

ut
similar to man and just requires one parameter, the command you
want help on. info organizes help into different topic pages with

io

O
links leading from page to page. It is the format preferred by the FSF

n
to man pages, and if the software, or command, in question is from

Pr
the FSF, the info pages will likely be more complete than the man

PY
oh
pages for that command. A good viewer to use to read info pages is
pinfo. Also, the Emacs editor provides an excellent info viewer,

ib
(info was originally designed as the documentation system for

ite
Emacs).

d
2-23
Lab 2
EV
Estimated Time:
S12: 25 minutes
R7: 25 minutes

U
Task 1: Login and Discovery U1604: 25 minutes

na

AL
Page: 2-25 Time: 10 minutes

ut
Requirements: b (1 station) d (graphical environment)

Task 2: Help with Commands


ho
riz
Page: 2-30 Time: 10 minutes

U
ed
Requirements: b (1 station) c (classroom server)

AT
Task 3: Switching Users With su

ep
Page: 2-34 Time: 5 minutes

ro
Requirements: b (1 station)

du

I
c tio

O
n
or

N
D
is
t
rib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
2-24
Objectives Lab 2

EV
y Login to the workstation using a virtual console.
y Use the various virtual console changing keystrokes.
y Login to the workstation using a GUI interface.
Task 1
Login and Discovery
y Use a variety of commands to gather information about the current login
Estimated Time: 10 minutes

U
and the other users on the system.

na

AL
Requirements

ut
b (1 station) d (graphical environment)

Relevance
ho
riz
The commands covered in this task will help you be able to login to a

U
ed
Linux system and identify the state of the system. These commands are
particularly important, because it is common when using Linux to access

R
many user accounts and systems, often from the same terminal.

AT
ep
Notices
y If this lab exercise is being run within a virtual environment, the use of

ro
special keystrokes may be needed to switch between virtual terminals.

du

I
c
1) If the system is currently logged in, log out. Use the menus to log out from the

tio

O
graphical interface, or type logout at the command prompt if logged into the text

n
terminal.

or

N
2) Switch to the second virtual terminal and login as the guru user:

D
is
Ó¿Ô¿Å Some virtual machines, or remote interfaces, do not

t
have a way to pass the Ó¿Ô¿Å key sequence.

rib
stationX login: guru

C
Password: work Õ An alternative is the command su -c "chvt 2" which

ut
. . . output omitted . . . will switch the display to /dev/tty2. (You will be

io
prompted for the root password.)

O
n
3) Use the id command to see the user id(uid) and group id(gid):

Pr

PY
$ id

oh
[R7] uid=1000(guru) gid=1000(guru) groups=1000(guru) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

ib
[S12] uid=1000(guru) gid=100(users) groups=100(users)

ite
[U1604] uid=1000(guru) gid=1000(guru) groups=1000(guru),4(adm),24(cdrom),a
27(sudo),30(dip),46(plugdev),110(lpadmin),125(sambashare)

d
2-25
4)

EV
See what account name you are logged in as:

$ id -un This can also be done with the whoami command.


guru

U
na
5)

AL
Use the tty command to observe what terminal is associated with the login:

ut
$ tty

ho
/dev/tty2

riz

U
6)
ed
Install the finger command for use by the visitor user in a later step:
[R7] $ su -c "yum install -y finger"

AT
[R7] Password: makeitso Õ

ep
[U1604] $ sudo apt-get install -y finger

ro
[U1604] Password: work Õ

du

I
7) Switch to the third virtual terminal and login as the visitor user:

c tio

O
Ó¿Ô¿

n
stationX login: visitor

or
Password: work Õ

N
. . . output omitted . . .

D
is
t
8) Since you logged into the third virtual terminal, the associated terminal will be

rib

C
different. Verify which terminal is in use:

ut
$ tty

io

O
/dev/tty3

n
9) Use the who and w commands to see all users logged onto the system:
Pr

PY
$ who
oh
ib
. . . output omitted . . . There should be at least two users logged in to the

ite
$ w workstation.

d
. . . output omitted . . .

2-26
10)

EV
Use the finger command to find out more information on the user visitor that
is logged in to the workstation:

$ finger visitor
. . . output omitted . . .

U
na

AL
Besides GECOS field information (Name, Primary contact info such as room
number, office phone number, other contact info), finger prints the following files:

ut
ž/.pgpkey, ž/.project, ž/.plan, and ž/.forward (PGP public key, current

ho
projects summary, general schedule such as work hours, and where email is

riz
forwarded, respectively).

U
11)
ed
[R7] This step should only be performed on RHEL7.

AT
Press Ô¿Ä, or run su -c "chvt 1" (with the accompanying root password of

ep
makeitso), to bring up the GUI login screen, and if needed, log in with account

ro
name guru and password work.

du
[Note:] Since release 6 of Enterprise Linux, the GUI boots to tty1, instead of the

I
next-available terminal. However, sometimes X will float to tty7 (the next

c tio
available) while using the system from a text-terminal. If you see what looks like

O
boot splash screen residual when switching to tty1, try tty7 instead.

n
or

N
12) [S12 U1604] This step should only be performed on SLES12/U16.04.

D
Press Ô¿Ê, or run sudo "chvt 7" (with the accompanying guru password of

is
work), to bring up the GUI login screen, and if needed, log in with account name

trib

C
guru and password work.

ut
io
13) Open a terminal window. Observe that the terminal window does not use a virtual

O
n
terminal, but a pseudo terminal:

Pr
$ tty

PY
oh
/dev/pts/0

ib
ite
14) With three different logins and terminal sessions on the system, use the who and
w commands to see all the active sessions:
$ who
d
2-27
. . . output omitted . . .

EV
$ w
. . . output omitted . . . Note that the second column of both commands lists
the associated terminal and that the displayed TTY is
different. Be aware that the :0 is the graphical login
15) Press Ó¿Ô¿Å to return to the second virtual terminal where the guru user is session itself.

U
still logged in:

na

AL
[guru@stationX ž]$

ut
16)
ho
Determine how much physical RAM and swap is configured in the system:

riz

U
ed
$ free
total used free shared buffers cached

R
Mem: 1034880 1013264 21616 0 135708 266452

AT
-/+ buffers/cache: 611104 423776

ep
Swap: 1959888 0 1959888

ro
Output on the system will likely vary from this example output. The top left

du
number is the installed physical RAM in bytes on your system. The bottom left

I
c
number is the amount of swap.

tio

O
n
17) Pass an option to the free command to display numbers in megabytes instead of

or
kilobytes:

N
D
$ free -m

is
total used free shared buffers cached

t
Mem: 1010 974 36 0 129 254

rib

C
-/+ buffers/cache: 590 420

ut
Swap: 1913 0 1913

io

O
n
18) Display the IP address of the main network adapter using the ip command. If the

Pr
primary network interface is called eth0, ip can show a specific interface's details

PY
oh
by specifying the interface name as follows:

ib
$ ip addr show dev eth0

ite
. . . output omitted . . .

d
2-28
19)

EV
Display the default IP gateway currently configured:
$ ip route
default via 10.100.0.254 dev eth0 proto static metric 1024
10.100.0.0/24 dev eth0 proto kernel scope link src 10.100.0.X

U
na
The first entry is the default gateway.

AL
20)
ut
ho
Display the currently configured DNS server(s):
The cat command displays to the terminal the contents

riz
$ cat /etc/resolv.conf
of a text file.

U
. . . snip . . .

ed
search example.com
nameserver 10.100.0.254 Sometimes this may point to a 127. address, which

AT
means a DNS server, e.g. named, dnsmasq, is handling

ep
The DNS servers are defined using the nameserver lines. Up to three nameserver the request.
lines are supported. Typically, this configuration file will be dynamically modified,

ro
even when not using DHCP. Normallly, there are comments at the top of the file

du
reminding administrators of this.

I
c tio

O
21) [R7] This step should only be performed on RHEL7.

n
The nmcli command, part of NetworkManager, can identify what the system is

or
using for its DNS server:

N
D
# nmcli dev show | grep DNS

is
IP4.DNS[1]: 10.100.0.254

t
rib

C
22) [U1604] This step should only be performed on U16.04.

ut
io
The nm-tool command, part of NetworkManager, can identify what the system is

O
n
using for its DNS server. Run nm-tool to identify the system's name resolver:

Pr
$ nm-tool | grep DNS

PY
oh
DNS: 10.100.0.254

ib
23) Using the Ò¿Ü and Ò¿Ý keys, the terminal window can be scrolled. Use

ite
these keys to scroll back as far as possible in the terminal. Note that scroll back is

d
possible using these same key sequences at the full screen text virtual terminals.
However, when using scroll back at the virtual terminal the scroll back buffer is
cleared when switching to another terminal (or back to X).

2-29
Objectives Lab 2

EV
y Use the built-in manual (man) system.
y Use the built-in info documentation system.
y Access usage information built into commands.
Task 2
Help with Commands
y Locate a program's README file and other bundled documentation.
Estimated Time: 10 minutes

U
na
Requirements

AL
b (1 station) c (classroom server)

ut
ho
Relevance
Being able to effectively use the powerful documentation system built into

riz
Linux is an important skill useful in many situations. This lab task covers

U
ed
the man and info systems.

AT
1) Use the man command to find which of its options is equivalent to the apropos

ep
command.

ro
$ man 1 man

du
When finished reading, press the q key to exit.

I
c tio

O
2)
n
Use the -k option to discover what manual pages contain the term "delete" in their
description:

or

N
$ man -k delete

D
. . . output omitted . . .

is
t
rib
This command uses a database that may not exist on the system (it is usually

C
rebuilt on a daily basis). If it fails, run the makewhatis or mandb command as root

ut
to build the database.

io

O
n
3) Use the man command to view one of the specific man pages returned by the

Pr
previous search:

PY
oh
$ man userdel

ib
. . . output omitted . . .

ite
d
4) The man command uses another command to display the output one page at a
time. By default, on Linux this is the less command. You can easily search within
a man page using the / key.

2-30
Search for the words SEE ALSO to view other related manual pages:

EV
/SEE ALSOÕ the SEE ALSO section of the man page is displayed
q the man command exits

5)
U
na
Using the man command, open the first chapter of the intro manual, and peruse

AL
the contents:

ut
ho
$ man 1 intro

riz
When finished reading, press the q key to exit.

U
6)
ed
Use the info command to learn about the wget downloading utility:

AT
ep
$ info wget the info page for the wget command is displayed

ro
press the down arrow key until the cursor is on the Overview line

du
Õ the overview page for wget is displayed

I
p

c
the previous info page is displayed again

tio

O
q the man command exits

n
or

N
7) [R7 U1604] This step should only be performed on RHEL7/U16.04.

D
Try using the newer pinfo viewer to browse the same wget info page:

is
t
rib
$ pinfo wget

C
ut
Notice the more browser-like interface compared with the traditional info
command. Use the arrow keys and Õ to navigate. When you are ready, press q

io

O
to quit.

n
8)
Pr

PY
Another useful resource for getting help is the package documentation directories.

oh
Most commands and programs will have an entry in these directories. Usually, the

ib
information in these text files is different than what is found with man or info.

ite
They commonly contain release notes, installation notes, etc. See what
information exists for the command wget:
[R7 U1604]
[S12]
$ cd /usr/share/doc/
$ cd /usr/share/doc/packages/ d
2-31
$ ls Lists all files and directories contained in the current
directory.

EV
. . . output omitted . . .

[R7] $ cd wget-version/ Replace version with the real wget version number
[S12 U1604] $ cd wget/ seen in the directory listing. Hint: Press Ð to use
shell auto-completion.

U
na
$ ls See what documentation files exist

AL
. . . output omitted . . .

ut
$ more AUTHORS Display the contents of the file (showing who the

ho
authors of wget are).

riz
9) Though most commands provide a usage summary when mistyped, with wget

U
and other GNU/Linux commands, a list of possible command line arguments can

ed
be obtained by running the command with the --help option. This provides both
the usage summary and more detailed information on running the command.

AT
Some GNU commands only provide --help instead of a man page. Some Unix

ep
derived commands rely on the usage summary and man page only. With GNU

ro
commands, --help is commonly used to build man pages, (since GNU prefers the
textbook style of the Emacs Texinfo format). Run the wget command with this

du
option to see the list of available arguments:

I
c tio

O
$ wget --help
. . . snip . . .

n
-c, --continue resume getting a partially-downloaded file.

or
--progress=TYPE select progress gauge type.

N
-N, --timestamping don•t re-retrieve files unless newer than

D
local.

is
-S, --server-response print server response.

trib
--spider don•t download anything.

C
-T, --timeout=SECONDS set all timeout values to SECONDS.

ut
--dns-timeout=SECS set the DNS lookup timeout to SECS.

io

O
--connect-timeout=SECS set the connect timeout to SECS.

n
--read-timeout=SECS set the read timeout to SECS.

Pr
. . . snip . . .

PY
oh
This output illustrates the GNU long option format common in many command
line utilities on Linux. Some options may have an equivalent POSIX flag (e.g. -?) to

ib
each GNU long option. Some options have only a short (POSIX) or long (GNU)

ite
version. All the long versions are prefixed by a double dash. Also, some GNU

d
commands may request that the --help option be run, when mistyping a
command.

2-32
10)

EV
Use the wget command a couple of times, with and without one of the options:

$ cd /tmp/
$ wget http://server1.example.com/
. . . output omitted . . .

U
$ wget -S http://server1.example.com/

na

AL
. . . output omitted . . . This time the server responses are printed.

ut
$ wget -S --spider http://server1.example.com/
. . . output omitted . . . This time the server responses are printed, but without

ho
downloading the file.

riz

U
11)
ed
If time permits, use the different help resources explored in this lab task to find
out more about the ls and cat commands.

AT
ep
ro
du

I
c tio

O
n
or

N
D
is
trib

C
ut
io

O
n
Pr

PY
oh
ib
ite
d
2-33
Objectives Lab 2

EV
y Use and explore the use of the su command.
y Observe the operation differences between su and su -. Task 3
Switching Users With su
Requirements
Estimated Time: 5 minutes

U
b (1 station)

na

AL
Relevance

ut
This lab task illustrates the difference between using su and su - on the

ho
environment.

riz

U
1) Ensure that guru is the currently logged in user:
$ cd
ed
R

AT
$ whoami

ep
guru If result is different, log out and log back in as the guru
$ id -un user. The id command can also be used to identify

ro
guru which user is currently logged in.

du

I
c
2) Observe and record the value of the existing environment variable $PATH:

tio

O
$ echo $PATH

n
. . . output omitted . . .

or

N
Result:

D
is
t
rib

C
3) Observe and record the current working directory:
ut
io

O
n
$ pwd

Pr
. . . output omitted . . .

PY
oh
Result:

ib
ite
4) [U1604] This step should only be performed on U16.04.

d
Ubuntu makes the first user of the system the administrative user. This means
that the path will be different for the guru and visitor users. Switch user to
visitor and compare the path difference:

2-34
$ su - visitor
Password: work Õ

EV
$ echo $PATH
. . . output omitted . . .

U
5) [S12 U1604] This step should only be performed on SLES12/U16.04.

na

AL
The ifconfig utility can be used to display network card IP address assignment

ut
and other NIC parameters and statistics. Try to use ifconfig (expecting an error):

$ ifconfig
ho
riz
-bash: ifconfig: command not found This message is to be expected as the ifconfig

U
ed
program is located in a directory that is not in an
unprivileged user's $PATH by default.
6) [U1604] This step should only be performed on U16.04.

AT
ep
With Ubuntu the root user is disabled by default. Follow the instructions in the
sudo_root(8) manual to enable the root user:

ro
du
$ exit Exit from the visitor owned shell, to the guru owned
$ sudo passwd root shell.

I
c
[sudo] password for guru: work Õ

tio

O
Enter new UNIX password: makeitso Õ

n
Retype new UNIX password: makeitso Õ

or
passwd: password updated successfully

N
D
is
7) Use the su command to become the root user:

trib

C
$ su
Password: makeitso Õ

ut
io

O
n
8) Observe how you have root privileges:

Pr
# id -u Note how the prompt has changed to ending in a #

PY
oh
0 instead of $ or > now that you are root, i.e. user ID 0.

ib
ite
9) Compare the output of these commands to the previously obtained (and recorded)
output:

# echo $PATH d
2-35
. . . output omitted . . .

EV
# pwd
. . . output omitted . . .

10) [S12] This step should only be performed on SLES12.

U
na

AL
Attempt to run the ifconfig utility again:

ut
# ifconfig On SUSE Linux Enterprise Server, the su command is

ho
Absolute path to •ifconfig• is •/sbin/ifconfig•, so running ita customized so that when su is run without the -, the
may require super user privileges (eg. root). sbin directories are added to the user's inherited $PATH

riz
variable.

U
ed
11) Return to the regular, unprivileged user account:

AT
# exit

ep
ro
12) Use the su command with the - option to become the root user via a login shell

du
(which processes root's login scripts):

I
c
$ su -

tio

O
Password: makeitso Õ

n
or

N
13) This time, the root shell has the correct environment. Check the user ID and

D
group memberships:

is
# id

t
rib

C
uid=0(root) gid=0(root) groups=0(root)

ut
io
14) Compare the output of these commands to the previously obtained output:

O
n
# echo $PATH

Pr
. . . output omitted . . .

PY
oh
# pwd
. . . output omitted . . .

ib
ite
Note how the environment has changed to be root's native environment. Most
distributions only include the sbin directories in the $PATH of the root user.

d
2-36
15)

EV
[S12] This step should only be performed on SLES12.

Run the ifconfig utility again:


# ifconfig

U
. . . output omitted . . .

na

AL
It works as the ifconfig utility is located at /sbin/ifconfig and that directory is

ut
in the root user's $PATH.

16) ho
riz
Observe how with root privileges the su command will switch to another account

U
without knowing or supplying a password:
# su - guru
ed There is no prompt for a password.

AT
ep
17) See that the environment has changed to that of the guru user:

ro
$ id

du
. . . output omitted . . .
$ pwd

I
c
. . . output omitted . . .

tio

O
n
18) Return to the root shell:

or

N
$ exit

D
is
Clean Up

t
rib

C
19) [R7 S12] This step should only be performed on RHEL7/SLES12.

ut
Administrative privileges are no longer required; exit the root shell to return to an

io

O
unprivileged account:

n
Pr
# exit

PY
20) [U1604] This step should only be performed on U16.04.
oh
ib
ite
Return to the guru user's shell and remove the root user's password:

d
# exit
$ sudo passwd -l root
[sudo] password for guru: work Õ

2-37

You might also like