Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63656565
document.tex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 21, 16:03
Size
34 KB
Mime Type
text/x-tex
Expires
Thu, May 23, 16:03 (2 d)
Engine
blob
Format
Raw Data
Handle
17802166
Attached To
rSCCINTROLINUX Introduction to Linux
document.tex
View Options
\note
{
##Course duration
0.5 day
##Description
The goal of this course is to give the basis on the usage of a Linux system in
order for the user to be able to use the general purpose clusters, and to feel
at ease like a penguin in cold water.
##Contents:
- Overview of Linux
- Connecting to a remote machine (from Linux, Windows or Mac)
- Using a Linux/Unix system with only the command line
- Basics on file organization
- Common shell commands
- Writing a shell script
##Prerequisites:
Participants are asked to bring their laptop in order for the training to be
personalized to their specific environment.
}
\begin
{
frame
}
\begin
{
minipage
}{
0.3
\textwidth
}
\centering
\includegraphics
[width=3cm]
{
images/Tux
}
\end
{
minipage
}
\begin
{
minipage
}{
0.5
\textwidth
}
\titlepage
\centering
\url
{
https://c4science.ch/u/linux
}
\end
{
minipage
}
\end
{
frame
}
\section
{
Overview of Linux
}
\begin
{
frame
}{
What is Linux
}
\begin
{
minipage
}{
0.7
\linewidth
}
\begin
{
block
}{
Just for fun
}
\begin
{
itemize
}
\item
1991 Linus Torvalds starts Linux ``for fun''
\item
\emph
{
``I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones.''
}
\end
{
itemize
}
\end
{
block
}
\end
{
minipage
}
\hspace*
{
0.5ex
}
\begin
{
minipage
}{
0.25
\linewidth
}
\centering
\vspace*
{
1.2ex
}
\includegraphics
[clip=true, trim=0 50px 0 30px,width=\linewidth]
{
images/220px-Linus
_
Torvalds
}
\end
{
minipage
}
\begin
{
block
}{
What is a Linux distribution
}
\begin
{
itemize
}
\item
Linux Kernel + softwares
\item
Desktop distributions: windowing system (X11) + desktop manager
(GNOME, KDE), package manager, service manager
\item
Common distributions: Debian, Ubuntu, Redhat, Arch, ...
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
Where can you find Linux
}
\begin
{
minipage
}{
0.45
\linewidth
}
\begin
{
block
}{
Supercomputers
}
\centering
\includegraphics
[width=\linewidth]
{
images/top
_
500
_
nov2017
}
\end
{
block
}
\end
{
minipage
}
\hspace*
{
2ex
}
\begin
{
minipage
}{
0.45
\linewidth
}
\begin
{
block
}{
Smartphones
}
\centering
\includegraphics
[width=\linewidth]
{
images/smartphones
_
2017
}
\end
{
block
}
\end
{
minipage
}
\begin
{
block
}{
Other numbers
}
\begin
{
itemize
}
\item
Desktop: 3.37
\%
\item
Servers (web): 37
\%
\item
Servers (mainframe): 28
\%
\item
Embedded: 29.44
\%
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
\section
{
Login
}
\begin
{
frame
}{
Login
}
\begin
{
block
}{
First step: get a shell
}
\begin
{
itemize
}
\item
Shell: user interface to the operating system's services
\item
Start a shell on your local machine
\item
Connect to a remote machine to get a shell
\item
SSH: Secure SHell
\end
{
itemize
}
\end
{
block
}
\vspace
{
2ex
}
\begin
{
minipage
}{
.45
\linewidth
}
\begin
{
block
}{
Windows
}
\begin
{
itemize
}
\item
\href
{
https://git-scm.com/downloads
}{
Git Bash
}
\item
\href
{
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
}{
Putty
}
\item
\href
{
http://www.bitvise.com/download-area
}{
Tunnelier
}
\end
{
itemize
}
\end
{
block
}
\end
{
minipage
}
\hspace*
{
4.5ex
}
\begin
{
minipage
}{
.45
\linewidth
}
\begin
{
block
}{
Unix like
}
\begin
{
itemize
}
\item
Start a terminal
\end
{
itemize
}
\end
{
block
}
\end
{
minipage
}
\end
{
frame
}
\begin
{
frame
}{
Login: Windows
}
\begin
{
minipage
}{
.4
\linewidth
}
\begin
{
block
}{
Putty
}
\vspace*
{
3.5ex
}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/putty
}
\draw
[thick, red]
(1.54cm, 2.85cm) --
(1.54cm, 3cm) --
(3.3cm, 3cm) --
(3.3cm, 2.85cm) -- cycle;
\end
{
tikzonimage
}
\vspace*
{
3.5ex
}
\end
{
block
}
\end
{
minipage
}
\hspace*
{
2ex
}
\begin
{
minipage
}{
.5
\linewidth
}
\begin
{
block
}{
Tunnelier
}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/tunnelier
}
\draw
[thick, red]
(1.5cm, 4.15cm) --
(1.5cm, 4.3cm) --
(2.68cm, 4.3cm) --
(2.68cm, 4.15cm) -- cycle;
\draw
[thick, red]
(3.6cm, 4.15cm) --
(3.6cm, 4.3cm) --
(4.8cm, 4.3cm) --
(4.8cm, 4.15cm) -- cycle;
\end
{
tikzonimage
}
\end
{
block
}
\end
{
minipage
}
\begin
{
tikzpicture
}
[overlay, red]
\node
(hostname) at (5cm, 2.5cm)
{
\code
{
$
<
$
hostname
$
>
$
}}
;
\node
(username) at (8cm, 1.8cm)
{
\code
{
$
<
$
username
$
>
$
}}
;
\node
(host1) at (3cm, 3.7cm)
{}
;
\node
(host2) at (6.9cm, 4.43cm)
{}
;
\node
(user2) at (9.3cm, 4.43cm)
{}
;
\path
[-latex]
(hostname) edge [bend left] (host1);
\path
[-latex]
(hostname) edge [bend right] (host2);
\path
[-latex]
(username) edge [bend right] (user2);
\end
{
tikzpicture
}
\end
{
frame
}
\begin
{
frame
}{
Login: Mac OS
}
\begin
{
block
}{
Terminal
}
\centering
\begin
{
tikzonimage
}
[scale=.4]
{
images/macos
_
terminal
}
\draw
[thick, red]
(1.8cm, 4.4cm) --
(1.8cm, 4.65cm) --
(4.7cm, 4.65cm) --
(4.7cm, 4.4cm) -- cycle;
\node
(host) at (3cm, 4.55cm)
{}
;
\node
[red]
(hostname) at (3.5cm, 2.5cm)
{
\code
{
ssh -l
$
<
$
username
$
>
$
$
<
$
hostname
$
>
$
}}
;
\path
[-latex, thick, red]
(hostname) edge [bend left] (host);
\end
{
tikzonimage
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
Some usefull commands
}
\begin
{
block
}{}
\centering
\begin
{
tabular
}{
r|l
}
\code
{
ls
}
&
list files
\\
\code
{
cd
}
&
change directory
\\
\code
{
pwd
}
&
path of the current directory
\\
&
\\
\code
{
man
}
&
get help on commands
\\
\code
{
apropos
}
&
search for a command and print a brief description
\\
\code
{
echo
}
&
print the arguments in the terminal
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
First commands
}
\begin
{
extrainfos
}
List of usefull links:
\href
{
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
}{
Putty
}
\href
{
http://www.bitvise.com/download-area
}{
Tunnelier
}
\vspace
{
1ex
}
List of usefull commands:
\vspace
{
1ex
}
\begin
{
tabular
}{
r|l
}
\code
{
ls
}
&
list files
\\
\code
{
cd
}
&
change directory
\\
\code
{
pwd
}
&
path of the current
\\
\code
{
man
}
&
get help on commands
\\
\code
{
apropos
}
&
search for a command and print a brief description
\\
\code
{
echo
}
&
print the arguments in the terminal
\\
\end
{
tabular
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Connect to the remote machine
\code
{
fidis.epfl.ch
}
.
\item
Check your current folder and your files.
\item
Check the help of
\code
{
ls
}
(
\texttt
{
Q
}
to quit).
\end
{
questions
}
\begin
{
block
}
<2->
{}
\begin
{
command
}
> pwd
> ls
%
\end
{
command
}
\end
{
block
}
\begin
{
block
}
<3->
{}
\begin
{
command
}
> man ls
%
\end
{
command
}
\end
{
block
}
\end
{
exo
}
\section
{
File-system
}
\begin
{
frame
}{
File structure
}
\begin
{
block
}{
``On UNIX everything is a file''
}
\begin
{
tabular
}{
rl
}
\textbf
{
Directories
}
&
files that are lists of other files
\\
\textbf
{
Special files
}
&
files for input/output mechanisms
\\
\textbf
{
Links
}
&
way to make files visible in different parts
\\
&
of the file system
\\
\textbf
{
Sockets,
}
&
way to communicate between processes
\\
\textbf
{
named pipes
}
&
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
File structure
}
\begin
{
block
}{
Standard directories
}
\begin
{
tabular
}{
ll
}
\textbf
{
/etc
}
&
System configurations files
\\
\textbf
{
/boot
}
&
Boot files, kernel and boot loader
\\
\textbf
{
/home
}
&
User accounts
\\
\textbf
{
/usr
}
&
Software, libraries, documentations, for user programs
\\
\textbf
{
/var
}
&
Variables files such as log files, mail queues, databases
\\
\textbf
{
/opt
}
&
Third-party and extra softwares
\\
\end
{
tabular
}
\end
{
block
}
\begin
{
block
}{
Virtual directories
}
\begin
{
tabular
}{
ll
}
\textbf
{
/dev
}
&
Peripheral hardware related files
\\
\textbf
{
/proc
}
&
Informations about processes
\\
\textbf
{
/sys
}
&
Informations about the kernel
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
Tree view
}
\begin
{
block
}{}
\centering
\begin
{
tikzpicture
}
[every node/.style=draw=black,thick,anchor=west,text depth=.5ex,text height=2.2ex]
\node
{
/
}
child
{
node
{
etc/
}}
child
{
node
{
usr/
}
child
{
node
{
bin/
}}
child
{
node
{
lib/
}}
}
child [missing]
{}
child
{
node
{
home/
}
child
{
node (a)
{
user1/
}
child
{
node
{
Download/
}}
child [missing]
{}
child
{
node (b)
{
Desktop/
}}
}
child [missing]
{}
child
{
node
{
user2/
}}
}
;
\end
{
tikzpicture
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Directory structure
}
\begin
{
questions
}
\item
Show directory structure under the root folder
\item
Change directory to the root folder and list the content
\end
{
questions
}
\begin
{
block
}
<2->
{}
\begin
{
command
}
> ls /
%
\end
{
command
}
\end
{
block
}
\begin
{
block
}
<3->
{}
\begin
{
command
}
> cd /
> ls
%
\end
{
command
}
\end
{
block
}
\end
{
exo
}
\begin
{
frame
}{
Relative/absolute path
}
\newcommand*\redcolor
{}
\newcommand*\bluecolor
{}
\newcommand*\fillbluecolor
{
none
}
\only
<1-3>
{
\renewcommand*\redcolor
{
red
}}
\only
<4->
{
\renewcommand*\bluecolor
{
blue
}}
\only
<4->
{
\renewcommand*\fillbluecolor
{
blue!20
}}
\begin
{
block
}{}
\centering
\begin
{
tikzpicture
}
[every node/.style=draw=black,thick,anchor=west,text depth=.5ex,text height=2.2ex]
\node
[\bluecolor]
{
/
}
child
{
node
{
etc/
}}
child
{
node
{
usr/
}
child
{
node
{
bin/
}}
child
{
node
{
lib/
}}
}
child [missing]
{}
child
{
node[
\bluecolor
] (p)
{
home/
}
child [missing]
{}
child
{
node[
\bluecolor
,
\redcolor
,fill=
\fillbluecolor
] (n)
{
user1/
}
child
{
node
{
Download/
}}
child [missing]
{}
child
{
node[
\bluecolor
]
{
Desktop/
}}
child [missing]
{}
child
{
node[
\redcolor
] (dot)
{
.
}}
child
{
node[
\redcolor
] (ddot)
{
..
}}
}
child [missing]
{}
child [missing]
{}
child
{
node
{
user2/
}}
}
;
\path
[\redcolor, -latex, visible on=<2-3>]
(dot) edge [bend right] (n);
\path
[\redcolor, -latex, visible on=<3-3>]
(ddot) edge [bend right] (p);
\end
{
tikzpicture
}
\end
{
block
}
\begin
{
block
}
<4->
{}
\code
{
/home/user1/Desktop
}
\\
\code
{
./Desktop
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Relative/absolute path
}
\begin
{
questions
}
\item
Try the command
\code
{
ls -a
}
\item
List the parent folder of your home
\item
List the root folder with a relative path
\item
To what correspond the folder
\code
{
../././..
}
\end
{
questions
}
\vspace*
{
-.7ex
}
\begin
{
block
}
<2->
{}
\begin
{
command
}
> ls ../
%
\end
{
command
}
\end
{
block
}
\vspace*
{
-.7ex
}
\begin
{
block
}
<3->
{}
\begin
{
command
}
> ls ../../
%
\end
{
command
}
\end
{
block
}
\vspace*
{
-.7ex
}
\begin
{
block
}
<4->
{}
\begin
{
command
}
> cd ../././..
> pwd
%
\end
{
command
}
\end
{
block
}
\end
{
exo
}
\begin
{
frame
}{
File creation/suppression commands
}
\begin
{
block
}{}
\centering
\begin
{
tabular
}{
r|l
}
\code
{
cp
}
&
copy files
\\
\code
{
mv
}
&
move/rename files
\\
\code
{
rm
}
&
remove file
\color
{
red
}{
caution no trash
}
\\
\code
{
mkdir
}
&
create a folder
\\
\code
{
cat
}
&
print the content of file, used to concatenate
\\
\code
{
touch
}
&
update the date of a file, used to create empty files
\\
\code
{
tail/head
}&
print the end/beginning of a file
\\
\code
{
more/less
}&
print the content of a file ``more or less the same''
\\
\code
{
grep
}
&
search a string in a file
\\
\code
{
find
}
&
find a file
\\
\code
{
file
}
&
the type of file based on content
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
File handling commands
}
\begin
{
extrainfos
}
\centering
\begin
{
tabular
}{
r|l
}
\code
{
cp
}
&
copy files
\\
\code
{
mv
}
&
move/rename files
\\
\code
{
rm
}
&
remove file
\color
{
red
}{
caution no trash
}
\\
\code
{
mkdir
}
&
create a folder
\\
\code
{
cat
}
&
print the content of file, used to concatenate
\\
\code
{
touch
}
&
update the date of a file, used to create empty files
\\
\code
{
tail/head
}&
print the end/beginning of a file
\\
\code
{
more/less
}&
print the content of a file ``more or less the same''
\\
\code
{
grep
}
&
search a string in a file
\\
\code
{
find
}
&
find a file
\\
\code
{
file
}
&
the type of file based on content
\end
{
tabular
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Test the different commands (do not forget you can check the help with
\code
{
man <command>
}
)
\item
Create a directory named
\code
{
exercise
\_
linux
}
\item
Copy the file
\code
{
CodingStyle
}
from /ssoft/playground/richart into the
\code
{
exercise
\_
linux
}
folder
\item
Check the content of this file
\item
Print the last 3 lines
\item
Find the lines containing the world ``coding'' independently of the case
\item
Rename the file as
\code
{
KernelCodingStyle
}
\item
Copy the folder
\code
{
exercise
\_
linux
}
to
\code
{
exo
\_
linux
}
\item
Remove the folder
\code
{
exercise
\_
linux
}
\end
{
questions
}
\end
{
exo
}
\begin
{
frame
}
[fragile]
{
Answer to exercise~
\arabic
{
exercise
}}
\begin
{
block
}{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> mkdir exercise
_
linux
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<2->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> cd exercise
_
linux
> cp /ssoft/playground/richart/CodingStyle .
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<3->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> less CodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<4->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> tail -n3 CodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<5->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> grep -n --color -i coding CodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<6->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> mv CodingStyle KernelCodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<7->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> cd ..
> cp -r exercise
_
linux exo
_
linux
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<8->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> rm -r exercise
_
linux
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
File permissions
}
\begin
{
block
}{
Possible permissions
}
Partial results of the command
\code
{
ls -l CodingStyle
}
\\
\texttt
{
-
}
\tikz
[baseline]
{
\node
[anchor=base, fill=blue!20 ]
(u1)
{
\texttt
{
rw-
}}
;
}
\tikz
[baseline]
{
\node
[anchor=base, fill=red!20 ]
(g1)
{
\texttt
{
r--
}}
;
}
\tikz
[baseline]
{
\node
[anchor=base, fill=green!20]
(o1)
{
\texttt
{
r--
}}
;
}
\hspace*
{
1em
}
\texttt
{
richart
}
\hspace*
{
1em
}
\texttt
{
scitas-ge
}
\hspace*
{
1ex
}
\texttt
{
CodingStyle
}
\begin
{
itemize
}
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=blue!20 ]
(u1)
{
u
}
;
}
User permissions
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=red!20 ]
(u1)
{
g
}
;
}
Group permissions
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=green!20 ]
(u1)
{
o
}
;
}
Other users permissions
\end
{
itemize
}
\end
{
block
}
\begin
{
block
}{
\texttt
{
rwx
}
/
\texttt
{
---
}
explanations
}
\begin
{
tabular
}{
r|l
}
\code
{
-
}
or 0
&
Permission not granted
\\
\code
{
r
}
or 4
&
Read/List permission
\\
\code
{
w
}
or 2
&
Write/Create permission
\\
\code
{
x
}
or 1
&
Execute/Traverse permission
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
Permission commands
}
\begin
{
block
}{}
\begin
{
tabular
}{
r|l
}
\code
{
chmod
}
&
change permissions
\\
\code
{
chgrp
}
&
change main group
\\
\code
{
chown
}
&
change ownership
\\
\code
{
newgrp
}
&
login with a new group as main group
\\
\code
{
id
}
&
print user and group ids
\\
\end
{
tabular
}
\end
{
block
}
\begin
{
block
}{
\texttt
{
chmod
}
details
}
\code
{
chmod [ugoa][+-=][rwxXst] files
}
\\
\code
{
chmod octal files
}
example:
\code
{
u=rw,go=r
}
equivalent to
\code
{
644
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Permissions
}
\begin
{
extrainfos
}
Partial results of the command
\code
{
ls -l CodingStyle
}
\\
\texttt
{
-
}
\tikz
[baseline]
{
\node
[anchor=base, fill=blue!20 ]
(u1)
{
\texttt
{
rw-
}}
;
}
\tikz
[baseline]
{
\node
[anchor=base, fill=red!20 ]
(g1)
{
\texttt
{
r--
}}
;
}
\tikz
[baseline]
{
\node
[anchor=base, fill=green!20]
(o1)
{
\texttt
{
r--
}}
;
}
\hspace*
{
1em
}
\texttt
{
richart
}
\hspace*
{
1em
}
\texttt
{
scitas-ge
}
\hspace*
{
1ex
}
\texttt
{
CodingStyle
}
\begin
{
itemize
}
\setlength\itemsep
{
.1em
}
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=blue!20 ]
(u1)
{
u
}
;
}
User permissions
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=red!20 ]
(u1)
{
g
}
;
}
Group permissions
\item
[]
\tikz
[baseline]
{
\node
[anchor=base, fill=green!20 ]
(u1)
{
o
}
;
}
Other users permissions
\end
{
itemize
}
\begin
{
tabular
}{
r|l
}
\code
{
-
}
or 0
&
Permission not granted
\\
\code
{
r
}
or 4
&
Read/List permission
\\
\code
{
w
}
or 2
&
Write/Create permission
\\
\code
{
x
}
or 1
&
Execute/Traverse permission
\\
\end
{
tabular
}
\begin
{
tabular
}{
r|l
}
\code
{
chmod
}
&
change permissions
\\
\code
{
chgrp
}
&
change main group
\\
\code
{
chown
}
&
change ownership
\\
\code
{
newgrp
}
&
login with a new group as main group
\\
\code
{
id
}
&
print user and group ids
\\
\end
{
tabular
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Print your ids
\item
Check the permissions of your home folders
\item
Change the the default group of the file
\code
{
KernelCodingStyle
}
to
\code
{
hpc-cluster-users
}
\item
Remove the list permission on
\code
{
exo
\_
linux
}
\item
Try to list the
\code
{
exo
\_
linux
}
folder of someone that as completed
the previous step
\end
{
questions
}
\end
{
exo
}
\begin
{
frame
}
[fragile]
{
Answer to exercise~
\arabic
{
exercise
}}
\begin
{
block
}{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> id
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<2->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> ls -l
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<3->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> chgrp hpc-cluster-users exo
_
linux/KernelCodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<4->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> chmod go-r exo
_
linux
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<5->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> ls -l /home/richart/exo
_
linux
> ls -l /home/richart/exo
_
linux/KernelCodingStyle
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}{
Permissions: the special case of
\texttt
{
root
}}
\begin
{
block
}{
The
\texttt
{
root
}
account
}
\begin
{
itemize
}
\item
It's a special account, to which regular permissions do not apply
\item
Used to administer the system
\item
Should only be used to install trusted software
\item
Preferably via the
\code
{
sudo
}
command
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
\section
{
Shell
}
\vspace
{
-.2cm
}
\begin
{
frame
}{
More about Shell
}
\begin
{
block
}{}
\begin
{
itemize
}
\item
Different shells:
\texttt
{
sh
}
,
\texttt
{
bash
}
,
\texttt
{
csh
}
,
\texttt
{
tcsh
}
,
\texttt
{
zsh
}
, etc.
\item
For EPFL account:
{
\scriptsize\url
{
https://cadiwww.epfl.ch/cgi-bin/accountprefs/
}}
\item
In general
\code
{
echo
\$
SHELL
}
\end
{
itemize
}
\end
{
block
}
\vspace
{
-.2cm
}
\begin
{
block
}{
What is happening when you run a command
}
\begin
{
itemize
}
\item
Expansions
\item
Redirection
\item
Execution
\end
{
itemize
}
\end
{
block
}
\vspace
{
-.2cm
}
\begin
{
block
}{
Key shortcuts
}
\begin
{
tabular
}{
r|l
}
\texttt
{
Tab
}
&
auto-complete
\\
\texttt
{
(up)
}
&
go back in the command history
\\
\texttt
{
(down)
}
&
go down in the command history
\\
\texttt
{
Ctrl-r
}
&
reverse search in the history
\\
\texttt
{
Ctrl-d
}
&
exit the shell
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}
[fragile]
{
Expansions
}
\begin
{
block
}{}
\begin
{
itemize
}
\item
Accolade:
\code
{
\{
a
\{
b,c
\}
,d
\}
}
$
\longrightarrow
$
\code
{
ab ac d
}
\item
Tilde:
\code
{
\textasciitilde
richart/
}
$
\longrightarrow
$
\code
{
/home/richart
}
\item
Variables:
\code
{
export FOO=bar
}
\code
{
\$
FOO
}
$
\longrightarrow
$
\code
{
bar
}
\item
Command:
\code
{
\$
(command)
}
$
\longrightarrow
$
result of command
\item
Split spaces:
\code
{
arg1 arg2 arg3
}
the quoted arguments are not split
\item
Path:
\code
{
*
}
matches any string
\\
\hspace
{
2.4em
}
\code
{
?
}
matches any single character
\\
\hspace
{
2.4em
}
\code
{
[...]
}
matches any character in the brackets
\end
{
itemize
}
\end
{
block
}
\begin
{
itemize
}
\item
\textbf
{
TIP:
}
use
\code
{
echo <command>
}
to test your expansions
\!
\end
{
itemize
}
\end
{
frame
}
\begin
{
exo
}{
Expansions
}
\begin
{
extrainfos
}
\begin
{
tabular
}{
r|l
}
\code
{
touch
}
&
change the date of a file used to create new files
\\
\code
{
echo
}
&
print to the screen
\\
\code
{
export
}
&
make a variable known in all the new subprocess
\\
\end
{
tabular
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Try the command
\code
{
touch file
\{
0,1,2
\}\{
0,1,2,3,4,5
\}
.log
}
\item
List your home folder with a tilde expression
\item
Set a variable
\code
{
FOO
}
to the content of your choice and print its
content
\item
Try the commands:
\\
\code
{
touch foo bar
}
\\
\code
{
touch "foo bar"
}
\\
\code
{
export BROL=brol
}
\\
\code
{
touch "foo bar
\$
BROL"
}
\\
\code
{
touch 'foo bar
\$
BROL'
}
\item
List all file of the form
\code
{
file<number>.log
}
\item
List the files
\code
{
file<number>.log
}
where
\texttt
{
<
}
number
\texttt
{
>
}
is any number
with last digit 2,3 or 4
\item
Remove the previous files using the results of the ls command
\end
{
questions
}
\end
{
exo
}
\begin
{
frame
}
[fragile]
{
Answer to exercise~
\arabic
{
exercise
}}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<1->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> ls ~/
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<2->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> export FOO="the content of my choice"
> echo
$
FOO
%
\end
{command}
%$
\vspace
*
{
-
1
.
4
ex}
\end
{block}
\vspace
*
{
-
1
.
1
ex}
\begin
{block}<
3
-
>{}
\vspace
*
{
-
.
8
ex}
The second command create a file name containing a space that can be escaped
with
\code
{
\textbackslash
}
\begin
{command}
> rm foo
\
bar foo bar foo
\
bar
\ \$
BROL foo
\
bar
\
brol
%
\end
{command}
\vspace
*
{
-
1
.
4
ex}
\end
{block}
\vspace
*
{
-
1
.
1
ex}
\begin
{block}<
4
-
>{}
\vspace
*
{
-
.
8
ex}
\begin
{command}
> ls file
*
.log
%
\end
{command}
\vspace
*
{
-
1
.
4
ex}
\end
{block}
\vspace
*
{
-
1
.
1
ex}
\begin
{block}<
5
-
>{}
\vspace
*
{
-
.
8
ex}
\begin
{command}
> ls file{
2
..
4
}.log
%
\end
{command}
\vspace
*
{
-
1
.
4
ex}
\end
{block}
\vspace
*
{
-
1
.
1
ex}
\begin
{block}<
6
-
>{}
\vspace
*
{
-
.
8
ex}
\begin
{command}
> rm
$
(ls file*.log)
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}
[fragile]
{
Redirection
}
\begin
{
block
}{
\texttt
{
process
}}
\centering
\begin
{
tikzpicture
}
\node
[draw,text width=9ex,text height=3ex,text centered,text depth=2ex] (p)
{
process
}
;
\node
(i) at (-2.5cm, 0cm)
{
stdin (0)
}
;
\node
(o) at ( 2.5cm, .4cm)
{
stdout (1)
}
;
\node
(e) at ( 2.5cm,-.4cm)
{
stderr (2)
}
;
\draw
(i) -- (p);
\draw
(p) -- (o);
\draw
(p) -- (e);
\end
{
tikzpicture
}
\end
{
block
}
\begin
{
block
}{
\texttt
{
process > file.out
}}
\centering
\begin
{
tikzpicture
}
\node
[draw,text width=9ex,text height=3ex,text centered,text depth=2ex] (p)
{
process
}
;
\node
(i) at (-2.5cm, 0cm)
{
stdin (0)
}
;
\node
(o) at ( 2.5cm, .4cm)
{
stdout (1)
}
;
\node
(e) at ( 2.5cm,-.4cm)
{
stderr (2)
}
;
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1ex]
(f) at (6cm, .4cm)
{
file.out
}
;
\node
(s) at (4.5cm, .4cm)
{
\color
{
red
}{
\texttt
{
>
}}}
;
\draw
(i) -- (p);
\draw
(p) -- (o);
\draw
(p) -- (e);
\draw
(o) -- (s) -- (f);
\end
{
tikzpicture
}
\end
{
block
}
\begin
{
block
}{
\texttt
{
process 2> file.err
}}
\centering
\begin
{
tikzpicture
}
\node
[draw,text width=9ex,text height=3ex,text centered,text depth=2ex] (p)
{
process
}
;
\node
(i) at (-2.5cm, 0cm)
{
stdin (0)
}
;
\node
(o) at ( 2.5cm, .4cm)
{
stdout (1)
}
;
\node
(e) at ( 2.5cm,-.4cm)
{
stderr (2)
}
;
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1ex]
(f) at (6cm, -.4cm)
{
file.err
}
;
\node
(s) at (4.5cm, -.4cm)
{
\color
{
red
}{
\texttt
{
2>
}}}
;
\draw
(i) -- (p);
\draw
(p) -- (o);
\draw
(p) -- (e);
\draw
(e) -- (s) -- (f);
\end
{
tikzpicture
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}
[fragile]
{
Redirection
}
\begin
{
block
}{
\texttt
{
process1 | process2
}}
\centering
\begin
{
tikzpicture
}
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1.5ex] (p1)
{
\scriptsize
{
process1
}}
;
\node
(i1) at (-1.8cm, 0cm)
{
\scriptsize
{
stdin (0)
}}
;
\node
(o1) at ( 1.8cm, .4cm)
{
\scriptsize
{
stdout (1)
}}
;
\node
(e1) at ( 1.8cm,-.4cm)
{
\scriptsize
{
stderr (2)
}}
;
\node
(pipe) at (3cm, .4cm)
{
\color
{
red
}{
\texttt
{
|
}}}
;
\draw
(i1) -- (p1);
\draw
(p1) -- (o1);
\draw
(p1) -- (e1);
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1.5ex]
(p2) at (5.9cm, .4cm)
{
\scriptsize
{
process2
}}
;
\node
(i2) at ( 4.1cm, .4cm)
{
\scriptsize
{
stdin (0)
}}
;
\node
(o2) at ( 7.7cm, .8cm)
{
\scriptsize
{
stdout (1)
}}
;
\node
(e2) at ( 7.7cm, 0cm)
{
\scriptsize
{
stderr (2)
}}
;
\draw
(i2) -- (p2);
\draw
(p2) -- (o2);
\draw
(p2) -- (e2);
\draw
(o1) -- (pipe) -- (i2);
\end
{
tikzpicture
}
\end
{
block
}
\begin
{
block
}{
\texttt
{
process > file.out 2>
\&
1
}}
\centering
\begin
{
tikzpicture
}
\node
[draw,text width=9ex,text height=3ex,text centered,text depth=2ex] (p)
{
process
}
;
\node
(i) at (-2.5cm, 0cm)
{
stdin (0)
}
;
\node
(o) at ( 2.5cm, .4cm)
{
stdout (1)
}
;
\node
(e) at ( 2.5cm,-.4cm)
{
stderr (2)
}
;
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1ex]
(f) at (6cm, .4cm)
{
file.out
}
;
\node
(s1) at (4.4cm, .4cm)
{
\color
{
red
}{
\texttt
{
>
}}}
;
\node
[draw,text width=7ex,text height=2ex,text centered,text depth=1ex]
(f) at (6cm, .4cm)
{
file.out
}
;
\node
(s2) at (4.4cm, -0cm)
{
\color
{
red
}{
\texttt
{
2>
\&
1
}}}
;
\draw
(i) -- (p);
\draw
(p) -- (o);
\draw
(p) -- (e);
\draw
(o) -- (s1) -- (f);
\draw
(e) -- (s2) -- (f);
\end
{
tikzpicture
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Redirection
}
\begin
{
extrainfos
}
\begin
{
tabular
}{
r|l
}
\code
{
date
}
&
print the date
\\
\code
{
wc
}
&
wc count the numbers of lines/words/characters in a file
\\
\end
{
tabular
}
\vspace
{
1.5ex
}
Syntax for redirections:
\vspace
{
-1.5ex
}
\begin
{
itemize
}
\item
\code
{
command > file
}
redirect the standard output to
\texttt
{
file
}
\item
\code
{
command 2> file
}
redirect the standard error to
\texttt
{
file
}
\item
\code
{
command < file
}
redirect
\texttt
{
file
}
to the standard input
\item
\code
{
command1 | command2
}
redirect the stdout of
\texttt
{
command1
}
in stdin of
\texttt
{
command2
}
\end
{
itemize
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Redirect the content of the
\code
{
date
}
command in the
\texttt
{
date.log
}
file
\item
Count the number of words generated by the command
\code
{
date
}
with the
help of the command
\code
{
wc
}
\item
Redirect the error output for the command
\code
{
ls / tmp
}
\end
{
questions
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<2->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> date > date.log
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<3->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> date | wc -w
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\vspace*
{
-1.1ex
}
\begin
{
block
}
<4->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> ls / tmp 2> errors
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\end
{
exo
}
\begin
{
frame
}{
Execution
}
\begin
{
block
}{}
\begin
{
itemize
}
\item
Execution generate a new process
\item
A process is identified by a
\texttt
{
pid
}
\item
Can be run in foreground or background (
\code
{
\&
}
)
\end
{
itemize
}
\end
{
block
}
\begin
{
block
}{
Commands
}
\begin
{
tabular
}{
r|l
}
\code
{
ps
}
&
list the running processes
\\
\code
{
jobs
}
&
list the jobs running in the current shell
\\
\code
{
kill
}
&
kill processes
\\
\code
{
bg
}
&
resume jobs in background
\\
\code
{
fg
}
&
resume jobs in foreground
\\
\end
{
tabular
}
\end
{
block
}
\begin
{
block
}{
Key shortcuts
}
\begin
{
tabular
}{
r|l
}
\texttt
{
Ctrl-c
}
&
kill the current job in foreground
\\
\texttt
{
Ctrl-z
}
&
suspend the current job in foreground
\\
\end
{
tabular
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Execution
}
\begin
{
extrainfos
}
\begin
{
tabular
}{
r|l
}
\code
{
ps
}
&
list the running processes
\\
\code
{
jobs
}
&
list the jobs running in the current shell
\\
\code
{
kill
}
&
kill processes
\\
\code
{
bg
}
&
resume jobs in background
\\
\code
{
fg
}
&
resume jobs in foreground
\\
\end
{
tabular
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Run the command
\code
{
(sleep 30; echo Slept well)
}
\item
Run the command
\code
{
(sleep 30; echo Slept well)
\&
}
\item
Now you have 30 seconds to check the
\texttt
{
pid
}
with
\code
{
ps
}
\item
If you still have spare seconds kill the process before it print on screen
\end
{
questions
}
\end
{
exo
}
\section
{
Editing files
}
\begin
{
frame
}{
Command line editors: nano vi emacs
}
\begin
{
block
}{
nano
}
\begin
{
itemize
}
\item
\code
{
Ctrl-o
}
to save file
\item
\code
{
Ctrl-x
}
to quit
\end
{
itemize
}
\end
{
block
}
\begin
{
block
}{
vi
}
\begin
{
itemize
}
\item
command mode and edition mode
\item
\code
{
i
}
to insert,
\code
{
esc
}
to go back to command mode
\item
\code
{
:wq
}
to save and quit
\item
\code
{
:q!
}
to force quit
\end
{
itemize
}
\end
{
block
}
\begin
{
block
}{
emacs
}
\begin
{
itemize
}
\item
\code
{
Ctrl-x Ctrl-s
}
to save file
\item
\code
{
Ctrl-x Ctrl-c
}
to quit
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Execution
}
\begin
{
extrainfos
}
\begin
{
itemize
}
\item
nano
\\
\begin
{
tabular
}{
r|l
}
\code
{
Ctrl-o
}
&
save file
\\
\code
{
Ctrl-x
}
&
quit
\\
\end
{
tabular
}
\item
vi
\\
\begin
{
tabular
}{
r|l
}
\code
{
i
}
&
insert
\\
\code
{
esc
}
&
go back to command mode
\\
\code
{
:wq
}
&
save and quit
\\
\code
{
:q!
}
&
force quit
\\
\end
{
tabular
}
\item
emacs
\\
\begin
{
tabular
}{
r|l
}
\code
{
Ctrl-x Ctrl-s
}
&
save file
\\
\code
{
Ctrl-x Ctrl-c
}
&
quit
\\
\end
{
tabular
}
\end
{
itemize
}
\end
{
extrainfos
}
\begin
{
questions
}
\item
Try this editors
\begin
{
itemize
}
\item
nano
\item
vim
\item
emacs
\end
{
itemize
}
\end
{
questions
}
\end
{
exo
}
\section
{
Scripts
}
\begin
{
frame
}{
Shell scripts
}
\begin
{
block
}{
What is it
}
\begin
{
itemize
}
\item
It is a file containing a list of commands to execute in order
\item
Can contain loops (
\texttt
{
for
}
,
\texttt
{
while
}
), conditions
(
\texttt
{
if
}
)
\item
Often start with interpreter information
\code
{
\#
!/bin/bash
}
\end
{
itemize
}
\end
{
block
}
\begin
{
block
}{
Example of bash script
}
\begin
{
itemize
}
\item
\texttt
{
\textasciitilde
/.bashrc
}
\item
cluster job script
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
\begin
{
exo
}{
Shell scripts
}
\begin
{
questions
}
\item
Write a script that print
\texttt
{
Hello World
}
, wait 2seconds and then
print the date
\item
Make your script executable
\item
Run it
\end
{
questions
}
\begin
{
block
}
<2->
{
hello.sh
}
\vspace*
{
-.8ex
}
\begin
{
command
}
#!/bin/bash
echo Hello World
sleep 2
date
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\begin
{
block
}
<3->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> chmod +x ./hello.sh
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\begin
{
block
}
<4->
{}
\vspace*
{
-.8ex
}
\begin
{
command
}
> ./hello.sh
%
\end
{
command
}
\vspace*
{
-1.4ex
}
\end
{
block
}
\end
{
exo
}
%\section{Extra Material}
\begin
{
frame
}{
Transferring files: SFTP clients
}
\begin
{
minipage
}{
.45
\linewidth
}
\begin
{
block
}{
Filezilla
}
{
\scriptsize\url
{
https://filezilla-project.org
}}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/filezilla
}
\end
{
tikzonimage
}
\vspace*
{
3.5ex
}
\end
{
block
}
\end
{
minipage
}
\hspace*
{
2ex
}
\begin
{
minipage
}{
.45
\linewidth
}
\begin
{
block
}{
Cyberduck
}
{
\scriptsize\url
{
https://cyberduck.io/
}}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/cyberduck
}
\end
{
tikzonimage
}
\end
{
block
}
\end
{
minipage
}
\end
{
frame
}
\begin
{
frame
}{
X11 Forwarding
}
\begin
{
block
}{
Windows
}
Install XMing
{
\scriptsize\url
{
http://sourceforge.net/projects/xming/
}}
or
XWin32 (distrilog)
\\
\centering
\begin
{
minipage
}{
.4
\linewidth
}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/putty-x11
}
\end
{
tikzonimage
}
\vspace*
{
3.5ex
}
\end
{
minipage
}
\hspace*
{
2ex
}
\begin
{
minipage
}{
.4
\linewidth
}
\centering
\begin
{
tikzonimage
}
[width=.96
\linewidth
]
{
images/tunnelier-x11
}
\end
{
tikzonimage
}
\end
{
minipage
}
\vspace*
{
-3ex
}
\end
{
block
}
\vspace*
{
-1ex
}
\begin
{
block
}{
Mac OS
}
Install XQuartz
{
\scriptsize\url
{
http://xquartz.macosforge.org/landing/
}}
, MacPort or Homebrew
\\
Connect with
\code
{
ssh -Y <username>@<hostname>
}
\end
{
block
}
\end
{
frame
}
%\section{Sources}
\begin
{
frame
}{
Sources
}
\begin
{
block
}{}
\begin
{
itemize
}
\item
Wikipedia:
\url
{
http://en.wikipedia.org/
}
\begin
{
itemize
}
\item
\href
{
https://en.wikipedia.org/wiki/History
_
of
_
Linux
}{
History
\_
of
\_
Linux
}
\item
\href
{
https://en.wikipedia.org/wiki/Usage
_
share
_
of
_
operating
_
systems
}{
Usage
\_
share
\_
of
\_
operating
\_
systems
}
\item
\href
{
https://en.wikipedia.org/wiki/Mobile
_
operating
_
system
}{
Mobile
\_
operating
\_
system
}
\end
{
itemize
}
\item
DistroWatch:
\url
{
http://distrowatch.com/
}
\item
\href
{
http://tldp.org/LDP/intro-linux/html/
}{
The Linux Documentation Project
}
\end
{
itemize
}
\end
{
block
}
\end
{
frame
}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "slides"
%%% End:
Event Timeline
Log In to Comment