Ubuntu Initial Setup Guide: 10 Essential Settings to Configure After Installation

目次

1. Introduction

Ubuntu is one of the most widely used Linux distributions, catering to both beginners and advanced users. Its open-source nature and strong community support make it an attractive choice. However, a fresh installation of Ubuntu does not immediately offer an optimal experience. Some basic initial settings must be configured to ensure smooth and efficient usage.

This guide will walk you through the essential setup steps after installing Ubuntu. Each step is explained in detail, including how to run commands and the purpose of each setting, ensuring even beginners can follow along with ease.

Why You Need to Configure Ubuntu After Installation

A fresh Ubuntu installation may lack certain functionalities in terms of usability and security. Some common issues include:

  • System Updates Required: The packages included in the installation media may not be the latest versions. Updating is essential for security patches and bug fixes.
  • Incomplete Language Support: Ubuntu is set to English by default. Additional configurations are necessary for seamless Japanese input and display.
  • Unconfigured Security Settings: Without enabling the firewall or properly setting up SSH, your system may be vulnerable to unauthorized access.
  • Missing Essential Software: The default installation includes only minimal applications. You may need to install additional software for daily use.

Who This Guide Is For

This guide is intended for the following users:

  • Beginners who have just installed Ubuntu
  • Users unfamiliar with basic Linux command-line configuration
  • Anyone looking to enhance Ubuntu’s usability and security

Each section provides step-by-step instructions, allowing you to smoothly configure your system. Follow along, and you’ll be ready to use Ubuntu efficiently.

In the next section, we will explain how to update Ubuntu’s software packages to the latest version.

2. System Updates

Right after installing Ubuntu, the software packages included in the system may not be up to date. To ensure security and system stability, the first step should be updating your system to the latest version.

Why System Updates Are Necessary

The Ubuntu installation media contains packages that were current at the time of release. However, since then, security patches and bug fixes may have been released. Not updating your system could result in the following risks:

  • Security Vulnerabilities: Older packages may contain security flaws that attackers can exploit.
  • Unresolved Bugs: Software issues that have already been fixed by developers may still exist in your system.
  • Compatibility Issues: New applications may not work properly due to outdated system libraries or dependencies.

To avoid these risks, it’s highly recommended to update the package list and upgrade all software immediately after installing Ubuntu.

Updating the Package List

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

sudo apt update

This command fetches the latest package information from Ubuntu’s repositories and updates the system’s internal database.

Upgrading Installed Packages

Once the package list is updated, upgrade all installed packages with the following command:

sudo apt upgrade -y

This will download and install newer versions of existing packages. The -y option allows the upgrade process to proceed without confirmation.

Removing Unnecessary Packages (Recommended)

After upgrading, it’s a good idea to remove outdated and unused packages to free up disk space. Run the following command:

sudo apt autoremove -y

This command automatically removes unused libraries and dependencies that are no longer needed.

Restarting the System (If Necessary)

If a kernel update or critical system package upgrade is included, a system reboot may be required. To check if a reboot is needed, run the following command:

sudo reboot

If a kernel update was applied, restarting is necessary to apply the changes.

侍エンジニア塾

3. Configuring the Japanese Environment

By default, Ubuntu is set to English as the primary language. To use Japanese comfortably, you need to install language packs and set up a Japanese input system.

This section provides a detailed guide on how to configure the Japanese environment in Ubuntu.

Installing the Japanese Language Pack

First, install the Japanese language pack to enable Japanese menus and system settings.

1. Installing the Japanese Language Pack

Open the terminal and run the following command:

sudo apt install language-pack-ja -y

This command installs the Japanese locale data required for system-wide Japanese language support.

2. Changing the System Language to Japanese

Next, set the system language to Japanese by running:

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

To apply the changes, log out and log back in, or restart the system:

sudo reboot

After rebooting, check if menus and dialogs are displayed in Japanese.

Setting Up Japanese Input (Installing Mozc)

By default, Japanese input is not enabled in Ubuntu. To type in Japanese, you need to install an Input Method Editor (IME).

Recommended IME:

  • Mozc (The open-source version of Google Japanese Input)

1. Installing Mozc

Run the following command to install Mozc, a popular Japanese input method:

sudo apt install fcitx-mozc -y

2. Switching the Input Method to Fcitx

To use Mozc, you need to change the input method to Fcitx. Run the following command:

im-config -n fcitx

Then, restart the system to apply the changes:

sudo reboot

3. Configuring Fcitx

After rebooting, open “Settings” → “Language Support” → “Keyboard Input Method” and ensure “Fcitx” is selected.

Next, open the Fcitx settings tool and enable Mozc:

fcitx-config-gtk3

If “Mozc” is not listed in the “Input Method” section, click the “+” button and add it manually.

Once configured, open a text editor and press the “Half-width/Full-width” key to check if Japanese input is working correctly.

Installing Japanese Fonts (Optional)

Ubuntu includes basic Japanese fonts, but you can install additional fonts for better readability.

To install Japanese fonts like Noto CJK, run:

sudo apt install fonts-noto-cjk -y

Final Steps to Apply the Settings

After completing the Japanese environment setup, restart the system to ensure all changes take effect:

sudo reboot

After rebooting, confirm that Japanese characters display correctly and that Japanese input works smoothly.

4. Configuring Time Zone and Locale

After installing Ubuntu, the default time zone and locale (regional and language settings) may not be correctly set. This is especially common when setting up Ubuntu in a global server or cloud environment, where the default time zone is often set to UTC (Coordinated Universal Time). If not properly configured, you may experience incorrect timestamps in logs or other applications.

This section explains how to correctly set the time zone and locale for your Ubuntu system.

Setting the Time Zone

In Ubuntu, you can use the timedatectl command to configure the time zone.

1. Checking the Current Time Zone

Run the following command to check your current time zone settings:

timedatectl

Example output:

               Local time: Thu 2025-03-05 12:34:56 UTC
           Universal time: Thu 2025-03-05 12:34:56 UTC
                 RTC time: Thu 2025-03-05 12:34:56
                Time zone: Etc/UTC (UTC, +0000)

In this example, the system is set to UTC, so we need to change it to Japan Standard Time (JST).

2. Changing the Time Zone to Japan Standard Time (JST)

Run the following command to change the time zone to Asia/Tokyo:

sudo timedatectl set-timezone Asia/Tokyo

3. Verifying the New Time Zone

Run the following command again to check if the time zone has been updated:

timedatectl

Example output:

               Local time: Thu 2025-03-05 21:34:56 JST
           Universal time: Thu 2025-03-05 12:34:56 UTC
                 RTC time: Thu 2025-03-05 12:34:56
                Time zone: Asia/Tokyo (JST, +0900)

If Asia/Tokyo (JST, +0900) appears in the output, the setting has been applied correctly.

Setting the System Locale

The locale settings define the system’s language and regional preferences. By default, Ubuntu may be set to English (en_US.UTF-8), so we will change it to Japanese (ja_JP.UTF-8).

1. Checking the Current Locale

Run the following command to check your current locale settings:

locale

Example output (default English settings):

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
...

2. Enabling the Japanese Locale

Check if the Japanese locale is installed and add it if necessary:

sudo locale-gen ja_JP.UTF-8

Then, set the default locale to ja_JP.UTF-8:

sudo update-locale LANG=ja_JP.UTF-8

3. Applying the Changes

To apply the new locale settings, either restart your system or run the following command:

source /etc/default/locale

Then, check if the changes have been applied:

locale

Example output:

LANG=ja_JP.UTF-8
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
...

Final Verification

To ensure that the time zone and locale settings are correctly applied, check the following:

  • Run timedatectl to confirm the time zone is set to Asia/Tokyo.
  • Run locale to confirm the locale is set to ja_JP.UTF-8.
  • Verify that system menus, timestamps, and language settings reflect the changes.

If the changes do not take effect, try logging out and logging back in, or restarting the system.

5. Configuring the Keyboard

Ubuntu’s default keyboard settings may not be optimized for Japanese users. If you are using a Japanese keyboard, some keys may not function correctly. Additionally, modifying the keyboard layout can improve usability, such as swapping the Caps Lock key with the Ctrl key.

This section explains how to configure your keyboard layout and customize key mappings in Ubuntu.

Setting the Keyboard Layout

1. Checking the Current Keyboard Layout

Run the following command to check your current keyboard layout settings:

localectl status

Example output:

   System Locale: LANG=ja_JP.UTF-8
       VC Keymap: us
      X11 Layout: us

In this example, the keyboard layout is set to us (English), so it needs to be changed if you are using a Japanese keyboard.

2. Changing the Keyboard Layout to Japanese

If you are using a Japanese keyboard (JP layout), update the settings with the following command:

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

To apply the changes, log out and log back in or restart your system.

Changing the Caps Lock Key to Ctrl

Many developers and power users prefer to use the Caps Lock key as an additional Ctrl key for improved efficiency. Ubuntu allows you to remap the Caps Lock key to Ctrl.

1. Temporarily Changing the Caps Lock Key

To change the Caps Lock key to Ctrl temporarily, run the following command:

setxkbmap -option ctrl:nocaps

This setting will reset after a reboot. To make it permanent, follow the next steps.

2. Permanently Changing the Caps Lock Key

To set Caps Lock as Ctrl permanently, edit the keyboard configuration file:

sudo nano /etc/default/keyboard

Find the following line:

XKBOPTIONS=""

Change it to:

XKBOPTIONS="ctrl:nocaps"

Save the file and apply the changes with:

sudo dpkg-reconfigure keyboard-configuration

Then, restart your system to activate the new keyboard settings:

sudo reboot

Additional Keyboard Customization (Optional)

Ubuntu allows further customization of key mappings. Here are some additional options:

  • Swap Ctrl and Caps Lock
setxkbmap -option ctrl:swapcaps
  • Assign Esc to the Caps Lock Key (Useful for Vim Users)
setxkbmap -option caps:escape

To make these settings permanent, add them to the XKBOPTIONS field in /etc/default/keyboard as shown earlier.

Verifying the Configuration

After configuring your keyboard, check if the settings have been applied correctly:

  • Run localectl status to confirm the keyboard layout is set to jp.
  • Press the Caps Lock key to verify if it functions as a Ctrl key (if changed).
  • If the settings are not applied, restart your system and check again.

With these configurations, your keyboard should now be properly set up for an improved Ubuntu experience.

6. Configuring the Firewall

Ubuntu comes with a built-in firewall called UFW (Uncomplicated Firewall), which makes it easy to manage firewall settings. By properly configuring UFW, you can block unauthorized access and enhance your system’s security.

This section explains how to enable UFW and set up basic firewall rules.

Enabling the Firewall

UFW is installed by default on Ubuntu, but it may not be enabled. First, check the current status of UFW.

1. Checking the Firewall Status

sudo ufw status

Example output if UFW is disabled:

Status: inactive

Example output if UFW is enabled:

Status: active

2. Enabling UFW

If UFW is inactive, enable it with the following command:

sudo ufw enable

Once enabled, UFW will start blocking unauthorized connections according to its default rules.

Setting Basic Firewall Rules

UFW allows you to specify which connections should be allowed or blocked. Below are the recommended settings for most users.

1. Setting Default Policies

By default, block incoming connections and allow outgoing connections with:

sudo ufw default deny incoming
sudo ufw default allow outgoing

2. Allowing SSH (Remote Access)

If you use SSH to connect to your system remotely, you need to allow SSH connections. Run the following command:

sudo ufw allow 22/tcp

If you have changed the SSH port (e.g., to port 2222), allow that port instead:

sudo ufw allow 2222/tcp

3. Allowing Web Server Traffic (HTTP/HTTPS)

If your system runs a web server (such as Apache or Nginx), allow HTTP and HTTPS traffic:

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

4. Allowing Other Services (If Needed)

If you use additional services, open their respective ports:

  • FTP (Port 21)
sudo ufw allow 21/tcp
  • MySQL (Port 3306)
sudo ufw allow 3306/tcp
  • PostgreSQL (Port 5432)
sudo ufw allow 5432/tcp

5. Applying the Rules

After setting the rules, reload UFW to apply the changes:

sudo ufw reload

Verifying Firewall Settings

1. Checking Allowed Rules

To view the currently allowed firewall rules, run:

sudo ufw status numbered

Example output:

Status: active

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

2. Removing a Firewall Rule

If you need to remove a rule, check the rule number using the previous command and delete it using:

sudo ufw delete 1

3. Enabling Firewall Logging (Optional)

To monitor firewall activity, enable logging with:

sudo ufw logging on

Firewall logs can be found in /var/log/ufw.log.

Temporarily Disabling the Firewall

If you need to temporarily disable UFW, use the following command:

sudo ufw disable

To re-enable it, run:

sudo ufw enable

Summary

UFW is a simple yet powerful firewall that provides essential security for Ubuntu systems. At a minimum, follow these steps:

  1. Enable UFW (sudo ufw enable)
  2. Set default policies (sudo ufw default deny incoming and sudo ufw default allow outgoing)
  3. Allow necessary ports (SSH, HTTP, HTTPS, etc.)
  4. Apply the rules (sudo ufw reload) and verify settings (sudo ufw status numbered)
  5. Enable firewall logging for security monitoring (sudo ufw logging on)

By following these steps, you can protect your Ubuntu system from unauthorized access while ensuring that essential services remain available.

7. Configuring the SSH Server

SSH (Secure Shell) is a protocol that allows you to connect to Ubuntu remotely and manage it securely. If you are using Ubuntu as a server, SSH is essential for remote administration. However, the default SSH settings may not be secure enough, so it is important to apply security enhancements.

This section explains how to install and configure an SSH server in Ubuntu while improving security.

Installing and Starting the SSH Server

The SSH server is not installed by default on Ubuntu Desktop, so you need to install it manually.

1. Installing the SSH Server (OpenSSH)

sudo apt install openssh-server -y

2. Checking SSH Server Status

To check if the SSH server is running, use the following command:

sudo systemctl status ssh

Example output:

● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since ...

If you see Active: active (running), SSH is running properly.

3. Enabling SSH to Start on Boot

sudo systemctl enable ssh

Changing the SSH Port (Security Enhancement)

The default SSH port (22) is commonly targeted by brute-force attacks. Changing the port number can help reduce attack attempts.

1. Editing the SSH Configuration File

sudo nano /etc/ssh/sshd_config

Find the following line and remove the # to uncomment it, then change the port number:

#Port 22

For example, to change the port to 2222, modify the line as follows:

Port 2222

2. Restarting the SSH Server to Apply Changes

sudo systemctl restart ssh

3. Allowing the New SSH Port in the Firewall

sudo ufw allow 2222/tcp

Then, verify that SSH is listening on the new port:

sudo netstat -tulnp | grep ssh

Setting Up Public Key Authentication (Disabling Password Login)

For enhanced security, it is recommended to disable password authentication and use public key authentication instead.

1. Generating SSH Key Pairs (On the Client Machine)

On your local machine (client), generate an SSH key pair:

ssh-keygen -t rsa -b 4096

This creates a private key (~/.ssh/id_rsa) and a public key (~/.ssh/id_rsa.pub).

2. Copying the Public Key to the Ubuntu Server

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

If ssh-copy-id is not available, you can manually copy the key:

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

3. Disabling Password Authentication

Edit the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Find the following line:

#PasswordAuthentication yes

Modify it as follows:

PasswordAuthentication no

Also, ensure that public key authentication is enabled:

PubkeyAuthentication yes

4. Restarting SSH to Apply Changes

sudo systemctl restart ssh

5. Testing SSH Login

Try logging in with the new port and key authentication:

ssh -p 2222 user@your-server-ip

If successful, you no longer need to enter a password for SSH login.

Additional SSH Security Measures

  • Change the SSH port (avoid using the default port 22).
  • Use public key authentication (disable password authentication).
  • Allow SSH access only to specific IP addresses (if applicable).
  • Limit login attempts to prevent brute-force attacks.

1. Installing fail2ban to Prevent Brute-Force Attacks

sudo apt install fail2ban -y

2. Restricting SSH to Specific Users (Optional)

Edit /etc/ssh/sshd_config and add:

AllowUsers your_username

3. Restarting SSH to Apply Changes

sudo systemctl restart ssh

Summary

By applying these SSH security enhancements, you can significantly reduce the risk of unauthorized access.

  1. Install and enable the SSH server.
  2. Change the default SSH port.
  3. Enable public key authentication and disable password authentication.
  4. Limit login attempts using fail2ban.
  5. Use the firewall to restrict SSH access to specific ports.

These steps will help ensure a secure and reliable remote management environment for your Ubuntu system.

8. Installing Essential Software

After installing Ubuntu, only a minimal set of applications is included. To create a more convenient and efficient work environment, you may need to install additional software.

This section introduces recommended software for Ubuntu and explains how to install them.

Methods for Installing Software

Ubuntu offers several ways to install software:

  1. Using APT (Advanced Package Tool)
sudo apt install package-name
  1. Using Snap Packages
sudo snap install package-name
  1. Using Flatpak (Optional)
flatpak install package-name
  1. Using PPA (Personal Package Archive)
sudo add-apt-repository ppa:repository-name
sudo apt update
  1. Manually Installing .deb Packages
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. Compression and Extraction Tools (zip, unzip, rar)

sudo apt install zip unzip rar unrar -y

7. Cloud Storage (Google Drive Integration)

sudo apt install gnome-online-accounts -y

Recommended Software for Developers

1. Docker (Container Management)

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 (Database Management)

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

Checking Installed Software

To list installed packages:

dpkg --get-selections | grep -v deinstall

To check installed Snap packages:

snap list

Summary

To enhance the usability of Ubuntu, consider installing the following software:

SoftwareDescriptionInstallation Method
Google ChromeFast web browserwget + dpkg
LibreOfficeFree office suiteapt install
VLCMultimedia playerapt install
Visual Studio CodeCode editorsnap install code --classic
GitVersion control systemapt install
DockerContainer virtualizationapt install
MySQLDatabase management systemapt install

Installing these applications will improve the functionality and usability of your Ubuntu system, making it more efficient for daily tasks and development.

9. Configuring Automatic Updates

Keeping Ubuntu updated is crucial for security and stability. While manual updates can be performed, automating the update process ensures your system stays up-to-date without requiring user intervention.

This section explains how to configure automatic updates in Ubuntu.

Installing and Configuring unattended-upgrades

Ubuntu includes a package called unattended-upgrades, which allows the system to automatically apply security and other important updates.

1. Installing unattended-upgrades

sudo apt install unattended-upgrades -y

2. Enabling Automatic Updates

sudo dpkg-reconfigure unattended-upgrades

3. Editing the Configuration File

To customize automatic updates, edit the configuration file:

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

Ensure the following lines are present (or uncommented):

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

To automatically remove unused packages, enable the following setting:

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

4. Configuring Update Frequency

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

Ensure the following lines are set:

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

5. Testing Automatic Updates

sudo unattended-upgrade --dry-run

Checking Automatic Update Logs

To verify if automatic updates are working, check the logs:

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

For real-time monitoring:

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

Disabling Automatic Updates (If Needed)

If you want to disable automatic updates, run:

sudo dpkg-reconfigure -plow unattended-upgrades

Alternatively, edit /etc/apt/apt.conf.d/20auto-upgrades and set:

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

Summary

Enabling automatic updates ensures that security patches and bug fixes are applied promptly, keeping your system secure.

  1. Install unattended-upgrades package.
  2. Enable automatic updates.
  3. Edit /etc/apt/apt.conf.d/20auto-upgrades to configure update frequency.
  4. Test the setup and check logs to confirm updates are applied.
  5. Monitor update logs regularly for any issues.

Since security updates are critical for system protection, enabling automatic updates is highly recommended.

10. FAQ (Frequently Asked Questions)

During the initial setup of Ubuntu, many users encounter common questions or issues. This section provides answers to frequently asked questions about Ubuntu’s setup and configuration.

Q1: Do I need to restart my system after completing the initial setup?

A1:
Yes, certain settings (such as language configuration, keyboard settings, time zone adjustments, and SSH configuration) require a reboot to take effect.

sudo reboot

Q2: Japanese input is not working properly. How can I fix it?

A2:
Check the following settings:

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

Q3: My system is displaying the wrong time zone. How do I fix it?

A3:

timedatectl
sudo timedatectl set-timezone Asia/Tokyo

Q4: I can’t connect to my Ubuntu system via SSH (connection refused or denied).

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: I can’t install software (error: “E: Unable to locate package”).

A5:

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

Q6: How do I check if the firewall (UFW) settings are applied correctly?

A6:

sudo ufw status verbose
sudo ufw reload

Q7: My system became unstable after an update. How do I fix it?

A7:

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

Q8: How can I free up disk space in Ubuntu?

A8:

sudo apt autoremove -y
sudo apt clean

Conclusion

This guide has covered the essential initial settings for Ubuntu in detail. The FAQ section has also provided answers to common issues that users may encounter. By following these steps, you can optimize Ubuntu for better performance, security, and usability.

Once you have completed the initial setup, explore Ubuntu further and customize it to suit your needs!

侍エンジニア塾