6 Nisan 2022 Çarşamba

Pluggable Authentication Modules (PAM)

Giriş
PAM'e bir sürü module takılabilir. Örneğin
- pam_unix
- pam_ldap

passwd komutu yazısında bazı örnekler var
Ayrıca Ubuntuda getty de giriş için PAM'i kullanır


pam_unix
pam_unix'in açıklaması şöyle. /etc/passwd dosyası artık kullanılmadığına göre, /etc/shadow dosyasındaki şifreye göre şifreyi kontrol eder
NAME
   pam_unix - Module for traditional password authentication

SYNOPSIS
   pam_unix.so [...]

DESCRIPTION
   This is the standard Unix authentication module. It uses standard calls
   from the system's libraries to retrieve and set account information as
   well as authentication. Usually this is obtained from the /etc/passwd
   and the /etc/shadow file as well if shadow is enabled.
nullok alanı
Açıklaması şöyle. /etc/shadow dosyasında şire alanı boş ise şifre sormadan giriş yapılabilir
nullok
The default action of this module is to not permit the user access to a service if their official password is blank. The nullok argument overrides this default.

(if it's enabled, and the password is empty, the module doesn't even ask for the password but accepts the login directly.)


getty - Ubuntu İçin Login

Giriş
Açıklaması şöyle
First, you don't log in to a shell, you log in to a (virtual) terminal.
  • a getty program opens a tty port, prompts for a login name and invokes a login program (/bin/login by default - although Linux's agetty may be configured to use a non-standard login program)

  • the login program performs authentication and session setup, including initializing the environment and invoking the user's login shell.
In current Ubuntu systems, getty is managed as a systemd service (ex. getty@tty1.service for the virtual terminal tty1), and login uses the Pluggable Authentication Modules (PAM) subsystem for authentication - in particular, the pam_unix module is "for traditional password authentication".


31 Mart 2022 Perşembe

find komutu permission'a göre arama seçenekleri

Giriş
Açıklaması şöyle
Using -perm, we can find all files with a particular permission combination.
Örnek
Şöyle yaparız.
find ./test -perm 0755
Örnek
Group permission olmayan dosyaları bulmak için şöyle yaparız.
find . \! -perm /g+rwx

find komutu last accessed/modified time'a göre arama seçenekleri

Giriş
Açıklaması şöyle. a ile başlayanlar accessed, c ile başlayanlar changed, m ile başlayanlar modified içindir
Here are all the options for checking access/modify time:

-amin n - the file was last accessed within n minutes ago.
-atime n - the file was last accessed within n days ago.
-cmin n - the file status changed within n minutes ago.
-ctime n - the file status changed within n days ago.
-mmin n - the file was last modified within n minutes ago.
-mtime n - the file was last modified within n days ago.
-anewer file - the searched file was modified more recently than [FILE]. If using -L or -H, and [FILE] is a symbolic link, then the file it points to is used.
-cnewer file - the search for file status changed more recently than [FILE]. If using -L or -H, and [FILE] is a symbolic link, then the file it points to is used. If you add -daystart to the end of any of these, the measurement will be taken from the start of the current day, rather than the current time, 
Burada şu açıklama önemli
Finally, + and - modifications are also available. For instance, -amin -5 will find anything modified in the last 5 minutes, but -amin +5 will find anything modified more than 5 minutes ago.

Modified Seçenekleri
-mmin seçeneği
Son x dakika değiştirmiş dosyaları listeler. Açıklaması şöyle.
-mmin on the other hand can count in minutes. So, if strict accuracy is vital, then -mmin +1440 ( 1440 minutes = 1 day ) could be used instead of -mtime +1
Örnek
Gün başından en fazla 5 dakika önce değiştirilmiş dosyaları bulmak için şöyle yaparız
find . -name "*.txt" -mmin 5 -daystart
-mtime seçeneği
Son x günde değiştirilmiş dosyaları listeler. Birim olarak gün kullandığı için 1.5 gün diye bir şey bilmez. Ya 1 gün ya 2 gün, ya da 3 gün şeklindedir. Açıklaması şöyle
In other words, -mtime can count only in units of 24 hours or one day each so as far as -mtime +1 goes, this means exactly more than one day by at least one day ( ie. two days+ )
Örnek
Şöyle yaparız. Son 6 günden eski dosyaları silmek için şöyle yaparız.
find "$DESDIR" -mtime +6 -type f -delete

find komutu büyüklüğe göre arama seçenekleri

Giriş
Açıklaması şöyle
... the full list of units can be found below:
b - 512-byte blocks (default).
c - just bytes.
w - two-byte words.
k - Kilobytes.
M - Megabytes.
G - Gigabytes.
Örnek
10M'den küçük dosyaları bulmak için şöyle yaparız
find ./test -size -10M

find komutu owner ve group'a göre arama seçenekleri

Giriş
Açıklaması şöyle
Using the -group or -user options, we can also find a directory or file by who owns it, or which group it belongs to.
-group seçeneği
Örnek
Şöyle yaparız
find ./test -group someGroup
- user seçeneği
Örnek
Şöyle yaparız
find ./test -user someOwner
Örnek
Belirtilen kullanıcının sahibi olmadığı dosyaları görmek için şöyle yaparız.
find /directory ! -user myusername -printf "%u %p\n" 

find komutu dosya tipine göre arama seçenekleri

Giriş
Açıklaması şöyle
Since there are many different types of files and directories, it is not always useful to just search for a specific string. If we want to mention the type of file or directory we are looking for, we can specify it with the -type option. To remove ambiguity, we also add the -name option before our search string. You can also just remove the search string entirely, and search for a particular file type.
Dosya tipleri şöyle
A full list of all types can be found below:

b - block devices
c - character devices
d - directory
p - named pipe (FIFO)
f - regular file
l - symbolic link - never used if we use the symbolic link -L option.
s - socket
Örnek - regular file
Şöyle yaparız
find ./test -type f -name "*.txt"
Örnek - symbolic link
Bir dizindeki symbolic linkleri silmek için şöyle yaparız
find /path/to/directory -maxdepth 1 -type l -delete