Title: The Linux
1Chapter 2
2Overview
-
- The purpose and function of files, directories,
and file systems will be discussed - Linux ext2 and ext3 native file systems will be
compared and contrasted
3Overview
-
- The hierarchical filing system of a
tree-structured directory will be explained - Will learn to read a syntax diagram
4Overview
- Run the terminal window in GNOME and navigate
within the terminal window using the absolute and
relative paths - Will mount and unmount file systems
5Overview
-
- Explain the function of and then use the cal,
date, pwd, cd, ls, find, history, locate, and
whereis commands - The purpose and function of arguments and
options will be explained and then used
6Overview
-
- Will explore file name expansions with those
commands that support the use of wildcards
(globbing) - Determine when redirection should be used and
then redirect output to a file and a device
7Understanding the Linux File System
- File
- Named and stored collection of related
information - Basic unit of storage
8Understanding the Linux File System
- Directory
- Way to organize programs/documents
- Hierarchical with system root at the top
- Path
- List of directories Linux follows to
locate/save/retrieve a file - Slashes in path act as delimiters
-
9Understanding the Linux File System
- File System
- Way any OS names/stores/organizes files on a
storage device - Consists of files/directories and information
needed to locate/access those objects
10Understanding the Linux File System
- Linux file system ext2 similar to ext3
- Major difference is that ext3 is a journaling
file system - Meta data is data about data
-
-
11Understanding the Linux File System
- Foreign file systems that Linux supports
- MSDOS
- UMSDOS
- VFAT
- NTFS
- NFT and SMB
-
12Understanding the Linux File System
- Linux file system (ext2 or ext3) is a secure
operating system
13Understanding the Linux File System
- Under ext2 or ext3 a file is owned by the person
who created it - Categories of file owners
- User
- Group
- Other
14Understanding the Linux File System
- Types of permissions to be granted
- Read
- Write
- Execute
- Executable programs have additional permissions
- set userid (UID)
- set group userid (GUID)
15Activity Looking at the File System
- KEY CONCEPTS
- Tree-hierarchical view of computers
directories - Hidden files in Linux begin with a dot
- Significance of right/downward pointing arrows
- Use of navigation icons and back/forward buttons
- Function of home, working/current directory
- Parent directorycontains other directories
- Bluecurve theme used with GNOME desktop
- Function of FHS (File System Hierarchy
Standard)
16Activity Looking at the File SystemTable 2.1
Common Linux Directories pp. 70-71
17Activity Looking at the File SystemTable 2.1
Common Linux Directories pp. 70-71
18Activity Looking at the File SystemTable 2.1
Common Linux Directories pp. 70-71
19Introducing the Bash Shell
- Shell
- Used to access command line
- Program that interprets keyed in commands
- Buffer between user and OS
20Introducing the Bash Shell
- Reasons for using the shell
- Interactive use
- Customizing of Linux session
- Programming
21Introducing the Bash Shell
- Using the shell interactively
- Shell processes and executes commands as they
are keyed in - Has built-ins
- Can use a shell script
22Introducing the Bash Shell
- Once in GNOMEcan access character with a
terminal emulation program (terminal) - If GNOME (startx) never starts, then you are at
command line and in Bash shell
23Command Syntax
- Syntax is the word order and punctuation of a
language - Command syntax is order for keying in computer
commands
24Command Syntax
- There are still syntax and rules when using a
graphical user interface such as GNOME
25What Are Options and Arguments?
- Option
- Modifies or qualifies a command
- Follows command name separated by a space
- Space is a delimiter
- Begins with a hyphen
- Case sensitive
26What Are Options and Arguments?
- Argument
- File or directory name
- Follows command options separated by a space
27What Are Options and Arguments?
- Delimiter
- Character identifies beginning or end of
character string - Not part of character string
- In command syntax, space, backslash, forward
slash are often delimitersdepends on rules of
command language - Program interprets character string and knows
what delimiters are
28What Are Options and Arguments?
- Can combine options and arguments
- ls -a /bin
- ls -A .
- ls -A . .
29Reading a Syntax Diagram
- Requirements of command line interface language
- Vocabularycommands
- Grammarpunctuation
- Syntaxorder
30Reading a Syntax Diagram
- Syntax information provided through online help
- man command name
- commandname --help
31Reading a Syntax Diagram
- Syntax for Is command
- ls OPTIONS. . .FILE. . .
32Introducing Commands and the Terminal Window
- To use Linux text commands
- Not have started GNOME
- Opened a terminal window in GNOME
- Know what command to use
- Know allowable options and arguments
33Activity Looking at the Shell
- KEY CONCEPTS
- How to access terminal window
- Function of profile
- Running terminal window in GNOME is the same as
running the shell program - Function and features of the shell
- Function of chsh -1 command
- Examples of popular shells i.e., sh, csh, tsch,
and ash
34Activity Looking at the ShellFigure 2.1 Command
Prompt p. 78
35Navigating in the Shell
- In GNOME, Nautilus is file manager used to locate
and manage files and directories
36Activity Navigating the Shell
- KEY CONCEPTS
- Linux prompt shows current current/working
directory, not entire path - Compare/contrast absolute/relative path
- Directory only knows its child directories and
its parent directory - Functions of pwd, cd, ls, and cal commands
- Use editing keys to alter command line
37Activity Navigating the ShellTable 2.2 Common
Editing Keys p. 81
38Activity Navigating the ShellTable 2.2 Common
Editing Keys p. 81
39Activity Navigating the Shell
- Syntax of the cal command
- cal -mjy13 month year
40The date and cal commands
- Date and cal commands
- OS keeps track of current date/time
- Date/time indicates system date/time
- System administrator usually maintains/alters
date/time - Way system date/time displayed can be altered
- Command is date
41The date and cal commands
- Cal command
- Displays calendar
- Syntax is cal -mjy13 month year
- No optionsdisplays current month and year
42The date and cal commandsTable 2.3 cal Options
p. 83
43Activity Using the date and cal Commands
- Key Concepts
- Display current date
- Display calendar for current month
- Can key in multiple commands on one command line
if each command is separated by semicolon
44Mounting File Systems
- File system
- Device formatted to allow the storing and
retrieval of files - Organized in a hierarchy
45Mounting File Systems
- Partitions
- Logical portion of disk
- Part of installation process
- May have its own file system
- Treated by Linux as if they were separate
physical entities - Partition labeled /dev/hda3 dedicated to Linux
swap file
46Mounting File Systems
- To access files on device (partition or file
system) must mount device - In Linux/Unix all files arranged in single tree
which begins with root directory
47Mounting File Systems
- In DOS/Windows world devices are mounted
automatically and process is more transparent - In Unix/Linux world instead of drive letter,
device is mounted at a mount point
48Mounting File SystemsFigure 2.2 The fdisk
Command p.86
49Mounting File Systems
- Mounting
- Checks a devices status
- Readies it for access
- Mount Point
- Directory in file system that device is mounted
from - Hard drivesmounted automatically
- Removable drivesmounted each time used
50Mounting File Systems
- Mount Point
- Only root user (system administrator) can
establish mount point - Once set up root user can allow other users to
mount/unmount device - To mount/unmount removable devices root must in
/etc/fstab file include correct user options -
51Mounting File Systems
- Cannot insert or remove removable media without
using mount and umount commands. - Syntax
- mount -t type device mount-point
52Mounting File Systems
- Any user can mount specified device (/dev/fd0) at
mount point (/mnt/floppy) by using mount
/mnt/floppy command if there is a line in fstab
file that reads - /dev /fd0 /mnt/floppy auto noauto,owner, kudzu
53Mounting File Systems
- Syntax for umount command is
- umount dir device
54Activity Mounting and Unmounting File Systems
- KEY CONCEPTS
- Mount and unmount a device
- Determine what removable devices are mounted
(options available) or need to be mounted - Shell scripts are text files and act as
executable programs - mtab file lists all file systems currently
mounted and options they are mounted with
55Filename Expansions
- To locate a group of files key in abbreviated
file names containing metacharacters
56Filename Expansions
- Wildcards (globbing) allow user to operate on a
group of files rather than a single file - ?substitutes for a single character
- substitutes for a group or string of
characters - allows shell to match individual characters
within the brackets
57Filename Expansions
- Ambiguous file references are file names that
contain special characters i.e., wildcards,
globbing
58Activity Filename Expansion
- KEY CONCEPTS
- Determine which version of a program you are
using in a GUI - Find utility not available in GUI when using Red
Hat Linux 9 Nautilus 2.2.1 - Move around window using key strokes and scroll
bar - Easier to use command line to locate file(s) or
directory/directories when exact name not known - Used , ?, and to locate files/directories
59The ls Command
- Key in ls
- Lists files and sorts them based on value of the
characters - Numbers/Symbols before letters
- Uppercase letter before lowercase letters
60The ls CommandTable 2.4 Options Used with ls
p.101
Option Name Purpose -1 Lists Lists files
in a single column Note that the option is
the number 1, not the lower case l. -C
Columns Lists files in columns vertically -F
Flags Lists files and directories with
visual clues to items are in a
directory some classify flags include
the following / Directories
Executable files _at_ Symbolic links
61The ls CommandTable 2.4 Options Used with ls
p.101 - Continued
Option Name Purpose -R Recursive Lists
recursively so that it will list the
directories and files in the subdirectories
of the current directory -S Size Lists
files by size, from largest to the
smallest -X Extension Lists in order by
extension files with no extensions appear
first -a All Lists all the files in the current
or specified directory, including any
hidden files or directories
62The ls CommandTable 2.4 Options Used with ls
p.101 - Continued
Option Name Purpose -d Directory Lists
directory name, not the names contents
of the directory -k Kilobytes Lists files
sizes in kilobytes Combined with -s option
(-sk) -l Long Provides long format
Includes file details size, date/time,
owner, and permissions -m
Commas Lists file names separated by commas
63The ls CommandTable 2.54 Options Used with ls
p.101 continued
Option Name Purpose -r Reverse Lists files in
reverse name order When combined with
-t, lists in reverse time order -s Size List
s size of files in blocks -t Time Lists files
by last time created or modified Most recent
files listed first -x Horizontally Lists
files horizontally in rows
64Activity Using Options with the ls Command
- KEY CONCEPTS
- Use options with the ls command to display files
in various ways - Terms recursively, links
- Function of hyphen in a permission slot
- Directories indicated name followed by /
- Files indicated by
65Activity Using Options with the Is
CommandFigure 2.3 Long Listing p. 103
66The locate Command
- locate command
- Fastest way to search for file/s in entire
directory tree - locate looks in pre-defined database
67Activity The locate Command
- KEY CONCEPTS
- ltCtrlgt C is quick way to break into command
and stop it from executing - Wildcards can be used with locate command
- If database not updated cannot locate files even
if files are in system
68The find Command
- find command
- Locates specific file or group of files
- Does not rely on a database
- Searches directory tree for files meeting
criteria specified - Searches recursively
- Wildcards can be used in filename statement
69The find Command
- find syntax
- find pathname -name filename
70The find CommandTable 2.5 find Options p. 108
71Activity The find Command
- KEY CONCEPTS
- Directories / follows their name
- Files indicated by
- ls command
- Used to place options after arguments
- Only lists files
- Most commands require options precede arguments
- If path name not specified find only looks in
default (home) directory
72Activity The find Command
- KEY CONCEPTS
- Wildcards can be used with find commands
- . (dot) in front of directory/file name
indicates that it is hidden - To see hidden directories and files use the -a
(all) with ls - If Permission denied appears many times, use
redirection to filter out these messages
73Redirection
- Redirection
- Only works with commands that get input from
standard input device and write to standard
output device - Tells OS to write information to file/device
instead of to screen. - Works with ls and find commands
74Redirection
- Redirection Syntax
- command gt destination
75Redirection
- Can redirect standard error to a device called
/dev/null - Example Redirecting error message in find
command - find / -iname gedit 2gt/dev/null
76Activity Redirecting Output to a File and a
Device
- KEY CONCEPTS
- Displayed contents of created file
- Used ls command to redirect output to a file and
to a null device - cat command analogous to type command in DOS
77 The whereis Command
- ls, locate, and find commands used to locate
files of interest - whereis command locates/displays locations of a
program, source, and manual pages for a specific
command
78 The whereis Command
- whereis command
- Determines directory path of programs or their
source files - Uses search path to locate list of directories
-
79 The 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
80Activity Using the whereis Command
- KEY CONCEPTS
- Most binary 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