Essential Ubuntu Setup Guide: Complete Initial Configuration After Installation

目次

1. Introduction

Ubuntu is one of the most widely used Linux distributions, suitable for beginners and advanced users alike. Its open-source nature and strong community support make it especially appealing. However, immediately after installation, the system may not be fully optimized for comfortable use, and several basic initial settings are required.

This article provides a detailed explanation of the essential configuration steps you should perform after installing Ubuntu. Each step is explained clearly, including the purpose of the setting and how to run the necessary commands, so even beginners can follow along without confusion.

Why You Should Configure Ubuntu After Installation

Right after installing Ubuntu, some areas may lack convenience or security. Common issues include:

  • System updates are required: The packages included in the installation media may not be the latest, so updates are necessary for security and bug fixes.
  • Japanese language support is incomplete: Since English is set as the default language, additional setup is needed to enable smooth Japanese input and display.
  • Security settings are not optimized: Without configuring the firewall or SSH properly, risks of unauthorized access increase.
  • Lack of essential software: The default installation includes only minimal applications, so you may need to install commonly used software.

Who This Article Is For

This guide is designed for users who:

  • Are installing Ubuntu for the first time
  • Are not yet comfortable using Linux commands
  • Want a more secure and convenient Ubuntu environment

By following each section step-by-step, you’ll have a smooth and efficient Ubuntu setup process.

The next section explains how to update Ubuntu packages to their latest versions.

2. Updating the System

Immediately after installing Ubuntu, the included software packages may not be up to date. Updating the system is essential to prevent security vulnerabilities and ensure stability.

Why System Updates Are Necessary

Ubuntu installation media contains packages from the release date. Without updating, the following risks may occur:

  • Remaining security vulnerabilities: Older packages may contain exploits attackers can target.
  • Exposure to unresolved bugs: Bug fixes applied after the release will not be reflected.
  • Compatibility issues: New software may fail to install due to outdated dependencies.

Updating the Package List

Ubuntu uses APT (Advanced Package Tool) to manage software packages. First, update the package list:

sudo apt update

Upgrading Packages

After updating the list, upgrade all installed packages:

sudo apt upgrade -y

Removing Unnecessary Packages (Recommended)

sudo apt autoremove -y

Rebooting the System (If Required)

sudo reboot

3. Setting Up the Japanese Environment

By default, Ubuntu is configured for English. To use Japanese comfortably, you must install language packs and configure Japanese input.

Installing the Japanese Language Pack

1. Install the Japanese language pack

sudo apt install language-pack-ja -y

2. Set the system language to Japanese

LANG=ja_JP.UTF-8
sudo update-locale LANG=ja_JP.UTF-8

Reboot to apply:

sudo reboot

Setting Up Japanese Input (Mozc)

Ubuntu does not enable Japanese input by default, so an input method (IME) must be installed.

Recommended IME:

  • Mozc (open-source Google Japanese Input)

1. Install Mozc

sudo apt install fcitx-mozc -y

2. Switch input method to Fcitx

im-config -n fcitx

Reboot:

sudo reboot

3. Configure Fcitx

fcitx-config-gtk3

Optional: Installing Japanese Fonts

sudo apt install fonts-noto-cjk -y

Final Step

Reboot to apply settings:

sudo reboot

4. Setting the Timezone and Locale

By default, new Ubuntu installations—especially cloud images—use the UTC timezone. This may cause incorrect timestamps, so adjusting the timezone and locale is important.

Setting the Timezone

1. Check current timezone

timedatectl

2. Change to JST (Japan Standard Time)

sudo timedatectl set-timezone Asia/Tokyo

Setting the Locale

1. Check current locale

locale

2. Enable Japanese locale

sudo locale-gen ja_JP.UTF-8

Set as default:

sudo update-locale LANG=ja_JP.UTF-8

3. Apply changes

source /etc/default/locale

5. Keyboard Configuration

Ubuntu’s default keyboard settings may not match Japanese keyboards. This section explains how to adjust the layout and remap the CapsLock key.

Checking the Keyboard Layout

localectl status

Switching to Japanese Keyboard Layout

sudo localectl set-keymap jp
sudo localectl set-x11-keymap jp

Remapping CapsLock to Ctrl

Temporary method

setxkbmap -option ctrl:nocaps

Permanent method

sudo nano /etc/default/keyboard

Change:

XKBOPTIONS="ctrl:nocaps"

Apply:

sudo dpkg-reconfigure keyboard-configuration
sudo reboot

6. Configuring the Firewall

Ubuntu includes a built-in firewall called UFW (Uncomplicated Firewall), which makes firewall management simple and effective. Proper configuration of UFW enhances system security by preventing unauthorized access.

This section explains the basic UFW setup and recommended security rules.

Enabling the Firewall

First, check whether UFW is enabled.

1. Check UFW status

sudo ufw status

Example (disabled):

Status: inactive

Example (enabled):

Status: active

2. Enable UFW

sudo ufw enable

Once enabled, UFW applies its default rules to manage network traffic.

Basic Firewall Rule Configuration

UFW works by allowing only the traffic you explicitly permit.

1. Set default policies

sudo ufw default deny incoming
sudo ufw default allow outgoing

2. Allow SSH (remote connection)

sudo ufw allow 22/tcp

If your server uses a non-standard SSH port (e.g., 2222):

sudo ufw allow 2222/tcp

3. Allow HTTP/HTTPS for web servers

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

4. Allow other services (optional)

FTP:

sudo ufw allow 21/tcp

MySQL:

sudo ufw allow 3306/tcp

PostgreSQL:

sudo ufw allow 5432/tcp

5. Apply changes

sudo ufw reload

Checking Rules and Logs

1. View current firewall rules

sudo ufw status numbered

Example:

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW       Anywhere
[ 2] 80/tcp                     ALLOW       Anywhere
[ 3] 443/tcp                    ALLOW       Anywhere

2. Remove unnecessary rules

sudo ufw delete 1

3. Enable logging (optional)

sudo ufw logging on

Logs appear in:

/var/log/ufw.log

Temporarily Disable UFW

sudo ufw disable

Re-enable:

sudo ufw enable

Summary

To configure the firewall effectively:

  1. Enable UFW
  2. Set default rules
  3. Allow necessary ports (SSH, HTTP/HTTPS)
  4. Reload and verify settings
  5. Enable logging for security monitoring

7. Configuring the SSH Server

SSH (Secure Shell) allows secure remote access to your Ubuntu system. For servers, enabling SSH and applying security hardening is essential.

This section covers installation and important security settings.

Installing and Starting the SSH Server

1. Install OpenSSH server

sudo apt install openssh-server -y

2. Check SSH server status

sudo systemctl status ssh

You should see:

Active: active (running)

3. Enable auto-start

sudo systemctl enable ssh

Changing SSH Port (Security Enhancement)

Port 22 is frequently targeted by attackers. Changing it reduces brute-force attempts.

1. Edit the SSH config

sudo nano /etc/ssh/sshd_config

Find:

#Port 22

Change to:

Port 2222

2. Restart SSH

sudo systemctl restart ssh

3. Allow the new port with UFW

sudo ufw allow 2222/tcp

Setting Up Public Key Authentication

This method replaces password-based login with key-based authentication, providing significantly better security.

1. Generate an SSH key pair (client PC)

ssh-keygen -t rsa -b 4096

2. Copy the public key to the server

ssh-copy-id -p 2222 user@your-server-ip

If ssh-copy-id cannot be used:

cat ~/.ssh/id_rsa.pub | ssh -p 2222 user@your-server-ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

3. Disable password authentication

sudo nano /etc/ssh/sshd_config

Change:

PasswordAuthentication no

Confirm:

PubkeyAuthentication yes

Then restart SSH:

sudo systemctl restart ssh

4. Test the connection

ssh -p 2222 user@your-server-ip

Summary of SSH Security Hardening

  • Change SSH port
  • Disable password authentication
  • Use key-based authentication
  • Limit login attempts (Fail2Ban)

Install Fail2Ban:

sudo apt install fail2ban -y

8. Installing Software

Ubuntu includes only minimal software by default. Installing essential and development tools greatly improves usability.

Ways to Install Software

  1. APT packages
sudo apt install package-name
  1. Snap packages
sudo snap install package-name
  1. Flatpak (optional)
flatpak install package-name
  1. PPA repositories
sudo add-apt-repository ppa:repository-name
  1. Installing .deb files
sudo dpkg -i package-name.deb

Recommended Basic Software

1. Web Browser (Google Chrome)

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt install -f

2. Office Suite (LibreOffice)

sudo apt install libreoffice -y

3. Media Player (VLC)

sudo apt install vlc -y

4. Code Editor (Visual Studio Code)

sudo snap install code --classic

5. Command-line Tools (htop, curl, git)

sudo apt install htop curl git -y

6. Archive Tools (zip, unzip, rar)

sudo apt install zip unzip rar unrar -y

7. Google Drive Integration

sudo apt install gnome-online-accounts -y

Developer Tools

1. Docker

sudo apt install docker.io -y
sudo systemctl enable --now docker
sudo usermod -aG docker $USER

2. Python & pip

sudo apt install python3 python3-pip -y

3. Node.js & npm

sudo apt install nodejs npm -y

4. MySQL Server

sudo apt install mysql-server -y
sudo systemctl enable --now mysql

Checking Installed Software

dpkg --get-selections | grep -v deinstall

Snap packages:

snap list

Summary

A recommended software list:

SoftwareDescriptionInstall Method
Google ChromeFast web browserwget + dpkg
LibreOfficeOffice suiteapt install
VLCMedia playerapt install
Visual Studio CodeCode editorsnap install
GitVersion controlapt install
DockerContainer virtualizationapt install
MySQLDatabaseapt install

9. Configuring Automatic Updates

Regular security patches and bug fixes are essential for maintaining a safe and stable Ubuntu environment. While you can apply updates manually, enabling automatic updates ensures your system stays up to date with minimal effort.

This section explains how to set up automatic updates using the unattended-upgrades package.

Installing and Configuring unattended-upgrades

1. Install unattended-upgrades

sudo apt install unattended-upgrades -y

2. Enable automatic updates

sudo dpkg-reconfigure unattended-upgrades

3. Edit the configuration file

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Enable these lines if they are commented out:

Unattended-Upgrade::Allowed-Origins {
        "Ubuntu stable";
        "Ubuntu security";
        "Ubuntu LTS";
};

To remove unused packages automatically, set:

Unattended-Upgrade::Remove-Unused-Dependencies "true";

4. Configure update frequency

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

Ensure the following:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";

5. Test the configuration

sudo unattended-upgrade --dry-run

Checking Automatic Update Logs

View logs:

cat /var/log/unattended-upgrades/unattended-upgrades.log

Monitor in real time:

tail -f /var/log/unattended-upgrades/unattended-upgrades.log

Disabling Automatic Updates (if necessary)

sudo dpkg-reconfigure -plow unattended-upgrades

Or manually edit:

APT::Periodic::Unattended-Upgrade "0";

Summary

To enable automatic updates:

  1. Install unattended-upgrades
  2. Enable the automatic update system
  3. Configure /etc/apt/apt.conf.d/20auto-upgrades
  4. Test the configuration
  5. Check logs regularly

Automatic updates are especially important for applying security patches quickly and maintaining safety.

10. FAQ (Frequently Asked Questions)

During Ubuntu setup, many users encounter similar questions or issues. This section answers common questions related to initial Ubuntu configuration.

Q1: Do I need to reboot after initial configuration?

A1:
Yes. Some settings—such as language configuration, keyboard mappings, timezone changes, and SSH settings—require a reboot to apply.

sudo reboot

Q2: Japanese input is not working. What should I do?

A2:
Check the following:

im-config -n fcitx
sudo apt install fcitx-mozc -y
fcitx-autostart

Q3: The Ubuntu timezone is incorrect. How can I fix it?

A3:

timedatectl
sudo timedatectl set-timezone Asia/Tokyo

Q4: SSH connection fails (or is refused). What should I check?

A4:

sudo systemctl status ssh
sudo systemctl start ssh
sudo ufw allow 22/tcp
sudo nano /etc/ssh/sshd_config
sudo systemctl restart ssh

Q5: Software installation fails with “Unable to locate package”. Why?

A5:
Update repositories:

sudo apt update

Enable additional repositories:

sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt update

Q6: How can I check if UFW firewall rules are applied correctly?

A6:

sudo ufw status verbose
sudo ufw reload

Q7: The system behaves strangely after updates. What should I do?

A7:

sudo reboot
sudo apt autoremove --purge
sudo apt install --reinstall package-name=version
sudo dpkg --configure -a
sudo apt install -f

Q8: I want to reduce disk usage in Ubuntu. How can I clean up the system?

A8:

sudo apt autoremove -y
sudo apt clean

Summary

This article has provided a detailed overview of the essential initial setup steps for Ubuntu. By following these configurations—system updates, Japanese language setup, timezone and locale adjustments, keyboard customization, firewall settings, SSH hardening, installing useful software, and enabling automatic updates—you can build a secure and efficient Ubuntu environment.

The FAQ section also covered common questions and troubleshooting tips to help you resolve typical issues encountered during setup.

Once your Ubuntu system is properly configured, feel free to explore more advanced customization and tailor your environment to your specific needs!

年収訴求