Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Picasoft
APIs
Init
Linux
Commits
9a447999
Verified
Commit
9a447999
authored
Jan 19, 2019
by
Stephane Bonnet
Browse files
Terminé les manips de système de fichier
parent
9fb70094
Pipeline
#33723
passed with stage
in 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/cli/basics.tex
View file @
9a447999
\subsection
{
Obtenir de l'aide
}
\begin{frame}
[fragile]
{
man
}
Une documentation complète est intégrée au système. On y accède par
\emph
{
man
}
.
\cmd
{
man
}
affiche le manuel complet d'une commande. Par exemple pour
obtenir le manuel de
\cmd
{
ls
}
:
\begin{beamercolorbox}
[wd=
\linewidth
,rounded=true,shadow=true]
{
terminal
}
\begin{Verbatim}
$
man ls
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\begin
{
alertblock
}{
Quelques pages utiles...
}
\begin
{
description
}
\item
[
\cmd
{
man
}
]
Le manuel du manuel
\item
[
\cmd
{
intro
}
]
Une introduction au système
\end
{
description
}
\end
{
alertblock
}
\end
{
frame
}
\begin
{
frame
}{
man
}
Une fois dans
\cmd
{
man
}
, quelques touches utiles:
\begin
{
center
}
\begin
{
tabular
}{
|c|c|
}
\hline
\textbf
{
Touche
}
&
\textbf
{
Explications
}
\\
\hline\hline
q
&
Quitter l'aide
\\
\hline
Espace
&
passe à la page suivante
\\
\hline
/
<motif>
&
Chercher <motif> dans la page
\\
\hline
n
&
Chercher suivant
\\
\hline
N
&
chercher précédent
\\
\hline
\end
{
tabular
}
\end
{
center
}
Le déplacement se fait avec les touches fléchées.
\begin
{
exampleblock
}{
A vous
}
Avec
\cmd
{
man
}
, cherchez comment faire afficher à
\cmd
{
ls
}
les fichiers du répertoire courant un par ligne,
dans l'ordre de leur taille.
\end
{
exampleblock
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
apropos
}
\cmd
{
apropos
}
permet de chercher par mot
-
clé:
\begin
{
beamercolorbox
}
[
wd
=
\linewidth
,rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
apropos copy
[...]
cp (1) - copy files and directories
cpgr (8) - copy with locking the given file to the password or group file
cpio (1) - copy files to and from archives
[...]
\end{Verbatim}
\end{beamercolorbox}
\begin{block}
{}
\cmd
{
man -k <mot>
}
assure la même fonction.
\end{block}
\end{frame}
\begin{frame}
[fragile]
{
Directement dans les commandes
}
Les commandes contiennent souvent de l'aide, accessible en général par les options
\cmd
{
-h
}
ou
\cmd
{
-
{}
-help
}
\begin{beamercolorbox}
[rounded=true,shadow=true]
{
terminal
}
\begin{Verbatim}
$
cd
--
help
cd: cd
[-
L|
[-
P
[-
e
]]
[-
@
]]
[
rép
]
Change le répertoire de travail du shell.
[
...
]
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\begin
{
alertblock
}{
Lisez la documentation
!
}
Il est toujours utile de RTFM quand on est perdu...
\end
{
alertblock
}{}
\end
{
frame
}
\subsection
{
Le système de fichiers
}
\begin
{
frame
}
[
fragile
]
{
Où sont les fichiers
}
Les fichiers sont contenus dans des répertoires qui forment
une arborescence.
\begin
{
block
}{}
La racine de l'arborescence est repérée par un
/
Ce répertoire est appelé répertoire racine, ou
\emph
{
root directory
}
\end
{
block
}
\begin
{
description
}
\item
[
\cmd
{
cd
}
]
Change de répertoire
\item
[
\cmd
{
pwd
}
]
Affiche le répertoire courant
\end
{
description
}
\begin
{
exampleblock
}{
Allons y
}
Allez dans
/
avec
\cmd
{
cd
}
et affichez son contenu.
\end
{
exampleblock
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
pwd
/home/bonnetst
$
cd
/
$
pwd
/
$
ls
bin dev initrd.img lib
64
mnt root snap sys var
[
...
]
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Chemins
}
L'emplacement d'un fichier ou un répertoire est repéré par son chemin dans l'arborescence.
\begin
{
block
}{
Chemin absolu
}
Le chemin dans l'arborescence qui indique où se trouve un fichier
\textbf
{
depuis la racine
}
\end
{
block
}
\begin
{
block
}{
Chemin relatif
}
Le chemin dans l'arborescence qui indique où se trouve un fichier
\textbf
{
depuis le répertoire courant
}
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Répertoires . et ..
}
Chaque répertoire contient un répertoire appelé `.' et un autre appelé `..'
\begin
{
columns
}
\begin
{
column
}{
.
45
\textwidth
}
\begin
{
block
}{
.
}
Représente le répertoire courant
\end
{
block
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
cd /usr/bin
$
pwd
/
usr
/
bin
$
cd .
$
pwd
/
usr
/
bin
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
column
}
\begin
{
column
}{
.
45
\textwidth
}
\begin
{
block
}{
..
}
Représente le répertoire parent
\end
{
block
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
cd /usr/bin
$
pwd
/
usr
/
bin
$
cd ..
$
pwd
/
usr
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
column
}
\end
{
columns
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Répertoire personnel
}
Chaque utilisateur dispose d'un répertoire personnel aussi appelé
\emph
{
home directory
}
.
Ce répertoire a le même nom que l'utilisateur.
\begin
{
block
}{
Répertoire
\texttt
{
\char
`
\~
}}
Le répertoire
\texttt
{
\char
`
\~
}
représente le home directory de l'utilisateur courant.
\end
{
block
}
\begin
{
alertblock
}{
Remarque
}
La commande
\cmd
{
cd
}
sans arguments revient au répertoire courant.
\end
{
alertblock
}
\begin
{
columns
}
\begin
{
column
}{
.
45
\textwidth
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
cd /usr/bin
$
pwd
/
usr
/
bin
$
cd ~
$
pwd
/
home
/
bonnetst
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
column
}
\begin
{
column
}{
.
45
\textwidth
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
cd /usr/bin
$
pwd
/
usr
/
bin
$
cd
$
pwd
/
home
/
bonnetst
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
column
}
\end
{
columns
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Que contiennent les répertoires?
}
L'arborescence est complexe mais organisée.
\begin
{
center
}
\begin
{
tabular
}{
|c|c|
}
\hline
\textbf
{
Chemin
}
&
\textbf
{
Contenu
}
\\
\hline\hline
/
&
Racine
\\
\hline
/
bin,
/
sbin
&
programmes indispensables
\\
\hline
/
boot
&
noyau du système et bootloader
\\
\hline
/
dev
&
Fichiers spéciaux d'accès aux périphériques
\\
\hline
/
etc
&
Fichiers de configuration de la machine
\\
\hline
/
home
&
Répertoires personnels
\\
\hline
/
lib
&
Bibliothèques système
\\
\hline
/
media
&
Media amovibles
(
clés usb...
)
\\
\hline
/
root
&
Répertoire personnel du superutilisateur
\\
\hline
/
tmp
&
Fichiers temporaires
\\
\hline
/
usr
&
Applications, programmes, etc.
\\
\hline
/
var
&
Spools, logs, caches etc.
\\
\hline
\end
{
tabular
}
\end
{
center
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Que contiennent les répertoires?
}
Beaucoup d'autres répertoires...
Qui contiennent des sous
-
répertoires...
\begin
{
exampleblock
}{
\cmd
{
tree
}}
\cmd
{
cd
/
}
\cmd
{
tree
-
d
}
\end
{
exampleblock
}
\begin
{
alertblock
}{}
\cmd
{
tree
}
n'est pas installée par défaut. Installez
-
la avec
\cmd
{
apt
}
.
\end
{
alertblock
}
\begin
{
alertblock
}{
C'est loooong
}
\cmd
{
CTRL
+
C
}
met fin à une commande
(
presque
)
sans lui demander son avis. Utilisez
-
la
quand vous en aurez assez de voir défiler des répertoires.
\end
{
alertblock
}
\begin
{
block
}{
Pour aller plus loin
}
\cmd
{
man hier
}
documente tous les répertoires
!
\end
{
block
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Liens symboliques: la commande
\cmd
{
ln
}}
Certains fichiers ne sont que des pointeurs vers d'autres fichiers. Ce sont des
\emph
{
liens symboliques
}
.
\begin
{
exampleblock
}{
Créez un fichier avec l'éditeur nano
}
\cmd
{
cd
}
\cmd
{
nano fichier.txt
}
Quittez nano avec
\cmd
{
CTRL
+
K
}
\end
{
exampleblock
}
\begin
{
exampleblock
}{
Créez un lien symbolique
}
\cmd
{
ln
-
s fichier.txt lien.txt
}
\end
{
exampleblock
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
ls -l
total 4
-rw-rw-r-- 1 bonnetst bonnetst 8 janv. 19 19:10 fichier.txt
lrwxrwxrwx 1 bonnetst bonnetst 11 janv. 19 19:12
\textcolor
{
cyan
}{
lien.txt
}
-> fichier.txt
$
cat fichier.txt
Salut
!
$
cat lien
_
vers
_
fichier.txt
Salut!
\end{Verbatim}
\end{beamercolorbox}
\end{frame}
\begin{frame}
[fragile]
{
Liens symboliques: la commande
\cmd
{
ln
}}
\begin{alertblock}
{}
Les liens ne contiennent que chemin vers la cible tel qu'il a été saisi !
\end{alertblock}
\begin{beamercolorbox}
[rounded=true,shadow=true]
{
terminal
}
\begin{Verbatim}
$
mkdir subdir
$
ln -s fichier.txt subdir/lien.txt
$
ls
-
l subdir
total
0
lrwxrwxrwx
1
bonnetst bonnetst
11
janv.
19
19
:
28
\textcolor
{
red
}{
lien.txt
}
-
>
\textcolor
{
red
}{
fichier.txt
}
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\textcolor
{
red
}{
Il y a du rouge, c'est mauvais signe
!
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
ln -sf ../fichier.txt subdir/lien.txt
$
ls
-
l subdir
total
0
lrwxrwxrwx
1
bonnetst bonnetst
11
janv.
19
19
:
29
\textcolor
{
cyan
}{
lien.txt
}
-
> ..
/
fichier.txt
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\begin
{
alertblock
}{
Quand on crée un lien, on utilise...
}
\begin
{
itemize
}
\item
Le chemin
\textbf
{
absolu
}
vers la cible
\item
Le chemin relatif vers la cible
\textbf
{
depuis l'emplacement du lien
}
\end
{
itemize
}
\end
{
alertblock
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
Commandes récursives
}
Traiter des sous
-
répertoires un par un est fastidieux.
\cmd
{
mkdir
}
,
\cmd
{
cp
}
,
\cmd
{
rm
}
admettent des fonctionnement
récursifs.
\begin
{
block
}{
\cmd
{
mkdir
-
p
}}
Crée un répertoire et tous ses parents d'un coup
\end
{
block
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
mkdir -p a/b
$
ls
-
d a
/
b
\textcolor
{
cyan
}{
a
/
b
}
\end
{
Verbatim
}
\end
{
beamercolorbox
}
\end
{
frame
}
\begin
{
frame
}
[
fragile
]
{
\cmd
{
cp
}
récursif
}
\begin
{
block
}{
\cmd
{
cp
-
R
}}
Copie un répertoire et tous ses sous
-
répertoires d'un coup
\end
{
block
}
\begin
{
beamercolorbox
}
[
rounded
=
true,shadow
=
true
]
{
terminal
}
\begin
{
Verbatim
}
$
cd a
$
cp
/
etc
/
fstab
/
etc
/
issue
/
etc
/
hosts .
$
ls
\textcolor
{
cyan
}{
b
}
fstab hosts issue
$
cp
-
R . ~
/
c
$
ls ~/c
\textcolor
{
cyan
}{
b
}
fstab hosts issue
\end{Verbatim}
\end{beamercolorbox}
\begin{alertblock}
{}
\cmd
{
cp -R
}
crée automatiquement la destination si elle n'existe pas.
\end{alertblock}
\end{frame}
\begin{frame}
[fragile]
{
\cmd
{
rm
}
récursif
}
\begin{block}
{
\cmd
{
rm -R
}}
Supprime un répertoire et tous ses sous-répertoires d'un coup
\end{block}
\begin{beamercolorbox}
[rounded=true,shadow=true]
{
terminal
}
\begin{Verbatim}
$
cd ~
/
c
$
ls
\textcolor
{
cyan
}{
b
}
fstab hosts issue
$
rm fstab hosts issue
$
cd ..
$
rmdir c
rmdir: impossible de supprimer 'c': Le dossier n'est pas vide
$
rm -R c
$
ls c
$
ls: impossible d'accéder à 'c': Aucun fichier ou dossier de ce type
\end{Verbatim}
\end{beamercolorbox}
\begin{alertblock}
{
Danger, Will Robinson
}
Cette commande est très puissante. Il faut faire attention à ne pas supprimer des données par inadvertance.
\end{alertblock}
\end{frame}
\subsection
{
Afficher des fichiers
}
\begin{frame}
{
Voir des fichiers
}
\begin{frame}
\frametitle
{
Voir des fichiers
}
\end{frame}
\subsection
{
Redirections
}
\begin{frame}
{
Les fichiers standards
}
\begin{frame}
\frametitle
{
Les fichiers standards
}
%% stdin, stdout, stderr
\end{frame}
\begin{frame}
{
Redirections
}
\begin{frame}
\frametitle
{
Redirections
}
\end{frame}
\subsection
{
Économiser le clavier
}
\begin{frame}
{
Pour les flemmards: l'autocomplétion
}
\begin{frame}
\frametitle
{
Pour les flemmards: l'autocomplétion
}
\end{frame}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment