# Install & Subscription

Installing RHEL and Rocky Linux, subscriptions and repositories, plus general command-line tips.

# Linux - RHeL Subscription

<p class="callout info">Last verified: October 2026 against Red Hat's registration and Simple Content Access documentation and the RHEL 10.0 release notes.</p>

We encountered the error message ‘*This system is not registered with an entitlement server*, *You can use “rhc” or “subscription-manager*” to register’. On CentOS Stream 9 Linux system while trying to perform package installations. For RHEL, this usually is an indication that your system is not registered with Red Hat’s subscription management service.

```
$ <mark class="has-inline-color has-ast-global-color-7-color">sudo dnf clean all</mark>
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.

21 files removed
```

Here is how we solved the issue on the system. Open the following file for editing:

```
sudo vi /etc/dnf/plugins/subscription-manager.conf
```

Change from `enabled=1` to `enabled=0`:

```
[main]
<mark class="has-inline-color has-ast-global-color-1-color">enabled=0</mark>

# When following option is set to 1, then all repositories defined outside redhat.repo will be disabled
# every time subscription-manager plugin is triggered by dnf or yum
disable_system_repos=0
```

You can then update package cache and try install your packages.

For RHEL system, run the following command to register your system with the Red Hat Subscription Manager:

```
sudo subscription-manager register --username <mark class="has-inline-color has-ast-global-color-1-color"><your_username></mark> --password<mark class="has-inline-color has-ast-global-color-1-color"> <your_password></mark>
```

Remember to replace the username and password with the ones for your Red Hat account. On RHEL 8.8 and later you can also register with `rhc`, using either an activation key or your account:

```
sudo rhc connect --activation-key=<key> --organization=<org_id>
sudo rhc connect --username=<your_username> --password=<your_password>
```

<p class="callout info">No attach step is needed after registering. Simple Content Access is now the default for all Red Hat accounts, so a registered system can use the content its account is entitled to straight away. `subscription-manager attach --auto` from older guides was deprecated in RHEL 9.5 and the attach commands were removed in RHEL 10.</p>

Check that registration was successful:

```
sudo subscription-manager status
```

To enable a specific repository, run:

```
sudo subscription-manager repos --enable=<mark class="has-inline-color has-ast-global-color-1-color"><repository_name></mark>
```

Listing of available repositories can be done using:

```
sudo subscription-manager repos --list
```

Enjoy using your CentOS Stream or Red Hat Enterprise Linux system!.

#### Sources

- [https://docs.redhat.com/en/documentation/subscription\_central/1-latest/html-single/getting\_started\_with\_rhel\_system\_registration/index](https://docs.redhat.com/en/documentation/subscription_central/1-latest/html-single/getting_started_with_rhel_system_registration/index)
- [https://access.redhat.com/articles/simple-content-access](https://access.redhat.com/articles/simple-content-access)
- [https://access.redhat.com/articles/transition\_of\_subscription\_services\_to\_the\_hybrid\_cloud\_console](https://access.redhat.com/articles/transition_of_subscription_services_to_the_hybrid_cloud_console)
- [https://docs.redhat.com/en/documentation/red\_hat\_enterprise\_linux/10/html/10.0\_release\_notes/removed-features](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/10.0_release_notes/removed-features)

# Linux Server - Install RedHat 9 SSH configuration

<p class="callout info">Last verified: October 2026 against Red Hat's RHEL 9 system-wide cryptographic policies guide and the sshd\_config manual.</p>

On Red Hat Enterprise Linux 9 (RHEL 9 / Rocky Linux 9 / AlmaLinux 9 etc.), SSH configuration is primarily managed through system-wide crypto policies. Direct settings in /etc/ssh/sshd\_config for KexAlgorithms, Ciphers, etc., are often ignored unless you properly override the policy.

### 1. Recommended: Add Curve25519 (preferred) and Diffie-Hellman group exchange

**Curve25519-sha256** (and its @libssh.org variant) is already enabled by default in RHEL 9 and is the modern, secure choice.

diffie-hellman-group-exchange-sha256 is also generally available and reasonably secure.

Create a drop-in config. Red Hat's guidance is to use a two-digit prefix smaller than 50 so the file is read before `50-redhat.conf` (which pulls in the crypto policy). sshd uses the **first** value it reads for each keyword:

```bash
sudo mkdir -p /etc/ssh/sshd_config.d
sudo tee /etc/ssh/sshd_config.d/49-custom-kex.conf << EOF
# Only offer these KEX algorithms (the client chooses the order)
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512
EOF
```

### 2. Test the config

```bash
sudo sshd -t
```

If no errors, reload SSH:

```bash
sudo systemctl reload sshd
```

### 3. Temporarily allow legacy algorithms (if needed for old clients/servers)

Legacy algorithms (e.g., SHA-1 based ones like diffie-hellman-group1-sha1 or older group-exchange) are disabled for security.

**Best temporary option** (least impact):

```bash
# Append legacy KEX to OpenSSH's built-in default list
sudo tee /etc/ssh/sshd_config.d/48-legacy-kex.conf << EOF
KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
EOF
```

Because 48-legacy-kex.conf is read first, its KexAlgorithms line is used instead of the one in 49-custom-kex.conf while it exists. Test with `sudo sshd -t`, reload sshd, and delete the file when the old clients are gone.

Or use the broader (but riskier) **LEGACY** crypto policy:

```bash
sudo update-crypto-policies --set LEGACY
sudo reboot
```

**Warning**: LEGACY weakens many other things system-wide (not just SSH). Revert with `sudo update-crypto-policies --set DEFAULT` and reboot when done. Red Hat recommends a reboot after changing the policy so every service picks it up.

### Verification commands

```bash
# Available KEX algorithms
ssh -Q kex

# Effective configuration used by sshd
sudo sshd -T | grep -E '^(kexalgorithms|ciphers|macs)'

# Test connection
ssh -v user@yourserver
```

### Notes for your homelab / self-hosted setup

- Prefer **drop-in files** under /etc/ssh/sshd\_config.d/ (numbered &lt; 50, for example 49-\*.conf, so they are read before Red Hat’s 50-redhat.conf; the first value read wins).
- After any change: sshd -t → systemctl reload sshd.
- If you have specific old clients (e.g., very old Windows, network devices, or RHEL 6-era), the + syntax to append is safest.

#### Sources

- [https://docs.redhat.com/en/documentation/red\_hat\_enterprise\_linux/9/html/security\_hardening/using-the-system-wide-cryptographic-policies\_security-hardening](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/security_hardening/using-the-system-wide-cryptographic-policies_security-hardening)
- [https://man.openbsd.org/sshd\_config](https://man.openbsd.org/sshd_config)

# Linux - Commands to Know

<p class="callout info">Last verified: October 2026 against the current man pages (tar, touch, useradd, userdel, groupadd, groupdel) for RHEL / Rocky Linux.</p>

This is a quick version of commands to be aware of.

#### System information 

`uname -a` : Displays all system information.

`hostnamectl` : Shows current hostname and related details.

`lscpu` : Lists CPU architecture information.

`timedatectl status` : Shows system time.

#### System monitoring and management

`top` : Displays real-time system processes.

`htop` : An interactive process viewer (needs installation; on RHEL / Rocky Linux it comes from the EPEL repository).

`df -h` : Shows disk usage in a human-readable format.

`free -m` : Displays free and used memory in MB.

`kill [PID]` : Terminates a process (sends SIGTERM by default).

#### Running commands 

`<command> &` : Runs command in the background.

`jobs` : Displays background commands.

`fg %1` : Brings background job 1 (number from jobs) to the foreground.

#### Service management

`sudo systemctl start [service]` : Starts a service.

`sudo systemctl stop [service]` : Stops a service

`sudo systemctl status [service]` : Checks the status of a service.

`sudo systemctl reload [service]` : Reloads a service’s configuration without interrupting its operation.

`journalctl -f` : Follows the journal, showing new log messages in real time.

`journalctl -u [unit]` : Displays logs for a specific systemd unit.

#### Cron jobs and scheduling

`crontab -e` : Edits cron jobs for the current user.

`crontab -l` : Lists cron jobs for the current user.

#### File management

`ls` : Lists files and directories.

`touch` : Creates an empty file, or updates the access and modification times of an existing file.

`cp` : Copies files from source to destination.

`mv` : Moves files or renames them.

`rm` : Deletes a file.

#### Directory navigation

`pwd` : Displays the current directory path.

`cd` : Changes the current directory.

`mkdir` : Creates a new directory.

#### File permissions and ownership

`chmod [who][+/-][permissions]` : Changes file permissions.

`chmod u+x` : Makes a file executable by its owner.

`chown [user]:[group] [file]` : Changes file owner and group.

#### Searching and finding

`find [directory] -name` : Finds files and directories.

`grep` : Searches for a pattern in files.

#### Archiving and compression

`tar -czvf [archive].tar.gz [files]` : Compresses files into a tar.gz archive.

`tar -xvf [archive].tar.gz -C [destination]` : Extracts a compressed tar archive into the destination directory.

#### Text editing and processing

`nano` : Opens a file in the Nano text editor.

`cat` : Displays the contents of a file.

`less` : Displays the paginated content of a file.

`head` : Shows the first few lines of a file.

`tail` : Shows the last few lines of a file.

`awk '{print}' [file]` : Prints every line in a file.

#### User management

`w` : Shows which users are logged in.

`sudo useradd [username]` : Creates a new user (Debian / Ubuntu also have the adduser front end).

`sudo userdel [username]` : Deletes a user (add -r to also remove the home directory).

`sudo passwd` : Sets or changes the password for a user.

`su` : Switches user.

`sudo passwd -l` : Locks a user account.

`sudo passwd -u` : Unlocks a user password.

`sudo chage` : Sets user password expiration date.

#### Group management

`id [username]` : Displays user and group IDs.

`groups [username]` : Shows the groups a user belongs to.

`sudo groupadd [group]` : Creates a new group.

`sudo groupdel [group]` : Deletes a group.

#### Sources

- [https://man7.org/linux/man-pages/man1/tar.1.html](https://man7.org/linux/man-pages/man1/tar.1.html)
- [https://man7.org/linux/man-pages/man1/touch.1.html](https://man7.org/linux/man-pages/man1/touch.1.html)
- [https://man7.org/linux/man-pages/man8/useradd.8.html](https://man7.org/linux/man-pages/man8/useradd.8.html)
- [https://man7.org/linux/man-pages/man8/userdel.8.html](https://man7.org/linux/man-pages/man8/userdel.8.html)
- [https://man7.org/linux/man-pages/man8/groupadd.8.html](https://man7.org/linux/man-pages/man8/groupadd.8.html)
- [https://man7.org/linux/man-pages/man8/groupdel.8.html](https://man7.org/linux/man-pages/man8/groupdel.8.html)
- [https://packages.fedoraproject.org/pkgs/htop/htop/](https://packages.fedoraproject.org/pkgs/htop/htop/)

# Linux - Bag of Tricks

## Introduction

This document has many useful command.

### Change Files and Folder Permissions

To change the permissions of files to 655 and subfolders to 755 (which is the common practice for directories to allow execution for navigating into them) within a specified directory and its subdirectories, you can use the `find` command with `chmod`.

Explanation of permissions:

- <div class="zMgcWd dSKvsb" data-il=""><div data-crb-p=""><div class="xFTqob"><div class="Gur8Ad"><span data-huuid="5743926955397761133">**655 for files:**</span></div><div class="vM0jzc">
    - <span data-huuid="5743926955397761748">Owner: Read (4) + Write (2) = 6</span>
    - <span data-huuid="5743926955397762158">Group: Read (4) + Execute (1) = 5</span>
    - <span data-huuid="5743926955397762568">Others: Read (4) + Execute (1) = 5</span>
    
    </div></div></div></div>
- <div class="zMgcWd dSKvsb" data-il=""><div data-crb-p=""><div class="xFTqob"><div class="Gur8Ad"><span data-huuid="5743926955397762978">**755 for directories:**</span></div><div class="vM0jzc">
    - <span data-huuid="5743926955397759497">Owner: Read (4) + Write (2) + Execute (1) = 7</span>
    - <span data-huuid="5743926955397759907">Group: Read (4) + Execute (1) = 5</span>
    - <span data-huuid="5743926955397760317">Others: Read (4) + Execute (1) = 5</span>
    
    </div></div></div></div>

Command

```bash
find /path/to/directory -type f -exec chmod 655 {} +
find /path/to/directory -type d -exec chmod 755 {} +

find /path/to/directory \( -type d -exec chmod 755 {} + \) -o \( -type f -exec chmod 644 {} + \)

chmod -R u+rwX,go+rX,go-w /path/to/directory

find /path/to/directory -type d -print0 | xargs -0 chmod 755
find /path/to/directory -type f -print0   | xargs -0 chmod 644

find /path/to/directory -print0 \
  \( -type d -exec chmod 755 {} + \) \
  -o \( -type f -exec chmod 644 {} + \)
```

### Linux Set Time Examples

You can also simplify format using following syntax:

```shell
date +%Y%m%d -s "20081128"
```

To set time use the following syntax:

```shell
date +%T -s "10:13:13"
```

Use the following syntax to set new data and time:

```shell
date --set="STRING"
```

For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:

```shell
date -s "2 OCT 2006 18:00:00"
```

OR

```shell
date --set="2 OCT 2006 18:00:00"
```

### Rclone Copy Examples

Click here for the page [HERE](https://docs.thehomestack.io/books/linux/page/linux-how-to-use-rclone "rClone")

### Rsync Copy Examples

This is to move files from one server to another

Ending the folder WITHOUT a “/” slash means copy that folder everything in that folder

Ending the folder WITH a “/” slash means copy everything within that folder

Example for “remote to local” location

```shell
rsync -chavzP --stats --progress -e ssh user@remote_host:/remote_folder/dir1/ /local_folder/dir1/
```

Example for “local to remote” location

```shell
rsync -chavzP --stats --progress -e ssh /local_folder/dir1/ user@remote_host:/remote_folder/dir1/
```

### Rsync Auto Login while sending

Example to add a Rsync key on the remote server

On the local server simply login as a given user ex: ROOT or USER

```shell
ssh-keygen -t rsa
```

If it already exists simply hit "n"

<table border="1" id="bkmrk-generating-public%2Fpr" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>Generating public/private rsa key pair.  
Enter file in which to save the key (/root/.ssh/id\_rsa):   
/root/.ssh/id\_rsa already exists.  
Overwrite (y/n)?</td></tr></tbody></table>

If not then simply hit enter through all options

Example: of using ROOT

<table border="1" id="bkmrk-generating-public%2Fpr-1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>Generating public/private rsa key pair.  
Enter file in which to save the key (/root/.ssh/id\_rsa):   
Enter passphrase (empty for no passphrase):   
Enter same passphrase again:   
Your identification has been saved in /root/.ssh/id\_rsa  
Your public key has been saved in /root/.ssh/id\_rsa.pub  
The key fingerprint is:  
SHA256:JoMN/cxvsqZWBHws4eyrU5Q0F0qRe//44qdrrjiQmbU root@client01  
The key's randomart image is:  
+---\[RSA 3072\]----+  
| .+=.. |  
| =B.+ |  
| ..=O |  
| ==+o |  
| = E=... |  
| o... oo |  
| ..o..++ o |  
| .oo+o==\*. |  
+----\[SHA256\]-----+  
You have mail in /var/spool/mail/root</td></tr></tbody></table>

Run the following to add the key to the remote server, you can also use IP instead of host name

```shell
ssh-copy-id -i ~/.ssh/id_rsa.pub remuser@server01
```

Example of using a USER you will have to enter yes and the USER password

<table border="1" id="bkmrk-%2Fusr%2Fbin%2Fssh-copy-id" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id\_rsa.pub"  
The authenticity of host 'server02 (192.168.x.x)' can't be established.  
ED25519 key fingerprint is SHA256:oZnvrgY+2Xpd2/huaffvzLMBAgI52AMPUmq/LPLIXbE.  
This key is not known by any other names  
Are you sure you want to continue connecting (yes/no/\[fingerprint\])?<span style="color: rgb(241, 196, 15);"> yes</span>  
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed  
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys  
r<span style="color: rgb(241, 196, 15);">emuser@server02's password: </span>  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified  
tput: No value for $TERM and no -T specified

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'remuser@server02'"  
and check to make sure that only the key(s) you wanted were added.

</td></tr></tbody></table>

<span style="color: rgb(241, 196, 15);">Optional:</span> If the command cannot be run above you can copy the key to the remote server manually into the “authorized\_keys” file

```shell
cd
cd .ssh
vi authrized_keys
```

<span style="color: rgb(241, 196, 15);">Optional:</span> Change the permissions on the local server

```shell
chmod 600 ~/.ssh/*
chmod 711 ~/.ssh
chmod 711 ~
```

### Synology Rsync

```shell
rsync -aXHmS --syno-acl /volum1/[xxx] /volume2/[xxx]
```

-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)  
-p, --perms preserve permissions  
-X, --xattrs preserve extended attributes  
-o, --owner preserve owner (super-user only)  
-g, --group preserve group  
\--syno-acl copy Synology ACL data

I use the following options myself:  
rsync -avhxWog --stats --backup --suffix $OLDSUFFIX --exclude-from=$RSYEXCL --syno-pseudo-root

No idea why I list options "og" since they're implied by -a, but it works...

Regards, Arild  
PS: "rsync --help" lists all available options for rsync

### Find and Replace String with <span class="code" spellcheck="false">sed</span>

There are several versions of <span class="code" spellcheck="false">sed</span>, with some functional differences between them. macOS uses the BSD version, while most Linux distributions come with GNU <span class="code" spellcheck="false">sed</span> pre-installed by default. We’ll use the GNU version.

The general form of searching and replacing text using <span class="code" spellcheck="false">sed</span> takes the following form:

```shell
sed -i 's/SEARCH_REGEX/REPLACEMENT/g' INPUTFILE
```

<span class="fabric-text-color-mark" data-text-custom-color="#ffffff">Cop</span>

- <span class="code" spellcheck="false">-i</span> - By default, <span class="code" spellcheck="false">sed</span> writes its output to the standard output. This option tells <span class="code" spellcheck="false">sed</span> to edit files in place. If an extension is supplied (ex -i.bak), a backup of the original file is created.
- <span class="code" spellcheck="false">s</span> - The substitute command, probably the most used command in sed.
- <span class="code" spellcheck="false">/ / /</span> - Delimiter character. It can be any character but usually the slash (<span class="code" spellcheck="false">/</span>) character is used.
- <span class="code" spellcheck="false">SEARCH\_REGEX</span> - Normal string or a regular expression to search for.
- <span class="code" spellcheck="false">REPLACEMENT</span> - The replacement string.
- <span class="code" spellcheck="false">g</span> - Global replacement flag. By default, <span class="code" spellcheck="false">sed</span> reads the file line by line and changes only the first occurrence of the <span class="code" spellcheck="false">SEARCH\_REGEX</span> on a line. When the replacement flag is provided, all occurrences are replaced.
- <span class="code" spellcheck="false">INPUTFILE</span> - The name of the file on which you want to run the command.

### Find and Replace String with <span class="code" spellcheck="false">sed</span> within <span class="code" spellcheck="false">vi</span>

This is to search and replace a file globally withing vi

```shell
:%s/search_string/replacement_string/g
```

### Kill Users in Linux

This is to be used when trying to kill users using the connection, replace the ? with the number of the session.

```shell
pkill -KILL -t pts/?
```

<p class="callout info">Continued in [Linux - Bag of Tricks (Part 2): Certificates, Databases, Disks &amp; Boot](https://docs.thehomestack.io/books/linux/page/linux-bag-of-tricks-part-2-certificates-databases-disks-boot).</p>

# Linux - Bag of Tricks (Part 2): Certificates, Databases, Disks & Boot

<p class="callout info">This page continues [Linux - Bag of Tricks](https://docs.thehomestack.io/books/linux/page/linux-bag-of-tricks).</p>

### Create a CERT

First, you need to generate the private key and the Certificate Signing Request (CSR). You can do this via the <span class="code" spellcheck="false">openssl</span> command:

```shell
openssl req -nodes -newkey rsa:2048 -keyout privatekey.key -out mail.csr  
```

Then, generate a signing request

```shell
openssl x509 -req -days 365 -in mail.csr -signkey privatekey.key -out secure.crt
```

Create a localhost cert on the server

```shell
openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt
```

#### Mariadb Log Rotate

If log file is large, try if the logrotate

<span lang="FR-CA" style="mso-ansi-language: FR-CA;">logrotate --force /etc/logrotate.d/mariadb</span>

#### MySQL Fail to Start

If MySQL does not restart, it probably will not as the index of the log files will not be changed

<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" id="bkmrk-cd-%2Fvar%2Flib%2Fmysqlmv-" style="width: 580.5pt; margin-left: -9.5pt; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in;" width="774"><tbody><tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;"><td style="width: 580.5pt; border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;" valign="top" width="774">cd /var/lib/mysql  
mv ib\_logfile0 ib\_logfile0.old  
mv ib\_logfile1 ib\_logfile1.old  
systemctl restart mariadb

</td></tr></tbody></table>

<span style="mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri;"> </span>

#### Configure Rsync

<span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">Useful for system migrations</span>

<span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">Create a “</span><span style="mso-bookmark: OLE_LINK22;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">/etc/rsyncd.conf</span></span><span style="mso-bookmark: OLE_LINK22;"><span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">” </span></span><span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">containing:</span>

<span style="mso-bookmark: OLE_LINK24;"><span lang="FR-CA" style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: FR-CA; mso-bidi-font-weight: bold;">\[root\]</span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span lang="FR-CA" style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: FR-CA; mso-bidi-font-weight: bold;">exclude = <span style="mso-bookmark: OLE_LINK142;">/dev /etc/fstab /proc /sys</span></span></span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span style="mso-bookmark: OLE_LINK144;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">path = /</span></span></span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span style="mso-bookmark: OLE_LINK145;"><span style="mso-bookmark: OLE_LINK144;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">read only = yes</span></span></span></span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span style="mso-bookmark: OLE_LINK145;"><span style="mso-bookmark: OLE_LINK144;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">list = yes</span></span></span></span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">uid = root</span></span></span>

<span style="mso-bookmark: OLE_LINK25;"><span style="mso-bookmark: OLE_LINK24;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">gid = root</span></span></span>

<span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;"> </span>

<span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">Enable and start:</span>

<span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">systemctl enable rsyncd.service </span>

<span style="mso-bookmark: OLE_LINK39;"><span style="mso-bookmark: OLE_LINK26;"><span style="font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-weight: bold;">systemctl start rsyncd.service<span style="mso-spacerun: yes;"> </span></span></span></span>

#### Change Run level

<span style="mso-bookmark: OLE_LINK136;"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">systemctl set-default multi-user.target</span></span>

To switch from graphical to multi-user:

<span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">systemctl isolate multi-user.target;</span>

#### Change Local settings

<span style="font-family: Consolas;">\# timedatectl set-timezone Europe/London<span style="mso-spacerun: yes;"> </span></span>

<span style="font-family: Consolas;">\# localectl set-locale LANG=en\_GB.UTF-8</span>

<span style="font-family: Consolas;">\# localectl set-keymap uk</span>

Temporary change

$ loadkeys us

#### Configure Alternate Authentication

<span style="mso-bookmark: OLE_LINK67;"><span style="mso-bookmark: OLE_LINK66;">authconfig-tui</span></span>

#### <span style="mso-bookmark: _Hlk96703517;">SSD Considerations</span>

<span style="mso-bookmark: _Hlk96703517;">Change the value of “</span><span style="mso-bookmark: _Hlk96703517;">`<span style="font-size: 10.0pt; line-height: 107%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">issue_discards”</span>` option from 0 to 1 in “</span><span style="mso-bookmark: _Hlk96703517;">`<span style="font-size: 10.0pt; line-height: 107%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">/etc/lvm/lvm.conf”</span>`</span>

<span style="mso-bookmark: _Hlk96703517;">`<span style="font-size: 10.0pt; line-height: 107%; font-family: Consolas; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">#systemctl enable fstrim.timer</span>`</span>

<span style="mso-bookmark: _Hlk96703517;"><span style="mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">Adjust “/etc/fstab</span></span><span style="mso-bookmark: _Hlk96703517;"><span style="font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">”</span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-bidi-font-weight: bold;">/dev/mapper/xxx /XXX<span style="mso-spacerun: yes;"> </span>xfs<span style="mso-spacerun: yes;"> </span>defaults<span style="background: yellow; mso-highlight: yellow;">,noatime,discard</span><span style="mso-spacerun: yes;"> </span>0 0</span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st">Optionally set /tmp in RAM</span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-weight: bold;">\# systemctl enable tmp.mount</span></span></span>

#### <span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="mso-bidi-font-weight: bold;">Adding a Disk</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="mso-bookmark: OLE_LINK109;"><span class="st"><span style="font-family: Consolas;">\# parted /dev/sdx</span></span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"> </span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="mso-bookmark: OLE_LINK111;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">mklabel gpt</span></span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="mso-bookmark: OLE_LINK112;"><span style="mso-bookmark: OLE_LINK111;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">unit s</span></span></span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="mso-bookmark: OLE_LINK112;"><span style="mso-bookmark: OLE_LINK111;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">mkpart primary 2048s 100%</span></span></span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">set 1 lvm on</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">quit</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: 'Courier New';"> </span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">\# pvcreate /dev/sdx1</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span style="font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New';">\# vgcreate rl\_ssd /dev/sdx1</span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">\# lvcreate –L 50GB -n mysql rl\_</span></span></span><span style="mso-bookmark: _Hlk96703517;"><span style="font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New';">ssd</span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">\# mkfs.xfs /dev/</span></span></span><span style="mso-bookmark: _Hlk96703517;"><span style="font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New';">rl-ssd</span></span><span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas; mso-bidi-font-family: 'Courier New';">/mysql</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas;">\# blkid /dev/sdc</span></span></span>

<span style="mso-bookmark: _Hlk96703517;"><span class="st"><span style="font-family: Consolas;">\# chown mysql:mysql /var/lib/mysql</span></span></span>

#### <span class="st">Growing a lvm partition</span>

<span class="st"><span style="font-family: Consolas;">\# parted /dev/sdc</span></span>

<span class="st"><span style="font-family: Consolas;"> </span></span>

<span class="st"><span style="font-family: Consolas;">(parted) unit b</span></span>

<span class="st"><span style="font-family: Consolas;">(parted) print free</span></span>

<span class="st"><span style="font-family: Consolas;">Number<span style="mso-spacerun: yes;"> </span>Start<span style="mso-spacerun: yes;"> </span>End<span style="mso-spacerun: yes;"> </span>Size<span style="mso-spacerun: yes;"> </span>Type<span style="mso-spacerun: yes;"> </span>File system<span style="mso-spacerun: yes;"> </span>Flags</span></span>

<span class="st"><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>1<span style="mso-spacerun: yes;"> </span>31744B<span style="mso-spacerun: yes;"> </span>5368709119B<span style="mso-spacerun: yes;"> </span>5368677376B<span style="mso-spacerun: yes;"> </span>primary</span></span>

<span class="st"><span style="font-family: Consolas;"><span style="mso-spacerun: yes;"> </span>5368709120B<span style="mso-spacerun: yes;"> </span>21474836479B<span style="mso-spacerun: yes;"> </span>16106127360B<span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>Free Space</span></span>

<span class="st"><span style="font-family: Consolas;">(parted) resizepart 1<span style="mso-spacerun: yes;"> </span>21474836479B</span></span>

<span class="st"><span style="font-family: Consolas;">(parted) quit</span></span>

<span class="st"><span style="font-family: Consolas;"> </span></span>

<span class="st"><span style="font-family: Consolas;">\# pvresize /dev/sdc1</span></span>

**<span style="font-size: 16.0pt; line-height: 107%;"> </span>**

<span class="st"> </span>

#### <span class="st">**Updating Bootloader configuration**</span>

<span class="st">/etc/default/grub</span>

<span class="st">grub2-mkconfig -o /boot/grub2/grub.cfg</span>

NMAP Scan for all Open Ports

TCP

```shell
sudo nmap -sT -p- example.com
```

UDP

```shell
sudo nmap -sU -p- example.com
```

Look for open Ports

```bash
nc -vz 203.0.113.10 514
```

Trace route

```bash
sudo tracepath 203.0.113.10
```

Looking at the Journal, this is an example to look at the mariadb process

```bash
journalctl -u mariadb -f
```

Search in sub folders

```bash
grep -r "MYSQL_HOST" . --include="compose.yaml" --include="docker-compose.yml"
```

Change Lines in KIDSENV and make a backup of it with a .bak extentions

```bash
find . -type f -name "KIDSENV" -exec sed -i.bak 's/^KWSQL_LOG=query/#KWSQL_LOG=query/' {} +
```

Delete file on the server

```bash
find . -type f \( -name "SQLQRY*" -o -name "SQLINFO" -o -name "SQLERROR" \) -delete
```

Delete files over 100M

```bash
find . -type f -size +100M
```

Delete files over 100M and list them

```bash
find . -type f -size +100M -exec ls -lh {} +
```

Grep files named TX\*.DA that are only 1 month back and files lines that have RETDT or RETHD

```bash
find . -type f -name "TX*.DA" -mtime -30 -exec grep -iE "RETDT|RETHD" {} +
```

Remove certain directory

```
find /path/to/drive/root -type d -name "@eaDir" -print0 | xargs -0 rm -rf
```

# Command - Cmnd_Alias

<p class="callout info">Last verified: October 2026 against the sudoers manual (sudo.ws).</p>

### What is Cmnd\_Alias?

Cmnd\_Alias (Command Alias) is a feature in /etc/sudoers (and files in /etc/sudoers.d/) that lets you **group multiple commands** under a single, easy-to-read name.

Instead of repeating long command paths many times, you define the group once and then reference the alias name in your user permission rules. This makes the sudoers configuration:

- Much cleaner and more readable
- Easier to maintain (add/remove commands in one place)
- Less error-prone

It is one of four main alias types in sudoers:

- User\_Alias — groups of users
- Host\_Alias — groups of hosts
- Runas\_Alias — groups of users to run as
- **Cmnd\_Alias** — groups of commands (this one)

### Basic Syntax

```bash
Cmnd_Alias  ALIAS_NAME = /full/path/to/command1, \
                       /full/path/to/command2 arg1 arg2, \
                       /full/path/to/command3
```

Rules:

- Alias name **must** start with a capital letter and can contain uppercase letters, numbers, and underscores (e.g., API\_SERVICE, SYSTEMCTL\_API).
- Always use **full absolute paths** to commands (never just systemctl).
- You can continue long lines with a backslash \\.
- You can include other Cmnd\_Alias names inside another one.

### Example for Your api.service (Recommended Version)

Create or edit the file with `sudo visudo -f /etc/sudoers.d/10-deploy-api`:

```bash
# Command alias for managing the api.service safely
Cmnd_Alias API_SERVICE_CMDS = /usr/bin/systemctl start api.service, \
                             /usr/bin/systemctl stop api.service, \
                             /usr/bin/systemctl restart api.service, \
                             /usr/bin/systemctl status api.service

# Grant the deploy user passwordless access to only these commands
deployuser ALL=(ALL) NOPASSWD: API_SERVICE_CMDS
```

This is cleaner than listing the four commands directly on the user line.

### More Flexible Example (Allow Any Action on the Specific Service)

If you want the deploy user to run **several** systemctl actions on api.service, do **not** use a wildcard such as `/usr/bin/systemctl * api.service`. In sudoers, wildcards in command arguments match any characters, including spaces, so that rule does not limit the user to api.service. It also matches, for example, `systemctl stop sshd.service api.service` or `systemctl edit api.service` (which opens an editor as root).

List each allowed command explicitly (as in the example above), or on sudo 1.9.10 and later (check with `sudo -V`) use a regular expression, which must start with `^` and end with `$`:

```bash
Cmnd_Alias API_SERVICE_CMDS = /usr/bin/systemctl ^(start|stop|restart|reload|status) api\.service$

deployuser ALL=(ALL) NOPASSWD: API_SERVICE_CMDS
```

This allows only the listed actions on api.service.

### How to Use It in Your Setup

- Create the file:

```bash
sudo visudo -f /etc/sudoers.d/10-deploy-api
```

- Paste the Cmnd\_Alias + user rule above.
- Set correct permissions:

```bash
sudo chmod 0440 /etc/sudoers.d/10-deploy-api
```

- Test it:

```bash
sudo -l -U deployuser
```

1. You should see the allowed commands listed for deployuser.

Then update your PowerShell script to use deployuser (instead of root).

### Why This Is Better Than the Original Line

Your original line:

```bash
deployuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop api.service, /usr/bin/systemctl restart api.service, /usr/bin/systemctl status api.service
```

Works fine, but using Cmnd\_Alias is preferred when:

- You have more than 2–3 commands
- You might want to add more actions later
- You manage multiple services (you can create one alias per service)

#### Sources

- [https://www.sudo.ws/docs/man/sudoers.man/](https://www.sudo.ws/docs/man/sudoers.man/)