Sumar - Cheatsheet

Căi în ierarhia de fișiere

Calea curentă

student@uso:~$ pwd
/home/student

Cale relativă și cale absolută

Cale relativă:

student@uso:~$ ls -l snap/spotify/
total 8
drwxr-xr-x 5 student student 4096 Oct  2 03:11 42
drwxr-xr-x 3 student student 4096 Oct  2 03:10 common
lrwxrwxrwx 1 student student    2 Oct  2 03:10 current -> 42

Cale absolută:

student@uso:~$ ls -l /home/student/snap/spotify
total 8
drwxr-xr-x 5 student student 4096 Oct  2 03:11 42
drwxr-xr-x 3 student student 4096 Oct  2 03:10 common
lrwxrwxrwx 1 student student    2 Oct  2 03:10 current -> 42

Schimbarea căii curente

student@uso:/etc$ pwd
/etc
student@uso:/etc$ cd /usr
student@uso:/usr$ pwd
/usr

Scurtături de căi

Caracterul -:

student@uso:~$ pwd
/home/student
student@uso:~$ cd /usr/bin/
student@uso:/usr/bin$ pwd
/usr/bin
student@uso:/usr/bin$ cd -
/home/student
student@uso:~$ cd -
/usr/bin
student@uso:/usr/bin$ cd -
/home/student
student@uso:~$ cd -
/usr/bin

Caracterul ~:

student@uso:/usr/bin$ cd /tmp/
student@uso:/tmp$ pwd
/tmp
student@uso:/tmp$ cd ~
student@uso:~$ pwd
/home/student
student@uso:~$ cd /usr/bin/X11/
student@uso:/usr/bin/X11$ pwd
/usr/bin/X11
student@uso:/usr/bin/X11$ cd ~
student@uso:~$ pwd
/home/student

Interacțiunea cu fișiere în linia de comandă

Ierarhie de fișiere

student@uso:~$ tree -L 1 /
/
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- initrd.img -> /boot/initrd.img-3.16.0-4-586
|-- lib
|-- lib64
|-- libx32
|-- lost+found
|-- media
|-- mnt
|-- opt
|-- proc
|-- root
|-- run
|-- sbin
|-- srv
|-- sys
|-- tmp
|-- usr
|-- var
``-- vmlinuz -> boot/vmlinuz-3.16.0-4-586

Afișarea conținutului unui director

student@uso:~/Avengers$ ls
Captain America  Iron Man  Thor
student@uso:~$ ls -l
(...)
-rw-rw-r-- 1 student student    0 Oct 13 13:02  cities
-rw-rw-r-- 1 student student    0 Oct 13 13:03 'cities in romania'
-rw-r--r-- 1 student student 8980 Sep 24 09:00  examples.desktop
-rw-rw-r-- 1 student student    0 Oct 13 13:02  romania
drwxr-xr-x 4 student student 4096 Oct  2 03:11  snap

Crearea fișierelor

student@uso:~$ ls cities
ls: cannot access cities: No such file or directory
student@uso:~$ touch cities
student@uso:~$ ls cities
cities

Crearea directoarelor

student@uso:~$ mkdir GameOfThrones
student@uso:~$ mkdir Avengers
student@uso:~$ ls -l
(...)
drwxr-xr-x 2 student student 4096 Sep 29 17:43 Avengers
(...)
drwxr-xr-x 2 student student 4096 Sep 29 17:43 GameOfThrones
(...)

Afișarea conținutului unui fișier

student@uso:~$ cat GameOfThrones/Arya
A girl has no name

Ștergerea fișierelor

student@uso:~$ ls Avengers/
Captain America  Hulk  Iron Man  Thor
student@uso:~$ rm Avengers/Hulk
student@uso:~$ ls Avengers/
Captain America  Iron Man  Thor

Ștergerea directoarelor

student@uso:~$ mkdir LordOfTheRings
student@uso:~$ ls -l
total 12
drwxr-xr-x 2 student student 4096 Sep 29 18:02 Avengers
drwxr-xr-x 2 student student 4096 Sep 29 17:44 GameOfThrones
drwxr-xr-x 2 student student 4096 Sep 29 18:09 LordOfTheRings
student@uso:~$ rmdir "LordOfTheRings"
student@uso:~$ ls -l
total 8
drwxr-xr-x 2 student student 4096 Sep 29 18:02 Avengers
drwxr-xr-x 2 student student 4096 Sep 29 17:44 GameOfThrones

Redenumirea și mutarea fișierelor și directoarelor

student@uso:~$ ls
GameOfThrones
student@uso:~$ mv GameOfThrones ThroneOfGames
student@uso:~$ ls
ThroneOfGames

Copierea fișierelor și directoarelor

student@uso:~$ cp Avengers/Thor /tmp/
student@uso:~$ ls /tmp/
Thor  ssh-ApUMKI3HSJ

Fișiere și directoare ascunse

student@uso:~$ ls -al
total 8
drwxr-xr-x 5 student student 4096 Sep 29 18:41 .
drwxr-xr-x 4 student student 4096 Sep 29 18:35 ..
drwxr-xr-x 2 student student 4096 Sep 29 18:20 Avengers
drwxr-xr-x 2 student student 4096 Sep 29 17:44 GameOfThrones
student@uso:~/Avengers$ ls -l
total 0
-rw-r--r-- 1 student student 0 Sep 29 18:20 Captain America
-rw-r--r-- 1 student student 0 Sep 29 18:20 Iron Man
-rw-r--r-- 1 student student 0 Sep 29 18:20 Thor
student@uso:~/Avengers$ touch .Hulk
student@uso:~/Avengers$ ls -l
total 0
-rw-r--r-- 1 student student 0 Sep 29 18:20 Captain America
-rw-r--r-- 1 student student 0 Sep 29 18:20 Iron Man
-rw-r--r-- 1 student student 0 Sep 29 18:20 Thor
student@uso:~/Avengers$ ls -al
total 8
drwxr-xr-x 2 student student 4096 Oct  6 16:44 .
drwxr-xr-x 5 student student 4096 Sep 29 19:14 ..
-rw-r--r-- 1 student student    0 Oct  6 16:44 .Hulk
-rw-r--r-- 1 student student    0 Sep 29 18:20 Captain America
-rw-r--r-- 1 student student    0 Sep 29 18:20 Iron Man
-rw-r--r-- 1 student student    0 Sep 29 18:20 Thor
uso/laboratoare/ac/laborator-02/cheatsheet.txt · Last modified: 2020/10/19 17:02 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0