Sıfır bir debian kurduğumuzda temelde yaptığımız bir kaç değişikliğin olması gerekir. Bize ilerde kolaylık sağlayacak olan bu değişiklikleri genellikle temel sunucu ayarları olarak adlandırırız.
Kullanıcı oluşturma
# [stretch] isimli kullanıcı oluşturma
root@debian:~# adduser stretch
Adding user `stretch' ...
Adding new group `stretch' (1001) ...
Adding new user `stretch' (1001) with group `stretch' ...
Creating home directory `/home/stretch' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: # Kullanıcı parolası tanımlama
Retype new UNIX password: # parola onayı
passwd: password updated successfully
Changing the user information for stretch
Enter the new value, or press ENTER for the default
Full Name []: # Bilgiler girilecek
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
root@debian:~#
Kullanıcı yetkilendirme
root@debian:~# usermod -G adm stretch
root@debian:~# nano /etc/pam.d/su
# admin grubuna eklemek için
auth required pam_wheel.so group=adm
Tüm kullanıcılar için Alias tanımlama
root@debian:~# nano /etc/profile
# Bitime aşağıdakini ekle
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# tekrar yükle
root@debian:~# source /etc/profile
Statik IP adresi ayarlama
root@debian:~# nano /etc/network/interfaces
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# Birincil ağ kartı
allow-hotplug ens3
# DHCP ayarını kapatıyoruz
#iface ens3 inet dhcp
# birincil ağ kartında tanımladığımızı yazıyoruz.
iface ens3 inet static
# IP adresimiz
address 10.0.0.30
# network adresimiz
network 10.0.0.0
# subnet mask
netmask 255.255.255.0
# broadcast adresimiz
broadcast 10.0.0.255
# default gateway
gateway 10.0.0.1
# name server
dns-nameservers 10.0.0.10
root@debian:~# reboot
IPv6 gerekli değilse kapatıyoruz.
root@debian:~# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
root@debian:~# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
Servislerin durumunu kontrol etmek için
# Çalışan servislerin listesini gösterir.
root@debian:~# systemctl -t service
UNIT LOAD ACTIVE SUB DESCRIPTION
console-setup.service loaded active exited Set console font and keym
cron.service loaded active running Regular background progra
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
getty@ttyS0.service loaded active running Getty on ttyS0
ifup@ens3.service loaded active exited ifup for ens3
keyboard-setup.service loaded active exited Set the console keyboard
...
...
...
systemd-update-utmp.service loaded active exited Update UTMP about System
systemd-user-sessions.service loaded active exited Permit User Sessions
user@0.service loaded active running User Manager for UID 0
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
28 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
# Tüm servislerin listelenmesi
root@debian:~# systemctl list-unit-files -t service
UNIT FILE STATE
apt-daily-upgrade.service static
apt-daily.service static
autovt@.service enabled
bootlogd.service masked
bootlogs.service masked
bootmisc.service masked
...
...
...
urandom.service static
user@.service static
x11-common.service masked
121 unit files listed.
İhtiyacınız yoksa bir hizmet için otomatik başlatma ayarını durdurun ve KAPATIN.
root@debian:~# systemctl stop atd
root@debian:~# systemctl disable atd
Modulleri güncelleştirme
# listeleri güncelliyoruz
root@debian:~# apt update
Ign:1 http://ftp.de.debian.org/debian stretch InRelease
Get:2 http://ftp.de.debian.org/debian stretch-updates InRelease [88.5 kB]
Hit:3 http://ftp.de.debian.org/debian stretch Release
Get:5 http://security.debian.org/debian-security stretch/updates InRelease [62.9 kB]
Get:6 http://security.debian.org/debian-security stretch/updates/main Sources [24.0 kB]
Get:7 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [43.7 kB]
Get:8 http://security.debian.org/debian-security stretch/updates/main Translation-en [19.0 kB]
Fetched 238 kB in 1s (148 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
# sistemi güncelle
root@debian:~# apt -y upgrade
Bazı kullanıcılar ayrıcalıkları paylaşıyorsa kullanıcıların görevlerini ayırmak için Sudo’yu yapılandırın.
root@debian:~# apt -y install sudo
root@debian:~# visudo
# [stretch] kullanıcısı için tüm yetkilerin verilmesi
stretch ALL=(ALL) ALL
# [Ctrl + x] ile visudodan çıkış yapıyoruz.
Spesifik yetkilerin limitlendirilmesi
root@debian:~# visudo
# makinanın kapatılmasını engellemek
# Cmnd özelliğinden faydalanıyoruz.
Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, \
/sbin/poweroff, /sbin/reboot, /sbin/init, /bin/systemctl
# [SHUTDOWN] ile makinenin kapatılmasını engelliyoruz.
stretch ALL=(ALL) ALL, !SHUTDOWN
Sudo için günlükler /var/log/auth.log içinde tutulur, ancak içinde birçok çeşit log vardır. Yani, bir dosyada sadece sudo kaydını tutmak isterseniz, aşağıdaki gibi bir satır eklemelisiniz.
root@debian:~# visudo
# satır sonuna ekliyoruz
Defaults syslog=local1
Log için tanımlamayı geçerli kılıyoruz.
root@debian:~# vi /etc/rsyslog.conf
# aşağıdaki eklemeyi yapıyoruz
local1.* /var/log/sudo.log
root@debian:~# systemctl restart rsyslog
Bash historyde kullanıcılar için kaydedilen komutların çalıştırıldıkları zaman bilgisinin gösterilmesi
nano /etc/profile.d/bash_history_date.sh
export HISTTIMEFORMAT="%d/%m/%y %T "
Host Yapılandırma
# Hostname'in FQDN (Fully Qualified Domain Name) olması gerekiyor.
root@debian:~# hostname mail.mertcangokgoz.com
# ardından sunucu ip adresiyle alan adı tanımını yapıyoruz.
root@debian:~# nano /etc/hosts
<sunucu_ip_adresi> mail.mertcangokgoz.com
# elle kontrol ediyoruz son durumu
root@debian:~# hostname -f
10.0.0.2 mail.mertcangokgoz.com
Swappiness Ayarlanması
# gereksiz yere swapness aktif olmaması için
root@debian:~# nano /etc/sysctl.conf
vm.swappiness = 1
# ayarın etkinleşmesi için
root@debian:~# sysctl -p