156
Company Confidential 1 Red Hat Enterprise Linux 5.0

Company Confidential 1 Red Hat Enterprise Linux 5.0

Embed Size (px)

Citation preview

Company Confidential

1

Red Hat Enterprise Linux 50

Red Hat Enterprise Linux

bull Enterprise-targeted operating systembull Focused on mature open source technologybull 18-24 month release cycle Certified with leading OEM and ISV productsbull Two variants available Server Clientbull Purchased with one year Red Hat Network subscription

and support contract Support available for seven years after release Up to 24x7 coverage plans available

Other Red Hat Supported Software

bull Global File system

bull Directory Server

bull Certificate Server

bull Red Hat Application Stack

bull JBoss Middleware Application Suite

Notes on Internationalization

bull Red Hat Enterprise Linux supports nineteen languages

bull Default language can be selected During installation With system-config-languagebull System-gtAdministration-gtLanguagebull Alternate languages can be used on a per-

command basis $ LANG=en_USUTF8 date Language settings are stored in

etcsysconfigi18n

The Fedora Project

bull Red Hat sponsored open source projectbull Focused on latest open source technology Rapid four to six month release cycle Available as free download from the

Internetbull An open community-supported proving

ground for technologies which may be used in upcoming enterprise products

bull Red Hat does not provide formal support

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Red Hat Enterprise Linux

bull Enterprise-targeted operating systembull Focused on mature open source technologybull 18-24 month release cycle Certified with leading OEM and ISV productsbull Two variants available Server Clientbull Purchased with one year Red Hat Network subscription

and support contract Support available for seven years after release Up to 24x7 coverage plans available

Other Red Hat Supported Software

bull Global File system

bull Directory Server

bull Certificate Server

bull Red Hat Application Stack

bull JBoss Middleware Application Suite

Notes on Internationalization

bull Red Hat Enterprise Linux supports nineteen languages

bull Default language can be selected During installation With system-config-languagebull System-gtAdministration-gtLanguagebull Alternate languages can be used on a per-

command basis $ LANG=en_USUTF8 date Language settings are stored in

etcsysconfigi18n

The Fedora Project

bull Red Hat sponsored open source projectbull Focused on latest open source technology Rapid four to six month release cycle Available as free download from the

Internetbull An open community-supported proving

ground for technologies which may be used in upcoming enterprise products

bull Red Hat does not provide formal support

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Other Red Hat Supported Software

bull Global File system

bull Directory Server

bull Certificate Server

bull Red Hat Application Stack

bull JBoss Middleware Application Suite

Notes on Internationalization

bull Red Hat Enterprise Linux supports nineteen languages

bull Default language can be selected During installation With system-config-languagebull System-gtAdministration-gtLanguagebull Alternate languages can be used on a per-

command basis $ LANG=en_USUTF8 date Language settings are stored in

etcsysconfigi18n

The Fedora Project

bull Red Hat sponsored open source projectbull Focused on latest open source technology Rapid four to six month release cycle Available as free download from the

Internetbull An open community-supported proving

ground for technologies which may be used in upcoming enterprise products

bull Red Hat does not provide formal support

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Notes on Internationalization

bull Red Hat Enterprise Linux supports nineteen languages

bull Default language can be selected During installation With system-config-languagebull System-gtAdministration-gtLanguagebull Alternate languages can be used on a per-

command basis $ LANG=en_USUTF8 date Language settings are stored in

etcsysconfigi18n

The Fedora Project

bull Red Hat sponsored open source projectbull Focused on latest open source technology Rapid four to six month release cycle Available as free download from the

Internetbull An open community-supported proving

ground for technologies which may be used in upcoming enterprise products

bull Red Hat does not provide formal support

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The Fedora Project

bull Red Hat sponsored open source projectbull Focused on latest open source technology Rapid four to six month release cycle Available as free download from the

Internetbull An open community-supported proving

ground for technologies which may be used in upcoming enterprise products

bull Red Hat does not provide formal support

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Objectives

bull A user who can use effectively employ RedHat Enterprise Linux to customize his or heroperating environment as well as accomplishcommon command-line tasks and desktop productivity roles

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Audience and Prerequisites

bull Audience Users new to Linux and UNIX users and administrators transitioning from another operating system

bull User-level experience with any computer system use of mouse menus and any graphical user interface

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 1

Linux Ideas and History

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

What is Open Source

bull Open source software and source code available to all

The freedom to distribute software and source code

The ability to modify and create derived works

Integrity of authors codebull The Free Software Foundation and the Four

Freedoms

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Linux Origins

bull 1984 The GNU Project and the Free Software Foundation Creates open source version of UNIX utilities Creates the General Public License (GPL) Software license enforcing open source principlesbull 1991 Linus Torvaldsbull Creates open source UNIX-like kernel released under the

GPL Ports some GNU utilities solicits assistance onlinebull Today Linux kernel + GNU utilities = complete open source UNIX-like operating system Packaged for targeted audiences as distributions

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Red Hat Distributions

bull Linux distribution are OSes based on the Linux kernelbull Red Hat Enterprise Linux

Stable thoroughly tested softwareProfessional support servicesCentralized management tools for large networks

bull The Fedora ProjectMore newer applicationsCommunity supported (no official Red Hat

support)For personal systems

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Linux principles

bull Everything is a file (including hardware)bull Small single-purpose programsbull Ability to chain programs together to

perform complex tasksbull Avoid captive user interfacesbull Configuration data stored in text

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 2

Linux Usage Basics

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Logging in to a Linux System

bull Two types of login screens virtual consoles

(text-based) and graphical logins (called display

managers)bull Login using login name and passwordbull Each user has a home directory for personal

file storage

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Switching between virtual consolesand the graphical environment

bull A typical Linux system will run six virtual

consoles and one graphical console

Server systems often have only virtual consoles

Desktops and workstations typically have both

bull Switch among virtual consoles by typing

Ctrl-Alt-F[1-6]

bull Access the graphical console by typing Ctrl-Alt-F7

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Elements of the X Window System

bull The X Window System is Linuxs graphical subsystem

bull Xorg is the particular version of the X Window System used by Red Hat

Open source implementation of Xbull Look and behavior largely controlled by the desktop

environmentbull Two desktop environments provided by Red Hat GNOME the default desktop environment KDE an alternate desktop environment

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Starting the X server

bull On some systems the X server starts automatically at boot time

bull Otherwise if systems come up in virtual consoles users must start the X server manually

bull The X server must be pre-configured by the systembull administratorbull 1048576m Log into a virtual console and run startxbull 1048576m The X server appears on Ctrl-Alt-F7

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing Your Password

bull Passwords control access to the system Change the password the first time you log in Change it regularly thereafter Select a password that is hard to guessbull To change your password using GNOME navigate to System-gtPreferences-gtAbout Me and then click Passwordbull To change your password from a terminalpasswd

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The root user

bull The root user a special administrative accountAlso called the superuser root has near complete control over the systemand a nearly unlimited capacity to damage itbull Do not login as root unless necessaryNormal(unprivileged ) userspotential to do damage is more limited

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing Identities

bull su - creates new shell as root

bull sudo command runs command as root

Requires prior configuration by a system administrator

bull id shows information on the current user

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Editing text files

bull The nano editor Easy to learn easy to use Not as feature-packed as some advanced

editorsbull Other editors gedit a simple graphical editor vim an advanced full feature editor gvim a graphical version of the vim editor

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 3

Running Commands andGetting Help

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Running Commands

bull Commands have the following syntax command options arguments

bull Each item is separated by a spacebull Options modify a commands behavior Single-letter options usually preceded by - Can be passed as -a -b -c or -abc Full-word options usually preceded by -- Example --helpbull Arguments are filenames or other data needed

by the commandbull Multiple commands can be separated by

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Some Simple Commands

bull date - display date and time

bull cal - display calendar

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Getting Help

bull Dont try to memorize everything

bull Many levels of help

whatis

command --help

man and info

usrsharedoc

Red Hat documentation

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The whatis Command

bull Displays short descriptions of commands

bull Uses a database that is updated nightly

bull Often not available immediately after install

$ whatis cal

cal (1) - displays a calendar

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The --help Option

bull Displays usage summary and argument listbull Used by most but not all commands $ date --help Usage date [OPTION] [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY]

[ss]] Display the current time in the given FORMAT or set the system date argument list omitted

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The man Command

bull Provides documentation for commands

bull Almost every command has a man page

bull Pages are grouped into chapters

bull Collectively referred to as the Linux Manual

bull man [ltchaptergt] ltcommandgt

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Navigating man Pages

bull While viewing a man page Navigate with arrows PgUp PgDn text searches for text nN goes to nextprevious match q quitsbull Searching the Manual man -k keyword lists all matching pages Uses whatis database

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The info Command

bull Similar to man but often more in-depth

bull Run info without args to list all page

bull info pages are structured like a web site

Each page is divided into nodes

Links to nodes are preceded by

info [command]

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Navigating info Pages

bull While viewing an info page Navigate with arrows PgUp PgDn Tab moves to next link Enter follows the selected link np u goes to the nextpreviousup-one node s text searches for text (default last search) q quits info

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Extended Documentation

bull The usrsharedoc directory

Subdirectories for most installed packages

Location of docs that do not fit elsewhere

Example configuration files

HTMLPDFPS documentation

License details

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Red Hat Documentation

bull Available on docs CD or Red Hat website

Installation Guide

Deployment Guide

Virtualization Guide

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 4

Browsing the Filesystem

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Linux File Hierarchy Concepts

bull Files and directories are organized into a

single-rooted inverted tree structure

bull Filesystem begins at the root directory represented by a lone (forward slash) character

bull Names are case-sensitive

bull Paths are delimited by

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Some Important Directories

bull Home Directories roothomeusernamebull User Executables bin usrbin usrlocalbinbull System Executables sbin usrsbin

usrlocalsbinbull Other Mountpoints media mntbull Configuration etcbull Temporary Files tmpbull Kernels and Bootloader bootbull Server Data var srvbull System Information proc sysbull Shared Libraries lib usrlib usrlocallib

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Current Working Directory

bull Each shell and system process has a current working directory (cwd)

bull pwd Displays the absolute path to the shells

cwd

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

File and Directory Names

bull Names may be up to 255 charactersbull All characters are valid except the forward slash

It may be unwise to use certain special characters in file or directory names

Some characters should be protected with quotes when referencing them

bull Names are case-sensitive

Example MAIL Mail mail and mAiL

Again possible but may not be wise

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Absolute and Relative Pahnames

bull Absolute pathnames Begin with a forward slash Complete road map to file location Can be used anytime you wish to specify a file namebull Relative pathnames Do not begin with a slash Specify location relative to your current working

directory Can be used as a shorter way to specify a file name

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing Directories

bull cd changes directories To an absolute or relative path cd homejoshuawork cd projectdocs To a directory one level up cd To your home directory cd To your previous working directory cd -

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Listing Directory Contents

bull Lists the contents of the current directory or a specified directory

bull Usage

ls [options] [files_or_dirs]bull Example

ls -a (include hidden files)

ls -l (display extra information)

ls -R (recurse through directories)

ls -ld (directory and symlink information)

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Copying Files and Directories

bull cp - copy files and directoriesbull Usage cp [options] file destinationbull More than one file may be copied at a time

if the destination is a directory cp [options] file1 file2 dest

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Copying Files and Directories The Destination

bull If the destination is a directory the copy is placed there

bull If the destination is a file the copy overwrites the destination

bull If the destination does not exist the copy is renamed

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Moving and Renaming Files andDirectories

bull mv - move andor rename files and directoriesbull Usage

mv [options] file destinationbull More than one file may be moved at a time if the

destination is a directory

mv [options] file1 file2 destinationbull Destination works like cp

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Creating and Removing Files

bull touch - create empty files or update file timestamps

bull rm - remove filesbull Usage

rm [options] ltfilegtbull Example

rm -i file (interactive)

rm -r directory (recursive)

rm -f file (force)

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Creating and Removing Directories

bull mkdir creates directories

bull rmdir removes empty directories

bull rm -r recursively removes directory trees

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Using Nautilus

bull Gnome graphical filesystem browserbull run in browser modebull Accessed via

Desktop icons

Home Your home directory

Computer Root filesystem network resources

and removable media

Applications-gtSystem Tools-gtFile Browser

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Moving and Copying in Nautilus

bull Drag-and-Drop

Drag Move on same filesystem copy on different filesystem

Drag + Ctrl Always copy

Drag + Alt Ask whether to copy move or create symbolic link (alias)

bull Context menu

Right-click to rename cut copy or paste

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Determining File Content

bull Files can contain many types of databull Check file type with file before opening to

determine appropriate command or application to use

bull file [options] ltfilenamegt

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 5

Users Groups and Permissions

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Users

bull Every user is assigned a unique User ID number (UID ) UID 0 identifies rootbull Users names and UIDs are stored in etc

passwdbull Users are assigned a home directory and a program that is run when they log in (usually a shell)bull Users cannot read write or execute each others files without permission

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Groups

bull Users are assigned to groupsbull Each group is assigned a unique Group ID number (gid )bull GIDs are stored in etcgroupbull Each user is given their own private group Can be added to other groups for additional

accessbull All users in a group can share files that belong to the group

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Linux File Security

bull Every file is owned by a UID and a GIDbull Every process runs as a UID and one or more

GIDs Usually determined by who runs the processbull Three access categories Processes running with the same UID as the

file (user ) Processes running with the same GID as the

file (group ) All other processes (other )

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Permission Precedence

bull If UID matches user permissions apply

bull Otherwise if GID matches group permissions apply

bull If neither match other permissions apply

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Permission Types

bull Four symbols are used when displaying permissions

r permission to read a file or list a directorys contents w permission to write to a file or create and

remove files from a directory x permission to execute a program or change

into a directory and do a long listing of the directory

- no permission (in place of the r w or x)

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Examining Permissions

bull File permissions may be viewed using ls -l

$ ls -l binlogin

-rwxr-xr-x 1 root root 19080 Apr 1 1826 binlogin

bull File type and permissions represented by a 10-character string

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Interpreting Permissions

-rwxr-x--- 1 andersen trusted 2948 Oct 11 1407 myscript

bull Read Write and Execute for the owner andersen

bull Read and Execute for members of the trusted group

bull No access for all others

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing File Ownership

bull Only root can change a files ownerbull Only root or the owner can change a files groupbull Ownership is changed with chown

chown [-R] user_name file|directorybull Group-Ownership is changed with chgrp

chgrp [-R] group_name file|directory

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing Permissions - SymbolicMethod

bull To change access modes

chmod [-R] mode filebull Where mode is

ug or o for user group and other

+ or - for grant or deny

r w or x for read write and executebull Examples

ugo+r Grant read access to all

o-wx Deny write and execute to others

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Changing Permissions - NumericMethod

bull Uses a three-digit mode number first digit specifies owners permissions

second digit specifies group permissions third digit represents others permissionsbull Permissions are calculated by adding 4 (for read) 2 (for write) 1 (for execute)bull Example chmod 640 myfile

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 6

Using the bash Shell

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Command Line ShortcutsThe Tab Key

bull Type Tab to complete command lines For the command name it will complete a

command name For an argument it will complete a file namebull Examples $ xteltTabgt $ xterm $ ls myfltTabgt $ ls myfiletxt

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Command Line ShortcutsHistory

bull bash stores a history of commands youveentered which can be used to repeat commandsbull Use history command to see list of

remembered commands $ history 14 cd tmp 15 ls -l 16 cd 17 cp etcpasswd 18 vi passwd output truncated

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

More History Tricks

bull Use the up and down keys to scroll through

previous commandsbull Type Ctrl-r to search for a command in

command history

(reverse-isearch)`

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Command Line ExpansionThe tilde

bull Tilde ( ~ )bull May refer to your home directory$ cat ~bash_profilebull May refer to another users home directory$ ls ~juliepublic_html

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Command Line ExpansionCommands and Braced Sets

bull Command Expansion $() or `` Prints output of one command as an argument to another $ echo This systems name is $(hostname) This systems name is server1examplecombull Brace Expansion Shorthand for printing repetitive strings $ echo file135 file1 file3 file5 $ rm -f file135

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Command Editing Tricks

bull Ctrl-a moves to beginning of line

bull Ctrl-e moves to end of line

bull Ctrl-u deletes to beginning of line

bull Ctrl-k deletes to end of line

bull Ctrl-arrow moves left or right by word

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

gnome-terminal

bull Applications-gtAccessories-gtTerminal

bull Graphical terminal emulator that supports

bull multiple tabbed shells

Ctrl-Shift-t creates a new tab

Ctrl-PgUpPgDn switches to nextprev tab

Ctrl-Shift-c copies selected text

Ctrl-Shift-v pastes text to the prompt

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Scripting Basics

bull Shell scripts are text files that contain a series of commands or statements to be executed

bull Shell scripts are useful for Automating commonly used commands Performing system administration and troubleshooting Creating simple applications Manipulation of text or files

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Creating Shell Scripts

bull Step 1 Use such as vi to create a text file containing commands

First line contains the magic

shebang sequence

binbashbull Comment your scripts

Comments start with a

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Creating Shell Scriptscontinued

bull Step 2 Make the script executable $ chmod u+x myscriptshbull To execute the new script Place the script file in a directory in the executable path -OR- Specify the absolute or relative path to the script on the command line

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Sample Shell Script

bull binbashbull This script displays some information about

your environment

echo Greetings The date and time are $(date)

echo Your working directory is $(pwd)

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 7

vim An Advanced Text Editor

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Introducing vim

bull Newer version of vi the standard Unix text editor Executing vi runs vim by defaultbull gvim Graphical version of vim Applications + Programming -gt Vi iMproved Provided by vim-X11 packagebull Advantages Speed Do more with fewer keystrokes Simplicity No dependence on mouseGUI Availability Included with most Unix-like OSesbull Disadvantages Difficulty Steeper learning curve than simpler editors Key bindings emphasize speed over intuitiveness

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

vim A Modal Editor

bull Keystroke behavior is dependent upon vims modebull Three main modes Command Mode (default) Move cursor cutpaste text change mode Insert Mode Modify text Ex Mode Save quit etcbull Esc exits current modebull EscEsc always returns to command mode

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

vim Basics

bull To use vim you must at least be able to

Open a file

Modify a file (insert mode)

Save a file (ex mode)

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Opening a file in vim

bull To start vi

vim filename

If the file exists the file is opened and the contents are displayed

If the file does not exist vi creates it when the edits are saved for the first time

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Modifying a FileInsert Mode

bull i begins insert mode at the cursorbull Many other options exist

A append to end of line

I insert at beginning of line

o insert new a line (below)

O insert new line (above)

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Saving a File and Exiting vimEx Mode

bull Enter Ex Mode with Creates a command prompt at bottom-left of

screenbull Common writequit commands w writes (saves) the file to disk wq writes and quits q quits even if changes are lost

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Using Command Mode

bull Default mode of vimbull Keys describe movement and text manipulation

commandsbull Commands repeat when preceded by a numberbull Example Right Arrow moves right one character 5 Right Arrow moves right five characters

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Moving AroundCommand Mode

bull Move by character Arrow Keys h j k l Non-arrow keys useful for remote connections to older

systemsbull Move by word w bbull Move by sentence ) (bull Move by paragraph bull Jump to line x xGbull Jump to end G

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Undoing ChangesCommand Mode

bull u undo most recent change

bull U undo all changes to the current line since the cursor landed on the line

bull Ctrl-r redo last undone change

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Learning more

bull vivim built-in help

help

help topic

Use q to exit helpbull vimtutor command

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 8

Basic System ConfigurationTools

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

TCPIP Network Configuration

bull Important network settings

IP Configuration

Device Activation

DNS Configuration

Default Gateway

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Managing Ethernet Connections

bull Network interfaces are named sequentially eth0 eth1 etc Multiple addresses can be assigned to a device

with aliases Aliases are labeled eth01 eth02 etc Aliases are treated like separate interfacesbull View interface configuration with ifconfig [ethX] Enable interface with ifup ethX Disable interface with ifdown ethX

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Graphical Network Configurationsystem-config-network

bull System-gtAdministration-gtNetwork

ActivateDeactivate interfaces

Assign IP AddressesDHCP

Modify DNS settings

Modify gateway address

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Network Configuration FilesEthernet Devices

bull Device configuration is stored in text files etcsysconfignetwork-scriptsifcfg-ethX

bull Complete list of options in usrsharedocinitscripts-sysconfigtxt

Dynamic Configuration Static Configuration

DEVICE=ethX DEVICE=ethX HWADDR=0028AA63045 HWADDR=0028AA63045 BOOTPROTO=dhcp IPADDR=1921680254 ONBOOT=yes NETMASK=2552552550 Type=Ethernet GATEWAY=1921682254 ONBOOT=yes Type=Ethernet

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Network Configuration FilesOther Global Network Settings

bull Global Settings in etcsysconfig network Many may be provided by DHCP GATEWAY can be overridden in ifcfg file NETWORKING=yes HOSTNAME=server1examplecom GATEWAY=1921682254

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Network Configuration FilesDNS Configuration

bull Domain Name Service translates hostnames to network addresses

bull Server address is specified by dhcp or in etcresolvconf

search examplecom crackerorg nameserver 1921680254 nameserver 1921681254

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Printing in Linux

bull Printers may be local or networked

bull Print requests are sent to queues

bull Queued jobs are sent to the printer on a first come first served basis

bull Jobs may be canceled before or during printing

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

system-config-printer

bull System-gtAdministration-gtPrintingbull Supported printer connections

Local (parallel or usb)

UnixLinux print server

Windows print server

Netware print server

HP JetDirectbull Configuration stored in etccupsprintersconf

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Printing Commands

bull lpr sends a job to the queue to be printed

Accepts ASCII PostScript PDF othersbull lpq views the contents of the queuebull lprm removes a job from the queuebull System V printing commands such as lpbull lpstat and cancel are also supported

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Setting the Systems Date and Time

bull GUI system-config-date System-gtAdministration-gtDate amp Time Can set datetime manually or use NTP Additional NTP servers can be added Can use local time or UTCbull CLI date [MMDDhhmm[[CC]YY][ss]] date 01011330 date 01011330200705

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 9Investigating and ManagingProcesses

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

What is a Process

bull A process is a set of instructions loaded into memory

Numeric Process ID (PID) used for identificationbull UID GID and SELinux context determines

filesystem access Normally inherited from the executing user

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Listing Processes

bull View Process information with ps Shows processes from the current terminal bybull default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY prints custom information pid comm cpu mem state tty euser ruser

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Finding Processes

bull Most flexible ps options | otherbull commands ps axo commtty | grep ttyS0bull By predefined patterns pgrep $ pgrep -U root $ pgrep -G studentbull By exact program name pidof $ pidof bash

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Signals

bull Most fundamental inter-process communication Sent directly to processes no user-interface

required Programs associate actions with each signal Signals are specified by name or number when

sent Signal 15 TERM (default) - Terminate cleanly Signal 9 KILL - Terminate immediately Signal 1 HUP - Re-read configuration files man 7 signal shows complete list

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Sending Signals to Processes

bull By PID kill [signal] pid bull By Name killall [signal] comm bull By pattern pkill [-signal] pattern

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Scheduling Priority

bull Scheduling priority determines access to the CPU

bull Priority is affected by a process nice valuebull Values range from -20 to 19 but default to

0bull Lower nice value means higher CPU

prioritybull Viewed with ps -o commnice

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Altering Scheduling Priority

bull Nice values may be altered

When starting a process

$ nice -n 5 command

After starting

$ renice 5 PIDbull Only root may decrease nice values

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Interactive Process Management Tools

bull CLI topbull GUI gnome-system-monitorbull Capabilities

Display real-time process information

Allow sorting killing and re-nicing

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Job Control

bull Run a process in the background Append an ampersand to the command line

firefox ampbull Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP)bull Manage background or suspended jobs List job numbers and names jobs Resume in the background bg [jobnum] Resume in the foreground fg [jobnum] Send a signal kill [-SIGNAL] [jobnum]

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Grouping Commands

bull Two ways to group commands

Compound date who | wc -lbull Commands run back-to-back

Subshell (date who | wc -l) gtgt tmptrace

All output is sent to a single STDOUT and STDERR

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Exit Status

bull Processes report success or failure with an

exit status

0 for success 1-255 for failure

$ stores the exit status of the most recent

commandbull Example

$ ping -c1 -W1 station999 ampgt devnull

$ echo $

2

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 10Configuring the Bash Shell

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Aliases

bull Aliases let you create shortcuts to commands

$ alias dir=ls -laF

bull Use alias by itself to see all set aliases

bull Use alias followed by an alias name to see alias value

$ alias dir

alias dir=ls -laF

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Login vs non-login shells

bull Startup is configured differently for login andnon-login shellsbull Login shells are Any shell created at login (includes X login) su -bull Non-login shells are su graphical terminals executed scripts any other bash instances`

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Bash startup tasks profile

bull Stored in etcprofile (global) and ~ bash_profile (user)bull Run for login shells only bull Used for Setting environment variables Running commands (eg mail-checker script)

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Bash startup tasks bashrc

bull Stored in etcbashrc (global) and ~bashrc (user)

bull Run for all shellsbull Used for Setting local variables Defining aliases

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Bash exit tasks

bull Stored in ~bash_logout (user)bull Run when a login shell exitsbull Used for

Creating automatic backups

Cleaning out temporary files

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 11Finding and Processing Files

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Objectives

Upon completion of this unit you should be

able tobull Use locatebull Use findbull Use the Gnome Search tool

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

locate

bull Queries a pre-built database of paths to files on the system

Database must be updated by administrator

Full path is searched not just filenamebull May only search directories where the user has

read and execute permission

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

locate Examples

bull locate foo Search for files with foo in the name or pathbull locate -r foo$bull Regex search for files ending in foobull Useful options -i performs a case-insensitive search -n X lists only the first X matches

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

find

bull find [directory] [criteria]bull Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria givenbull Can execute commands on found filesbull May only search directories where the userhas read and execute permission

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Basic find Examples

bull find -name snowpngSearch for files named snowpngbull find -iname snowpngbull 1048576m Case-insensitive search for files named

snowpngbull Snowpng SNOWPNG etcbull find -user joe -group joebull 1048576m Search for files owned by the user joe andbull the group joe

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

find and Logical Operators

bull Criteria are ANDed together by defaultbull Can be ORd or negated with -o and -notbull Parentheses can be used to determine logic

order but must be escaped in bashndash find -user joe -not -group joendash find -user joe -o -user janendash find -not ( -user joe -o -user jane )

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

find and Permissions

bull Can match ownership by name or idndash find -user joe -o -uid 500

bull Can match octal or symbolic permissionsndash find -perm 755 matches if mode is

exactly 755ndash find -perm +222 matches if anyone can writendash find -perm -222 matches if everyone can writendash find -perm -002 matches if other can write

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

find and Numeric Criteria

bull Many find criteria take numeric valuesbull find -size 1024k Files with a size of exactly 1megabytebull find -size +1024k Files with a size over 1 megabytebull find -size -1024k Files with a size less than 1 megabyte

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

find and Access Times

bull find can match by inode timestamps -atime when file was last read -mtime when file data last changed -ctime when file data or metadata last

changedbull Value given is in days find -ctime -10 Files modified less than 10 days ago

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Executing Commands with find

bull Commands can be executed on found files

Command must be preceded with -exec or -ok

-ok prompts before acting on each file

Command must end with Space

Can use as a filename placeholder

find -size +102400k -ok gzip

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The Gnome Search Tool

bull Places-gtSearch for Filesbull Graphical tool for searching by

name

content

ownergroup

size

modification time

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 12Network Clients

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Web Clients

bull Firefoxbull Other web browsersbull Non-GUI web browsersbull wget

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Firefox

bull Fast lightweight feature-rich web browser

Tabbed browsing

Popup blocking

Cookie management

Multi-engine search bar

Support for many popular plug-insbull Themes and Extensions

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Non-GUI Web Browsers

bull links

Provided by the elinks rpm

Full support for frames and ssl

Examples

links httpwwwredhatcom

links -dump httpwwwredhatcom

links -source httpwwwredhatcom

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

wget

bull Retrieves files via HTTP and FTPbull Non-interactive - useful in shell scriptsbull Can follow links and traverse directory trees

on the remote server - useful for mirroring web

and FTP sites

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

OpenSSH Secure Remote Shell

bull Secure replacement for older remote-access tools

bull Allows authenticated encrypted access to

remote systems

ssh [user]hostname

ssh [user]hostname command

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

scp Secure File Transfer

bull Secure replacement for rcpbull Layered on top of ssh

ndash scp source destinationndash Remote files can be specified using

bull [user]hostpathtofile

ndash Use -r to enable recursionndash Use -p to preserve times and permissionsndash Use -C to compress datastream

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

rsync Efficient File Sync

bull Efficiently copies files to or from remote

bull systems

bull Uses secure ssh connections for transportndash rsync conf barneyhomejoeconfigs

bull Faster than scp - copies differences in like

files

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

FTP Clients

bull CLI lftp$ lftp ftpexamplecom$ lftp -u joe ftpexamplecom

ndash Automated transfers with lftpget

bull GUI gFTPndash Applications-gtInternet-gtgFTPndash Allows Drag-and-Drop transfersndash Anonymous or authenticated accessndash Optional secure transfer via ssh (sftp)

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Network Diagnostic Tools

ping

traceroute

host

dig

netstat

gnome-nettool (GUI)

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 15

Advanced Topics in Users

Groups and Permissions

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

User and Group ID Numbers

bull User names map to user ID numbers

bull Group names map to group ID numbers

bull Data stored on the hard disk is stored

numerically

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

etcpasswd etcshadow and etcgroup files

bull Authentication information is stored in plain text filesndash etcpasswdndash etcshadowndash etcgroupndash etcgshadow

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

User management tools

bull Graphical toolsndash system-config-users

bull Command-linendash useraddndash usermodndash userdel [-r]

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Monitoring Logins

bull Connected users w

bull Recent Logins last lastb

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Default Permissions

bull Default permission for directories is 777 minus umask

bull Default permission for files is the directory default without execute permissionndash umask is set with the umask commandndash Non-privileged users umask is 002

bull Files will have permissions of 664bull Directories will have permissions of 775

bull roots umask is 022

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Special Permissions for Executables

bull Special permissions for executablesndash suid command run with permissions of the owner of

the command not executor of the commandndash sgid command runs with group affiliation of the group

of the command

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Special Permissions for Directories

bull Special permissions for directoriesndash sticky bit files in directories with the sticky bit

set can only be removed by the owner and root regardless of the write permissions of the directory

ndash sgid files created in directories with the sgid bit set have group affiliations of the group of the directory

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Unit 16

The Linux Filesystem In-Depth

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Partitions and Filesystems

bull Disk drives are divided into partitionsbull Partitions are formatted with filesystems

allowing users to store datandash Default filesystem ext3 the Third Extended Linux

Filesystemndash Other common filesystemsndash ext2 and msdos (typically used for floppies)ndash iso9660 (typically used for CDs)ndash GFS and GFS2 (typically for SANs)

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Hard Links

bull A hard link adds an additional pathname to reference a single filendash One physical file on the filesystemndash Each directory references the same inode numberndash Increments the link count

bull The rm command decrements the link countbull File exists as long as at least one link remainsbull When the link count is zero the file is removed

ndash Cannot span drives or partitions

bull Syntaxndash ln filename [linkname]

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Symbolic (or Soft) Links

bull A symbolic link points to another filendash ls -l displays the link name and the referenced file

lrwxrwxrwx 1 joe joe 11 Sep 25 1802 pf -gtetcpasswdndash File type l for symbolic linkndash The content of a symbolic link is the name of the file

that it references

bull Syntaxndash ln -s filename linkname

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

The Seven Fundamental Filetypes

ls -l symbol File Type- regular filed directoryl symbolic linkb block special filec character special

filep named pipes socket

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Checking Free Space

bull df - Reports disk space usagendash Reports total kilobytes kilobytes used kilobytes freeper file

systemndash -h and -H display sizes in easier to read units

bull du - Reports disk space usagendash Reports kilobytes used per directoryndash Includes subtotals for each subdirectory

bull -s option only reports single directory summary

ndash Also takes -h and -H options

bull Applications-gtSystem Tools-gtDisk Usage Analyzer or baobab - Reports disk space usage graphically

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Removable Media

Mounting means making a foreign filesystem look like part of the main tree

Before accessing media must be mounted Before removing media must be unmounted By default non-root users may only mountcertain devices (cd dvd floppy usb etc) Mountpoints are usually under media

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Mounting CDs and DVDs

Automatically mounted in GnomeKDE Otherwise must be manually mounted

ndash CDDVD Reader

mount mediacdromndash CDDVD Writer

bull mount mediacdrecorder

eject command unmounts and ejects the disk

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Mounting USB Media

bull Detected by the kernel as SCSI devicesndash devsdaX or devsdbX or similar

bull Automatically mounted in GnomeKDEndash Icon created in Computer windowndash Mounted under mediaDevice ID

bull Device ID is built into device by vendor

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Mounting Floppy Disks

bull Must be manually mounted and unmountedndash mount mediafloppyndash umount mediafloppy

bull DOS floppies can be accessed with mtoolsndash Mounts and unmounts device transparentlyndash Uses DOS naming conventions

bull mdir abull mcopy homefiletxt a

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Archiving Files and Compressing Archives

bull Archiving places many files into one target filendash Easier to back up store and transferndash tar - standard Linux archiving command

bull Archives are commonly compressedndash Algorithm applied that compresses filendash Uncompressing restores the original filendash tar natively supports compression using gzip and

gunzip or bzip2 and bunzip2

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Creating Listing and Extracting File Archives

bull Action arguments (one is required)ndash -c create an archivendash -t list an archivendash -x extract files from an archive

bull Typically requiredndash -f archivename name of file archive

bull Optional argumentsndash -z use gzip compressionndash -j use bzip2 compressionndash -v be verbose

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156

Classification Confidential

Thank You

  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156
  • Red Hat Enterprise Linux
  • Other Red Hat Supported Software
  • Notes on Internationalization
  • The Fedora Project
  • Objectives
  • Audience and Prerequisites
  • Unit 1
  • What is Open Source
  • Linux Origins
  • Red Hat Distributions
  • Linux principles
  • Unit 2
  • Logging in to a Linux System
  • Switching between virtual consoles and the graphical environment
  • Elements of the X Window System
  • Starting the X server
  • Changing Your Password
  • The root user
  • Changing Identities
  • Editing text files
  • Unit 3
  • Running Commands
  • Some Simple Commands
  • Getting Help
  • The whatis Command
  • The --help Option
  • The man Command
  • Navigating man Pages
  • The info Command
  • Navigating info Pages
  • Extended Documentation
  • Red Hat Documentation
  • Unit 4
  • Linux File Hierarchy Concepts
  • Some Important Directories
  • Current Working Directory
  • File and Directory Names
  • Absolute and Relative Pahnames
  • Changing Directories
  • Listing Directory Contents
  • Copying Files and Directories
  • Copying Files and Directories The Destination
  • Moving and Renaming Files and Directories
  • Creating and Removing Files
  • Creating and Removing Directories
  • Using Nautilus
  • Moving and Copying in Nautilus
  • Determining File Content
  • Unit 5
  • Users
  • Groups
  • Linux File Security
  • Permission Precedence
  • Permission Types
  • Examining Permissions
  • Interpreting Permissions
  • Changing File Ownership
  • Changing Permissions - Symbolic Method
  • Changing Permissions - Numeric Method
  • Unit 6
  • Command Line Shortcuts The Tab Key
  • Command Line Shortcuts History
  • More History Tricks
  • Command Line Expansion The tilde
  • Command Line Expansion Commands and Braced Sets
  • Command Editing Tricks
  • gnome-terminal
  • Scripting Basics
  • Creating Shell Scripts
  • Creating Shell Scripts continued
  • Sample Shell Script
  • Unit 7
  • Introducing vim
  • vim A Modal Editor
  • vim Basics
  • Opening a file in vim
  • Modifying a File Insert Mode
  • Saving a File and Exiting vim Ex Mode
  • Using Command Mode
  • Moving Around Command Mode
  • Undoing Changes Command Mode
  • Learning more
  • Unit 8
  • TCPIP Network Configuration
  • Managing Ethernet Connections
  • Graphical Network Configuration system-config-network
  • Network Configuration Files Ethernet Devices
  • Network Configuration Files Other Global Network Settings
  • Network Configuration Files DNS Configuration
  • Printing in Linux
  • system-config-printer
  • Printing Commands
  • Setting the Systems Date and Time
  • Unit 9 Investigating and Managing Processes
  • What is a Process
  • Listing Processes
  • Finding Processes
  • Signals
  • Sending Signals to Processes
  • Scheduling Priority
  • Altering Scheduling Priority
  • Interactive Process Management Tools
  • Job Control
  • Grouping Commands
  • Exit Status
  • Unit 10 Configuring the Bash Shell
  • Aliases
  • Login vs non-login shells
  • Bash startup tasks profile
  • Bash startup tasks bashrc
  • Bash exit tasks
  • Unit 11 Finding and Processing Files
  • Objectives
  • locate
  • locate Examples
  • find
  • Basic find Examples
  • find and Logical Operators
  • find and Permissions
  • find and Numeric Criteria
  • find and Access Times
  • Executing Commands with find
  • The Gnome Search Tool
  • Unit 12 Network Clients
  • Web Clients
  • Firefox
  • Non-GUI Web Browsers
  • wget
  • OpenSSH Secure Remote Shell
  • scp Secure File Transfer
  • rsync Efficient File Sync
  • FTP Clients
  • Network Diagnostic Tools
  • Unit 15
  • User and Group ID Numbers
  • etcpasswd etcshadow and etcgroup files
  • User management tools
  • Monitoring Logins
  • Default Permissions
  • Special Permissions for Executables
  • Special Permissions for Directories
  • Unit 16
  • Partitions and Filesystems
  • Hard Links
  • Symbolic (or Soft) Links
  • The Seven Fundamental Filetypes
  • Checking Free Space
  • Removable Media
  • Mounting CDs and DVDs
  • Mounting USB Media
  • Mounting Floppy Disks
  • Archiving Files and Compressing Archives
  • Creating Listing and Extracting File Archives
  • Thank You
  • Slide 156