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 uso-lab/labs/
(...)

Cale absolută:

student@uso:~$ ls -l /home/student/uso-lab/labs/
(...)

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 -F -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:~/uso_lab02/Avengers$ ls
Captain America  Iron Man  Thor
student@uso:~/uso_lab02$ 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:~/uso_lab02$ ls cities
ls: cannot access cities: No such file or directory
student@uso:~/uso_lab02$ touch cities
student@uso:~/uso_lab02$ ls cities
cities

Crearea directoarelor

student@uso:~/uso_lab02$ mkdir GameOfThrones
student@uso:~/uso_lab02$ mkdir Avengers
student@uso:~/uso_lab02$ 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:~/uso_lab02$ cat GameOfThrones/Arya
A girl has no name

Ștergerea fișierelor

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

Ștergerea directoarelor

student@uso:~/uso_lab02$ mkdir LordOfTheRings
student@uso:~/uso_lab02$ 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:~/uso_lab02$ rmdir "LordOfTheRings"
student@uso:~/uso_lab02$ 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:~/uso_lab02$ ls
GameOfThrones
student@uso:~/uso_lab02$ mv GameOfThrones ThroneOfGames
student@uso:~/uso_lab02$ ls
ThroneOfGames

Copierea fișierelor și directoarelor

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

Fișiere și directoare ascunse

student@uso:~/uso_lab02$ 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:~/uso_lab02/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:~/uso_lab02/Avengers$ touch .Hulk
student@uso:~/uso_lab02/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:~/uso_lab02/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

Afișarea tipului de fișier

student@uso:~/uso_lab02$ file Picture.abc
Picture.abc: PNG image data, 742 x 320, 8-bit/color RGBA, non-interlaced
student@uso:~/uso_lab02$ file index.rst
index.rst: ASCII text
student@uso:~/uso_lab02$ file archive.tar
archive.tar: POSIX tar archive (GNU) 
student@uso:~/uso_lab02$ ln -s ~/ .
student@uso:~/uso_lab02$ ls -l
total 0
lrwxrwxrwx 1 student student 28 Oct  6 17:58 mkdir -> /home/student/

Execuția programelor

student@uso:~/uso_lab02$ ./my_ls
executie  mkdir  my_ls  touch
uso/laboratoare/laborator-02/cheatsheet.txt · Last modified: 2022/10/16 19:54 by liza_elena.babu
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