Вы находитесь на странице: 1из 76

Module 05

GNU and Unix Commands


n
C

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Objectives
Work on the Command Line

The Interactive Shell


Command History and Editing
Manpages
Process Text Streams Using Filters
Perform Basic File Management
Filesystem Objects
File-Naming Wildcards (File
Globbing)
Use Streams, Pipes, and Redirects
Standard I/O and Default File
Descriptors
Pipes
Redirection
Using the tee Command
The xargs Command

Create, Monitor, and Kill Processes


Processes
Process Monitoring
Signaling Active Processes
Terminating Processes
Shell Job Control
Modify Process Execution Priorities
Search Text Files Using Regular
Expressions
Regular Expression Syntax
Using grep
Using sed
Examples
Perform Basic File Editing Operations
Using vi
Invoking vi
vi Basics

Work on the Command Line

For Linux system administration, a text interface is typically


used, called the command line
It is the job of a program called a shell to providen the
o
command prompt and to interpret commands ati
c
i
f
The shell provides an interface layer between
m
i thecoLinux
t
r d.
e
kernel and the end user
C aca
x bk
u
.
n
w
i
L ww

I
P
L

//
:
tp
t
h

Work on the Command Line

The Interactive Shell


The shell is a powerful programming environment, capable of
automating nearly anything you can imagine on your Linux system
nwithin a
o
Shells can run standalone, as on a physical terminal, or
i
t
a
window in a GUI environment
c
i

Shell variable basics

i f com
t
r d.
e
a
C

PS1
c
a
x
kcommand prompt
u
b
o This special variable holds the contents
of
the
.
n
w
i
that are displayed when bash is ready
to w
accept commands
L
I
/w
/
:
o Display the contents of PS1: P
L http

Work on the Command Line

Entering commands at the command prompt


Consist of four components:
o A valid command
n
o
o Command options, usually preceded by a dash (-)ti
a
c
o Arguments
i
f
m
i
o
t
c
o Line acceptance (i.e., pressing the Enter key)
e r d.

I
P
L

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

Work on the Command Line

Entering multiple-line commands interactively


Looping constructs, including for, until, and while, are often used
this way.
n
o
Exp: if you wanted to repetitively execute a series of commands
i
t
a you could
each time with a different argument from a known iseries,
c
enter the following:
om
tif

r
e
C

I
P
L

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

c
.
d

Work on the Command Line

Entering command sequences


There may be times when it is convenient to place multiple
commands on a single line

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Work on the Command Line

Command History and Editing


The history list is controlled by the HISTSIZE shell variable
By default, HISTSIZE is set to 1,000 lines, but you can control that
n
o
number by simply adjusting HISTSIZEs value
i
t
a
history command
c
i

i f com
t
r d.
e
a
C

Command substitution

c
This feature allows you to replace the result
of a command
with a
a
x
k
script
.b
nu
w
i
w
L
I
/w
/
:
L P t tp
h

Work on the Command Line

Man pages
Although the books were convenient, many users didnt always
want to dig through printed documentation or carry it around
n on the
o
The man (manual) command was created to put the books
i
t
a
system, giving users immediate access to the information
they
c
i
i f com
needed
t
r d.
e
There is a manpage for most commands on your
a
C system

I
P
L

c
a
x
k
u
b
.
n
i
ww
L
w

//
:
tp
t
h

Work on the Command Line


Man pages

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


Cat command:
Concatenate files and print on the standard output

Cut command:

i
t
er

n
o
i
t
a
c
fi
d

.c o

a one or more
Cut out (that is, print) selected columns or fields
C from
c
a
x
k
files
u
b
.
n
w
i
The source file is not changed
w
L
I
/w
/
:
LP http

Process Text Streams Using Filters


expand command:
Convert Tabs to spaces.
This command eliminates Tabs and replaces them with the
equivalent number of spaces.
By default, Tabs are assumed to be eight spaces apart n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


fmt command:
It breaks long lines and joins short lines as required, but doesn't
remove empty lines.
Set line width. The default is 75 characters

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


head command:
Print the first few lines of one or more files
When more than one file is specified, a header is printed at the
beginning of each file

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


join command:
join two files based on a common field
-1 N : Nth field in 1st file
-2 N : Nth field in 2nd file

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


nl command:
Number the lines of files

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


od command:
This program prints a listing of a files contents in a variety of
formats

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


paste command:
Paste together corresponding lines of one or more files into vertical
columns.
Similar in function to the join command, but simpler in scope.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


pr command:
Convert a text file into a paginated, columnar version, with headers
and page fills
The header will consist of the date and time, the filename, and a
page number.
n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


sort command:
Write input to stdout (standard out), sorted alphabetically

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


split command:
Split infile into a specified number of line groups, with output going
into a succession of files, outfileaa, outfileab, and so on

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


tac command:
This command is named as an opposite for the cat command

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


tail command:
Print the last few lines of one or more files
The default is 10 last lines printed

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


tr command:
Translate characters.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters


unexpand command:
Convert spaces to Tabs.
This command performs the opposite action of expand command

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters

uniq command:
Writes input (or stdin) to output (or stdout), eliminating duplicate
lines.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Process Text Streams Using Filters

wc command:
Print counts of characters, words, and lines for files

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


Directories and files
A directory is a container intended to hold objects such as files and
other directories.
A directorys purpose is primarily for organization
A file exists within the directory, and its purpose is to store
n raw
o
i
t
data.
a
c
At the top of all Linux filesystem hierarchies is a directory
it fi comdepicted
simply by /; this is known as the root directoryer
d.

I
P
L

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

Perform Basic File Management


Inodes
Inodes carry information about objects, such as where they are located
on disk, their modification time, security settings, and so forth

File and directory management commands

bzip2
cp
cpio
dd
file
find
gzip and gunzip
mkdir
mv
rm
rmdir
touch

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
cp
o Used to Copy

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
cpio
o cpio is used to create and extract archives, or copy files from
one place to another.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
cpio

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
dd
o dd converts and copies files
o This is especially useful when performing backups of block
devices, such as hard drive partitions, CD-ROMs, or nfloppy
io
t
disks
a

I
P
L

c
i
f
m
i
o
t
c
e r d.

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

Perform Basic File Management


File and directory management commands
dd

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
file
o file is designed to determine the kind of file being queried
o Linux (and other Unix-likesystems) dont require filename
extensions to determine the type of a file
n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
find
o find searches recursively through directory trees for files or
directories that match certain characteristics

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
gzip and gunzip
o Compress or uncompress files
o gzip is one of the most common compression formats found on
Linux systems, although it is starting to be replaced by
n the more
o
i
t
efficient bzip2
a
c
o Files compressed with gzip usually have the extension
m .gz
ifi

I
P
L

t
r
e

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

co
.
d

Perform Basic File Management


File and directory management commands
gzip and gunzip

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
mkdir
o Create one or more directories
o You must have write permission in the directory where
directories are to be created
n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
mkdir

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
mv
o Move or rename files and directories

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
rm
o Delete one or more files from the filesystem
o The rm command also removes directories when the -d, -r, or
-R option is used.
n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
rmdir
o Delete directories, which must be empty.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File and directory management commands
touch
o Change the access and/or modification times of files

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File-Naming Wildcards (File Globbing)

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Management


File-Naming Wildcards (File Globbing)

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Use Streams, Pipes, and Redirects

Among the many beauties of Linux and Unix systems is the


notion that everything is a file
Things such as disk drives and their partitions, tape
drives,
n
io are
t
terminals, serial ports, the mouse, and even audio
a
c
mapped into the filesystem.
it fi com
rwith many
.
e
This mapping allows programs to interact
d
C aca
different devices and files in the sameuxway k
b
.
n
Li www

I
P
L

//
:
tp
t
h

Use Streams, Pipes, and Redirects

Standard I/O and Default File Descriptors


a file descriptor is an abstract indicator for accessing a file

i
t
er

n
o
i
t
a
c
fi
d
a
c

.c o

a
x
k
u
bprovided with three
.
n
When a program is launched, it is automatically
w
i
w
L
file descriptors
I
/w
/
:
LP http

Use Streams, Pipes, and Redirects

Pipes
From a programs point of
view there is no difference
between reading text data
from a file and reading it from
your keyboard.
Similarly, writing text to a file
and writing text to a display
are equivalent operation
As an extension of this idea, it
is also possible to tie the
output of one program to the
input of another that called
pipes (|)

Use Streams, Pipes, and Redirects

Redirection
Each pipe symbol in the
previous pipeline example
instructs the shell to feed
output from one command
into the input of another.
This action is a special form
of redirection, which allows
you to manage the origin of
input streams and the
destination of output
streams.

Create, Monitor, and Kill Processes

Process
The management and control of processes is also essential for
smooth system operation
nscript, that
o
Every program, whether its a command, application, or
i
t
a
runs on your system is a process
c
i
f
mfrom the
i
Your shell is a process, and every command yout execute
o
c
r d.
e
shell starts one or more processes of its ownC(referred
a to as child
c
x
processes).
ka

I
P
L

u
b
.
n
Li www
//
:
tp
t
h

Create, Monitor, and Kill Processes


Process
Attributes and concepts associated with these processes include:
o Lifetime: length of time it takes to execute (while it lives)
o Process ID (PID): Every process has a number assigned to it
when it starts
n
o
i and GID are
t
o User ID (UID) and Group ID (GID): processs UID
a
c
associated with the user who started the process
it fi com
r d.
o Parent process
e
C aca
o Parent process ID (PPID)
x bk
u
.
n list ofwvariables
o Environment: Each process holdsia
and their
L list /iswwknown as the
associated values. Collectively, Ithis
:/
p
environment of the process LP
t
ht
o Current working directory: The default directory associated
with each process

Create, Monitor, and Kill Processes


Process Monitoring
Monitoring these processes is done using three convenient utilities:
ps, pstree, and top.
ps command:
o This command generates a one-time snapshot of thencurrent
io
t
processes on standard output
a

I
P
L

c
i
f
m
i
o
t
c
e r d.

x bk
u
.
n
w
i
w
L
w

//
:
tp
t
h

a
c
a

Create, Monitor, and Kill Processes


Process Monitoring
pstree command:
o Displays a hierarchical list of processes in a tree format

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Create, Monitor, and Kill Processes


Process Monitoring
top command:
o The top command offers output similar to ps, but in a continuously
updated display
o This is useful for situations in which you need to watch the status of
one or more processes or to see how they are using your system.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Create, Monitor, and Kill Processes


Process Monitoring
free command:
o Display amount of free and used memory in the system.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Create, Monitor, and Kill Processes


Process Monitoring
uptime command:
o One-line display of the following information: the current time,
how long the system has been running, how many users are
currently logged on, and the system load averages for
the past
n
1, 5, and 15 minutes.
tio

i
t
er

a
c
fi

d
a
c

.c o

a
x
k
b
.
o Load average on a Linux system is nu
w
i
w
L
defined as the number of blocking processes
in the run queue
w
I
/
:/
averaged over a certain time period.
P
p
tt
L

A blocking process is a process that his waiting on a resource to


continue, usually the CPU, disk I/O, or network
This is usually indicative of a busy system

Create, Monitor, and Kill Processes

Signaling Active Processes


Each process running on your system listens for signals, simple
messages sent to the process either by the kernel or by a user
n
For example, if you are executing a program from theio
command
t
a
line that appears to hang, you may elect to type Ctrl-C
to abort the
c
i
if comsignal) to
program. This action actually sends an SIGINT (interrupt
t
e r ad .
the process, telling it to stop running.

I
P
L

c
a
x
k
u
b
.
n
i
ww
L
w

//
:
tp
t
h

Create, Monitor, and Kill Processes


Signaling Active Processes

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Create, Monitor, and Kill Processes


Signaling Active Processes
Kill process
o The command kill sends the specified signal to the specified
process or process group.
o If no signal is specified, the TERM signal is sent.
n

I
P
L

i
t
er

io
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Create, Monitor, and Kill Processes


Signaling Active Processes
Terminating Processes
o Occasionally, youll find a system showing symptoms of high
CPU load or one that runs out of memory for no obvious
reason. This often means an application has gone out
of control
n
io
on your system. You can use ps or top to identify processes
that
t
a
c for the
may be having a problem. Once you know the iPID
f
m
i the process
o
t
process, you can use the kill command to stop
c
r d.
e
nicely with SIGTERM (kill -15 PID), escalating
C athe
ca signal to
x bk terminates
higher strengths if necessary until the process
u
.
n child wprocesses.
o Killing a process will also kill all of its
i
For
w
L
example, killing a shell will kill allI the processes
initiated from
/w
/
:
that shell, including other shells.
LP http

Create, Monitor, and Kill Processes

Shell Job Control


When a process is put in the
background, you create a job
Each job is assigned a job
number, starting at 1 and
numbering sequentially
programs can be placed in the
back-ground by adding a &
character to the command
For example, if you start
firefox from the command line,
you dont want the shell to sit
and wait for it to terminate

Create, Monitor, and Kill Processes

Shell Job Control


bg command
o This command places the specified job in the back-ground
n
o Using this command on a job that is stopped will allowioit to run in
t
a
the background
c
i
f
m
i
fg command
o
t
c
r
.
e
d
o This command places the specified job in the foreground
C aca
x bk
jobs command
u
.
n
w
i
o List the active jobs
w
L

I
P
L

//
:
tp
t
h

Modify Process Execution Priorities

Part of Linuxs flexibility is to let users and administrators


prioritize process execution
This feature is handy when you have a high-load machine
n
o
i rights
t
and want to make sure special processes get more
a
c
to use system resources than others
it fi com
r by dexamining
.
e
The priority of a process can be determined
C aca
x frombk issuing either
the PRI column in the results produced
u
.
n
w
i
the top or ps -l commands
L ww

I
P
L

//
:
tp
t
h

Modify Process Execution Priorities


Nice
One of the parameters used by the kernel to assign process priority
is supplied by the user and is called a nice number
n
Nice numbers range from 20 to +19.
o
i
t
a
Any user can start a process with a positive nice number,
but only
c
i
m thus
if coand
the superuser (root) can lower a processs nice number
t
r d.
e
raise its priority.
C aca
The lower the nice number, the higher the x
upriority kto the CPU.

I
P
L

n
i
L

b
.
w
w
//w

:
tt p
The nice command works to change theh nice number for new
processes only at the time that theyre started. To modify a
running program, use the renice command.

Modify Process Execution Priorities

Renice
Alter the nicenumber to set the scheduling priority of one or more
running target processes
nPIDs.
o
By default, renice assumes that the targets are numeric
ti

I
P
L

i
t
er

a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Regular Expression Syntax

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Regular Expression Syntax

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Regular Expression Syntax

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Regular Expression Syntax

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Using grep

n
o
i to
Search files or standard input for lines containing a match
t
a
c
regular expression regex
i
f
m
i
o
t
For example, to find all lines in file1 that contain
either
Linux
or
c
r d.
e
linux, you could use grep like this:
C aca
x bk
u
.
n
w
i
w
L
w
I
//
:
P
L http

Search Text Files Using Regular Expressions


Using Anchors
Anchors are used to describe position information.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Using Groups and ranges
Characters can be placed into groups and ranges to make regular
expressions more efficient.

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Search Text Files Using Regular Expressions


Using Modifiers
Modifiers change the meaning of other characters in a regular
expression

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Perform Basic File Editing Operations Using vi

vi Basics
The vi editor has two modes of operation: command or insert
In command mode, vi allows you to navigate around your file and
n
o
enter commands
i
t
a
To enter new text,put vi into insert mode
c
i
f
i
om
t i .key
To switch from command to insert mode, pressrthe
c
e
d
a
To terminate insert mode, press the Escape C
key (Esc),
c which puts
a
you back in command mode
ux .bk

I
P
L

n
i
L

:
tt p
h

w
w
//w

Perform Basic File Editing Operations Using vi


vi Basics

I
P
L
<full key command: page 142>

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Вам также может понравиться