Linux

Nginx Basic Auth config

Configure location:

    location / {
    auth_basic "closed site";
    auth_basic_user_file htpasswd;
    }

Create password file:

yum install httpd-tools</pre>

New file:

htpasswd -c htpasswd-file "username"

New password:

Append user to existing file:

htpasswd htpasswd-file "username"

Remove old kernels

Current running kernel

uname -an

Show installed kernels:

rpm -q kernel

CentOS 7: Remove old kernels with package-cleanup (yum-utils required)

package-cleanup --oldkernels package-cleanup --oldkernels --count=2

CentOS 8: Remove old kernels with dnf

dnf remove --oldinstallonly
dnf remove --oldinstallonly --setopt installonly_limit=2

Manjaro Linux Open dolphin shortcut

Open Terminal / shell:

kmenuedit

In KDE Menu Editor:
* go to System -> Dolphin
* Context Menu -> Advanced -> Current shortcut key

CentOS Postfix Configuration

Scenario: Homeserver should send e-mails by your ISP-hosted domain:

Packages:

yum -y install postfix

Edit the following lines in the postfix main config:

/etc/postfix/main.cf

mydomain = "MY-DOMAIN"
myorigin = $myhostname
myorigin = $mydomain
inet_interfaces = all
inet_interfaces = localhost
inet_protocols = ipv4
mydestination = $myhostname- localhost.$mydomain- localhost
mynetworks_style = host
relayhost = <STMP.HOST.ADDRESS>:<PORT>
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = smtpd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_type = cyrus
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous

Systemd

Helps for system administration with systemd:

Control and manipulate services

systemctl
systemctl enable [servicename]
systemctl stop/start [servicename]
systemctl disable [servicename]

Remove services from systemd

systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
systemctl daemon-reload
systemctl reset-failed

Sudoers

To give a user rights on a root privileged command:

vi /etc/sudoers
<USER> ALL = NOPASSWD: /bin/systemctl restart httpd

Now the user could restart the httpd deamon:

sudo systemctl restart httpd

Linux Daily admin commands

Postfix:

mailq                 # show queue
postqueue -f          # Resend all queued messages
postsuper -d ALL      # clear message queue
postcat -q            # Show message (-v)

selinux immediately change:

getenforce            # show selinux state
setenforce 0          # turn off selinux

Smtp telnet syntax

telnet <MAILSERVER> 25

HELO <MAILSERVER>

mail from: test-mail@wiki.kissel.ch

rcpt to: receiver@<MAILSERVER>

data
from: test-mail@wiki.kissel.ch
to: receiver@<MAILSERVER>
subject: TestMessage

Hello World!

.

quit

Configure static IP address

Position of the interface configuration files:

/etc/sysconfig/network-scripts

ip addr

shows the names of available interfaces:

enp0s3: <BROADCAST-MULTICAST-UP-LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000
link/ether 08:00:27:66:c7:99 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.40/24 brd 192.168.0.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe66:c799/64 scope link
valid_lft forever preferred_lft forever

Now the config file ifcfg-enp0s3 can be edited with the static config:

TYPE="Ethernet"
NAME="enp0s3"
ONBOOT="yes"
IPADDR="192.168.0.40"  
BOOTPROTO="static" 
GATEWAY="192.168.0.1"