Complete Ubuntu 16.04 Server Configuration Guide

Initial Setup and Network Configuration

Before begining the Ubuntu server setup, ensure your virtual machine network adapter is set to bridge mode. For wireless connections, select your appropriate wireless network adapter in the virtualization settings.

Basic Network Commands

# Test network connectivity
ping -c 4 192.168.1.181

# Display routing table
netstat -rn

# Reboot system
reboot

# Shutdown immediately
shutdown -h now

Enabling Root Access

By default, Ubuntu disables the root account for security reasons. To enable it:

sudo passwd root

Enter your new root password twice when prompted. After this, you can switch to root using su -.

Essential Software Installation

VIM Editor

apt-get update
apt-get install vim

SSH Server Configuration

apt-get install openssh-server

To enable root login via SSH, edit the SSH daemon configuration:

vim /etc/ssh/sshd_config

Locate and modify these settings:

# Authentication settings
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

Restart the SSH service to apply changes:

systemctl restart sshd

Chinese Language Support

apt-get install language-pack-zh-hans

Static IP Configuration

Edit the network interfaces configuration:

vim /etc/network/interfaces

Disable DHCP and configure static addressing:

# Disable DHCP (add comment)
# iface ens33 inet dhcp

# Add static IP settings
iface ens33 inet static
address 192.168.1.181
gateway 192.168.1.1
netmask 255.255.255.0

DNS Resolution Setup

vim /etc/resolv.conf

Add nameserver entries:

nameserver 192.168.1.1

To make DNS settings persistent across reboots:

vim /etc/resolvconf/resolv.conf.d/base

Add the following nameservers:

nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

Google Public DNS: Primary 8.8.8.8, Secondary 8.8.4.4

Restart networking to apply changes:

/etc/init.d/networking restart

Package Repository Configuration

Backup and modify the sources list:

cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list

If apt-get update fails, ensure DNS is working by adding:

nameserver 8.8.8.8

to /etc/resolv.conf

Aliyun Mirror for Ubuntu 16.04 LTS

# Base repositories
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe

# Security updates
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe

# Proposed updates
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe

# Backports
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

# Partner repository
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner

# Universe and multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

Firewall Management

# Disable firewall
ufw disable

# Enable firewall
ufw enable

Java Development Environment

Download JDK and Tomcat archives, then extract to your preferred directory:

tar -xzf jdk-8u131-linux-x64.tar.gz -C /opt/
tar -xzf tomcat9.tar.gz -C /opt/

Configuring Environment Variables for Root User

vim ~/.profile

Append the following configuration:

export JAVA_HOME=/opt/jdk1.8.0_131
export JRE_HOME=/opt/jdk1.8.0_131/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
source ~/.profile

Configuring Environment Variables System-Wide

vim /etc/profile

Add the same export statements at the end of the file:

export JAVA_HOME=/opt/jdk1.8.0_131
export JRE_HOME=/opt/jdk1.8.0_131/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
source /etc/profile

Redis Database Installation

apt-get install redis-server

Verification Steps

Check if Redis server process is running:

ps aux | grep redis

Expected output shows the redis-server process listening on port 6379:

redis 13743  0.0  0.6  41876  6660 ?  Ssl 19:51  0:00 /usr/bin/redis-server *:6379

Verify the listening port:

netstat -nlt | grep 6379

Check service status:

/etc/init.d/redis-server status

Security Configuration

vim /etc/redis/redis.conf

Set a password by finding and uncommenting:

requirepass your_secure_password

Allow remote connections by commenting out the bind directive:

# bind 127.0.0.1

Restart Redis to apply configuration:

/etc/init.d/redis-server restart

Redis CLI Usage

Connect with authentication:

redis-cli -a your_secure_password

Local connection without password:

redis-cli

Remote connection from another Linux host:

redis-cli -a your_secure_password -h 192.168.1.190

Common Redis commands to testing:

127.0.0.1:6379> keys *
1) "sample_key2"
2) "sample_key1"

127.0.0.1:6379> set sample_key3 "test_value"
OK

127.0.0.1:6379> keys *
1) "sample_key2"
2) "sample_key3"
3) "sample_key1"

127.0.0.1:6379> get sample_key3
"test_value"

127.0.0.1:6379> del sample_key3
(integer) 1

127.0.0.1:6379> keys *
1) "sample_key2"
2) "sample_key1"

Tags: Ubuntu Linux server-configuration ssh Redis

Posted on Fri, 05 Jun 2026 16:13:28 +0000 by pythian