Il comando chmod modifica gli attributi di un file e i permessi in lettura ed in esecuzione.
I file e le directory sono protetti da operazioni non autorizzate. Fissando i criteri di protezione, che possono riguardare la lettura la scrittura e l’esecuzine dei file. I valori correnti dei permessi possono essere controllati con il comando ls -l.
All’inizio di ogni riga della lista visualizzata c’è una sequenza di dieci caratteri.Se il primo carattere a sinistra è un segno meno siamo in presenza di un file ordinario mentre il carattere d indica una directory. I successivi nove caratteri sono tre terne di permessi:
1.utente proprietario del file o della directory.
2.Gruppo.
3.Tutti gli altri utenti.
I caratteri r, w, x, indicano rispettivamente i permessi di lettura, scrittura ed esecuzione.
Esempio 1:
chmod tipoutente opzione permesso phatname
dove tipo utente può essere uno dei caratteri
u per user utente
g per group gruppo
o per others altri
a per all tutti (è il tipo utente di default)
in assenza viene sottointesa la a
L’opzione può essere:
+ aggiunge un permesso
- toglie un permesso
= sostituisce i permessi esistenti con i nuovi
formato 1:
The chmod command changes the attributes of a file and read permission and running.
The files and directories are protected from unauthorized transactions. By setting the security policies that can affect the reading and writing esecuzine files. The current values of permits can be controlled with the command ls-l.
Beginning of each row in the list provided there is a sequence of ten caratteri.Se the leftmost character is a minus sign we are dealing with an ordinary file and the character d indicates a directory. The next nine characters are three triples of permits:
1.utents owner of the file or directory.
2.Group.
3.All other users.
The characters r, w, x, respectively indicate permission to read, write and execute.
Esxample 1:
chmod tipoutente option enabled phatname
where user type can be one of the characters
u for user
g for group
o for others
a for all (it’s the default utent type)
is implied in the absence the a
The option can be:
+ adds a permit
- remains a permit
=replaces existing permissions with the new
Format 1:
il permesso è indicato con:
1)r(ead) = per un file consente la lettura del suo contenuto; per una directory consente solo di listare i nomi dei file e delle directory in essa contenuti.
2)w(rite) = per un file consente la propria modifica e sostituzione; per una directory consente l’aggiunta e la cancellazione di file in essa presenti.
3)(e)x(ecute) = per un file lo rende eseguibile; per una directory consente una lista dettagliata dei file (purche sia presente anche il permesso “r”); inoltre i file in essa contenuti possono essere letti e modificati in accordo con i permessi sui singoli file.
esempi:
chmod u=rx *.prg
per l’utente corrente sostituisce i permessi correnti con la lettura e esecuzione di tutti i file di estensione .prg
chmod +r archivio1
aggiunge il permesso di lettura alla directory archivio1 a tutti gli utenti come se ci fosse la a
chmod g-w archivio2
per il gruppo toglie il permesso di scrittura alla directory archivio2
formato 2:
Per modificare le autorizzazioni e gli accessi a un file si può utilizzare il comando “chmod” con la notazione ottale e si chiama così perchè usa una combinazione di tre terne di bit per indicare le tre terne di permessi; infatti con tre bit si possono rappresentare le cifre del sistema ottale da zero a sette. Poiché le lettere r w x compaiono nella sequenza sempre nello stesso ordine, basta associare un bit uno se è presente la lettera, un bit 0 per indicare il carattere – (meno).
Per esempio la sequenza rwx rw- r– corrisponde a
binaria 111 110 100
ottale 7 6 4
allora il comando sarà:
chmod 764 nome_file
se vogliamo dare tutti i permessi a tutti gli utenti
chmod 777 nome_file
se vogliamo dare il permesso di lettura a tutti gli utenti
chmod 444 nome_file
se vogliamo dare il permesso di lettura e scrittura a u e o e a g solo scrittura
chmod 646
permission is given by:
1)r(ead) = for a file allows reading its contents; for a directory allows you to list only the names of files and directories in it.
2)w(rite) = for a file allows your modification and replacement, for a directory allows the addition and deletion of files in it.
3)(e)x(ecute) = makes a file executable in a directory allows for a detailed list of the files (provided that this is also permitted “r”), and also the files in it can be read and modified in accordance with the permissions on individual files.
Examples:
chmod u=rx *.prg
for the current user replaces the current permits with the reading and execution of all file extension. prg
chmod +r archivio1
adds read permission to the directory archivio1 to all users as if there was a
chmod g-w archivio2
for the group removes the write permission to the directory archivio2
format 2:
To change permissions and access to a file you can use the command “chmod” with the octal and is so named because it uses a combination of three triples of bits to indicate the three trios of permits because with three bits can be represented the digits of the octal from zero to seven. Since the letters rwx appear in sequence in the same order, just bind a bit if there is one point, a bit 0 to indicate the character – (minus).
For example, the sequence rwx rw-r– Matches
binary 111 110 100
octal 7 6 4
then the command would be:
chmod 764 name_file
if we want to give all permissions to all users
chmod 777 name_file
if we want to give read permission to all users
chmod 444 nome_file
if we give permission to read and write only write a u e o e a g
chmod 646













