# CLI

# User anlegen und zur sudogruppe hinzufügen

adduser <span style="color: rgb(224, 62, 45); background-color: rgb(0, 0, 0);">USERNAME</span>

/usr/sbin/usermod -aG sudo hubobel

usermod -aG sudo <span style="color: rgb(224, 62, 45); background-color: rgb(0, 0, 0);">USERNAME</span>

# Zeitzone im Terminal ändern

sudo dpkg-reconfigure tzdata

# Sprache im Terminal ändern

sudo dpkg-reconfigure locales

# Debian Version ermitteln

```none
cat /etc/debian_version
```

# fstab prüfen

die geänderte /etc/fstab neu einlesen:

```
systemctl daemon-reload
```

dann auf Fehler prüfen mittels:

```
findmnt --verify
```

# Debian point-Release upgraden

```
apt update
apt full-upgrade
```

# Postfix/Sendmail einrichten

```
apt install -y postfix libsasl2-modules mailutils
```

```
sudo nano /etc/postfix/sasl_passwd
```

```
[smtp.gmail.com]:587 carsten.richter77@googlemail.com:zymrushsucfjulri
```

```
sudo postmap /etc/postfix/sasl_passwd
```

```
sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
```

```
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
```

```
sudo nano /etc/postfix/main.cf
```

```
  GNU nano 7.2                                                                                   /etc/postfix/main.cf                                                                                             
# See /usr/share/postfix/main.cf.dist for a commented, more complete version

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
recipient_delimiter = +

compatibility_level = 2

relayhost = [smtp.gmail.com]:587

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +

inet_interfaces = loopback-only
inet_protocols = ipv4


smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CApath = /etc/ssl/certs
smtpd_tls_CApath = /etc/ssl/certs
smtp_use_tls = yes
```

```
sudo systemctl restart postfix
```

```
sudo systemctl enable postfix
```

```
echo "This email confirms that Postfix is working" | mail -s "Testing Posfix" schneeschieben@hintergasse.de
```

Quelle: [https://blog.wermescher.com/gmail-e-mails-uber-linux-kommandozeile-mittels-postfix/](https://blog.wermescher.com/gmail-e-mails-uber-linux-kommandozeile-mittels-postfix/)

# Emailbenachrichtigung bei SSH-Login

[vorher Postfix/Sendmail konfigurieren](https://wiki.hintergasse.de/link/55#bkmrk-page-title)

```
sudo apt-get install finger
```

```
sudo nano /opt/ssh-login-mail.sh
```

```
#!/bin/bash
echo "Login auf $(hostname) am $(date +%Y-%m-%d) um $(date +%H:%M)" 
echo "Benutzer: $USER" 
echo 
finger
```

```
sudo nano /etc/profile
```

am Ende einfügen:

```
/opt/ssh-login-mail.sh | mail -s "SSH Login auf DEIN SERVERNAME" schneeschieben@hintergasse.de
```

(Servername ändern)

```
sudo chmod 755 /opt/ssh-login-mail.sh
```