Skip to main content

Ubuntu Server Setup

Disable auto sleep​

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
note

For more details, see this post.

Driver​

note

Check out the Nvidia installation docs for how to install Nvidia drivers.

WoL​

For checking the current WoL status, see instructions in https://help.ubuntu.com/community/WakeOnLan

For setting up on-boot service, see https://www.techrepublic.com/article/how-to-enable-wake-on-lan-in-ubuntu-server-18-04/

Docker​

note

Check out the official documentation for instructions.

Also, don't forget to follow the post-installation instructions after docker installation.

Driver docker support​

note

Desktop environment​

Install Xfce:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes xfce4 desktop-base

Install Cinnamon:

sudo DEBIAN_FRONTEND=noninteractive \
apt install --assume-yes cinnamon-core desktop-base
note

For details, see the official CRD configure example.

User​

Add users​

To add a Linux user with home directory and login shell (bash), use the following command:

sudo useradd -m -s /usr/bin/bash "$NEW_USERNAME"
sudo passwd "$NEW_USERNAME"
note

For more options, see this post.

Delete users​

To remove a Linux user, use the following command:

sudo userdel "$NEW_USERNAME"
note

For more options, see this doc.

Permissions​

For any Linux developer account to make sense, it need as least the following:

sudo usermod -aG docker "$NEW_USERNAME"
sudo usermod -aG sudo "$NEW_USERNAME"
note

Alternatively, we can use the admin account to setup all the sudo related tools and remove other users from sudo which is safer, but can cause inconveniences.

Remote Access​

Here is an official example for setting up CRD on GCloud VM.

Here is an official example for setting up CRD for Linux workstation.

Essential apps​

VS code​

Visit https://code.visualstudio.com.

Portainer​

version: '3'
services:
portainer_agent:
container_name: portainer_agent
image: portainer/agent
ports:
- '9001:9001'
restart: always
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/var/lib/docker/volumes:/var/lib/docker/volumes'

Chrome​

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
note

Check out this post for more details.

Drive​

note

This is not needed for Ubuntu server since you can set up a Raid 0 during installation which works better.

Network​

SSH​

Here is a sample configuration file:

Host example
HostName 192.168.1.10
User example-user
Port 7654
LocalForward 5901 192.168.1.10:5901
RemoteForward 5037 localhost:5037

Development environments​

Android​

Device not connecting​

When Android devices are connected but adb devices cannot find the devices, it's because the adb server doesn't have sufficient permission to access usb devices.

Short term solution​

For short term solution, we can just restart the adb server with sudo privilege:

sudo adb kill-server
sudo adb start-server
note

For more details, please see this answer.

Long term solution​

For long term solution, we need to add the correct user as the usb device owner.

First, we need to find the vendor ID and product ID of the Android device with:

lsusb
Bus 001 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
...
tip

Here 046d is the vendor ID and c52b is the product ID.

Then we need to add the ownership config as /etc/udev/rules.d/51-android.rules which contains something like:

# adb for Moto E devl device
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="username"
tip

Here we need to replace idVendor, idProduct and username.

note

For more details, see this answer.