29 Mayıs 2019 Çarşamba

shuf komutu

-n seçeneği
Dosyadan kaç tane satır örneklemek istediğimizi belirtir.

Örnek
Şöyle yaparız. 1-139 arasında 1519 tane sayı üretir. Sayıları tekrar kullanır
shuf -i 1-139 -n 1519 -r
-r seçeneği
reuse anlamına gelir. Eğer -n ile belirtilen sayıdan daha az satır varsa, satırları tekrar kullanır.

28 Mayıs 2019 Salı

chmod komutu - Dosya Ve Dizinlerin Haklarını Değiştirir

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
Grupların belirtilerek hakların tanımlanması için chmod komutu ve Gruplar yazısına bakınız

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
guid bit yazısına taşıdım

Ö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

27 Mayıs 2019 Pazartesi

systemd-run komutu

--on-calendar seçeneği
Belirtilen zamanda işi çalıştırır.

Örnek
Şöyle yaparız.
systemd-run --on-calendar="2019-08-31 20:00:00 CET" /sbin/shutdown now

atq komutu

Örnek
Şöyle yaparız.
% atq
161     Sat Aug 31 20:00:00 2019 a sweh

26 Mayıs 2019 Pazar

bash kodlama - suffix removal

Örnek
Alt dizinlerdeki *.mp4 dosyalarını bulup bu dosya ile aynı dizindeki folder.jpg dosyasını mp4 dosya ismi.jpg haline getirmek isteyelim. Şöyle yaparız.
for movie in ./*/*.mp4; do mv -- "${movie%/*}/folder.jpg" "${movie%.mp4}.jpg"; done
Açıklaması şöyle.
${movie%/*} and ${movie%.mp4} are both examples of suffix removal. ${movie%/*} returns the directory that the movie file is in and ${movie%.mp4} returns the name of the movie file minus the extension .mp4.

gsettings komutu

Giriş
Komut satırından Gnome Desktop ayarlarını okumak ve atamak için kullanılır.

Örnek - Cursor
PrintScreen tuşuna basında cursor'ı da kaydetmek mümkün. Seçeneğin değerini görmek için şöyle yaparız.
gsettings get org.gnome.gnome-screenshot include-pointer
false
Değer atamak için şöyle yaparız.
gsettings set org.gnome.gnome-screenshot include-pointer true
Örnek - Pil ve Priz
Pil kullanıyorken şu kadar saniye kullanılmazsa inactive yap ayarı için şöyle yaparız. Hiç istemiyorsak 0 veririz.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout
  <time_in_seconds>
Prizdeyken şu kadar saniye kullanılmazsa inactive yap ayarı için şöyle yaparız.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
  <time_in_seconds>
Login ekranının kararmaması için şöyle yaparız.
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
Örnek - dash
Şöyle yaparızz
gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false

bash seçenekleri

-c seçeneği
Açıklaması şöyle
bash -c allows arguments to be passed to the script, and $0 to be set:
Şöyle yaparız. some command içinde $1'e abc değeri ve  $2'ye  def değeri atanır..
bash -c 'some command' sh abc def
Açıklaması şöyle
bash -c 'some command' retains access to the standard input of the caller, so read or commands reading from standard input will work normally.
Şöyle yaparız.
$ bash -c cat
abc
abc
^D
--debug seçeneği
Şöyle yaparız.
$ bash --debugger
$ declare -Ff quote
quote 143 /usr/share/bash-completion/bash_completion
-v seçeneği
Şöyle yaparız.
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)