Initial tasks performed in a Linux environment#

There are certain tasks you must perform every time you get a new Linux environment. However, it is inefficient to re-examine the work details every time. In this article, I summarized the initial setup and subsequent maintenance work that I did. Mainly assumes an Ubuntu-based environment.

Initial tasks as root user#

First, perform the following steps as root user or a user with sudo privileges.

Package updates#

sudo apt update && sudo apt upgrade -y

Installing basic tools#

Install the minimum tools required for development and configuration.

sudo apt install -y build-essential git curl vim

Installing Japanese fonts#

Install the fonts required for Japanese display.

sudo apt install -y fonts-noto-cjk

Locale settings#

Set the Japanese locale.

sudo apt install -y language-pack-ja
sudo locale-gen ja_JP.UTF-8
sudo update-locale LANG=ja_JP.UTF-8
source /etc/default/locale

Check whether the settings are reflected.

locale

It is OK if part of the output contains the following:

LANG=ja_JP.UTF-8

Time zone settings#

Set to JST (Japan Standard Time).

sudo timedatectl set-timezone Asia/Tokyo

Confirmation command:

timedatectl

Example output:

Time zone: Asia/Tokyo (JST, +0900)

Firewall settings#

Configure basic security settings.

sudo apt install -y ufw
sudo ufw enable
sudo ufw allow OpenSSH

Confirmation command:

sudo ufw status verbose

Example output:

To                         Action      From
--                         ------      ----
22/tcp (OpenSSH)           ALLOW IN    Anywhere
22/tcp (OpenSSH (v6))      ALLOW IN    Anywhere (v6)

Regular package maintenance#

Use cron to periodically remove unnecessary packages.

sudo tee /etc/cron.d/apt-autoremove > /dev/null <<EOF
17 3 1 * *   root   apt update -qq && apt -y autoremove && apt -y clean
EOF

Adding work users and setting permissions#

Create a working user and grant sudo privileges.

sudo adduser your-username
sudo usermod -aG sudo your-username

Initial work with users#

From here, switch to the work user you created (e.g. your-username).

Configuring SSH public key#

Place the public key in .ssh/authorized_keys in preparation for SSH connection.

mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "your-public-key" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Connection confirmation#

Verify that you can connect via SSH from another machine.

ssh your-username@your-server-ip

summary#

This article summarizes the basic setup steps and minimum maintenance that should be performed in a Linux environment. I will use it as my own reference to save myself the trouble of having to look it up every time. It will be updated from time to time as necessary.

Article information

Post date:

2025-05-01

author:

Mr. Takagi