Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Chapter 1: Linux Overview
...
7
Chapter 2: Overview of the GNOME Desktop
...
8
•
Panels
...
9
•
Windows
...
9
•
Nautilus file manager
...
9
•
Start Here location
...
10
Panels
...
10
To Delete Panels
...
11
To Add Objects to Panels
...
11
•
Launchers
...
12
•
Drawers
...
12
To Manipulate Panel Objects
...
13
Windows in the Desktop Environment
...
13
To Manipulate Windows
...
15
Workspaces
...
16
To Add Workspaces
...
17
To Open Files From the File Manager
...
18
Desktop and Desktop Objects
...
19
To Add Objects to the Desktop
...
19
•
Applications
...
19
Desktop Environment Preferences
...
20
To Find Out More
...
21
To Find Out More About Applets
...
22
Chapter 3: GNOME Desktop Sessions
...
23
To Log in to a Session
...
23
To Lock Your Screen
...
24
Defining Session Behavior When You Log In and Log Out
...
24
To Browse Applications in the Current Session
...
25
Ending a Session
...
26
Chapter 5 : Overview Of Shell
...
27
Gaining Access to the Shell
...
28
Getting Information about a Command
...
29
Working with the Shell History
...
30
File Name and Path Completion
...
31
Working with Pipes in the Bash Shell
...
32
Environment Variables
...
34
Summary
...
36
Defining Storage
...
37
* Create File System using command and mount it permanently
...
38
Important
...
39
Using system-config-lvm
...
42
Adding Unallocated Volumes to a Volume Group
...
45
Adding a New Hard Disk Using LVM
...
48
Extending a Volume Group
...
52
Tips:
...
54
Tips:
...
55
Useful Websites
...
56
System Resources Overview
...
56
Monitoring Memory Usage
...
58
Monitoring Running Process
...
62
RPM Design Goals
...
62
Powerful Querying
...
63
Pristine Sources
...
63
Finding RPM Packages
...
64
Package Already Installed
...
65
Uninstalling
...
66
Querying
...
68
man command
...
69
Documentation in /usr/share/doc
...
70
IPv4 Networking Concepts
...
71
Method-1
...
72
Chapter 11: User and Group administration in redhat linux
...
75
How to create a user :-
...
77
4
Set or Change User Password :-
...
78
To see password status of any user account, enter:
...
79
Removing a user Accounts :-
...
80
How to change the login shell for Linux user :
...
81
How to create a group :
...
83
Group Administration
...
84
1
...
84
2
...
85
3
...
86
4
...
86
5
...
87
6
...
87
7
...
88
Chapter 13: Boot Process in Linux System
...
BIOS
...
MBR
...
GRUB
...
Kernel
...
Init
...
Runlevel programs
...
93
1
...
93
2
...
93
3
...
93
4
...
94
5
...
94
5
6
...
94
7
...
94
8
...
94
9
...
94
10
...
95
11
...
95
12
...
95
13
...
95
14
...
95
15
...
95
16
...
95
Chapter 15: Installation Red Hat Enterprise
...
96
Note:
...
108
Printer Configuration Tool
...
109
Adding an IPP Printer
...
111
Confirming Printer Configuration
...
112
Managing Print Jobs
...
113
Chapter 17: Basic Linux Commands
...
114
6
Chapter 1: Linux Overview
Red Hat Enterprise Linux (RHEL) is a Linux distribution developed by Red Hat and targeted
toward the commercial market
...
All of the Red Hat's
official support and training, together with the Red Hat Certification Program, focuses on the Red Hat
Enterprise Linux platform
...
[4]
The first version of Red Hat Enterprise Linux to bear the name originally came onto the market as "Red
Hat Linux Advanced Server"
...
Red Hat uses strict trademark rules to restrict free re-distribution of their officially supported versions of
Red Hat Enterprise Linux, but still freely provides its source code
...
RHEL 6
Red Hat Enterprise Linux 6 was forked from Fedora 12 and contains many back ported features from
Fedora 13 and 14
...
6
...
1, also termed Update 1, 19 May 2011 (kernel 2
...
32-131)
o 6
...
6
...
3, also termed Update 3, 20 June 2012 (kernel 2
...
32-279)
o 6
...
6
...
5, also termed Update 5, 21 November 2013 (kernel 2
...
32-431)
o 6
...
6
...
Before you
start to use the desktop environment, read this chapter to familiarize yourself with the various features,
and how the main components work
...
Introducing Desktop Environment Components
When you start a desktop environment session for the first time, you should see a default startup
screen, with panels, windows, and various icons
...
Figure 2–1 A Typical Desktop Environment
The major components of the desktop environment are as follows:
•
Panels
Panels are areas in your desktop environment from which you can access all of your system
applications and menus
...
A particularly important panel in Figure 2–
1 is the Menu Panel
...
The
Menu Panel includes two special menus, as follows:
8
o
o
Applications menu: Contains all applications and configuration tools
...
To start the file manager, choose Home
Folder from the Applications menu
...
Click on the icon at the extreme right of the Menu Panel to display a list of all open windows
...
The Menu Panel contains
menus, so you can use a combination of menus and panels to perform your tasks
...
You can also access almost all of the standard applications, commands, and configuration options
from the GNOME Menu
...
You can add the GNOME Menu as a button to your panels
...
You can run different applications in each
window
...
The window manager
enables you to perform standard actions such as move, close, and resize windows
...
A workspace is a discrete
area in your desktop environment in which you can work
...
You can switch to a different workspace, but you can
only display one workspace at a time
...
You
can display the contents of your files within a Nautilus window, or open the files in the
appropriate application from Nautilus
...
•
Desktop
The desktop lies behind all of the other components in the desktop environment
...
You can place objects on the desktop to quickly access
your files and directories, or to start applications that you use often
...
•
Start Here location
9
The Start Here location provides an access point to some of the key features of the desktop
environment
...
You can also access programs that enable you to configure your system as a server,
and to choose other system settings
...
Each tool controls a particular part
of the behavior of the desktop environment
...
Choose the item that you want to configure from the submenus
...
The desktop environment provides interoperability of the desktop environment components
...
For example, you can start applications from
panels, from menus, or from the desktop
...
Nevertheless, this chapter
provides a useful quick guide to how to work with the desktop environment
...
When you start a session for the first time, the desktop
environment usually contains at least two panels, as follows:
•
•
Menu Panel
Edge panel at the bottom of the screen
You can perform the following actions with panels:
•
•
•
•
•
Create panels
...
Hide panels
...
Manipulate panel objects
...
Right-click on a vacant space on any panel, then choose New Panel
...
Choose the type of panel that you want to create from the submenu
...
You can create as many panels as you want
...
You can
create different types of panel to fit your own requirements
...
For example, you can change the background of your panels
...
To Hide Panels
Except for the Menu Panel, panels can have hide buttons at each end of the panel
...
To Add Objects to Panels
A panel can hold several types of objects
...
Figure 2–2 A Panel With Various Panel Objects
You can add any of the following objects to all types of panels:
•
Applets
Applets are small, interactive applications that reside within a panel, for example CD Player in
Figure 2–2
...
The following applets appear in your panels by default:
o
o
Window List:
Displays a button for each window that is open
...
By default, Window List appears in the edge
panel at the bottom of the screen
...
You can use
Workspace Switcher to switch between workspaces
...
To add an applet to a panel, right-click on a vacant space on the panel, then choose Add to Panel
...
The calculator
icon in Figure 2–2 is a launcher for the Calculator application
...
Click on the launcher to perform the action that is associated with the launcher
...
For example, you can create a launcher for a
word processor application that you use frequently, and place the launcher in a panel for
convenient access
...
Alternatively, to add a launcher from a menu, right-click on a vacant space on the panel, then
choose Add to Panel -> Launcher from menu
...
•
Menus
You can access all desktop environment functions through menus
...
To open a menu
from a panel, click on the icon that represents the menu
...
Menus that you add to your panels are represented by an icon with an arrow
...
The icon in Figure 2–2 is the icon that is displayed when you add
the Desktop Preferences menu to a panel
...
To add the GNOME Menu to a panel,
right-click on a vacant space on the panel, then choose Add to Panel -> GNOME Menu
...
Drawers can help you to organize your work when you run a lot of
applications simultaneously
...
To add a drawer to a panel, right-click on a vacant space on the panel, then choose Add to Panel > Drawer
...
To close a drawer click on the drawer again
...
The lock icon in Figure 2–2 is the Lock button
...
To add the buttons to a panel, right-click on a vacant space on the panel, then choose Add to
Panel
...
12
To Manipulate Panel Objects
You can manipulate panel objects in the following ways:
•
Move objects within a panel, or to another panel
...
You can also move an object from one
panel to another panel
...
•
Copy menu items to a panel
...
Alternatively, if the menu item is a launcher right-click
on the menu item, then choose Add this launcher to panel
...
Your default panels contain menus, so
you can use a combination of menus and panels to perform your tasks
...
You can also add the GNOME Menu to your panels
...
You can also access the items in the Applications and
Actions menus from the GNOME Menu
...
To add a GNOME Menu to a panel, right-click on the panel then choose Add to Panel -> GNOME Menu
...
You can add as many additional menus as you want to any of your panels
...
You can perform other actions on your menus, such as
copy menu items to panels
...
Each window has a frame
...
Types of Windows
The desktop environment features the following types of window:
13
•
Application windows
When you run an application, a frame usually borders the window
...
The titlebar contains buttons that you can use to work with
the window
...
The Window Menu provides commands that you
can perform on the window
...
A dialog window consists of the
window frame, and a single interactive pane that provides information and controls for the user
...
The frame of a dialog
window contains buttons that enable you to open the Window Menu, or to close the dialog
window
...
Most of the control elements are located on the top edge of the window frame
...
Figure 2–3 Top Edge of Frame for a Typical Application Window
The active control elements of the window frame are as follows:
Control
Element
Window
button
Description
Menu
Click on the Window Menu button to open the Window Menu
...
Minimize button
Click on the Minimize button to minimize the window
...
To maximize a window click on the Maximize button
...
Close
button
Window
Border
Click on the Close Window button to close the window
...
To change the size of windows grab the border of the window, but not the titlebar
...
To Give Focus to a Window
A window that has focus can receive input from the mouse and the keyboard
...
The window that has focus has a different appearance than other windows
...
Shortcut
keys
Use shortcut keys to switch between the windows that are open
...
The default shortcut keys to switch between
windows are Alt + Tab
...
Workspace
Switcher
Click on the window that you want to give focus to in the Workspace Switcher
display
...
Your windows are
displayed in subdivisions of your desktop environment that are called workspaces
...
15
Every workspace contains the same desktop, the same panels, and the same menus
...
You can display only one
workspace at a time ion your desktop environment but you can have windows open in other workspaces
...
When your current workspace becomes crowded with windows, you can move your work to
another workspace
...
Workspaces are displayed in the Workspace Switcher applet
...
The first three workspaces contain open windows
...
Figure 2–4 Workspaces Displayed in Workspace Switcher
To Switch Between Workspaces
You can switch between workspaces in the following ways:
•
•
•
In Workspace Switcher, click on the workspace where you want to work
...
Press Ctrl + Alt + left arrow to switch to the workspace on the left of the current workspace
...
The Workspace Switcher Preferences dialog is displayed
...
16
Nautilus File Manager
The Nautilus file manager provides an integrated access point to your files, applications, and FTP sites
...
The following figure shows a Nautilus
window that displays the contents of a folder
...
This pane also displays information about the current
file or folder
...
View pane
Displays the contents of files and folders
...
Nautilus
•
enables you to do the following:
View files and folders
17
You can view your files and folders as icons or as a list
...
Alternatively, you can open the files in the appropriate
application from Nautilus
...
•
Run scripts
You can run scripts from Nautilus, and you can select files and folders on which to run your
scripts
...
For example, you can
add an important emblem to a file to indicate that the file is important
...
Specify a custom background pattern for a folder
...
also creates the desktop
...
When the file that you want to open is displayed, double-click on the file icon to open the
file
...
Open a different folder in
each window, and then drag the files from one window to the other
...
You can use the desktop to perform the following
actions:
•
Start your applications, and open your files and folders
...
For example, you add a launcher for an application that you use often
...
18
Right-click on the desktop to open the Desktop menu
...
The file manager manages the desktop
...
You can set your preferences in a file
manager window so that you click once on an object to execute the default action
...
You can add objects to your desktop in the following ways:
•
•
•
Use the Desktop menu to add a launcher to the desktop
...
For example, you can create a
symbolic link to a file that you use often, then drag the link to your desktop
...
To open the file, double-click on the icon
...
Drag an application launcher from a menu to the desktop
...
Start Here Location
The Start Here location enables you to access the following functions:
•
Applications
Double-click on Applications to access your key GNOME applications
...
•
Desktop Preferences
Double-click on Desktop Preferences to customize your desktop environment
...
You can access the Start Here location in the following ways:
•
From a Nautilus window
19
Choose Go -> Start Here
...
•
From the desktop
Double-click on the Start Here object on the desktop
...
Desktop Environment Preferences
You can use desktop environment preference tools to configure almost every feature of the desktop
environment
...
For
example, you can use a preference tool to select a theme for your desktop environment
...
For convenience, the tools are grouped under the following headings:
•
•
•
Basic
Accessibility
Advanced
You can open your desktop environment preference tools in either of the following ways:
•
•
Choose Applications -> Desktop Preferences
...
Double-click on the Start Here object on the desktop
...
Double-click on the Desktop Preferences object in the file manager window to
display the preference tools
...
Applications
The applications that are provided with the GNOME Desktop share several characteristics
...
The applications share characteristics because the
applications use the same programming libraries
...
For example, Nautilus and the gedit text
editor are GNOME-compliant applications
...
The libraries
enable GNOME to run your existing applications as well as GNOME-compliant applications
...
Some of the features of GNOME-compliant applications are as follows:
•
Consistent look-and-feel
GNOME-compliant applications have a consistent look-and-feel
...
You can use
the following tools to change the look-and-feel of your GNOME-compliant applications:
20
Applications -> Desktop Preferences -> Menus & Toolbars
Applications -> Desktop Preferences -> Theme
Menu bars, toolbars, and status bars
o
o
•
Most GNOME-compliant applications have a menu bar, a toolbar, and a status bar
...
The File menu always contains an Quit menu
item, and the Help menu always contains an About menu item
...
A toolbar contains buttons for the most
commonly-used commands
...
GNOME-compliant
applications might also contains other bars
...
Some of the bars in GNOME-compliant applications are detachable
...
You can drag the bar to snap to another
side of the window, or to another part of the desktop environment
...
•
Default shortcut keys
GNOME-compliant applications use the same shortcut keys to perform the same actions
...
To undo an action in a
GNOME-compliant application, press Ctrl + Z
...
Therefore, GNOME-compliant applications provide consistent feedback when you drag-and-drop
items
...
For example, GNOME-compliant applications recognize the format of the
items that you drag
...
However, when you drag the HTML file to a
text editor, the file is displayed in plain text format in the text editor
...
To
start the Yelp help system, choose Applications -> Help
...
To Find Out More About Applications
To find out more about a specific application, start the application, then choose Help -> Contents
...
22
Chapter 3: GNOME Desktop Sessions
Starting a Session
A session occurs between the time that you log in to the desktop environment and the time that you log
out
...
The
login screen provides fields for you to enter your username and password
...
You start a session when you log in
...
The session manager enables you to manage the session
...
The
session manager saves and restores the following:
•
•
The appearance and behavior settings, for example fonts, colors, and mouse settings
...
You
cannot save and restore applications that the session manager does not manage
...
To Log in to a Session
To log in to a session, perform the following actions
...
Choose Options -> Session
...
2
...
3
...
When you log in successfully, the session manager starts a session
...
If you have logged in before, then the session manager restores
your previous session
...
1
...
Choose the GNOME Desktop from the list of
available desktop environments
...
On the login dialog, choose Options -> Language
...
Choose the language group that includes the language that you want
...
Choose a language
...
Log in
...
The Options menu on the Login
Manager dialog enables you to access other languages
...
The system restores the default language at the end
of the session
...
If the Lock button is present on a panel, click on the Lock button
...
Choose Add to Panel -> Lock button
...
To unlock the screen, move your mouse to display the
locked screen dialog
...
Note – To lock your screen correctly, you must have a screensaver enabled
...
The Sessions preference tool recognizes the following types of
application:
•
•
Applications that are session-managed
...
If you log out, then log in again, the
session manager automatically starts the session-managed applications
...
When you save the settings for your session, the
session manager does not save any applications that are not session-managed
...
You must start
the application manually
...
Defining Session Behavior When You Log In and Log Out
To set how a session behaves when you log in and log out, choose Applications -> Desktop Preferences > Advanced -> Sessions
...
For
example, you can select to display a splash screen when you log in
...
To configure
non-session-managed startup applications, choose Applications -> Desktop Preferences -> Advanced ->
Sessions
...
If you save your
settings and log out, the next time that you log in, the startup applications start automatically
...
The Current Session tabbed section lists the following:
•
•
All GNOME applications that are currently running, that can connect to the session manager, and
that can save the state of the application
...
You can use the Current Session tabbed section to perform a limited number of actions on the session
properties of an application or preference tool
...
To Save Session Settings
To save your session settings, perform the following steps:
1
...
To configure
your session, choose Applications -> Desktop Preferences -> Advanced -> Sessions
...
Select the automatically save changes to session option on the Session
Options tabbed section
...
End your session
...
To save your settings, select the option, and then continue to log
out
...
Open the GNOME Menu, then choose Log Out
...
Before you end a session, you might want to save your current settings so that you can restore the session
later
...
In the Sessions
preference tool, you can select an option to automatically save your current settings
...
With Nautilus you can explore the
file system, create files and folders, view file properties, and manipulate files and folders(copy, delete,
move, cut, paste and so on)
...
Files and folders are represented by icons and file names by default(icon view)
...
Select the Arrange items menu items, to list files by name, size, time, date or
emblem
...
Files names beginning with a period(
...
To see files or folders beginning
with a period in your current folder, select View->Show Hidden Files
...
When coping a file or folder, if the source and destination folders are on different physical disk
partitions, the default drag and drop action between those folders will be copy instead of a move
...
4
...
it may be
changed to operate in browser mode, in which the contents displayed in the window changes each time
you change to a new folder
...
In the File Management Preferences window on the
Behavior tab, make sure Always open in browser windows is checked, and Close the window
...
Whilst the
graphical desktop environments such as GNOME and KDE included with Linux provide a user
friendly interface to the operating system, in practice the shell environment provides far greater
capabilities, flexibility and automation than can ever be achieved using graphical desktop tools
...
The goal of this chapter, therefore, is to provide an overview of the default shell environment on
RHEL 6 (specifically the Bash shell)
...
The origins of the
shell can be traced back to the early days of the UNIX operating
...
A variety of shell environments have been developed over the years
...
Yet another early creation was the C shell which shared some syntax similarities with the C
Programming Language and introduced usability enhancements such as command-line editing
and history
...
The default shell on RHEL 6 is the Bash shell (shorthand for Bourne again shell)
...
Gaining Access to the Shell
From within the GNOME desktop environment, the shell prompt may be accessed from a
Terminal window either by selecting the Applications -> System Tools -> Terminal menu option
or right clicking on the desktop and selecting Open in Terminal from the resulting menu
...
When booting a server based system in which a desktop environment has not been
installed, the shell is entered immediately after the user completes the login procedure at the
console terminal or remote login session
...
Whilst some commands perform tasks silently, most will display some
form of output before returning to the prompt
...
The location on the file system of a command may be identified using the which command
...
Using the which command to locate the
path to commands that are built into the shell will result in a message indicating the executable
cannot be found
...
3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/demo/bin)
(/usr/lib64/qt-
Getting Information about a Command
Many of the commands available to the Linux shell can seem cryptic to begin with
...
For example, to learn more about the pwd
command:
# man pwd
When the above command is executed, a detailed description of the pwd command will be
displayed
...
This meant that if
you spotted an error at the beginning of a long command line you were typing, you had to delete
all the following characters, correct the error and then re-enter the remainder of the command
...
A list of previously executed commands may be viewed using the history command:
[user@pc ~]$ history
29
1
2
3
4
5
6
ps
ls
ls –l /
ls
man pwd
man apropos
In addition, the Ctrl-p (or up arrow) and Ctrl-n (or down arrow) may be used to scroll back and
forth through previously entered commands
...
Another option is to enter the ‘!’ character followed by the first few characters of the command
to be repeated followed by the Enter key
...
For example, to display the
content of a text file named list
...
txt
Similarly, the content of multiple text files could be displayed by specifying all the file names as
arguments:
# cat list
...
txt list3
...
txt
Instead of typing in each name, pattern matching can be used to specify all files with names
matching certain criteria
...
txt
The above command will display the content of all files ending with a
...
This could
be further restricted to any file names beginning with list and ending in
...
txt
Single character matches may be specified using the ‘?’ character:
# cat list?
...
In order to use filename
completion, simply enter the first few characters of the file or path name and then press the Esc
key twice
...
To obtain a list of possible matches, press
Esc = after entering the first few characters
...
By default
this output goes to a device file called stdout which is essentially the terminal window or console
in which the shell is running
...
Output from a command can be redirected from stdout to a physical file on the file system using
the ‘>’ character
...
txt, the following command would be required:
# ls *
...
txt
Upon completion, files
...
Similarly, the
contents of a file may be fed into a command in place of stdin
...
txt
The above command will display the number of lines contained in files
...
It is important to note that > redirection operator creates a new file, or truncates an existing file
when used
...
dat >> files
...
Whilst
output from a command is directed to stdout, any error messages generated by the command are
directed to stderr
...
This is generally the desired behavior, though stderr may also be redirected if
desired using the 2> operator:
# ls dkjfnvkjdnf 2> errormsg
On completion of the command, an error reporting the fact that the file named dkjfnvkjdnf could
not be found will be contained in the errormsg file
...
31
Working with Pipes in the Bash Shell
In addition to I/O redirection, the shell also allows output from one command to be piped
directly as input to another command
...
For example, to count the number of
process running on a system the output from the ps command can be piped through to the wc
command:
# ps –ef | wc –l
There is no limit to the number of pipe operations that can be performed on a command line
...
For example, you may often use the ls
command with the l and t options:
# ls –lt
To reduce the amount of typing involved in issuing a command it is possible to create an alias
that maps to the command and the arguments
...
Environment Variables
Shell environment variables provide temporary storage of data and configuration settings
...
A listing of current defined variables may be obtained using the env
command:
[user@pc ~]$ env
HOSTNAME=rhel6
SELINUX_ROLE_REQUESTED=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=192
...
2
...
3
32
QTINC=/usr/lib64/qt-3
...
...
Perhaps the most useful environment variable is PATH
...
The PATH environment variable for a newly installed RHEL 6 system running a GNOME
desktop session will likely be configured as follows:
[user@pc ~]$ echo $PATH
/usr/lib64/qt-3
...
If, for
example, you wanted the shell to also look for commands in the scripts directory located in your
home directory, you would modify the PATH variable as follows:
# export PATH=$PATH:$HOME/scripts
The current value of an existing environment variable may be displayed using the echo
command:
# echo $PATH
You can create your own environment variables using the export command
...
For example, to assign the current date and time to an
environment variable called NOW:
# export NOW=`date`
echo $NOW
Thu Nov 18 11:09:07 EST 2010
If there are environment variable or alias settings that you need to be configured each time you
enter the shell environment, they may be added to a file in your home directory named
...
For example, the following example
...
bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
33
...
By interactive we
mean manually entering commands at the prompt one by one and executing them
...
Arguably one of the most powerful aspects of the shell involves the ability to create shell scripts
...
In addition to the ability to execute commands,
the shell provides many of the programming constructs such as for and do loops and if
statements that you might reasonably expect to find in a scripting language
...
There
are, however, many books and web resources dedicated shell scripting that do the subject much
more justice than we could ever hope to achieve here
...
The first step in creating a shell script is to create a file (for the purposes of this example we
name it simple
...
This could equally be, for example, /bin/csh or /bin/ksh if either were the
interpreter you wanted to use
...
This may be executed by passing the name of the script through as an argument to sh:
# sh simple
...
sh
Once the execute bit has been set on the file’s permissions, it may be executed directly
...
/simple
...
In the world of graphical desktop environments it is easy to forget that the
true power and flexibility of an operating system can often only be utilized by dropping down
below the user friendly desktop interface and using a shell environment
...
The capabilities of the shell go far beyond the areas covered in this chapter
...
Once familiar with the
concepts you will quickly find that it is quicker to perform many tasks using the shell in a
terminal window than it is to wade through menus and dialogs on the desktop
...
Most Red Hat Enterprise Linux Systems on the *86 and *86-64 processor architectures use the
MBR partitioning format for their hard disks
...
The
first 446 bytes contains the first part of the boot loader that starts the system, followed by 64
bytes that contains the partition table
...
Total allowed partitions: 3/4 primary partitions
If required one primary partition can be converted to Extended partition
...
Storage devices are represented by device files in /dev
...
The second is /dev/sdb, (2nd hard disk) and so on
...
The Palimpset Disk Utility Application is used as graphical interface to manage disk partitions
...
36
The standard file system used in RHEL is ext4, the fourth extended file system
...
Then the contents of that file system can be browsed as
if they are the contents of the mount point directory
...
A file which only root can edit, /etc/fstab, lists what partitions should have their
file systems mounted on what mount points with which options, one partition per line
...
Once this is set, root can 'mount'
/data to mount the file system above and 'unmount' /data to unmount it
...
* Steps to create a permanent mount to a logical drive
Create a new partition as extended
...
Select Extended ---> Create Logical Partition
...
Create new directory 'data' in the file system
...
Copy the recently temporary mounted (last entry) log
...
Open file ---> Filename /etc/fstab
...
Save
...
* Create File System using command and mount it permanently
# fdisk –l
# fdisk /dev/hda
#n
#l
# Press Enter
# +50M
#W
# partprobe
#mkfe
...
With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes
...
The physical volumes are combined into logical volumes, with the exception of the /boot/
partition
...
If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not
a part of a volume group
...
LVM Group
Figure 6
...
Logical Volumes
On the other hand, if a system is partitioned with the ext3 file system, the hard drive is divided into
partitions of defined sizes
...
Even if the partition is moved to another hard drive, the original hard drive space has to be reallocated as
a different partition or not used
...
e
...
For comprehensive information on the creation and configuration of LVM partitions in clustered and
non-clustered storage, please refer to the Logical Volume Manager Administration guide also provided by
Red Hat
...
For more information, refer to the Create LVM
Logical Volume section of the Installation Guide for Red Hat Enterprise Linux 6
...
6 kernel
...
4 kernel
...
You can access
the application by selecting from your menu panel System > Administration > Logical Volume
Management
...
In the example used in this section, the following are the details for the volume group that was created
during the installation:
/boot - (Ext3) file system
...
(DO NOT initialize this partition)
...
LogVol02 - (LVM) contains the (/home) directory (128 extents)
...
The logical volumes above were created in disk entity /dev/hda2 while /boot was created in /dev/hda1
...
7, “Uninitialized Entities”
...
The logical and the physical views of
the above configuration are illustrated below
...
39
Main LVM Window
Figure 6
...
Main LVM Window
The figure below illustrates the physical view for the volume
...
Steps to
migrate extents are discussed in Figure 6
...
Figure 6
...
Physical View Window
40
The figure below illustrates the logical view for the selected volume group
...
Logical View Window
Figure 6
...
Logical View Window
On the left side column, you can select the individual logical volumes in the volume group to view more
details about each
...
To perform this operation select the respective logical volume and click on the Edit Properties
button
...
The
figure below illustrates this
...
If there was remaining space, this option would be enabled
...
To cancel your changes click on the Cancel button
...
A snapshot can be created by clicking on
the Create Snapshot button on the LVM utility window
...
41
Edit Logical Volume
Figure 6
...
Edit Logical Volume
Utilizing Uninitialized Entities
'Uninitialized Entities' consist of unpartitioned space and non LVM file systems
...
Please view each partition and ensure that you read the 'Properties for Disk Entity' on the right
column of the window to ensure that you do not delete critical data
...
Uninitialized entities are illustrated below
...
7
...
To initialize a
partition or unpartioned space, select the partition and click on the Initialize Entity button
...
Adding Unallocated Volumes to a Volume Group
Once initialized, a volume will be listed in the 'Unallocated Volumes' list
...
The respective buttons at the bottom of the window allow you to:
•
•
•
create a new volume group,
add the unallocated volume to an existing volume group,
remove the volume from LVM
...
Unallocated Volumes
Figure 6
...
Unallocated Volumes
Clicking on the Add to Existing Volume Group button will display a pop up window listing the existing
volume groups to which you can add the physical volume you are about to initialize
...
In this example only one volume group exists as illustrated
below
...
9
...
You can use the unused space to:
•
•
create a new logical volume (click on the Create New Logical Volume(s) button,
select one of the existing logical volumes and increase the extents select an existing logical
volume and remove it from the volume group by clicking on the Remove Selected Logical
Volume(s) button
...
The figure below illustrates the logical view of 'VolGroup00' after adding the new volume group
...
10
...
Logical view of volume group
Figure 6
...
Logical view of volume group
Migrating Extents
To migrate extents from a physical volume, select the volume and click on the Migrate Selected
Extent(s) From Volume button
...
An error message will be displayed if you do not have a sufficient
number of free extents
...
If a sufficient number
of free extents is detected in the volume group, a pop up window will be displayed from which you can
select the destination for the extents or automatically let LVM choose the physical volumes (PVs) to
migrate them to
...
45
Migrate Extents
Figure 6
...
Migrate Extents
The figure below illustrates a migration of extents in progress
...
Migrating extents in progress
Figure 6
...
Migrating extents in progress
46
Once the extents have been migrated, unused space is left on the physical volume
...
Please note that the extents of LogVol00
which were initially in hda2 are now in hda3
...
Logical and physical view of volume group
Figure 6
...
Logical and physical view of volume group
Adding a New Hard Disk Using LVM
In this example, a new IDE hard disk was added
...
From the figure below, the disk is uninitialized and not mounted
...
Once initialized, LVM will add the new volume to the list of unallocated
volumes as illustrated in Figure 6
...
47
Uninitialized hard disk
Figure 6
...
Uninitialized hard disk
Adding a New Volume Group
Once initialized, LVM will add the new volume to the list of unallocated volumes where you can add it to
an existing volume group or create a new volume group
...
The volume if removed from LVM will be listed in the list of 'Uninitialized Entities' as illustrated in
Figure 3
...
In this example, a new volume group was created as illustrated
below
...
16
...
The logical view will display the new volume group with unused space as no logical volumes have
been created
...
Please select the extents you wish to use on the volume group
...
Create new logical volume
Figure 6
...
Create new logical volume
The figure below illustrates the physical view of the new volume group
...
49
Physical view of new volume group
Figure 6
...
Physical view of new volume group
Extending a Volume Group
In this example, the objective was to extend the new volume group to include an uninitialized entity
(partition)
...
To extend the volume
group, click on the Extend Volume Group button
...
On the 'Extend Volume Group' window, you can select disk entities (partitions) to
add to the volume group
...
15, “Uninitialized hard disk”)
...
50
Select disk entities
Figure 6
...
Select disk entities
Once added, the new volume will be added as 'Unused Space' in the volume group
...
Logical and physical view of an extended volume group
Figure 6
...
Logical and physical view of an extended volume group
51
Editing a Logical Volume
The LVM utility allows you to select a logical volume in the volume group and modify its name, size and
specify file system options
...
Clicking on the Edit Properties button will display the 'Edit Logical Volume' popup window from which
you can edit the properties of the logical volume
...
Please note that you should indicate the
mount point
...
The 'Edit Logical Volume' window is illustrated below
...
21
...
To
mount the volume when the system is rebooted, select the 'Mount when rebooted' checkbox
...
This is illustrated in the figure below
...
22
...
Please note in this example that the logical volume named 'Backups'
spans across two hard disks
...
53
Edit logical volume
Figure 6
...
Edit logical volume
Tips:
Logical Volume (8e) Using Command
Tips:
•
PV+VG [extent] +LV
1
...
A Logical volume can contain at best 65534 extents
...
# lvcreate –L 256M –n myvol vg0 ; if we want to create a LV having 256M size
Formating LV Volume
# mkfs
...
lvm help — This command shows all LVM commands available
...
redhat
...
http://tldp
...
55
Chapter 7: Linux System Resources & Performance Monitoring
System Resources Overview
You may be a user at home, a user in a LAN (local area network), or a system administrator of a
large network of computers
...
Whatever may be your function, monitoring your Linux system is of
paramount importance to keep it running in top condition
...
Analysis of the information made available during monitoring is necessary, since all the
resources are limited
...
Monitoring the Hard Disk Space
Use a simple command like:
$ df -h
This results in the output:
Filesystem
Size
Used
Avail
Use%
Mounted on
/dev/sda1
22G
5
...
1G
72%
/home
This shows there are two partitions (1 & 2) of the hard disk sda, which are currently at 24% and
72% utilization
...
How much is used and balance
available is shown as well
...
It is better that the system checks the disks and informs you by email if there is a
potential danger
...
For the GUI, there is a graphical tool called ‘Baobab’ for checking the disk usage
...
Monitoring Memory Usage
RAM or memory is used to run the current application
...
56
For a static snapshot of the memory, use ‘free -m’ which results in the output:
$ free -m
total
used
free
Mem:
1998
1896
-/+ buffers/cache:
1231
290
77
101
buffers
0
cached
766
Swap:
shared
59
605
213
Here, the total amount of RAM is depicted in megabytes (MB), along with cache and swap
...
Both will give you a picture of which process is using what amount of memory and the
picture will be updated periodically
...
Whereas ‘top’ has a purely numerical display, ‘htop’ is somewhat more colorful
and has a semi-graphic look
...
[root@pc ~]# top
top - 01:04:18 up 81 days, 11:05, 1 user, load average: 0
...
28, 0
...
4%us, 0
...
0%ni, 96
...
5%wa, 0
...
0%si, 0
...
0
0 12424 756 544 S 0
...
0
0 38480 2868 2008 S 0
...
0
0 38336 2700 2020 S 0
...
0
0 71548 22m 1400 S 0
...
1
0
...
1
0
...
3
0
...
3
2
...
86
0:13
...
09
0:10
...
31
0:01
...
69
0:01
...
0
6
...
51 spamd
23935 firewall 18 0 15276 1180 980 S 0
...
1
0:00
...
0
0
...
62 exim
23993 root
15 0 141m 49m 2760 S 0
...
8
1:00
...
0
0
...
17 queueprocd
24494 root
18 0 44524 8028 2200 S 0
...
8
1:20
...
0
1
...
00 cpdavd
24536 root
33 18 23892 2556 680 S 0
...
2
0:02
...
0
1
...
87 cpsrvd-ssl
25952 named 22 0 349m 8052 2076 S 0
...
8
20:17
...
0
0
...
00 udevd
28031 root
17 0 48696 8232 2380 S 0
...
8
0:00
...
0
0
...
00 httpd
28524 root
18 0 90944 3304 2584 S 0
...
3
0:00
...
There are other system monitors available under various window managers in Linux
...
To see what each CPU
is doing or how two CPUs are sharing the load, you have to use ‘top’ or ‘htop’
...
You can also see process
statistics, memory utilization, uptime, load average, CPU status, process counts, and memory and
swap space utilization statistics
...
You may have to install ‘sysstat’ in your system, since
it may not be installed by default
...
Finding out if any specific process is hogging the CPU needs a little more command line
instruction such as:
$ ps -eo pcpu,pid,user,args | sort -r -k1 | less
OR
$ ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
Similar output can be obtained by using the command ‘iostat’ as root:
[root@pc ~]# iostat -xtc 5 3
Linux 2
...
18-028stab094
...
firewall
...
38 0
...
43
0
...
00 96
...
89 0
...
26
0
...
00 95
...
31 0
...
15
1
...
00
98
...
CPU usage under GUI is very well depicted by the Gnome System Monitor and other system
monitoring applications
...
Detailed memory
maps can be accessed, signals can be sent and processes controlled remotely
...
The handiest applications are the old faithfuls - ‘top’ and ‘htop’
...
However, if you prefer a more static
view, use ‘ps’
...
Red Hat, Inc
...
RPM is distributed under the terms of the GPL
...
For the end user,
RPM makes system updates easy
...
RPM maintains a database of installed packages and their
files, so you can invoke powerful queries and verifications on your system
...
tar
...
For the developer, RPM allows you to take software source code and package it into source and
binary packages for end users
...
This clear delineation between pristine sources and your patches
along with build instructions eases the maintenance of the package as new versions of the
software are released
...
RPM Design Goals
To understand how to use RPM, it can be helpful to understand the design goals of RPM:
Upgradability
With RPM, you can upgrade individual components of your system without completely
reinstalling
...
RPM allows intelligent, fullyautomated, in-place upgrades of your system
...
There are no special
upgrade files needed to upgrade a package because the same RPM file is used to install
and upgrade the package on your system
...
You can do searches through
your entire database for packages or just for certain files
...
The files an RPM
package contains are in a compressed archive, with a custom binary header containing
useful information about the package and its contents, allowing you to query individual
packages quickly and easily
...
If you are worried that
you deleted an important file for some package, you can verify the package
...
Any configuration files that you modified are preserved during reinstallation
...
With RPM, you have the pristine sources along with
any patches that were used, plus complete build instructions
...
For instance, if a new version of a program is released, you
do not necessarily have to start from scratch to get it to compile
...
All the compiled-in defaults, and all of the
changes that were made to get the software to build properly, are easily visible using this
technique
...
Using RPM
RPM has five basic modes of operation (not counting package building): installing, uninstalling,
upgrading, querying, and verifying
...
For complete details
and options, try rpm --help or man rpm
...
An Internet search returns
many RPM repositories, but if you are looking for RPM packages built by Red Hat, they can be
found at the following locations:
The Red Hat Enterprise L
inux CD-ROMs
The Red Hat Errata Page available at http://www
...
com/apps/support/errata/
63
Installing
RPM packages typically have file names like test-1
...
i386
...
The file name includes the
package name (test), version (1
...
To install a package, log in
as root and type the following command at a shell prompt:
# rpm -ivh test-1
...
i386
...
0-1
...
rpm
If the installation is successful, the following output is displayed:
Preparing
...
The signature of a package is checked automatically when installing or upgrading a package
...
For example, if the
verification of the signature fails, an error message such as the following is displayed:
error: V3 DSA signature: BAD, key ID 0352860f
If it is a new, header-only, signature, an error message such as the following is displayed:
error: Header V3 DSA signature: BAD, key ID 0352860f
If you do not have the appropriate key installed to verify the signature, the message contains the
word NOKEY such as:
warning: V3 DSA signature: NOKEY, key ID 0352860f
Package Already Installed
If a package of the same name and version is already installed, the following output is displayed:
Preparing
...
0-1 is already installed
However, if you want to install the package anyway, you can use the --replacepkgs option, which tells
RPM to ignore the error:
# rpm -ivh --replacepkgs test-1
...
i386
...
If you attempt to install a package that contains a file which has already been installed by another
package, the following is displayed:
Preparing
...
0-1 conflicts with file from package bar-2
...
20
To make RPM ignore this error, use the --replacefiles option:
# rpm -ivh --replacefiles test-1
...
i386
...
If you try to install a package which has an unresolved dependency, output
similar to the following is displayed:
error: Failed dependencies:
bar
...
2 is needed by test-1
...
0
...
i386
...
Find the suggested package(s) on the Red Hat Enterprise
Linux CD-ROMs or from Red Hat Network , and add it to the command:
# rpm -ivh test-1
...
i386
...
0
...
i386
...
1:test
2:bar
########################################### [100%]
########################################### [ 50%]
########################################### [100%]
If it does not suggest a package to resolve the dependency, you can try the -q --whatprovides option
combination to determine which package contains the required file
...
so
...
65
Uninstalling
Uninstalling a package is just as simple as installing one
...
01
...
rpm
...
You can encounter a dependency error when uninstalling a package if another installed package
depends on the one you are trying to remove
...
0
...
i386
...
Upgrading
Upgrading a package is similar to installing one
...
0-1
...
rpm
As part of upgrading a package, RPM automatically uninstalls any old versions of the test
package
...
Because RPM performs intelligent upgrading of packages with configuration files, you may see a
message like the following:
saving /etc/test
...
conf
...
You should investigate the differences between the two configuration files
and resolve them as soon as possible, to ensure that your system continues to function properly
...
0-1 (which is newer than test-1
...
0-1
...
rpm
66
Querying
The RPM database stores information about all RPM packages installed in your system
...
To query this database, use the -q option
...
For example,
using rpm -q test to query installed package test might generate the following output:
test-2
...
queries the RPM database for which package owns f
...
-p
...
The
following options are used to select the type of information for which you are searching
...
•
•
•
•
•
displays package information including name, description, release, size, build date,
install date, vendor, and other miscellaneous information
...
-s displays the state of all the files in the package
...
-c displays a list of files marked as configuration files
...
cf,
passwd, inittab, etc
...
67
Chapter 9: Get help in Textual environment in Red Hat
man command
About man
The man command is short for manual and provides in depth information about the requested
command or allows users to search for commands related to a particular keyword
...
man [-] [-k keywords] topic
-
Displays the manual without stopping
...
topic
Displays the manual for the topic or command typed in
...
# man -k irc
Quickly search for manuals containing irc within them
...
Space: Scroll forward one screen
...
DnArrow: Scroll forward one line
...
UpArrow: Scroll back one line
...
/string: Search forward for string in the man page
...
n: Repeat previous search forward in the man page
...
N: Repeat previous search background in the man page
...
q: Exit man and return to the prompt
...
It is
provided mainly for GNU commands and utilities
...
The
pinfo command is an info reader that is relatively easy to use
...
Documentation in /usr/share/doc
By convention most other documentation is found in the /usr/share/doc directory, in sub
directories named by RPM package
...
69
Chapter 10: Establish Network Connectivity in Red Hat
The internet protocol, or IP, is the protocol used to send network traffic between hosts across the
internet
...
IPv4 is what most system administrators think of as "IP", in
which 32-bit network addresses on variable sized networks are used to address hosts
...
IPv4 Networking Concepts
IP Address:
172
...
5
...
255
...
0
...
The address is divided into two parts; the network part and the host part
...
In the modern internet, the size of a subnet is variable
...
The netmask indicates how many bits of the IPv4 address belongs to the subnet
...
The lowest possible address on a subnet (host part is all zeros in binary) is sometimes called the network
address
...
The older syntax for a netmask which uses 24 bits for the
network part would read 255
...
255
...
A newer syntax called CIDR notation would specify a network
prefix of /24
...
Note :The special address 127
...
0
...
0
...
0 netmask always points to the local system
("localhost"), so that it can talk to itself using network protocols
...
It can set system-wide defaults that affect all users, or it can be configured to activate
certain network interfaces (perhaps connected to VPN tunnels) only when particular users are logged in
...
Right click the Network Manager applet and select Edit Connections
...
Click Add or select a profile and click Edit button
...
Make sure Connect automatically is checked so that the interface comes up immediately
...
Also make sure Available to all users is checked so that the interface comes up for all users at boot
and is not just up when the current user is looged in
...
Select IPv4 Settings tab
...
Select method as Automatic (DHCP) or Manual
...
With Manual, click Add and specify the IPv4 address, netmask, gateway, and DNS servers
...
Click Apply
...
Use Network Manager to create a static network configuration profile for your server machine
...
Right click on the Network Manager applet icon, and choose Edit Connections
...
Select System etho and Edit
...
Navigate to the IPv4 Settings pannel
...
Choose a configuration Method of Manual
...
Add a new address lines
...
Fill in the following paramaters
...
Address: 192
...
0
...
Netmask: 24 (or 255
...
255
...
Gateway: 192
...
0
...
DNS Servers: 192
...
0
...
Search domains: example
...
168
...
0/24 dev etho proto kernel scope link src 192
...
0
...
168
...
1 dev etho
proto static
71
Note: This shows us that we have a direct route to hosts on 192
...
0
...
168
...
1
...
168
...
1 which
can be reached throught etho
...
example
...
168
...
254
[student@serverx ~]$ host instructor
...
com
instructor
...
com has address 192
...
0
...
168
...
254
254
...
168
...
in-addr
...
example
...
example
...
168
...
254
Method-2
The normal network configuration files in /etc/sysconfig/network-scripts are updated and store the
configuration settings
...
Subnetting allows each computer or networking device in its own subnet to
communicate with each other and still allow communication between subnets by routing the traffic
through the network router
...
A common example of a subnet mask for class C IP addresses is
255
...
255
...
Netmask
A netmask is a 32-bit mask used to divide an IP address into subnets and specify the networks available
hosts
...
For example, in 255
...
225
...
255
...
255, "255" is the assigned broadcast address
...
72
Below is an example of a netmask and an example of its binary conversion
...
255
...
255
Binary:
11111111
11111111
11111111
11111111
Netmask length
8
16
24
32
Counting out the bits in the binary conversion allows you to determine the netmask length
...
However, this address is a broadcast address and does
not allow any hosts (computers or other network devices) to be connected to it
...
Netmask:
255
...
255
...
0
...
x - 223
...
254
...
This is commonly plenty of addresses for one network
...
With the
understanding that the netmask length is 24, subtract three from that number, e
...
24-3 = 21
...
Which
would be 2^21 - 2 = 2,097,150
...
To determine the amount of hosts a netmask is capable of supporting is similar to the above
...
This number is similar to the 21 we determined earlier
...
(where x is the number of zeros in the netmask)
...
Again, two is subtracted from this number to account for the broadcast and network addresses
...
Class
Netmask length
# of networks
# of hosts
Netmask
Class A
8
126
16,777,214
255
...
0
...
255
...
0
Class C
24
2,097,150
254
255
...
255
...
1
...
He is the administrator user
...
System users
System users are the users created by the softwares or applications
...
This kind of users is known as system users
...
Normal users ($)
Normal users are the users created by root user
...
Only the root
user has the permission to create or remove a user
...
It is known as UID
...
Root user UID will be "0"
2
...
Normal users UID will be "500 - 60000"
The range of MIN_GID and MAX_GID is specified in the file "/etc/login
...
There are three important files a user administrator should be aware of
...
"/etc/passwd"
2
...
"/etc/group"
Each of the above mentioned files have specific formats
...
"/etc/passwd"
The first line will be like this
...
User_name is the name of the user
...
Pointer to shadow file is the pointer to the "/etc/shadow" where the encrypted password for that user is
stored
...
UID is the user ID
...
GID is the goup ID for the user
...
Comment is a field where we can add some info about that user
...
6
...
By default for root user it'll be "/root" and for
normal user it'll be "/home/user_name"
...
Default login shell will be "/bin/bash"
...
If no
login shell is required for that user then give
"/sbin/nologin"
2
...
The first line will be like this
root:$1fdsfsgsdfsdkffefje:14757:0:99999:7:::
The fields are as follows,
1
...
Encrypted password
3
...
4
...
5
...
6
...
7
...
8
...
3
...
The first line will be like this
76
root:x:0:root
The fields are as follows
...
Group_name, the name of the group
2
...
GID, Group ID
4
...
Separated by commas
...
The
options are as follows
...
Actually useradd is the real command
and adduser is a soft link to the useradd command
...
A command to add a user with all the fields we mentioned before is as follows
...
You can also add -p for
password and -G for secondary groups which we will see later
...
For example,
[root@pc ~]# useradd -p encrypted_password anup
How do I change passwords for specific user account under Linux operating
systems using command line?
You need to use the passwd command to change passwords
...
A normal user may only change the password for his/her own account
2
...
3
...
First, login as the root user
...
To change password of specific
user account, use the following syntax:
77
Set or Change User Password :Type passwd command as follows to change your own password:
[root@pc ~]# passwd < Press Enter >
Output:
Changing password for russell
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
...
To see password status of any user account, enter:
Syntax :[root@pc ~]# passwd -S userNameHere
Examples :
[root@pc ~]# passwd -S russell
Sample outputs:
russell P 05/05/2012 0 99999 7 -1
The status information consists of 7 fields as follows:
1
...
P : This field indicates if the user account has a locked password (L), has no password
(NP), or has a usable password (P)
3
...
4
...
99999 : Password expiry maximum age
...
7 : Password expiry warning period
...
-1 : Inactivity period for the password
Modifying existing users :
We can also modify the existing user with #usermod command
...
[root@pc~]# usermod -U username
Executing the above command will unlock the user with username
...
This is for taking back up of the
files from it in case needed
...
[root@pc~]# passwd -d u_name
Deleting the password of a user or allowing password less login for a user
...
[root@pc~]# useradd -M russell
To create user without creating home directory
...
Switching users
Sometimes we may need to switch between users
...
[root@pc~]# su
Switch to root user
...
2
...
Gets privileges and home directory access
...
[root@pc~]# su billah
Switch to user billah
2
...
Note : If you are logged in as root user and switching to normal user, you won’t be prompted for the
password
...
How to change the login shell for Linux user :
Use chsh command to change the user login shell
...
A normal user may only change the login shell for her own account; the super user may
change the login shell for any account
...
Specifying the
"-D" switch on its own will simply display the default settings, while specifying -D in conjunction with
other switches will change the defaults to those values
...
They are :
1
...
Secondary group
When we create a user a group also will be created in the same name of the user
...
And if the user abc creates a file
xyz, it's owner will be user abc and group will be group abc
...
Thats
normally all the files and directories created by a user belongs to its primary group
...
All the other groups are added as the
secondary groups of that user
...
But you can appended the secondary groups to a user using the -a option with usermod
command
...
We can append the group admin to him as
follows
...
To change the name of a group
[root@pc~]# groupmod -n newname oldname
82
Chapter 12 :Managing User and Group in RHEL 6
To create a user in RHEL 6 we can use commands as well as graphical user administration tools
...
•
To create a user run command:
# useradd user_name
•
To define a password for the user:
# passwd user_name
•
Create a user with specific UID:
# useradd -u 802 user_name
•
•
The above command will create a user with UID 802
...
To
delete the home directory as well as the files contained in it run following command"
#userdel -r user_name
Given below are some sample questions about user and group administration:
Q1
...
Ans
...
To see the results view /etc/passwd and /etc /group files
...
Create a user john with UID 566 and assign it no interactive shell
...
useradd -s /bin/false john
The above command will add a user john, and give it non interactive shell
...
Make the user roni to expire on date 17-09-2011
...
chage -E 2011-09-17 roni
The above command will make the accountof user roni unavailable from 17-09-2012
Q4
...
Ans
...
In the last post I described about the the user administration
...
To see the present groups in your system you can type groups command
...
You create groups and add users to a group
using both GUI tool and Command line, but I will suggest you to use command line because it is fast and
easy
...
To create new group you can edit /etc/group file or you can run the following command:
•
•
•
•
groupadd group_name : this will add a group named group_name in /etc/group
...
groupmod : modifies group members
...
To add users named russell to a group named sales you can run the following command:
usermod -G sales russell : this command will add user russell to the group sales
...
List the password and its related details for an user
As shown below, any user can execute the chage command for himself to identify when his password is
about to expire
...
$ chage --list billah
chage: permission denied
Note: However, a root user can execute chage command for any user account
...
$ date
Thu Sept 23 00:15:20 PDT 2012
$ passwd russell
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
$ chage --list russell
Last password change
: Sept 23, 2012
Password expires
: never
Password inactive
: never
Account expires
: never
Minimum number of days between password change
:0
Maximum number of days between password change
: 99999
Number of days of warning before password expires
:7
2
...
In the following example, user
russell password is set to expire 10 days from the last password change
...
Syntax: # chage -M number-of-days username
# chage -M 10 russell
# chage --list russell
Last password change
: Sept 23, 2012
Password expires
: Oct 03, 2012
Password inactive
: never
Account expires
: never
Minimum number of days between password change
:0
Maximum number of days between password change
: 10
Number of days of warning before password expires
:7
3
...
So, in the above example, when
the user russell tries to login on Sept 30, 2012 — he’ll get the following message
...
User Forced to Change Password after Expiry Date
If the password expiry date reaches and user doesn’t change their password, the system will force the user
to change the password before the login as shown below
...
You must change your password now and login again!
Changing password for russell
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
5
...
The date
given below is in “YYYY-MM-DD” format
...
# chage -E "2012-10-31" russell
# chage -l russell
Last password change
: Sept 23, 2012
Password expires
: Oct 03, 2012
Password inactive
: never
Account expires
: Oct 31, 2012
Minimum number of days between password change
:0
Maximum number of days between password change
: 10
Number of days of warning before password expires
:7
6
...
You can also set
an additional condition, where after the password is expired, if the user never tried to login for 10 days,
you can automatically lock their account using option -I as shown below
...
Once an account is locked, only system administrators will be able to unlock it
...
How to disable password aging for an user account?
To turn off the password expiration for an user account, set the following:
-m 0 will set the minimum number of days between password change to 0
-M 99999 will set the maximum number of days between password change to 99999
-I -1 (number minus one) will set the “Password inactive” to never
-E -1 (number minus one) will set “Account expires” to never
...
Have you
ever wondered what happens behind the scenes from the time you press the power button until the Linux
login prompt appears?
The following are the 6 high level stages of a typical Linux boot process
...
BIOS
BIOS stands for Basic Input/Output System
Performs some system integrity checks
Searches, loads, and executes the boot loader program
...
You can press a key (typically F12 or F2, but
it depends on your system) during the BIOS startup to change the boot sequence
...
So, in simple terms BIOS loads and executes the MBR boot loader
...
MBR
MBR stands for Master Boot Record
...
Typically /dev/hda, or /dev/sda
MBR is less than 512 bytes in size
...
It contains information about GRUB (or LILO in old systems)
...
89
3
...
If you have multiple kernel images installed on your system, you can choose which one to be
executed
...
GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand
filesystem)
...
conf (/etc/grub
...
The following is
sample grub
...
xpm
...
6
...
el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2
...
18-194
...
6
...
el5PAE
...
So, in simple terms GRUB just loads and executes Kernel and initrd images
...
Kernel
Mounts the root file system as specified in the “root=” in grub
...
Do a
‘ps -ef | grep init’ and check the pid
...
initrd is used by kernel as temporary root file system until kernel is booted and the real root file
system is mounted
...
5
...
Following are the available run levels
0 – halt
90
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – unused
5 – X11
6 – reboot
Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program
...
If you want to get
into trouble, you can set the default run level to 0 or 6
...
Typically you would set the default run level to either 3 or 5
...
Runlevel programs
When the Linux system is booting up, you might see various services getting started
...
OK”
...
Depending on your default init level setting, the system will execute the programs from one of the
following directories
...
d/rc0
...
d/rc1
...
d/rc2
...
d/rc3
...
d/rc4
...
d/rc5
...
d/rc6
...
So,
/etc/rc0
...
d/rc0
...
Under the /etc/rc
...
d/ directories, you would see programs that start with S and K
...
S for startup
...
K for kill
...
Those are the sequence number in which
the programs should be started or killed
...
S80sendmail
is to start the sendmail daemon, which has the sequence number of 80
...
91
There you have it
...
92
Chapter 14 : Directory structure in Red Hat
1
...
Only root user has write privilege under this directory
...
2
...
Common linux commands you need to use in single-user modes are located under this directory
...
For example: ps, ls, ping, grep, cp
...
/sbin – System Binaries
•
Just like /bin, /sbin also contains binary executables
...
For example: iptables, reboot, fdisk, ifconfig, swapon
4
...
This also contains startup and shutdown shell scripts used to start/stop individual programs
...
conf, /etc/logrotate
...
/dev – Device Files
•
•
•
Contains device files
...
For example: /dev/tty1, /dev/usbmon0
6
...
This is a pseudo filesystem contains information about running process
...
This is a virtual filesystem with text information about system resources
...
/var – Variable Files
•
•
•
var stands for variable files
...
This includes — system log files (/var/log); packages and database files (/var/lib); emails
(/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots
(/var/tmp);
8
...
Files under this directory are deleted when system is rebooted
...
/usr – User Programs
•
•
•
•
•
Contains binaries, libraries, documentation, and source-code for second level programs
...
If you can’t find a user binary under /bin, look
under /usr/bin
...
If you can’t find a system binary under
/sbin, look under /usr/sbin
...
For example, when you install
apache from source, it goes under /usr/local/apache2
94
10
...
For example: /home/john, /home/nikita
11
...
Kernel initrd, vmlinux, grub files are located under /boot
For example: initrd
...
6
...
6
...
/lib – System Libraries
•
•
•
Contains library files that supports the binaries located under /bin and /sbin
Library filenames are either ld* or lib*
...
*
For example: ld-2
...
1
...
so
...
7
13
...
Contains add-on applications from individual vendors
...
14
...
15
...
For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder
for CD writer
16
...
Contains server specific services related data
...
95
Chapter 15: Installation Red Hat Enterprise
Installation Steps:
•
•
First of all select DVD and reboot your computer
...
Select Install or Upgrade an Existing
System and press Enter
...
Now you can see the first
screen after Getting GUI Installation Wizard as follow Click on NEXT to Continue…
96
•
Select your preferred Language and Select Keyboard Layout
...
Basic Storage Devices – Select this if you are installation on Local Hard disk or some local
Storage
Specialized Storage Devices - Select this if you are installing on SAN ( Storage Area Network )
or DASD ( Direct Access Storage Devices)
Set your Hostname here
...
e
...
linuxsoftwares
...
Editing Ethernet Cards
...
98
99
•
Iif you have windows/Linux already installed follow the following screen and select fresh or
upgrade and click on NEXT
...
You can create as per your requirement
...
Click on Create -> Select Standard Partition, Enter /boot as
Mount Point, Enter Size 500MB, and Keep all information as it is, Click on OK
...
...
Click on Create -> Select Standard Partition, Enter / as Mount Point,
Select Fill to maximum allowable size and Click on OK
...
Sure then click on Write Changes to disk
...
You can set password for Grub here; you can modify booting entry
Here you choose Desktop environment for better work otherwise choose different types of
environment and package group selection like Virtual Host, Basic Server, Web Server, Database
Server, etc
...
After completion of insatalling package you are prompt to click Reboot
...
Create User and Click Forward
•
•
•
You can set your Date & Time Here
Enable Kdump if you want to configure it otherwise Click on Forward
Congrats users, you have successfully installed RHEL 6
Note:
Possible Sizes For Your Partitions
/boot – usually don’t need more than 200Mb but disk space is cheap so give it 500Mb (0
...
(swap) – depends on amount of RAM, but for modern system with lots of RAM, make it the same size as
the amount of RAM you have (e
...
2Gb RAM – 2Gb swap)
/home – this one depends on how you plan to use the system, how many users you plan to have and the
kind of work they plan to do
...
/usr – depends on how many packages you plan to install on your system
...
For a regular home
system, 20Gb should be plenty
...
/opt – similar situation as /usr and /usr/local here, make it the same size as the other two
...
If you do plan to run a few servers, this may need to be much bigger (depending on what
servers you plan to run)
...
To
give yourself some future flexibility make this one around 20Gb
...
This
one is normally less important, give it around 10Gb
...
Since this partition will contain all the
data which you decide not to put in a partition of it’s own, the size required can change drastically
...
However, if you decide not to have a separate partition for something else, you will need to increase the
size of this partition accordingly
...
This tool helps maintain the printer
configuration
file,
spool
directories,
filters,
and
printer
classes
...
If a system was upgraded
from a previous Red Hat Enterprise Linux version that used CUPS, the upgrade process preserves the
configured queues
...
To start the application, select System (on
the panel) => Administration => Printing, or type the command system-config-printer at a shell prompt
...
Internet Printing Protocol (IPP) — a printer that can be accessed over a TCP/IP network via
the Internet Printing Protocol (for example, a printer attached to another Red Hat Enterprise
Linux system running CUPS on the network)
...
Networked Windows (SMB) — a printer attached to a different system which is sharing a
printer over an SMB network (for example, a printer attached to a Microsoft Windows™
machine)
...
Clicking the Apply button prompts the printer daemon to restart with the changes you have
configured
...
Adding a Local Printer
To add a local printer, such as one attached through a parallel port or USB port on your computer,
click the New Printer button in the main Printer Configuration Tool window to display the
window in Figure
...
Enter a unique name for the printer in the Printer Name field
...
You can also use
the Description and Location fields to further distinguish this printer from others that may be
configured on your system
...
109
Click Forward to open the New Printer dialogue (refer to Figure) If the printer has been
automatically detected, the printer model appears in Select Connection
...
If the device does not automatically appear, select the device to which the printer is connected
(such asLPT #1 or Serial Port #1) in Select Connection
...
OR if you select ipp Printer then do the following process:-
Adding an IPP Printer
An IPP printer is a printer attached to a different system on the same TCP/IP network
...
If a firewall is enabled on the printer server, then the firewall should be configured to allow send /
receive connections on the incoming UDP port 631
...
You can add a networked IPP printer by clicking the New Printer button in the main Printer
Configuration Tool window to display the window in Figure
...
Click Forward to proceed
...
110
Click Forward to continue
...
Selecting the Printer Model and Finishing
Once you have properly selected a printer queue type, you can choose either option:
Select a Printer from database - If you select this option, choose the make of your printer
from the list of Makes
...
o Provide PPD file - A PostScript Printer Description (PPD) file may also be provided with
your printer
...
If you are provided with
a PPD file, you can choose this option and use the browser bar below the option
description to select the PPD file
...
Figure appears
...
The recommended printed driver is automatically selected based on the printer model you chose
...
111
Since a local printer is attached directly to your computer, you need a printer driver to process the
data that is sent to the printer
...
You can then browse the filesystem for the PPD file by
clicking Browse
...
Click Apply to add the print queue if the
settings are correct
...
After applying the changes, print a test page to ensure the configuration is correct
...
To print a test page, select the printer that you want to try out from the
printer list, then click Print Test Page from the printer's Settings tab
...
Managing Print Jobs
When you send a print job to the printer daemon, such as printing a text file from Emacs or
printing an image from The GIMP, the print job is added to the print spool queue
...
During the printing process, the Printer Status icon appears in the Notification Area on the panel
...
112
To cancel a specific print job listed in the GNOME Print Status, select it from the list and
select Edit =>Cancel Documents from the pull down menu
...
The
last few lines look similar to the following:
Rank Owner/ID
Class Job Files
Size Time
active user@localhost+902 A 902 sample
...
Example of lpq output
If you want to cancel a print job, find the job number of the request with the command lpq and
then use the command lprm job number
...
You must have proper permissions to cancel a print job
...
You can also print a file directly from a shell prompt
...
txt prints the text file sample
...
The print filter determines what type of file it is and
converts it into a format the printer can understand
...
Installed Documentation
o
map lpr — The manual page for the lpr command that allows you to print files from the command
line
...
man cupsd
...
man classes
...
queue
...
113
Chapter 17: Basic Linux Commands
Basic Linux Commands
To start-up with the Linux first someone needs to know about the basic Linux commands
...
If you know these basic Linux commands, it will be
easy for you to get further in in your goal to achieve a RedHat Certification
...
Because most of the system administration tasks are managed
remotely using the secure shell also known as SSH
...
Basic Linux Commands and there explanation is given below:
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
uname :- this command returns the name of Operatng System
...
Fully Qualified Domain Name
...
Date and time that the kernel was compiled
...
echo :- prints to the screen
...
clear :- clears the screen / terminal
...
whoami :- reveals the current logged-in user
...
history :- reveals your command history
...
cd ~ will also change to the home directory
...
will change one level up in the directory tree
...
ls / lists the contents of / (root) directory
...
This command shows properties of files and directories
...
ls -ld will show properties of the directory
...
Create files and also show contents of files
...
txt dumps the contents of the file 123
...
114
•
cat > xyz creats new file xyz
...
•
mkdir :- creates a new directory
...
•
rm :- remove files
...
•
stat :- reveals the statistics of a file
...
•
find / -name filename will search the file named filename in the / directory/
•
alias :- return/set aliases for command
...
•
head :- display opening lines of a file
...
•
wc :- counts words and optionally lines and characters in a file
...
•
su :- to switch user
...
These are the the basic Linux commands
...
NOTE : There are many options which can be used with these commands or other commands
...
I think using man command is very
good habit