Professional Documents
Culture Documents
Track
Sector
Cylinders
Sectors
Head
1234
A 2 FAT32 2000
1234
Boot Sectors
P. P. 1 P. P. 2 P. P. 3 P. P. 4
Type: FAT32 Type: Extended Type: Ext2 Type: NTFS
M
B
R
< 1024
Linux-OS
49
Performing the Installation:
Starting the Installation
(continued)
Linux-OS
50
Choosing the Language,
Keyboard, Mouse, and Monitor
Keyboard model and layout automatically
detected
Check “Emulate 3 Button” if mouse does
not have third button
Most monitors automatically detected
If not, try to locate on list of monitor models or
use generic model with correct horizontal and
vertical sync
Incorrect monitor settings can damage
monitor
Linux-OS
51
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)
Verifying keyboard
configuration
Linux-OS
53
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)
Linux-OS
56
Specifying the Installation Type
(continued)
Linux-OS
58
Hard Disk Partitioning
(continued)
Linux-OS
59
Hard Disk Partitioning
(continued)
Linux-OS
61
Hard Disk Partitioning
(continued)
Linux-OS
64
Configuring the Boot Loader
(continued)
Linux-OS
66
Configuring the Boot Loader
(continued)
Linux-OS
67
Configuring the Network and
Firewall
Linux-OS
68
Configuring the Network and
Firewall (continued)
Will NIC be activated at boot time?
Manual IP configuration
Set IP address, Netmask, host name, gateway, primary
domain name space (DNS)
Automatic IP configuration via DHCP
Firewall prevents traffic from entering computer
Customize which traffic is allowed through
Linux-OS
69
Configuring the Network and
Firewall (continued)
Configuring a firewall
Linux-OS
70
Choosing a System Language
and Time Zone
Linux-OS
71
Choosing a System Language
and Time Zone (continued)
Linux-OS
72
Creating the Root User
Authentication: Users log in via valid user
name and password
Configure two user accounts
Administrator account (root)
Full rights to system
Regular user account
Linux-OS
73
Creating the Root User
(continued)
Linux-OS
74
Selecting Packages
Linux-OS
77
Completing the Firstboot Wizard
(continued)
Linux-OS
78
Completing the Firstboot Wizard
(continued)
Linux-OS
80
Completing the Firstboot Wizard
(continued)
Configuring authentication
Linux-OS
82
Installing Linux: Installation
Methods
FTP server
HTTP Web server
NFS server
Packages on hard disk
Boot from first Red Hat (Fedora) Linux CD-
ROM
83
Performing the Installation: Starting
the Installation (continued)
85
Choosing the Language, Keyboard,
Mouse, and Monitor
Keyboard model and layout
automatically detected
Check “Emulate 3 Button” if mouse
does not have third button
Most monitors automatically detected
If not, try to locate on list of monitor models
or use generic model with correct horizontal
and vertical sync
86
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)
91
Specifying the Installation Type
(continued)
93
Hard Disk Partitioning
(continued)
94
Hard Disk Partitioning
(continued)
97
Configuring the Boot Loader
Boot loader: Program started by BIOS ROM
Loads kernel into memory
Can also boot other existing OSs
GRand Unified Bootloader (GRUB): Boot
loader configured during Fedora Linux
installation
Dual booting: Choose OS to boot at startup
98
Configuring the Boot Loader
(continued)
99
Configuring the Boot Loader
(continued)
Boot loader usually resides on the MBR or
on first sector of / or /boot partition
Kernel parameters: Information passed to
Linux kernel via the boot loader
Large Block Addressing 32-bit (LBA32):
Enables Large Block Addressing in boot
loader
For large hard disks not fully supported by the
BIOS
100
Configuring the Boot Loader
(continued)
101
Configuring the Network and
Firewall
102
Configuring the Network and
Firewall (continued)
Will NIC be activated at boot time?
Manual IP configuration
Set IP address, Netmask, host name, gateway, primary
domain name space (DNS)
Automatic IP configuration via DHCP
Firewall prevents traffic from entering computer
Customize which traffic is allowed through
103
Configuring the Network and
Firewall (continued)
Configuring a firewall
104
Choosing a System Language and
Time Zone
107
Creating the Root User
(continued)
108
Selecting Packages
Selecting packages
109
Installing Packages
Package Installation
110
Completing the Firstboot Wizard
Complete the installation
License agreement
Graphics settings
User accounts and authentication
Install additional software
Log in with user account for daily tasks
Shadow password: stored in separate DB
from user accounts
MD5: password encryption method
111
Completing the Firstboot Wizard
(continued)
112
Completing the Firstboot Wizard
(continued)
113
Completing the Firstboot Wizard
(continued)
114
Completing the Firstboot Wizard
(continued)
Configuring authentication
116
Local Login
Text mode login at Virtual consoles
Multiple non-GUI logins are possible through the
use of virtual consoles
There are by default 6 available virtual consoles
Available through Ctrl-Alt-F[1-6]
Graphical login
If X is running, it is available as Ctrl-Alt-F7
Shells, terminals
119
Common Linux terminals
120
Running Commands
Command-line terminal may be accessed
from GUI environment
Command prompt:
Root user: #
Regular user: $
121
Running Commands
Command have the following syntax:
command [options] [arguments]
Each item is separated by a space
Case sensitive
Options modify the command’s behavior
Arguments are filenames or other
information needed by the command
Separated commands with semicolon (;)
Example: date;cal
124
The Filesystem Hierarchy
Standard
Filesystem Hierarchy Standard (FHS):
Standard set of directories for Linux and
UNIX systems
File and subdirectory contents
Gives Linux software developers ability to locate
files on any Linux system
Create non-distribution–specific software
125
The Filesystem Hierarchy
Standard (continued)
126
The Filesystem Hierarchy
Standard (continued)
127
Linux File Hierarchy
Concepts
128
Linux File Hierarchy Concepts
Directories may /
contain plain files
or other directories bin users tmp
Leads to a tree
structure for the doug rocket
filesystem
Root directory: / joke.txt cs2204
lab1.txt lab2.txt
130
The Home Directory
Every user has a home directory, typically under
/home
137
Manual page section numbers
138
Getting Command Help
Examples
man ls
man 5 passwd (5 for section)
man passwd
Gnome documentation
142
Moving and Renaming
Files and Directories
mv – move and/or rename files and directories
Usage:
mv [options] file destination
More than one files may be moved at a time if the
destination is a directory
mv [options] file1 file2 dest
143
Moving and Renaming Files and
Directories: the Destination
If the destination exists and is a directory, the source
files or directory is moved there with the same name
If the destination exist and is a file, the source file is
moved to that filename, overwriting the file
If the destination does not exist, the source file or
directory is renamed with that name
144
Removing and Creating Files
rm – remove files
Usage:
rm [options] filenames
-i interactive
-r recursive (when removing directory)
-f force
145
Creating and Removing
Directories
mkdir – make a directory
rmdir – remove an empty directory
rm –r – recursively remove a directory
and all of its content
Determining File Content
Files can contain many types of data
Check file type before opening to determine
appropriate command or application to use
Syntax
file [options] filename (s)
Syntax
cat [options] [file …]
Contents of the files are displayed
sequentially with no break
Files display “concatenated”
Example
$ls /usr/bin/b*
$ls /usr/bin/?b*
$ls a[0-9]
$ls [!Aa]*
152
The Tab key
Type <TAB> key to complete command line:
For the command name, it will complete a command
name
For an argument, it will complete a file name
Examaple:
slo<TAB>
slocate
ls myf<TAB>
154
History-2
Use the up and down arrow keys to scroll
through previous commands
Type <CTRL-R> to search for a command
in command history
(reverse-i-search)`’:
To recall last argument from previous
command:
<ESC>. Or <ALT-.>
156
Command Editing Tricks
Editing Modes
By default, bash uses emacs-style key
bindings for command editing
Type set –o vi
to change key bindings to vi-style
Make vi the default by adding the command
above to $HOME/.inputrc
$ cat ~/.bashrc
May refer to another user’s home directory:
$ ls ~issa/.bashrc
158
The bash Shell
Variable
A variable is a label that has a value
Variables are resident in memory
Tow types: local and environment
Local variables are used only by the shell
Environment variables are passed onto other
commands and shells.
set to display all variables
env display environment variables
command
mode
wrong command
i ESC :
insert last line
mode Mode or Ex mode
$ ls –l /bin/df
-rwxr-xr-x 1 root root 4096 Apr 1 18:26 /bin/df
$ ls –l README
-rw-rw-r-- 1 issa teachers 9080 Oct 1 8:26 README
209
Special Permissions
Special permissions: a fourth permission set (in
addition to user/group/other), Applicable in four
cases:
SUID (set user ID) for an executable, Processes are
granted access to system resources based on user
who owns the file.
SGID (set group ID) for and executable, Same with
SUID except group is affected.
SGID a directory: Files created in that directory will
have their group set to the directory's group.
213
Numeric representation of regular and special
permissions
214
SUID Permissions(example)
When you login, your login shell process’ values are your user
ID and group ID
E.g., if you run passwd (owned by root), THE user ID is your ID, not
root; then how can it update /etc/passwd file owned by root ?
SUID bit enables this functionality
When an executable file with set user ID (SUID) permission is executed,
command run with permission of the owner of the command, not
executor of the command
File permission of /usr/bin/passwd is r-s--x—x
The SUID can only be applied to binary compiled programs
217
Inode
An inode tables contains a list of all files in an ext2 or ext3
filesystem
An inode (index nodes) is an entry in the table, containing
information about a file (the metadata), including:
File type, permission, link count, UID, GID
The file’s size and various time stamps
Pointers to the file’s data blocks on disk
223
Symbolic (or Soft) links
ls –i for displaying inode number
A symbolic link point to another file
ls –l display the link name and the
referenced file
$ ls –l pf
lrwxrwxrwx 1 issa issa 11 Oct 1 8:26 ps/etc/passwd
Syntax
ln –s filename [linkname]
November 17, 2009 224
The structure of symbolically linked files
225
Hard links
Do not work with networked file systems, any
mounted devices, or any other file system
Only exist on same disk and partition as original
file
One physical file on the filesystem
Each link references the file’s inode
File is present in the filesystem as long as at
least one link remain
Syntax
ln filename [linkname]
Ch 2 230
find command
Syntax
find <dirs> [conditions] [action]
Recurses down in file tree in dirs
Optionally executes command on
each line of output
<Ctrl> + C is quick way to break
into command and stop it from
executing
November 17, 2009 231
some find options
Ch 2 232
Finding Examples
Example:
find . -print
find
all files in the current directory (and all
subdirectories) & display the results
find . -name “*.c” -print
find all files in the current directory (and all
subdirectories) with the extension .c & display
the results
whereis command
locates/displays locations of a
program, source, and manual pages
for a specific command
Ch 2 237
whereis Command
whereis command
Faster than find command since
search path is built in
More specific than locate
command
Searching for files that are
programs
whereis
KEY CONCEPTS:
Most binary Command programs
located in the /usr/bin directory
Most documentation located in
/usr/share/man directory
Cannot execute a command unless it
is in your search path
Must have permission to execute a
command
File Compression
bunzip2
Used to uncompress file/files
Syntax: bunzip2 [options] [filenames . . .]
File Compression
zcat
Reads compressed files compressed
with gzip and writes them to
standard output
Identical to gunzip –c
KEY CONCEPTS:
file no longer exist in home directory with
original name
To see size of file when uncompressed pipe
output from zcat to wc command
File seen in red—compressed/archived file
Can see contents of .gz file (must be text
file) with zcat command
Archiving Tools
Tape archive (tar) utility: One of oldest and
most common backup utilities
Can create archive in a file on a filesystem or
directly on a device
Accepts options to determine location of archive
and action to perform on archive
Archiving Tools
tar:
Used for archiving file/files
Often compressed
Easier to back up, store, and transfer
Used to create single file that when
unpacked creates a directory structure
Software that has been processed by tar
and compressed by gzip usually has
extension .tar.gz, or tgz
Archiving Tools
Syntax:
tar [options] [tarfile] [other-
files]
.tar .tar.gz
sub-
directory
266
String Processing Tools
tail
tail command display last few line (default : 10 lines) of
text in a file
tail /etc/passwd
Use –n or --lines parameter to change number of line
displayed
tail –n 5 /etc/passwd
Use –f to follow the end of a text file as it changes
tail –f 5 make.out
Used to watch log files
267
String Processing Tools
wc
“word count” – also counts lines and characters
wc story.txt
39 237 1901 story.txt
Use –l for only line count
Use –w for only word count
Use –c for only character count
268
String Processing Tools
sort
Sort text to stout –original file unchanged
sort [option] file(s)
Common option:
-r Reverse sort to sort descending
-n Numeric sort
-f Ignore case of characters in strings
-u unique (remove duplicate lines in output)
-t ‘x’ Use x as field separator
-k pos1 sort from field pos1
269
String Processing Tools
sort
$ cat b
fish
dog
animal
bird
$ sort -r b
fish
dog
bird
animal
270
String Processing Tools
sort
Sort numeric file as text
$ cat c
5412 this line should go last
998 this line should go second
50 this line should go first
999 this line should go third
$ sort c
50 this line should go first
5412 this line should go last
998 this line should go second
999 this line should go third
271
String Processing Tools
sort
Sort numeric file as numbers
$ cat c
5412 this line should go last
998 this line should go second
50 this line should go first
999 this line should go third
$ sort -n c
50 this line should go first
998 this line should go second
999 this line should go third
5412 this line should go last
272
String Processing Tools
uniq
Remove successive, duplicate lines in a file
Can use in conjunction with sort to remove all
duplicated (or use sort –u)
Use –c to count number of occurrences of
duplicate data
273
String Processing Tools
uniq
Just sorted: sort | uniq:
274
String Processing Tools
cut
Display specific column of file data
cut –f4 result.dat
Common option:
-f Specifies field or column
-d Specifies field delimiter (default is TAB)
cut –f3 –d: /etc/passwd
-c Cuts by characters
cut –c2-5 /usr/share/dict/words
275
String Processing Tools
cut
Example – output second word on each
line:
Delimiter: space “ “
Fields: 2
$ cat a
the quick brown fox
jumped over a quick brown fox
$ cut -f 2 -d ' ' a
quick
over
276
String Processing Tools
cut
Example – output characters 1-3, 5, 7-end
$ cat a
the quick brown fox
jumped over a quick brown fox
$ cut -c 1-3,5,7- a
theqick brown fox
jume over a quick brown fox
278
String Processing Tools
paste
paste - merge line of files
Syntax:Paste file1 file2
279
Version Comparison with
diff
Compares two files for differences
diff area.c /tmp/area.c
33c33
< x = y + 2;
----
> x = y +4;
33c33 indicated line where files differ
< indicates line in first file
> indicates line in second file
280
Formatting a
Document with pr
pr utility program:
Converts text files into a paginated,
columned version
If no files specified, pr read standard
input
By default, pr formats files into single-
column pages of 66 lines
To print in formatted form—pipe
formatted document to lpr
Syntax: pr [options] [arguments]
Ch 7 281
Formatting a
Document with pr
282