Giriş
chmod sadece dosya sahibi veya root tarafından izinleri değiştirmek için
kullanılabilir.
Of course, only the owner of a file may use chmod to alter a file's permissions
chmod ile kullanılan sayıların anlamı
şöyledir.
0 no permission
1 execute
2 write
3 execute + write
4 read
5 read + execute
6 read + write
7 all
Gruplar
şöyledir.
u - Owner
g - group
o - others
Bazı Sabitler
Bu sabitler man 2 chmod ile görülebilir. S_I "stat inode" anlamına
gelir.
Şöyledir
S_IRUSR (00400) read by owner
S_IWUSR (00200) write by owner
S_IXUSR (00100) execute/search by owner ("search" applies for direc-
tories, and means that entries within the directory
can be accessed)
S_IRGRP (00040) read by group
S_IWGRP (00020) write by group
S_IXGRP (00010) execute/search by group
S_IROTH (00004) read by others
S_IWOTH (00002) write by others
S_IXOTH (00001) execute/search by others
suid, guid ve sticky bitler için sabitler
şöyledir.
S_ISUID (04000) set-user-ID (set process effective user ID on
execve(2))
S_ISGID (02000) set-group-ID (set process effective group ID on
execve(2); mandatory locking, as described in
fcntl(2); take a new file's group from parent direc-
tory, as described in chown(2) and mkdir(2))
S_ISVTX (01000) sticky bit (restricted deletion flag, as described in
unlink(2))
Örnek
Sayı vererek şöyle
yaparız.
chmod 777 myapp
Dizin İçin Haklar
Açıklaması
şöyle.
For a directory, "read" access lets you list the contents, and "execute" access lets your traverse the directory to open one of its children (file or subdirectory). So if you remove:
-just the read access, people can still access subdirectories by guessing their names
-just the execute flag, people can still list the names of the contents even if they cannot access them, and this can still be revealing
-both read and execute privileges on a directory, anything below it becomes unreachable, and you don't need to make a recursive change.
Eğer Tüm Haklar 0 İse
Elimizde şöyle bir dosya olsun
---------- myFile.txt
root bu dosyayı
okuyabilir ve dosyaya
yazabilir ancak
çalıştıramaz.
Çalıştırabilmesi için en az bir grubun x (execute) hakkına sahip olması gerekir. Yani şöyle
olmalıdır.
---x------ myFile.txt
veya
------x--- myFile.txt
veya
---------x myFile.txt
Hakları Geri Almak
Açıklaması
şöyle. Eksi işareti ile hak geri alınır.
The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes them to be removed; and = causes them to be added and causes unmentioned bits to be removed except that a directory's unmentioned set user and group ID bits are not affected.
Örnek
Şöyle
yaparız.
chmod -664 my_file
execute hakkı - (x harfi)
Dizinlere girebilmek için read değil için execute hakkının olması gerekir. Dizinler için genellikle,777 (herkes erişebilir) 750 (sahip ve grup erişebilir) veya 700 (sadece sahip erişebilir) hakkı
verilir.
Örnek
Kullanıcıya execute hakkı vermek için şöyle
yaparız.
chmod u+x myfolder
Örnek
Herkese execute hakkı vermek için şöyle
yaparız.
sudo chmod a+x your_program
Örnek
Herkesten execute hakkını kaldırmak için şöyle
yaparız.
chmod a-x /path/to/program
read hakkı - (r harfi)
Örnek
user,group ve owner'dan read hakkını recursive olarak almak için şöyle
yaparız
chmod -R ugo-r [path]
write hakkı - (w harfi)
Örnek
Gruba yazma hakkı vermek için şöyle
yaparız.
chmod g+w [path]
sticky bit - Bir dizinde herkes dosya oluşturabilir ancak sadece dosyanın sahibi silebilir.
sticky bit yazısına taşıdım.
suid bit - Dosya Sahibinin Hakları İle Çalıştırılır
suid bit yazısına taşıdım.
guid bit - Dizinde Gruba Ait Herkes Dosya Oluşturabilir
Örnek - user
Şöyle
yaparız. 4 sayısı u+s anlamına
gelir.
chmod 4755 file
-R seçeneği
Recursive çalışır. Şöyle
yaparız.
# Give read access to everyone
chmod -R a+r folder