Professional Documents
Culture Documents
Linux102 2
Linux102 2
Linux
Fang
(Cherry)
Liu,
PhD
Scien:c
Compu:ng
Consultant
PACE,
Gatech
fang.liu@oit.gatech.edu
Brief
review
Common
commands
in
Linux
cd,
ls,
le,
cat,
pwd,
mkdir,
mv,
cp,
nd,
grep,
tail,
head,
di,
scp,
chmod,
sort,
uniq
fang.liu@oit.gatech.edu
Outline
Environment
variables
and
PACE
modules
Regular
expressions
Advance
commands
grep,
tar,
cut,
awk,
tr,
sed,
ps
Bash
scrip:ng
Basic
building
blocks,
e.g.
for
loop,
if
statements
Example:
queue
usage
analysis
Build
packages
fang.liu@oit.gatech.edu
fang.liu@oit.gatech.edu
fang.liu@oit.gatech.edu
PACE
Modules
~/.pacemodules
setup
the
default
environment
for
user
Module
load/unload
<packages>
Module
purge
allows
the
user
to
clean
up
the
default
environment
fang.liu@oit.gatech.edu
Regular
Expressions
Meaning
Example
Th? Matches Th or T
()
Group characters
[]
(Mon)|(Tues)day
matches
Monday
or
Tuesday
{}
Beginning of a string
End of a string
fang.liu@oit.gatech.edu
Beginning
of
the
line
(^)
:
grep
^T
grep.txt
will
return
all
lines
star:ng
with
T
in
the
le.
fang.liu@oit.gatech.edu
Grep
(Cont.)
End
of
the
line
($)
:
grep
6$
grep.txt
will
return
all
lines
ending
with
6
in
the
le.
Empty
lines
(^$):
grep
c
^$
grep.txt
will
count
all
empty
lines
in
the
le
Escaping
the
special
character
(\)
:
grep
127\.0\.0\.1
dFile
will
return
the
line
matches
127.0.0.1
fang.liu@oit.gatech.edu
10
Grep
(Cont.)
Character
class
[0-9],
[a-z]
and
[A-Z],
grep
will
match
one
out
of
list
characters
in
the
bracket
fang.liu@oit.gatech.edu
11
Create
an
archive
tar
czf
home.tgz
home/
Extract
an
archive
tar
tzf
home.tgz
#
look
inside
the
archive
without
extrac:ng
(-tjf
home.tar.bz2)
tar
xzf
home.tgz
tar
xjf
home.tar.bz2
fang.liu@oit.gatech.edu
12
fang.liu@oit.gatech.edu
13
Cut
(Cont.)
Using
eld
delimiter
fang.liu@oit.gatech.edu
14
fang.liu@oit.gatech.edu
15
Awk
(Cont.)
Print
every
lines
:
awk
{print}
awk.txt
Print
all
columns
:
awk
{print
$0}
awk.txt
Print
all
columns
but
not
3rd
column
:
awk
{$3=;print
$0}
fang.liu@oit.gatech.edu
16
Awk
(Cont.)
Print
the
rst
column
:
awk
{print
$1}
awk.txt
Print
the
third
and
forth
column
:
awk
{print
$3,
$4
}
awk.txt
awk
{print
$3
$4}
awk.txt
fang.liu@oit.gatech.edu
17
Awk
(Cont.)
Print
the
lines
match
paver
a
:
awk
/a/
awk.txt
Print
the
lines
with
more
than
18
characters
:
awk
length($0)
>
18
awk.txt
fang.liu@oit.gatech.edu
18
fang.liu@oit.gatech.edu
19
Tr
(Cont.)
Convert
braces
in
a
le
with
parenthesis
tr
'{}'
'()'
<
inpuile
>
outpuile
fang.liu@oit.gatech.edu
20
21
Sed
(Cont.)
Replacing
or
subs:tu:ng
the
rst
old
string
to
new
in
each
line
of
sed.txt
:
sed
s/old/new/
test.txt
fang.liu@oit.gatech.edu
22
Sed
(Cont.)
Replacing
all
occurrence
of
the
pavern
in
a
line
:
sed
's/old/
new/g
sed.txt
Replacing
the
occurrence
on
the
third
line
:sed
5s/old/
new/
sed.txt
fang.liu@oit.gatech.edu
23
Sed
(Cont.)
Replace
old
string
to
new
string
for
all
occurrence,
and
print
out
the
line
if
there
is
subs:tu:on
happened,
output
the
changed
lines
to
a
new
le.
fang.liu@oit.gatech.edu
24
25
26
fang.liu@oit.gatech.edu
27
fang.liu@oit.gatech.edu
28
fang.liu@oit.gatech.edu
29
fang.liu@oit.gatech.edu
30
31
32
Modify Makele
MKLDIR=${MKLROOT}
ACML4DIR=${ACMLROOT}
ACML5DIR=${ACMLROOT}
make
poit_mpi_evo_apot_terso_stress_fweight
fang.liu@oit.gatech.edu
33
34
35
36