Difference between revisions of "Ubuntu"

From Got Opinion Wiki
Jump to navigation Jump to search
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 ===

Revision as of 06:45, 5 September 2023

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-get update

Install newest versions of all software packages

sudo apt-get 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*

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

To Linux