Set up GNU/Linux on a VM to learn about LVM, sudo/password policy and user management
Project description
This is a project I did to run-through some system administration jobs; that is:
- running GNU/Linux on a virtual machine
- Logical Volume Manager (LVM)
- password policy
- sudo policy
- user management
- lighttpd
- mariaDB
Set up with:
- virt-manager
- debian libre
What’s a LVM?
A Logical Volume Manager (LVM) allows dynamic management of partition. That is, the size of a partition can be modified after the installation. For example, if root is running of space, the user can expand the size of root while shriking the size of home. Other attributes:
- backup one logical volume at a time
- encrypt multiple physical partitions with a single password
Why partition?
Don’t put all your eggs in the same basket: e.g. if the root partition becomes corrupted only that partition is affected, not the whole system.
Primary vs logical partitions
Legacy. Historically, 4 primary partitions only could be created.
To bypass this limit, extended partitions, that can contain as many partitions, called logical partitions, were created.
Source: Linux System Administrators Guide: Chapter 5. Using Disks and Other Storage Media, 5.9.2 Extended and logical partitions; https://tldp.org/LDP/sag/html/partitions.html
We have one primary partition: /boot # “contains everything required for the boot process” ex. config files
Partition of the logical volume
- /root # home directory of the system adminstrator
- swap
- /home # director of a specific user
- /var # to store variable data files e.g. log, caches, temporary files
- /srv
- /tmp # some programs write temporary files here.
- /var-log
What is swap?
“swap area—a reserved area of disk space used to supplement the computer’s RAM” — The Linux Programming inTerface A Linux and UNIX System Programming Handbook, Michael Kerrisk, p.119
Instructions
Download the operating system
wget the iso file from a debian mirror and check the integrity of the file.
$ wget https://gitlab.com/api/v4/projects/74667529/packages/generic/debian-libre-live/13.2.0/debian-live-13.2.0-arm64-libre-slim.iso
$ wget https://gitlab.com/api/v4/projects/74667529/packages/generic/debian-libre-live/13.2.0/debian-live-13.2.0-arm64-libre-slim.iso.SHA256SUM
$ sha256sum -c debian-live-13.2.0-arm64-libre-slim.iso.SHA256SUM
Expected output:
debian-live-13.2.0-arm64-libre-slim.iso: OK
Setting up the LVM
Install Debian
After setting up languages etc:
- select
Manualfor partitioning method. - select
SCSI (0, 0, 0) sda … HARDDISK. - select
Yes - select
Create a new partition - we enter
500MBfor/bootwhich we won’t encrypt - select
Primary# see diff between primary and logical below - select
Beginning - change
Mount pointto/boot - select
FREE SPACEto create a new partition - select
Create a new partition - select
Logicalas we will create multiple volumes # see diff between primary and logical below - change
Mount pointtonone, we will create a mount point for each volume - select
Configure encrypted volumesto create volumes inside the second partition - select
Create encrypted volumes - select
/dev/sda5, i.e. the logical volume only (not/boot) - select
Done setting the partition - select
Finish - select
Yes - select
Yes - select
Configure the LVM - select
Create volume group - assign the encrypted logical partition to this volume group
- select
Create logical volume - select
Select the LVM - write the name of the first logical volume you want to create i.e.
root - select the size of the volume # check the subjet for examples
- repeat the last 4 steps for each logical volume
- you can see where you are at by selecting
Display configuration details - when you have created all the logical volume, select
Finish
Now we set the type of each logical volume and mount them.
- select the
/homelogical volume - select
Use as: - select
Ext 4 journaling file system, that is the type - then we mount it on
/home - repeat the above 4 points for each of the volume; for
swapselect typeswap; for var-log set the mount point manually, type/var/log
Finish the install
- skip through the proxy, survey etc.
- unselect
Debian Desktop EnvironmentandGNOME— we do not want a graphical interface - install GRUB, the bootload, on your primary partition.
You should be able to log in the VM.
Run $ lsblk to see the logical volumes.
Install sudo
We need to get root access.
To do so, we run:
$ sudo -
Enter sudo’s password.
Now, to install sudo, we run:
# apt install sudo
We can check sudo is installed by running:
# apt list sudo
We exist sudo mode:
# exit
$
Install Vim
$ sudo apt install vim
Make Vim the default editor (instead of Nano):
$ sudo update-alternatives --config editor
And select /usr/bin/vim.basic.
Set up connection via SSH from host to guest
In the network settings of the virtual machine set up port forwarding host to, say, 2222, and guest to 4242, so you can connect from host to VM via port 2222.
On the tty of the virtual machine, install SSH:
$ su -
# apt install ssh
# apt install openssh-server
I read that when you install ssh on a server, it’s started and enabled automatically, but just in case:
# systemctl start ssh
# systemctl enable ssh
Verify that SSH is running:
# systemctl status ssh | grep Active
Then we set the SSH port to Port 4242.
In /etc/ssh/sshd_config, instead or:
# Port 22
Uncomment Port and set it to 4242:
Port 4242
On the virtual machine, set up a SSH port forwarding rule under TCP with host IP 127.0.0.1, host port 2222 and guest port 4242.
We can check that the VM is listening on post 4242:
$ ss -tln | grep 4242
- -t is to display TCP socket
- -l is to tell ss to listen
- -n show bandwidth values
Now, on the host, we can connect to the VM via SSH by running:
$ ssh -p 2222 username@localhost
-p is the SSH post on the host
As far as I understand, localhost tells SSH to scan for machines listening on localhost; our VM listens on port 4242, for SSH.
If successful, the host should prompt you to verify the fingerprint of the VM, then enter your usernname password.
Check that the fingerprint is the right one, on the VM, run:
$ ssh-keygen -lf /etc/ssh/path/to/pubkey
To do so, run
$ sudo vi /etc/ssh/sshd_config.d/\*.conf</code>
We can copy the public of our host to the VM by running so that we don’t have to enter passwords to log in via SSH:
https://yctct.com/ssh-show-keyfingerprint
$ ssh-copy-id -p 2222 username@localhost
You should be able to connect to the guest from the host via SSH with:
$ ssh -p 2222 username@localhost
Next we disable root login via SSH
Disable Root login via SSH
The information to do so is in:
$ man sshd_config
Then search for PermitRootLogin.
To disable Root login via SSH set PermitRootLogin to no in /etc/ssh/sshd_config.
Add super user (sudo) privilege to a user
Display user with sudo privilege:
$ getent group sudo
sudo:x:27
or
# cat /etc/group | grep ^sudo
sudo:x:27
The second field is the for the group password, which I read is unused in modern Linux system. x is a placeholder. 27 is the group id.
To grant sudo to a user we run:
# usermod -a -G sudo username
We use usermod to append, -a, username to the group, -G, sudo .
Log out and SSH again for the username to have sudo privilege.
$ exit
$ ssh -p 2222 username@localhost
Install man pages
We first need to install man-db so we can read the manpages we’ll need.
$ sudo apt install man-bd
Other man packages: manpages-posix manpages-dev manpages-posix-dev.
Install and set up UFW (Uncomplicated Fire Wall)
To install ufw run:
$ sudo apt install ufw
Add rule to open port 4242:
$ sudo ufw allow 4242
so you can still log via SSH. Make sure you set up SSH first.
Enable UFW:
$ sudo ufw enable
Check status
$ sudo ufw status
Modify hostname
To display hostname run: ud $ hostname
To modify hostname:
$ sudo hostamectl set-hostname [hostname]
and check that the hostname in the file /etc/hostname has been updated.
Reboot machine.
The hostname should be updated.
Set up password policy
See the password policy in Project Description.
To set up the password policy update /etc/login.defs with the following values:
PASS_WARN_AGE 30
PASS_MIN_DAYS 2
PASS_WARN_AGE 7
See:
$ man login.defs
Please note that:
Any changes to these settings won’t affect existing accounts.
That is from the man pages of login.defs.
So we need to update the password policy for existing users. To do so, we use the command chage to so.
See:
$ man chage
First, you can display the current password policy by running:
$ chage -l username
To update the password policy run:
$ chage --maxdays 30 username
$ chage --mindays 2 username
To implement the rest of the password policy, we use PAM.
PAM (Pluggable Authentication Modules) allows system adminstrators to control how applications authenticate users.
To find the PAM package we need using apropos password | grep pam:
pam_pwhistory (8) - PAM module to remember last passwords
pam_pwquality (8) - PAM module to perform password quality checking
pam_systemd_loadkey (8) - Read password from kernel keyring and set it as PAM authtok
pam_unix (8) - Module for traditional password authentication
From the man page of pam_pwquality:
The action of this module is to prompt the user for a password and check its strength against a system dictionary and a set of rules for identifying poor choices.
The first action is to prompt for a single password, check its strength and then, if it is considered strong, prompt for the password a second time (to verify that it was typed correctly on the first occasion). All being well, the password is passed on to subsequent modules to be installed as the new authentication token.
To find the name of the package we can run:
# sudo apt list *pwquality* | grep pam
libpam-pwquality/stable,now 1.4.5-5 amd64 [installed]
To install the package libpam-pwquality we run:
$ sudo apt install libpam-pwquality
Now we look at OPTIONS in the man page find options we need for our password policy.
- minlen=10: Must be at least 10 characters long.
- lcredit=-1: Must contain at least one lowercase character.
- ucredit=-1: Must contain at least one uppercase character.
- dcredit=-1: Must contain at least one digit.
- maxrepeat=3: Must not contain more than 3 consecutive identical characters.
- reject_username: Must not include the username.
- enforce_for_root: Must apply to the root password
In the man page of pwquality.conf we can read that, usercheck, the option that checks that the password does not contain the username, is enabled by default.
The difok=7 rule does not apply to the root password because, from the man page:
Note that root is not asked for an old password so the checks that compare the old and new password are not performed.
Now we edit the configuration files. Before this we backup the current configuration directory:
$ sudo mkdir /etc/pam.d/backup
$ sudo cp -r /ect/ect/pam.d/* /etc/pam.d/backup
Then we append the primary block of /etc/pam.d/common-password with the above rule, we end up with:
password requisite pam_pwquality.so retry=3 minlen=10 lcredit=-1 ucredit=-1 dcredit=-1 maxrepeat=3 difok=7 enforce_for_root reject_username
Now we want to test if the password policy took effect.
We use $ apropos with keywords to look for a package to change passwords
$ apropos -a change password
chage (1) - change user password expiry information
passwd (1) - change user password
Creating users
We can user useradd or adduser.
adduser is a wrapper for useradd which creates /home automatically, amongst many other things (you can see the script by running $ sudo cat $(type adduser)).
With useradd, we have to create /home manually.
To create a new user and its /home directory we run:
$ sudo useradd -m username
or
$ sudo adduser username # a wrapper for useradd
To set up the password for the new user we run:
$ sudo passwd username
To switch to the new user we run:
$ su username
Check what the ownership of /home is, run:
$ ls -l
To update the ownership run:
$ sudo chown -R $USER:$USER username
To list all users run:
$ cat /etc/passwd | cut -d ':' -f 1
Delete users
$ sudo userdel username
Create a group
We look for the command:
$ apropos -a add group
addgroup (8) - add or manipulate users or groups
adduser (8) - add or manipulate users or groups
adduser.conf (5) - configuration file for adduser (8) and addgroup (8)
groupadd (8) - create a new group
vgextend (8) - Add physical volumes to a volume group
and check the syntax to create a group in $ man groupadd.
To create a group, run:
$ sudo groupadd groupname
To check that the group exist, we query the file /etc/group/ with getent:
$ getent group | grep groupname | cut -d ':' -f 1
which should print the name of the group.
Add user to a group
To add a user to a group run:
$ sudo usermod -a -G group username
This command appends, -a, username to the group, -G, group.
See the list of groups a user is in
To check whether the user was added, run:
$ sudo groups username
to list all the groups a user is part of.
Set up sudo policy
From man sudo we can read:
The default security policy is sudoers, which is configured via the file /etc/sudoers, or via LDAP.
We can also use apropos to see what comes up for the the keywords sudo and policy.
$ apropos -a sudo policy
sudoers (5) - default sudo security policy plugin
Then:
$ man sudoers
Under the OPTIONS section, we can read:
- The option
insults“will insult users when then enter an incorrect passowrd”. - The option
log_inputwill “log all user input.”
- The option
log_outputwill “log all user output.”
- The option
logfilesets the “path to the sudo log file”. - The option
requiretty“If set, sudo will only run when the user is logged in to a reall tty.” - The option
passwd_trieswill set the maximum number of tries before the user is not allowed to run the command.
We will add these options in /etc/sudoers.d/mysudoers, and not in the file /etc/sudoers, because the package manager might override the file /etc/sudoers when it updates our system.
NB: do not add a . in the name of your custom sudoers file.
One more thing, we edit /etc/sudoers.d/mysudoers with the command visudo -f. The option -f “specif[ies] an alternate sudoers file location”.
Read the first 2 paragrpahs of the man page of visudo to learn how visudo behaves when there are issues with your sudo configuration.
So, in /etc/sudoers.d/mysudoers we add:
Defaults log_input
Defaults log_output
Defaults logfile=/var/log/sudo/sudo.log
Defaults requiretty
Defaults passwd_tries=3
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
After editing we can check that there are no syntax errors with the -c flag:
$ sudo visudo -c
/etc/sudoers: parsed OK
/etc/sudoers.d/README: parsed OK
/etc/sudoers.d/mysudoers: parsed OK
We reboot for the configuration to be taken into consideration.
You can run sudo -l to print the sudo configuration.
$ sudo -l
Matching Defaults entries for username on hostname:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty, insults,
log_input, log_output, logfile=/var/log/sudo/sudo.log, requiretty, passwd_tries=3,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User username may run the following commands on hostname:
(ALL : ALL) ALL
We can check that sudo activities are logged:
$ sudo tail /var/log/sudo/sudo.log
Jan 9 16:18:21 : username : TTY=tty1 ; PWD=/home/username ; USER=root ;
TSID=000001 ; COMMAND=/usr/sbin/reboot
Jan 9 16:20:54 : username : TTY=pts/0 ; PWD=/home/username ; USER=root ;
TSID=000002 ; COMMAND=/usr/bin/less /etc/sudoers
Jan 9 16:30:35 : username : TTY=pts/0 ; PWD=/home/username ; USER=root ;
TSID=000003 ; COMMAND=/usr/bin/tail /var/log/sudo/sudo.log
We can test the insult option:
$ sudo visudo /etc/sudoers.d/mysudoers
[sudo] password for username:
That is no basis for supreme executive power!
We can test the option requiretty by running sudo via SSH:
$ ssh -p 2222 username@localhost sudo -l
sudo: sorry, you must have a tty to run sudo
Monitor system’s information
We want the script monitoring.sh to display the following:
- The architecture of your operating system and its kernel version.
- The number of physical processors.
- The number of virtual processors.
- The current available RAM on your server and its utilization rate as a percentage.
- The current available storage on your server and its utilization rate as a percentage.
- The current utilization rate of your processors as a percentage.
- The date and time of the last reboot.
- Whether LVM is active or not.
- The number of active connections.
- The number of users using the server.
- The IPv4 address of your server and its MAC (Media Access Control) address.
- The number of commands executed with the sudo program.
Redirecting errors tno /dev/null
Note that apply to all commands I wrote: if the command output an error it is redirected to /dev/null/.
Display the architecture and kernel version
We know uname but we can also look for other utility to display arch and kernel version.
To look for a command to display so we run:
$ apropos -a print arch
arch (1) - print machine hardware name (same as uname -m)
$ apropos -a display arch
lscpu (1) - display information about the CPU architecture
We wil use arch as it only prints the machine architecture.
To display kernel version, we use uname -r.
The number of physical and virtual processors.
See: nproc, lscpu, /proc/cpuinfo
My understanding: in /proc/cpuinfo each virtual process is counted as processor e.g.:
$ grep processor /proc/cpuinfo/ | head
processor : 0
processor : 1
processor : 2
processor : 3
processor : 4
processor : 5
processor : 6
processor : 7
processor : 8
processor : 9
and each physical process is present under its own id physical id, e.g.:
$ grep 'physical id' /proc/cpuinfo/ | head
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
physical id : 0
which is just showing the same physical id; i.e. its id is 0.
To print the total number of physical processors, we use:
$ grep 'physical id' /proc/cpuinfo/ | uniq | wc -l
1
To print the total number of virtual processors, we use:
$ grep processor /proc/cpuinfo/ | uniq | wc -l
24
Display the current available RAM on your server and its utilization rate as a percentage
$ apropos -a display memory
free (1) - Display amount of free and used memory in the system
We use free and awk to display the columns we need.
Display the current available storage on your server and its utilization rate as a percentage
$ apropos -a display size
df (1) - report file system disk space usage
duf (1) - Disk Usage/Free Utility
ncdu (1) - NCurses Disk Usage
We use df -h –total to display the total disk usage in human readable format and use awk to display the information we need.
Display the current utilization rate of your processors as a percentage.
We use vmstat.
From The Linux Documentation Project:
The vmstat command will provide a report showing statistics for system processes, memory, swap, I/O, and the CPU.
[…] CPU These are percentages of total CPU time
We display the last line of vmstat only with tail and then, with awk, we print the sum of time spent running user time (non-kernel code), system time (kernel time) and time stolen from a virtual machine.
Display the date and time of the last reboot.
We use who with the option -b to output the last reboot, then we use awk to print the date and time. Note the coma between the two field specifiers to add a space when we print.
Display whether LVM is active or not
We count the number of line that contains ‘lvm’, if the output is equal to zero we return no, else yes.
Display the number of active connections.
Connections are made via sockets so we look for sockets.
$ apropos sockets
[...]
ss (8) - another utility to investigate sockets
[...]
ss --summary
show the number of sockets in use.
We can also cat the file where this information lives and add the third column with awk (we ignore the first line with NR>1).
$ cat /proc/net/sockstat | awk 'NR>1 {sum+=$3} END {print sum}'
Display the number of users using the server.
$ apropos -a print users
users (1) - print the user names of users currently logged in to the current host
We use wc -c to count the number of word the command users outputs.
Display the IPv4 address of your server and its MAC (Media Access Control) address.
We use hostname which we know from above and print the first column with awk.
For the MAC address, we use the command ip and grep the line where the MAC address lives, then, we use awk to print the column.
Display the number of commands executed with the sudo program.
Earlier we added a rule in our sudo configuration for sudo to write a log to the file Defaults logfile=/var/log/sudo/sudo.log . We can grep and count the occurence of COMMAND (with grep’s -c option).
Set up a cron job to run the script every 10 minutes
We set up a cron jobs so that the script runs every 10 minutes.
$ apropos cron
cron (8) - daemon to execute scheduled commands (Vixie Cron)
crontab (1) - maintain crontab files for individual users (Vixie Cron)
crontab (1posix) - schedule periodic background work
crontab (5) - tables for driving cron
We look at man crontab.
We need to run crontab -e to edit the file where cron jobs live.
Note that wall needs to run as sudo (because of wall) so the script lives in /root and crontab -e is run as root user.
In man 5 crontab, we can see what the syntax is to write cron job.
See the section EXAMPLE CRON FILE in crontab(5).
We make sure the cron daemon is running:
$ systemctl status cron | grep Active
Active: active (running) since Tue 2026-01-13 12:18:52 CET; 2h 39min ago
To stop a cron job run:
$ sudo service cron stop
Show cron jobs:
$ crontab -l
Note on printf syntax
printf("%.2f%%")
- % is the specifier
- .2 says print 2 decimal digits
- f for float
- %% to print a single %
Appendix
Copy files from host to VM:
$ scp -P 2222 file.txt username @localhost:/path/
Set up lighttpd, Wordpress (WP), MariaDB and PHP
We can install lighttpd via GNU/Linux’s pacakage manager as specified in https://redmine.lighttpd.net/projects/lighttpd/wiki/GetLighttpd:
$ sudo apt install lighttpd
From what I understand, you don’t need to run a start lighttpd by running the systemctl start command; lighttpd starts automatically once installed. You can check that the command systemctl status lighttpd says it is active:
$ systemctl status lighttpd | grep Active
Active: active (running) since Wed 2026-01-14 14:17:45 CET; 3min 3s ago
From the man pages, we can see that the configuration file of lighttpd is located at /etc/lighttpd/lighttpd.conf.
We opened port 80, the default port for https; we closed it earlier when we enabled UFW.
$ sudo ufw allow http
or
$ sudo ufw allow 80
We also need to add a port forwarding rule to our VM, for example:
http tcp host:8080 guest:80
(When I query http://127.0.0.1:8080/ ’Apache Debian page loaded up, so I purged apache2).
In the ‘5 minutes’ quick configuration guide of lighttpd, on https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration, there is a test to run to check the configuration file:
$ lighttpd -tt -f /etc/lighttpd/lighttpd.conf # update path to conf file
If we query the address http://127.0.0.1:8080/ we should see the placeholder page of lighttpd should show up.
Side note: on my system the placeholder page is /var/www/html/index.light.html and not index.html as suggested in lighttpd’s 5 minute guide.
I understand that we have to use GCI because wordpress servers dynamic website (when lighttpd only serves static website?).
In index.lighttpd.html we can read:
CGI scripts are looked for in /usr/lib/cgi-bin, which is where Debian packages will place their scripts. You can enable cgi module by using command “lighty-enable-mod cgi”.
So we run:
$ sudo lighty-enable-mod cgi
[sudo] password for username:
Enabling cgi: ok
Run "service lighttpd force-reload" to enable changes
username@localhost:~$ sudo service lighttpd force-reload
In the log file of lighttpd we can see the server started again.
Now that lighttpd is running we can test PHP.
We create a file /var/www/html/info.php with the following content:
<?php
phpinfo();
?>
Test that this is running under https://127.0.01:8080/info.php but get a “403 Forbidden error”
On the wiki page for lighttpd on Debian https://wiki.debian.org/Lighttpd I read:
> In PHP
There are two solutions for using PHP with Lighttpd. The older solution is with PHP-CGI, the newer (and faster!) solution is using PHP-FPM, however PHP-FPM requires using Lighttpd from Debian 11, or Debian 10's backports.
Configuration is fairly simple either way. Install php-cgi or php-fpm depending on which method you chose. Then run either lighty-enable-mod fastcgi-php (For PHP-CGI) or lighty-enable-mod fastcgi-php-fpm (For PHP-FPM), and then reload your Lighttpd configuration with systemctl reload lighttpd for it to take effect. It should now be properly handling PHP files.
So we run:
$ sudo lighty-enable-mod fastcgi-php
Now we can display the PHP info page.
Then we look at MariaDB’s documentation to set up MariaDB: https://mariadb.com/docs/server/mariadb-quickstart-guides/installing-mariadb-server-guide. The guide suggests to install 3 packages mariadb-server, mariadb-client and galera-9. I believe mariadb-client provides a command-line interface and galera-9 a few more features which we might both not use. So we only install mariadb-server
$ sudo install mariadb-server
We also don’t run sudo mariadb-secure-installation as suggested by the documentation as running the script itself says: “MariaDB is secure by default in Debian. Running this script is useless.”
There is not need to enable or start MariaDB, it is done automatically. We can check that MariaDB is active:
$ systemctl status mariadb | grep Active
Active: active (running) since Wed 2026-01-14 15:00:58 CET; 7min ago
To check that properly installed run:
$ sudo mariadb # type \q to quit
Now we go to WP’s documentation: https://developer.wordpress.org/advanced-administration/before-install://developer.wordpress.org/advanced-administration/before-install/howto-install/
Step 1 suggests to download the latest version of WP and untar the files. I will use the package available in the distribution for that project. I am thinking it is easier to stick to the package (if it is not too old and we can) cause WP will update when we update through apt, and we can remove wordpress by running sudo apt purge wordpress.
Step 2 is to create a databse (DB) but only gives instruction DB tools other than MariaDB. However, elsewhere on WP’s website there is a short paragraph explaining how to create a DB for WP with MariaDB. I copy it for convenience:
Since MariaDB is a drop-in replacement for MySQL, installing WordPress with MariaDB does not differ from the standard method with MySQL. Basically, you download the latest WordPress package, extract the archive in a directory on your server, then access the corresponding location with your web browser to complete the installation procedure. During the first step of the setup you are prompted to provide the database details. Assuming you’ve installed MariaDB already as shown above, you can create the new database and assign a user to it from the command-line interface [with the commands below].
https://mariadb.com/resources/blog/how-to-install-and-run-wordpress-with-mariadb/ scroll to ‘Install a fresh Wordpress’.
The commands are:
$ sudo mariadb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 11.8.3-MariaDB-0+deb13u1 from Debian
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database wordpress_db;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> grant all privileges on wordpress_db.* to username@localhost identified by 'some_pw';
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> \q
Change username to your username.
localhost remains.
Password goes in between single quotes.
PS: I ran FLUSH PRIVILEGES; later.
Side note about useful command to troubleshoot on mariadb:
> SHOW DATABASES
> SELECT User FROM mysql.user;
> DROP USER username@localhost
We install the latest version of WP, extract the files and copy them in the directory served by the web server; then we delete the compressed directory:
$ wget http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz
$ sudo mv wordpress/* /var/www/html/
$ rm -rf latest.tar.gz wordpress/
In wordpress/ there is a default config. We copy that to a new file wp-config.php and edit this newly created file with the information about the database we created earlier
$ sudo mv /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
$ sudo vim /var/www/html/wordpress/wp-config.php
<?php
/* ... */
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_db' );
/** Database username */
define( 'DB_USER', 'username' );
/** Database password */
define( 'DB_PASSWORD', 'password' );
/** Database host */
define( 'DB_HOST', 'localhost' );
We update the ownership and permission for the user wwww-data (the web server) so the web server can access WP’s files:
$ sudo chown -R www-data:www-data /var/www/html/
$ sudo chmod -R 755 /var/www/html/
$ sudo systemctl restart lighttpd
To see the homepage of the WP website, query http://127.0.0.1:8080/ from a browser.
Generating a .vdi file
sha1sum file.vdi
Resources
man pages for ssh, sshd_config, ufw, usermod, hostnamectl, login.defs, chage, pam_pwquality
On LVM
- https://tldp.org/HOWTO/LVM-HOWTO/whatisvolman.html
- https://tldp.org/LDP/sag/html/partitions.html
- https://trisquel.info/en/wiki/how-resize-trisquels-default-encrypted-partitions
On filesystem hierarchy:
- https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
- https://tldp.org/HOWTO//Partition/requirements.html
On PAM
- https://www.debian.org/doc/manuals/securing-debian-manual/ch04s11.en.html
- https://computing.help.inf.ed.ac.uk/pam_pwquality
On creating user
- https://www.linuxfromscratch.org/lfs/view/development/chapter04/addinguser.html
- https://tldp.org/LDP/sag/html/adduser.html
On basic set up
On SSH
- https://yctct.com/ssh-show-keykeyfingerprint/
- yctct about ssh
On sudo
- man pages of sudoers, sudo, visudo
On archicture and CPU
- man pages of lscpu, nproc and arch
On memory
- man page of free
On disk size and storage
- man page of df
On processor usage
- Linux System Administrator’s Guide, version 0.9, Wirzenius, Oja, Stafford, Weeks, 7.1. System Resources
- man pages of top, vmstat
On active connections and sockets
- man pages of ss
On user activity
- man pages of users, who and w
On IP and MAC addresses
- man page of ip
on cron
- Linux Administration Made Easy, Steve Frampton, Chapter 9. Various & Sundry Administrative Tasks, 9.4. Automating Tasks with Cron and Crontab files
- man pages of cron, crontab
On Mariadb