Unit 3:Exploring interfaces and filesystems - PowerPoint PPT Presentation

Loading...

PPT – Unit 3:Exploring interfaces and filesystems PowerPoint presentation | free to download - id: 55caed-Yzg2M



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Unit 3:Exploring interfaces and filesystems

Description:

... Basic shell commands Basic ... name from the pg command once used on UNIX system less command ... reverse of normal command Find lines that don t ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 76
Provided by: vee08
Learn more at: http://technologyproservices.com
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Unit 3:Exploring interfaces and filesystems


1
Unit 3Exploring interfaces and filesystems
  • Unit objectives
  • Outline structure of the Linux interface, and
    roles of the kernel, terminal and shell
  • Enter shell commands, find documentation, use
    metacharacters, shut down system
  • Learn directory structure, file types, and use
    wildcards
  • Display contents of text and binary files
  • Search text files by using grep, identify common
    text editors, and use the vi editor

2
Topic A Linux interfaces
3
Shells, terminals, and the kernel
  • Kernel
  • The core component of the OS
  • An actual file on the HD
  • Need an interface to interact with kernel
  • Terminal
  • Screen that allows you to log in
  • Shell
  • Runs within the terminal
  • Interface that accepts commands and passes them
    to the kernel
  • BASH Shell (Bourne Again Shell) the default shell

4
Shells, terminals, and the kernel, continued
5
Shells, terminals, and the kernel
  • One kernel
  • Multiple shells and terminal sessions can be
    going at once
  • Terminals can be run locally or remote across
    network
  • Text only commands
  • Can run the system
  • Graphical mode
  • User friendly

6
Shell Prompts and Guis
  • Shell Prompts
  • As root
  • root_at_localhost root
  • As a regular user
  • root_at_localhost user1
  • GUI
  • Loaded based on installation and preferences

7
GNOME
8
KDE
9
Topic B Basic shell commands
10
Basic Shell Commands
  • Commands
  • Indicate name of the program to execute
  • Options
  • Letters starting with a dash - that alter way
    the command works
  • Arguments
  • Specify the parameters the command works upon

11
Some common Linux commands
12
Command Examples
  • Last login Tue Feb 13 224326 2007 from
    192.168.1.4
  • epapates_at_localhost finger
  • Login Name Tty Idle Login
    Time Office Office Phone
  • epapates Elias Papatestas pts/1 21 Feb
    13 2039 (192.168.1.3)
  • epapates Elias Papatestas pts/2 1 Feb
    13 2246 (0.0)
  • epapates Elias Papatestas pts/3 Feb
    13 2248 (192.168.1.4)
  • epapates_at_localhost who
  • epapates pts/1 2007-02-13 2039
    (192.168.1.3)
  • epapates pts/2 2007-02-13 2246 (0.0)
  • epapates pts/3 2007-02-13 2248
    (192.168.1.4)

13
Command Examples
  • epapates_at_localhost w
  • 224834 up 253, 3 users, load average
    0.64, 0.42, 0.44
  • USER TTY FROM LOGIN_at_ IDLE
    JCPU PCPU WHAT
  • epapates pts/1 192.168.1.3 2039 2141
    101 1.08s sshd epapates
  • epapates pts/2 0.0 2246 122
    1.07s 5.30s gnome-terminal
  • epapates pts/3 192.168.1.4 2248 1.00s
    0.98s 0.31s w
  • epapates_at_localhost whoami
  • epapates
  • epapates_at_localhost id
  • uid500(epapates) gid500(epapates)
    groups500(epapates) contextuser_usystem_runcon
    fined_t
  • epapates_at_localhost

14
Shell metacharacters
  • Key combinations that have special meaning in the
    Linux OS
  • character
  • Tells shell that following text refers to a
    variable
  • Variable
  • Information stored in memory
  • Many pre-defined

15
Using variables
  • epapates_at_localhost echo Hi There!
  • Hi There!
  • epapates_at_localhost echo My shell is SHELL
  • My shell is /bin/bash
  • epapates_at_localhost

16
Common BASH shell metacharacters
17
Using Metacharacters
  • If you need to use a metacharacter, place it in
    quotes
  • Echo I need 2.00
  • epapates_at_localhost echo I need 2.00
  • I need .00
  • epapates_at_localhost echo I need ''2.00
  • I need 2.00
  • epapates_at_localhost

18
Activity B-1
  • Page 3-8, 3-9
  • Examples of basic commands
  • Examples of metacharacters

19
Getting command help
  • Manual pages
  • Commonly referred to as man pages
  • Documents the commands function and the syntax
    it accepts
  • Usage
  • man whoami
  • Multiple levels
  • Depending on what type of command

20
Manual page section numbers
21
Getting command help
  • Multiple Names
  • Lowest page appears
  • Searching Man pages
  • Man k command/apropos command
  • man k who
  • apropos who

22
Getting command help
  • Info pages
  • Less techie
  • Usage
  • info who
  • Help command
  • Used for commands that may not have info or man
    pages
  • Usage
  • help echo

23
System Shutdown
  • System writes data from memory to HD
  • If shutdown happens while system is writing, it
    can corrupt data
  • Use shutdown commands to shut down gracefully
  • Tell everyone to please log off
  • Can cancel with CTRL-c or shutdown -c
  • Usage
  • -h halt
  • -r reboot
  • 15 time

24
Topic C Files and directories
25
The Linux directory structure
26
The Linux directory structure
  • Start at root directory
  • Directory structure doesnt usually show
    partition mount points
  • Directory
  • Special file used to organize other files into a
    logical structure
  • Absolute pathname
  • Full pathname to a certain file or directory
    starting from the root directory

27
Paths
  • Route to location of file or directory
  • Absolute pathname
  • Full pathname to a certain file or directory
    starting from the root directory

28
Mounting Filesystems
  • Directories can be in same partition or different
  • Can make a partition part of the directory
    structure with the mount command
  • Mount the hda2 to appear as the home directory

29
Home directory
  • Home directory
  • A directory for users to store personal files and
    information
  • Each user has a sub-directory
  • Located at /home/username

30
Navigating Filesystem
  • pwd (print working directory)
  • Used to identify the current directory path
  • cd (change directory)
  • Used to move from one directory to another

31
The metacharacter and relative paths
  • Refers to the current users home directory
  • Can specify another users home directory by
    adding the username after
  • Relative pathname
  • Pathname of a target directory relative to your
    current location in the tree

32
Tab-completion
  • Tab-completion
  • Fills in the remaining characters of a unique
    filename or directory name when you press the Tab
    key
  • If more than one match, system will beep

33
File types
  • Text files
  • Binary data files
  • Executable program files
  • Directory files
  • Linked files
  • Special device files
  • Named pipes and socket files

34
Filenames
  • Filename
  • User-friendly identifier given to a file
  • Filename suffixes
  • Identifiers following a dot (.) at the end of a
    filename
  • used to denote the type of the file

35
(No Transcript)
36
The ls command
  • Used to list the files in a directory
  • Most common method for displaying files
  • Displays all the files in the current directory
  • You can use an argument with ls to list a
    directory different from current one

37
Ls F file type characters
  • _at_ Linked file
  • Executable file
  • / Subdirectory
  • Socket file
  • Named pipe

38
Ls l file details
  • File type
  • Permission list
  • Important
  • Link count
  • Owner
  • Group
  • Size
  • Modified date
  • filename

39
Ls l file details
  • File type Permissions Links Owner Group Size
    Modified date filename

total 143860 -r--r--r-- 1 epapates epapates
35618816 Nov 13 1606 linux.iso -r-xr-xr-x 1
epapates epapates 111527809 Feb 14 0256
VMware-workstation-5.5.3-34685.tar.gz
40
The file command
  • File command
  • Displays detailed information about any file
  • Works with multiple files
  • Uses to include all files in a directory

41
Hidden files
  • Hidden files
  • Files that are not normally displayed with common
    filesystem commands
  • represent important configuration files or
    program directories
  • View with a option from ls command

42
ls command options
continued
43
ls command options, continued
44
Wildcard metacharacters
  • Can simplify more than one filename to a command
  • Interpreted by the shell and can be used with
    most filesystem commands
  • Matches certain portions of filenames or an
    entire filename

continued
45
Wildcard metacharacters, continued
46
Activity C 2 and 3
  • Examining files and file types
  • Using wildcard metacharacters

47
Any Questions?
48
Topic D Displaying the contents of files
49
Displaying content of text files
  • cat command
  • Display the entire contents of a text file to the
    screen
  • tac command
  • Displays a file to the screen beginning with the
    last line of the file and ending with the first
    line of the file
  • head command
  • Displays the first 10 lines (including blank
    lines) of a text file to the terminal screen
  • Can also take a numeric option specifying a
    different number of lines to display

continued
50
Displaying content of text files, continued
  • tail command
  • By default, displays the last 10 lines (including
    blank lines) of a text file to the terminal
    screen
  • Can also take a numeric option specifying a
    different number of lines to display

51
Tail Command Options
  • -f, --follownamedescriptor
  • output appended data as the file grows -f,
    --follow, and --followdescriptor are equivalent
  • -n, --linesN output the last N lines, instead of
    the last 10
  • -s, --sleep-intervalS
  • with -f, sleep for approximately S seconds
    (default 1.0) between iterations.

52
Other text file viewing commands
  • more command
  • Displays a text file page-by-page and
    line-by-line
  • Gets its name from the pg command once used on
    UNIX system
  • less command
  • Displays a text file page-by-page
  • Use the cursor keys to navigate the file

53
Displaying the contents of binary files
  • strings commands
  • Linux command used to search for and display text
    characters in a binary file
  • od command
  • Linux command that is used to display the
    contents of a file in octal format (numeric base
    8 format)
  • Safe to use on binary files and text files

54
Topic E Searching and editing text files
55
Searching for text within files
  • Regular expressions (regexp)
  • Special metacharacters used to match patterns of
    text within text files
  • Commonly used by many text tool commands such as
    grep

56
Searching for text within files
  • Grep
  • Awk
  • Sed
  • Vi
  • Emacs
  • Ex
  • Ed
  • PERL

57
Regular expressions and wildcards
  • Regular expressions are interpreted by a text
    tool program, wildcard metacharacters are
    interpreted by the shell,
  • Regular expressions match characters within text
    files, wildcard metacharacters match characters
    in filenames or directory names

continued
58
Regular expressions and wildcards, continued
  • Wildcard metacharacters regular expressions
    usually have different definitions than wildcard
    metacharacters
  • More metacharacters are available for regular
    expressions
  • Regular expressions are divided into two
    different categories
  • Common
  • extended

continued
59
(No Transcript)
60
The grep command
  • Grep
  • Displays lines in a text file that match a common
    regular expression
  • Egrep
  • Displays text that match extended regular
    expressions
  • Fgrep
  • Does not interpret regular expressions
  • Returns results faster than the egrep command

61
The grep command
  • Options
  • -v reverse of normal command
  • Find lines that dont contain expression
  • -I case sensitive
  • Example
  • grep t.e Highland_Inn
  • epapates_at_localhost Unit_03 grep "t.e"
    Highland_Inn
  • Hi there, I hope you are well.
  • to see the model of the Highland Inn, and the
    train
  • I've been reading the history of Algonquin Park,
    but
  • couldn't find a description of where the Highland

62
The vi editor
  • One of the oldest and most popular text editors
    available for Linux and UNIX operating systems
  • vim an improved version for Linux
  • Not easy, but portable
  • The vi editor is called bi-modal as it functions
    in two modes
  • Command mode
  • Perform editing tasks not related to inserting
    text
  • Insert mode
  • Allows inserting text into the document

63
Entering insert mode using keyboard keys
64
Key combinations
continued
65
Key combinations, continued
continued
66
Key combinations, continued
67
Key combinations used at prompt
68
Vi hints
  • i enters insert mode
  • ESC returns to command mode
  • tells system to get ready for commands
  • Watch bottom of screen
  • s/findword/replaceword/g
  • Search and replace globally
  • G
  • Go to a line 25G goes to 25th line

69
Other common text editors
  • Pico (PIne COmposer) editor
  • Mcedit editor (Midnight Commander Editor)
  • Emacs (Editor MAcroS) editor
  • Xemacs editor

70
Activity E 1, 2, 3
  • Log in an try them

71
Emacs editor
  • Alternative to the vi editor that offers equal
    functionality
  • Not an easy-to-use editor as you must memorize
    several key combinations to work effectively

continued
72
Emacs editor, continued
73
Graphical text editors
  • nedit editor

74
Gedit editor
  • gedit editor
  • Text editor for the GNOME desktop

75
Unit summary
  • Explored the components of the user interface
  • Used the shell to execute commands and use shell
    metacharacters
  • Learned about filesystems and files, and used
    shell wildcards to specify multiple file names
  • Displayed the contents of text files and binary
    files
  • Searched text files for regular expressions by
    using grep, and identified common editors
  • Used the vi editor
About PowerShow.com