Difference between revisions of "Ubuntu"

From Got Opinion Wiki
Jump to navigation Jump to search
 
(40 intermediate revisions by the same user not shown)
Line 35: Line 35:


<code>sudo adduser johndoe</code>
<code>sudo adduser johndoe</code>
==== sudo group stuff ====
Add user to sudo group
<code>sudo usermod -aG sudo <USER_NAME></code>
Verify user belongs to sudo group
<code>groups <USER_NAME></code>
Verify sudo access
<code>su - <USER_NAME></code>
Remove user from sudo group
<code>sudo deluser <USER_NAME> sudo</code>


=== Networking utilities ===
=== Networking utilities ===
Line 41: Line 59:


<code>ip a</code>
<code>ip a</code>
==== Configure hostname ====
[https://linuxize.com/post/how-to-change-hostname-on-ubuntu-18-04/ How to change hostname on Ubuntu 18 04]
==== systemctl ====
Verify which processes run on Ubuntu 18.04 start up use <code>$ sudo systemctl list-unit-files</code>.
=== Check version of Ubuntu ===
<code>$ cat /etc/os-release</code>


== CLI Software Management ==
== CLI Software Management ==


Synchronize package index from Internet.  Location of repositories <code>/etc/apt/sources.list</code>
Synchronize package index from Internet.  Location of repositories <code>/etc/apt/sources.list</code>
<pre>sudo apt-get update</pre>
<pre>sudo apt update</pre>
Install newest versions of all software packages
Install newest versions of all software packages
<pre>sudo apt-get upgrade</pre>
<pre>sudo apt upgrade</pre>
Update distribution
Update distribution
<pre>sudo apt-get dist-upgrade</pre>
<pre>sudo apt-get dist-upgrade</pre>
Line 54: Line 83:
List installed packages
List installed packages
<pre>apt list --installed</pre>
<pre>apt list --installed</pre>
List installed packages that start with 'python'
<pre>$ apt list -a --installed python*</pre>
To upgrade Ubuntu release, see [https://ubuntu.com/server/docs/how-to-upgrade-your-release How To Upgrade Your Release]
== Python on Ubuntu Notes ==
See [[ Python | My Python Notes]] for information not specific to Ubuntu and Python.
Verify Python 3 is installed
<pre>anon@hammerhead:~$ python --version
Command 'python' not found, but can be installed with:
sudo apt install python3     
sudo apt install python       
sudo apt install python-minimal
You also have python3 installed, you can run 'python3' instead.
anon@hammerhead:~$ python3 --version <----- Python 3 installed.
Python 3.6.7 <----- Version 3.6.7</pre>
Verify Python 3 PIP installed
<pre>$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)</pre>
To install Python 3 PIP
<pre>$ sudo apt-get install -y python3-pip</pre>
I use Python virtual environments. Verify Python venv module is installed
<pre>$ apt list -a --installed *venv* <----- If nothing with Python 3 venv comes back then you most install venv module</pre>
To install Python 3 venv module
<pre>$ sudo apt-get install -y python3-venv</pre>
Create virtual environment. I keep my Python virtual environments in a single directory. To create directory <code>$ mkdir python-venv</code>
Switch do directory <code>$ cd python-venv/</code>
Create virtual environment
<pre>$ python3 -m venv udmey-django</pre>
Activate virtual environment
<pre>$ source udmey-django/bin/activate</pre>
Prompt changes to reflect virtual environment
<pre>(udmey-django) anon@hammerhead:~/python-venv$</pre>
Note: Within virtual environment, you can use the command python instead of python3, and pip instead of pip3.
Deactivate virtual environment and prompt returns to normal
<pre>$ deactivate</pre>
== mongoDB ==
[[My MongoDB notes]]
== PostgreSQL ==
=== Install PostgreSQL ===
<pre>$ sudo apt install postgresql postgresql-contrib
...
Success. You can now start the database server using:
    /usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -l logfile start
Ver Cluster Port Status Owner    Data directory              Log file
10  main    5432 down  postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
update-alternatives: using /usr/share/postgresql/10/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql (10+190) ...
Setting up postgresql-contrib (10+190) ...
Processing triggers for systemd (237-3ubuntu10.11) ...
Processing triggers for ureadahead (0.100.0-20) ...</pre>
=== Use PostgreSQL ===
Switch to postgres account
<pre>sudo -i postgres</pre>
Access PostgreSQL prompt
<pre>psql</pre>
Exit PostgreSQL prompt
<pre>\q</pre>
Log directly into PostgreSQL prompt with postgres user
<pre>sudo -u postgres psql</pre>
Add user (username must be same as PostgreSQL role and database)
<pre>sudo adduser user_name</pre>
Check current connection information
<pre>\conninfo</pre>
<b>While logged in as postgres user...</b>
Create a new role. Use <code>man createuser</code> for more information.
<pre>createuser --interactive</pre>
Create new database
<pre>createdb db_name</pre>
Same user connect to different database
<pre>psql -d postgres</pre>
== Nginx ==
[[My Nginx notes]]
[https://www.tecmint.com/install-nginx-with-virtual-hosts-and-ssl-certificate/ Install Nginx with virtual hosts and SSL certificates]


== Apache 2 ==
== Apache 2 ==
=== Resources ===
[https://help.ubuntu.com/lts/serverguide/httpd.html Ubuntu server guide to HTTPD]
[https://help.ubuntu.com/community/OpenSSL#SSL_Certificates Ubuntu Open SSL guide]
[https://help.ubuntu.com/lts/serverguide/certificates-and-security.html.en Ubuntu Certificates and Security]
[http://tldp.org/HOWTO/SSL-Certificates-HOWTO/index.html SSL Certificate HOWTO] not Ubuntu specific
[https://stuff-things.net/2015/09/28/configuring-apache-for-ssl-client-certificate-authentication/ Configure Apache for SSL client certificate authentication]
=== Installation ===


Update all your software and install Apache 2
Update all your software and install Apache 2
Line 98: Line 247:
443/tcp (Apache Secure (v6)) ALLOW IN    Anywhere (v6)</pre>
443/tcp (Apache Secure (v6)) ALLOW IN    Anywhere (v6)</pre>


== PostgreSQL ==
== Teamspeak 3 setup on Ubuntu 16.04 and 18.x via command line ==
 
Switch to postgres account
<pre>sudo -i postgres</pre>
Access PostgreSQL prompt
<pre>psql</pre>
Exit PostgreSQL prompt
<pre>\q</pre>
Log directly into PostgreSQL prompt with postgres user
<pre>sudo -u postgres psql</pre>
Add user (username must be same as PostgreSQL role and database)
<pre>sudo adduser user_name</pre>
Check current connection information
<pre>\conninfo</pre>
 
<b>While logged in as postgres user...</b>
 
Create a new role. Use <code>man createuser</code> for more information.
<pre>createuser --interactive</pre>
Create new database
<pre>createdb db_name</pre>
Same user connect to different database
<pre>psql -d postgres</pre>
 
== Teamspeak3 setup on Ubuntu 16.04 via command line ==
Followed steps at [https://www.vultr.com/docs/how-to-install-teamspeak-3-server-on-ubuntu-16-04-64-bit How to install Teamspeak 3 server on Ubuntu 16.04 64-bit] to install Teamspeak 3 and get basic server running.
Followed steps at [https://www.vultr.com/docs/how-to-install-teamspeak-3-server-on-ubuntu-16-04-64-bit How to install Teamspeak 3 server on Ubuntu 16.04 64-bit] to install Teamspeak 3 and get basic server running.


Line 147: Line 272:
Test your connection using the <CUSTOM UDP Port>
Test your connection using the <CUSTOM UDP Port>


== Factorio Headless Setup ==
=== Upgrade Teamspeak3 server ===


Resources:
[https://www.gazblog.com/2019/01/update-teamspeak-3-server-on-ubuntu-18-04/ original steps]
* [https://wiki.factorio.com/Multiplayer Multiplayer Factorio wiki]
* Stable [https://www.factorio.com/download-headless Factorio headless] server


Check that your version of glibc is >= 2.18.
Login to SSH as root


<pre>robot01@apu01:~$ ldd --version
Stop your current Teamspeak 3 Server <code>systemctl stop teamspeak.service</code>
ldd (Ubuntu GLIBC 2.23-0ubuntu10) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.</pre>


Output of ldd command confirms glibc version 2.23.
Change to your teamspeak user <code>cd /home/teamspeak/;su teamspeak</code>


Switch to <code>/opt</code> directory and download latest Factorio stable headless version (0.16.36 as of this writing)
Download Teamspeak, extract it, update and tidy up.
<pre>robot01@apu01:~$ cd /opt
<pre>wget https://files.teamspeak-services.com/releases/server/3.9.1/teamspeak3-server_linux_amd64-3.9.1.tar.bz2
robot01@apu01:/opt$ sudo wget https://www.factorio.com/get-download/0.16.36/headless/linux64
tar xvfj teamspeak3-server_linux_amd64-3.9.1.tar.bz2
...
cd teamspeak3-server_linux_amd64
...
cp * -R /home/teamspeak
...
cd ..
Saving to: ‘linux64’
rm -r teamspeak3-server_linux_amd64
linux64                  100%[==================================>]  23.04M  401KB/s    in 2m 48s
rm teamspeak3-server_linux_amd64-3.9.1.tar.bz2</pre>


2018-05-01 20:38:47 (141 KB/s) - ‘linux64’ saved [24163736/24163736]</pre>
Return to root and start the Teamspeak server
<pre>exit
systemctl start teamspeak.service
</pre>


Rename file to match version (0.16.36 in this example)
Check to make you can connect to Teamspeak 3 server
<pre>robot01@apu01:/opt$ sudo mv linux64 factorio_headless_x64_0.16.36.tar.xz</pre>


Extract archived and zipped file
== Factorio Headless Setup ==
<pre>robot01@apu01:/opt$ sudo tar -xJf factorio_headless_x64_0.16.36.tar.xz
robot01@apu01:/opt$ ls -l
total 47204
drwxr-xr-x 4 root    root        4096 May  1 21:12 factorio
-rw-r--r-- 1 factorio factorio 24163736 May  1 20:56 factorio_headless_x64_0.16.36.tar.xz</pre>


Remove file (save space, you can always download again if needed)
[[My Factorio Info]]
<pre>robot01@apu01:/opt$ sudo rm factorio_headless_x64_0.16.36.tar.xz</pre>


Add a new user to run factorio and assign ownership of <code>/opt/factorio</code> directory to same user
== Hardware ==
<pre>robot01@apu01:/opt$ sudo useradd factorio
robot01@apu01:/opt$ sudo chown -R factorio:factorio /opt/factorio/</pre>


Identify video card:
<pre>paul@congo:~$ lspci -nn | grep VGA
01:00.0 VGA compatible controller [0300]: nVidia Corporation G92 [GeForce 8800 GT] [10de:0611] (rev a2)</pre>


Verify permissions show factorio for both user and group
Verify interface speed
<pre>robot01@apu01:/opt$ ls -l
total 4
drwxr-xr-x 4 factorio factorio 4096 May  1 21:12 factorio</pre>


<code>cat /sys/class/net/<interface>/speed</code>


Test Factorio binary by switching to factorio user then start server
replace <interface> with name of your NIC (e.g. eth0)
<pre>robot01@apu01:/opt$ sudo su - factorio
No directory, logging in with HOME=/
$</pre>


Start server and look for something like "File /savename does not exist."
[[Ubuntu video card]]
<pre>$ /opt/factorio/bin/x64/factorio --start-server savename
  0.000 2018-05-01 21:20:47; Factorio 0.16.36 (build 36253, linux64, headless)
  0.260 Operating system: Linux (Ubuntu 16.04)
  0.260 Program arguments: "/opt/factorio/bin/x64/factorio" "--start-server" "savename"
  0.260 Read data path: /opt/factorio/data
  0.260 Write data path: /opt/factorio [103696/111098MB]
  0.260 Binaries path: /opt/factorio/bin
  0.304 System info: [CPU: AMD G-T40E Processor, 2 cores, RAM: 3550 MB]
  0.304 Environment: DISPLAY=<unset>, WAYLAND_DISPLAY=<unset>
  0.305 Running in headless mode
  0.316 Error GlobalModSettings.cpp:107: Failed to migrate mod settings file: Error when opening /opt/factorio/mods/mod-settings.json for reading: No such file or directory
  0.322 Loading mod core 0.0.0 (data.lua)
  0.388 Loading mod base 0.16.36 (data.lua)
  1.063 Loading mod base 0.16.36 (data-updates.lua)
  1.313 Checksum for core: 1316978547
  1.313 Checksum of base: 4140083139
  2.006 Info PlayerData.cpp:67: Local player-data.json unavailable
  2.006 Info PlayerData.cpp:72: Cloud player-data.json unavailable
  2.012 Custom inputs active: 0
  2.015 Factorio initialised
  2.016 Info ServerSynchronizer.cpp:29: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
  2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(Ready) to(PreparedToHostGame)
  2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(PreparedToHostGame) to(CreatingGame)
  2.017 Loading map /savename
  2.017 Error ServerMultiplayerManager.cpp:96: MultiplayerManager failed: "File /savename does not exist."
  2.017 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(CreatingGame) to(InitializationFailed)
  2.017 Info GlobalContext.cpp:694: Waiting for child processes to exit:
  2.020 Info ServerMultiplayerManager.cpp:142: Quitting multiplayer connection.
  2.020 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(InitializationFailed) to(Closed)
  2.062 Info UDPSocket.cpp:206: Closing socket
  2.065 Goodbye</pre>
 
As factorio user create <code>/opt/factorio/</code> saves directory
<pre>$ mkdir /opt/factorio/saves</pre>
 
At this point you can load up saved games or create some games. Before that I want to install Factorio init script


Exit from factorio user back to sudo account
=== Resizing logical volume ===
<pre>$ exit
logout</pre>


Switch to <code>/opt</code> directory
Background
<pre>robot01@apu01:/opt/factorio$ cd /opt</pre>


Clone Factorio init script from github
A 2 TB SSD was physically installed in the system ox and after installation, the LVM used 100 GB.
<pre>robot01@apu01:/opt$ sudo git clone https://github.com/Bisa/factorio-init.git
Cloning into 'factorio-init'...
remote: Counting objects: 484, done.
remote: Total 484 (delta 0), reused 0 (delta 0), pack-reused 484
Receiving objects: 100% (484/484), 109.47 KiB | 0 bytes/s, done.
Resolving deltas: 100% (276/276), done.
Checking connectivity... done.</pre>


Make Factorio start on operating system boot and restart if failure (configurable - I kept defaults for now)
Reference [https://community.spiceworks.com/topic/2325763-how-can-i-make-ubuntu-vg-ubuntu-lv-consume-the-entire-disk-space-available How To Make ubuntu-vg-ubuntu-lv Use 100% Free Disc Space]
<pre>robot01@apu01:/opt$ sudo cp /opt/factorio-init/factorio.service.example /etc/systemd/system/factorio.service
robot01@apu01:/opt$ sudo systemctl daemon-reload</pre>


Sysvinit
<pre>anon@ox:~$ sudo pvs
<pre>robot01@apu01:/opt/factorio$ sudo ln -s /opt/factorio-init/factorio /etc/init.d/factorio
  PV            VG        Fmt  Attr PSize  PFree
robot01@apu01:/opt/factorio$ sudo chmod +x /opt/factorio-init/factorio</pre>
  /dev/nvme0n1p3 ubuntu-vg lvm2 a-- <1.82t <1.72t


Show help
anon@ox:~$ sudo vgs
<pre>robot01@apu01:/opt/factorio$ service factorio help
  VG        #PV #LV #SN Attr  VSize  VFree
Usage: /etc/init.d/factorio COMMAND
  ubuntu-vg  1  1  0 wz--n- <1.82t <1.72t


Available commands:
anon@ox:~$ sudo lvs
  start                                Starts the server
  LV        VG        Attr      LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  stop                                  Stops the server
  ubuntu-lv ubuntu-vg -wi-ao---- 100.00g # <----------- This shows 100 GB and I want 1.8T.
  restart                              Restarts the server
 
  status                                Displays server status
anon@ox:~$ sudo lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  players-online                        Shows online players
  players                              Shows all players
  cmd [command/message]                Open interactive commandline or send a single command to the server
  chatlog [--tail|-t]                  Print the current chatlog, optionally tail the log to follow in real time
  new-game name [map-gen-settings] [map-settings]      Stops the server and creates a new game with the specified name using the specified map gen settings and map settings json files
  save-game name                        Stops the server and saves game to specified save
  load-save name                        Stops the server and loads the specified save
  install [tarball]                    Installs the server with optional specified tarball (omit to download and use the latest headless server from Wube)
  update [--dry-run]                    Updates the server
  invocation                            Outputs the invocation for debugging purpose
  listcommands                          List all init-commands
  listsaves                            List all saves
  version                              Prints the binary version
  help                                  Shows this help message</pre>


Setup Autocompletion
Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <1.82 TiB (476150 extents).
<pre>robot01@apu01:/opt/factorio$ sudo ln -s /opt/factorio-init/bash_autocomplete /etc/bash_completion.d/factorio
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
robot01@apu01:/opt/factorio$ sudo echo "source /opt/factorio-init/bash_autocomplete" >> ~/.bashrc</pre>


Copy example server settings (make any changes you want to copy)
anon@ox:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
<pre>robot01@apu01:/opt/factorio$ sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json</pre>


Copy example configuration (make any changes you want to copy)
resize2fs 1.46.5 (30-Dec-2021)
<pre>robot01@apu01:/opt/factorio$ sudo cp /opt/factorio-init/config.example /opt/factorio-init/config</pre>
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 233
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 487577600 (4k) blocks long.


Make any changes to config ini
anon@ox:~$ sudo pvs
<pre>robot01@apu01:/opt/factorio$ sudo vi /opt/factorio/config/config.ini</pre>
  PV            VG        Fmt  Attr PSize  PFree
  /dev/nvme0n1p3 ubuntu-vg lvm2 a--  <1.82t    0


== Hardware ==
anon@ox:~$ sudo vgs
  VG        #PV #LV #SN Attr  VSize  VFree
  ubuntu-vg  1  1  0 wz--n- <1.82t    0


Identify video card:
anon@ox:~$ sudo lvs
<pre>paul@congo:~$ lspci -nn | grep VGA
  LV        VG        Attr      LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
01:00.0 VGA compatible controller [0300]: nVidia Corporation G92 [GeForce 8800 GT] [10de:0611] (rev a2)</pre>
  ubuntu-lv ubuntu-vg -wi-ao---- <1.82t # <----------- This was 100 GB Size, now it's 1.8T.


Verify interface speed
anon@ox:~$ df -h
 
Filesystem                        Size  Used Avail Use% Mounted on
<code>cat /sys/class/net/<interface>/speed</code>
tmpfs                              6.3G  1.9M  6.3G  1% /run
 
/dev/mapper/ubuntu--vg-ubuntu--lv  1.8T  37G  1.7T  3% / # <----------- This was 100 GB Size, now it's 1.8T.
replace <interface> with name of your NIC (e.g. eth0)
tmpfs                              32G  200K  32G  1% /dev/shm
 
tmpfs                              5.0M    0  5.0M  0% /run/lock
[[Ubuntu video card]]
/dev/nvme0n1p2                    2.0G  252M  1.6G  14% /boot
/dev/nvme0n1p1                    1.1G  6.1M  1.1G  1% /boot/efi
tmpfs                              6.3G  4.0K  6.3G  1% /run/user/1001
tmpfs                              6.3G  4.0K  6.3G  1% /run/user/1000</pre> 


<center>[[Linux|To Linux]]</center>
<center>[[Linux|To Linux]]</center>

Latest revision as of 11:29, 28 August 2024

Shell commands

Enable root account (not recommended):

$sudo passwd root

Disable root account you lock root account:

$sudo passwd -l root

Want to use root @ console:

$sudo -i

Windows Dual Boot page

Recovering Ubuntu After Windows Install

Grub2 on Ubuntu wiki

Grub2 GUI Customizer

For support-related question you can use Launchpad. You can also search the complete history of questions and answers.

Ubuntu web forums

Grub 2 basics

Enable SSH server

apt-get install openssh-server

Secure SSH server using /etc/hosts.allow

Add a User

Example adding a user with username johndoe. Follow the instructions provided by the command.

sudo adduser johndoe

sudo group stuff

Add user to sudo group

sudo usermod -aG sudo <USER_NAME>

Verify user belongs to sudo group

groups <USER_NAME>

Verify sudo access

su - <USER_NAME>

Remove user from sudo group

sudo deluser <USER_NAME> sudo

Networking utilities

See IP address information

ip a

Configure hostname

How to change hostname on Ubuntu 18 04

systemctl

Verify which processes run on Ubuntu 18.04 start up use $ sudo systemctl list-unit-files.

Check version of Ubuntu

$ cat /etc/os-release

CLI Software Management

Synchronize package index from Internet. Location of repositories /etc/apt/sources.list

sudo apt update

Install newest versions of all software packages

sudo apt upgrade

Update distribution

sudo apt-get dist-upgrade

Install package (if already installed, will attempt to update package)

apt-get install package-name

List installed packages

apt list --installed

List installed packages that start with 'python'

$ apt list -a --installed python*

To upgrade Ubuntu release, see How To Upgrade Your Release

Python on Ubuntu Notes

See My Python Notes for information not specific to Ubuntu and Python.

Verify Python 3 is installed

anon@hammerhead:~$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3       
sudo apt install python        
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

anon@hammerhead:~$ python3 --version <----- Python 3 installed.
Python 3.6.7 <----- Version 3.6.7

Verify Python 3 PIP installed

$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

To install Python 3 PIP

$ sudo apt-get install -y python3-pip

I use Python virtual environments. Verify Python venv module is installed

$ apt list -a --installed *venv* <----- If nothing with Python 3 venv comes back then you most install venv module

To install Python 3 venv module

$ sudo apt-get install -y python3-venv

Create virtual environment. I keep my Python virtual environments in a single directory. To create directory $ mkdir python-venv

Switch do directory $ cd python-venv/

Create virtual environment

$ python3 -m venv udmey-django

Activate virtual environment

$ source udmey-django/bin/activate

Prompt changes to reflect virtual environment

(udmey-django) anon@hammerhead:~/python-venv$

Note: Within virtual environment, you can use the command python instead of python3, and pip instead of pip3.

Deactivate virtual environment and prompt returns to normal

$ deactivate

mongoDB

My MongoDB notes

PostgreSQL

Install PostgreSQL

$ sudo apt install postgresql postgresql-contrib
...
Success. You can now start the database server using:

    /usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -l logfile start

Ver Cluster Port Status Owner    Data directory              Log file
10  main    5432 down   postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
update-alternatives: using /usr/share/postgresql/10/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql (10+190) ...
Setting up postgresql-contrib (10+190) ...
Processing triggers for systemd (237-3ubuntu10.11) ...
Processing triggers for ureadahead (0.100.0-20) ...

Use PostgreSQL

Switch to postgres account

sudo -i postgres

Access PostgreSQL prompt

psql

Exit PostgreSQL prompt

\q

Log directly into PostgreSQL prompt with postgres user

sudo -u postgres psql

Add user (username must be same as PostgreSQL role and database)

sudo adduser user_name

Check current connection information

\conninfo

While logged in as postgres user...

Create a new role. Use man createuser for more information.

createuser --interactive

Create new database

createdb db_name

Same user connect to different database

psql -d postgres

Nginx

My Nginx notes

Install Nginx with virtual hosts and SSL certificates

Apache 2

Resources

Ubuntu server guide to HTTPD

Ubuntu Open SSL guide

Ubuntu Certificates and Security

SSL Certificate HOWTO not Ubuntu specific

Configure Apache for SSL client certificate authentication

Installation

Update all your software and install Apache 2

# apt-get update
# apt-get upgrade
# apt install apache2

Verify Apache is running

# systemctl status apache2
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Sun 2018-10-21 14:44:30 CDT; 11min ago
 Main PID: 17131 (apache2)
    Tasks: 55 (limit: 4181)
   CGroup: /system.slice/apache2.service
           ├─17131 /usr/sbin/apache2 -k start
           ├─17132 /usr/sbin/apache2 -k start
           └─17134 /usr/sbin/apache2 -k start

Oct 21 14:44:30 apu02 systemd[1]: Starting The Apache HTTP Server...
Oct 21 14:44:30 apu02 apachectl[17120]: AH00558: apache2: Could not reliably determine the server's
Oct 21 14:44:30 apu02 systemd[1]: Started The Apache HTTP Server.

Firewall

Update firewall to allow only port 443 (default HTTPS TCP port)

# ufw app list
Available applications:
  Apache
  Apache Full
  Apache Secure
  OpenSSH

# ufw allow 'Apache Secure'

# ufw status verbose | grep 443
443/tcp (Apache Secure)    ALLOW IN    Anywhere
443/tcp (Apache Secure (v6)) ALLOW IN    Anywhere (v6)

Teamspeak 3 setup on Ubuntu 16.04 and 18.x via command line

Followed steps at How to install Teamspeak 3 server on Ubuntu 16.04 64-bit to install Teamspeak 3 and get basic server running.

If you want to customize the server port follow next steps.

Install simple command-line program named sqlite3. How to use sqlite

robot00@apu00:~$ sudo apt install sqlite3

Launch sqlite3 using Teamspeak 3 sqlite database file:

robot00@apu00:~$ sudo sqlite3 /home/teamspeak/ts3server.sqlitedb
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.

Update port command:

sqlite> update servers set server_port=<CUSTOM UDP Port>;

Restart Teamspeak 3 server

robot00@apu00:~$ systemctl restart teamspeak.service

Test your connection using the <CUSTOM UDP Port>

Upgrade Teamspeak3 server

original steps

Login to SSH as root

Stop your current Teamspeak 3 Server systemctl stop teamspeak.service

Change to your teamspeak user cd /home/teamspeak/;su teamspeak

Download Teamspeak, extract it, update and tidy up.

wget https://files.teamspeak-services.com/releases/server/3.9.1/teamspeak3-server_linux_amd64-3.9.1.tar.bz2
tar xvfj teamspeak3-server_linux_amd64-3.9.1.tar.bz2
cd teamspeak3-server_linux_amd64
cp * -R /home/teamspeak
cd ..
rm -r teamspeak3-server_linux_amd64
rm teamspeak3-server_linux_amd64-3.9.1.tar.bz2

Return to root and start the Teamspeak server

exit
systemctl start teamspeak.service

Check to make you can connect to Teamspeak 3 server

Factorio Headless Setup

My Factorio Info

Hardware

Identify video card:

paul@congo:~$ lspci -nn | grep VGA
01:00.0 VGA compatible controller [0300]: nVidia Corporation G92 [GeForce 8800 GT] [10de:0611] (rev a2)

Verify interface speed

cat /sys/class/net/<interface>/speed

replace <interface> with name of your NIC (e.g. eth0)

Ubuntu video card

Resizing logical volume

Background

A 2 TB SSD was physically installed in the system ox and after installation, the LVM used 100 GB.

Reference How To Make ubuntu-vg-ubuntu-lv Use 100% Free Disc Space

anon@ox:~$ sudo pvs
  PV             VG        Fmt  Attr PSize  PFree 
  /dev/nvme0n1p3 ubuntu-vg lvm2 a--  <1.82t <1.72t

anon@ox:~$ sudo vgs
  VG        #PV #LV #SN Attr   VSize  VFree 
  ubuntu-vg   1   1   0 wz--n- <1.82t <1.72t

anon@ox:~$ sudo lvs
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 100.00g # <----------- This shows 100 GB and I want 1.8T.
  
anon@ox:~$ sudo lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <1.82 TiB (476150 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.

anon@ox:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 233
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 487577600 (4k) blocks long.

anon@ox:~$ sudo pvs
  PV             VG        Fmt  Attr PSize  PFree
  /dev/nvme0n1p3 ubuntu-vg lvm2 a--  <1.82t    0 

anon@ox:~$ sudo vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  ubuntu-vg   1   1   0 wz--n- <1.82t    0 

anon@ox:~$ sudo lvs
  LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <1.82t # <----------- This was 100 GB Size, now it's 1.8T.

anon@ox:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              6.3G  1.9M  6.3G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  1.8T   37G  1.7T   3% / # <----------- This was 100 GB Size, now it's 1.8T.
tmpfs                               32G  200K   32G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p2                     2.0G  252M  1.6G  14% /boot
/dev/nvme0n1p1                     1.1G  6.1M  1.1G   1% /boot/efi
tmpfs                              6.3G  4.0K  6.3G   1% /run/user/1001
tmpfs                              6.3G  4.0K  6.3G   1% /run/user/1000
To Linux