Debian12.5 ; OS installation and initial setup

1.Debian12 Overview and Installation Instructions

In this article, we will explain how to build a server with Debian, the basis of the user-friendly Linux distribution UBUNTU.
The latest is Debian 12 (codenamed "bookworm") (released on June 10, 2023), a point-release version of Debian 12.5 (released on February 10, 2024) with bug fixes and security updates.

1.1 Download Debian12.install image

Download site for Debian12.  https://www.debian.org/

Please access the above official website and download the latest "debian-12.5.0-amd64-netinst.iso." which is convenient for setup in an environment connected to the Internet. (It will fit on one CD.)

Burn the iso image saved above as a boot disk to CD or USB using your favorite writing software.

1.2 Debian12 Install

The installation procedure after that is the same as for Debian 12.1, so we omit it. Please refer to the following page.

2. initialization

2.1 Installing and configuring the vim editor

Debian has "nano" as the default editor. nano is somewhat difficult to use, and there are few environments where it is used, so we will show you how to change the editor to "vim".

Check the vim package
Debian comes with vim installed by default, but the package is called "vim-tiny", which is a less functional version. To check the installed vim packages, use the "dpkg" command. The "-l" option will display a list of packages.

Since the "dpkg" command as is will show all packages installed on the system, we will use the "grep" command to extract only those packages that contain the string "vim". Execute as follows

You can see that only the "vim-tiny" package is installed as shown above.

①Installing the vim package
The "-y" option to the apt install command is an option to automatically confirm the installation.

Vim is installed as shown above.

➁Change the editor used by default
Change the default editor to "vim" installed from nano. To change the default editor, run the command "update-alternatives --set editor".

If the output looks like the above, the editor has been modified.

➂Change vim settings
To allow all users, create a ".vimrc" file in "/root/".
To create a vim environment for each user, create a ".vimrc" file in the user's home directory.
This time, we will create a ".vimrc" file in the root user's home directory "/root/".

Please comment out anything unnecessary in the above

④Activation of vim configuration changes
Please log out of the system for the settings to take effect. When you log in to the system again, the above information will be reflected.

2.2 Network Settings

①Host Name Settings
This section describes how to change the hostname of a host that has been set during Debian installation for some reason.
To set the hostname, use the command "hostnamectl set-hostname". Execute the command as follows In this example, the hostname is set to "Lepard".

The result of the configuration can be confirmed by referring to the "/etc/hostname" file.
Refer to the "/etc/hostname" file with the "cat" command, and if the "Lepard" value is displayed as shown below, the host name confirmation is complete.

➁Set IP address to network interface
The IP address of the Debian 12 installation is set to a dynamic IP address (DHCP), so set a fixed IP address. Then reboot the network interface (ens33 in this case).
The network interface name will vary depending on the environment in which the setup was performed.
The command to check the network information is "ip addr (or ip a)". Running this command will display the network interface name and IP address information.

The one displayed after the sequential number is the "network interface name. Since "lo" is the "local loopback interface," it is not usually used. In the above case, "ens33" is the network interface name.

➂Setting up a static IP address
Now that we know the network interface name, we will configure the network settings. We will proceed assuming the following information necessary for network configuration and the parameters to be configured this time.

・IP address    192.168.11.83
・subnet mask   255.255.255.0(24Bit)
・default gateway 192.168.11.1
・DNS Server   192.168.11.1

IP addresses are configured by modifying the "/etc/network/interfaces" file.
Open the interfaces file with the vi command.

④Enable static IP address

2.3 Set server time synchronization

We will configure "timesyncd", a service that automatically adjusts the server time.

①Configuration of timesyncd service
The timesyncd service is configured in the file "/etc/systemd/timesyncd.conf".
Before changing the file, make a backup copy of the original file.

We will edit the configuration file.

➁Reflection of timesyncd service settings

If no error is printed, the service has restarted. Check the time synchronization. The "timedatectl status" command is used to check the time synchronization. Execute as follows

If "System clock synchronized: yes" is displayed, the time is synchronized.

2.4 Restrict users who can su

In Debian, any user can be changed to the root user with the "su" command in the default configuration.
If multiple users are created on the server, and if any of the users' login information is known, the su command can be used to take away root user privileges after unauthorized access is gained.
Only users who belong to the wheel group can be authorized to execute su.

①Adding users to the wheel group
First, create a wheel group with the following command

Run the usermod command to add a user to the wheel group. As an example, let us assume that the user to be added is "lan".

Confirm that the wheel group is added to the wheel group using the id command.

➁Edit configuration file for su command
The configuration file for the su command is /etc/pam.d/su. (around line 15)

The "lan" user can now transition to root privileges using the "su -" command.

2.5 Debian Repository Mirror Settings Edit

The repository mirror configuration file is /etc/apt/sources.list, make a copy and edit it.

The file contents are

The top one is the media used during installation. It is no longer used, so it is commented out.
Add Backports repository (add the following to the last line)

Update source list

2.6 Make the locate command available

To search for a specific file on the entire Linux system, use the find command, but find is somewhat confusing in its options.
The locate command can extract all files with a specified filename.
Although a database of file and folder names must be created in advance, it has the advantage of being fast and easy to use. In this example, the "locate" command is used.

①Installing the locate package

➁Create database

➂Executing the locate command
As an example, search for all files named "sshd".

A list of filenames containing sshd is now displayed.

2.7 Locale Settings

If you have selected Japanese as your locale when installing Debian, you are already in a Japanese environment and do not need to change it.
If your environment is "English locale" and you prefer to use Japanese locale, please do so.

①Check current locale
Check the locale set in the system. Use the "localectl status" command to check the locale.
(Currently, LANG=en_US.UTF-8 is used for English.)

➁Changed to Japanese locale
Set the locale with the dpkg-reconfigure command

Delete "*" from "en_US.UTF-8 UTF-8" and click OK

Select "ja_JP,UTF-8" and click OK

Check again

We have confirmed that the "ja_JP.UTF-8" locale is set as shown above.

2.8 Time Zone Settings

In most cases, the time zone for Debian 12 is set during installation, but if the Japanese time zone "JST" is not specified, it can be changed with the "timedatectl" command.

①Display of current time zone
To check the time zone set on the server, run the "timedatectl status" command

The time zone is set to "Asia/Tokyo (JST)" as shown above.

➁Change time zone to Japan
If it is not "Asia/Tokyo (JST)", you can change the time zone with the "timedatectl set-timezone" command.

2.9 Update system packages

Debian systems installed from the media may contain outdated packages. Debian also uses "apt" to update all packages.
To see only the list of packages to be updated without updating the packages, run the "apt update" command. The command is executed as follows

In this case, all packages have been updated, but if you need to update any of them, run the "apt upgrade" command.

Copied title and URL