Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".(Japanese Version)

Debian10.13 ; Initialization

1. Install and configure 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".

1.1 Check vim package

Debian has vim installed by default, but the package is called "vim-tiny", which is a less-featured 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.

1.2  Installing the vim package

The "-y" option to the apt install command is an option that automatically confirms the installation.

After installation, check the vim package again with the dpkg command

Vim is installed as above

1.3  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.

1.4  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/".

"Enables pasting and copying of text
set clipboard+=autoselect
" Use vim's own extensions (not compatible with vi)
set nocompatible
" Specify character code
set encoding=utf-8
" Specify file encoding
set fileencodings=utf-8,iso-2022-jp,sjis,euc-jp
" Specify the line feed code to be automatically recognized
set fileformats=unix,dos
" Obtain a backup
set backup
" Specify the directory from which to obtain backups
set backupdir=~/backup
" Number of generations to keep search history
set history=50
" Do not distinguish between upper and lower case letters when searching
set ignorecase
"Mixing capital letters in search terms makes the search case sensitive
set smartcase
" Highlight words matching your search term
set hlsearch
" Use incremental search
set incsearch
" Display line numbers
set number
" Visualize line breaks ( $ ) and tabs ( ^I )
set list
" Highlight corresponding parentheses when entering parentheses
set showmatch
"No newlines at the end of files
set binary noeol
" Enable automatic indentation
set autoindent
" Color-coded display by syntax
syntax on
"change color of comment text in case of [ syntax on]
highlight Comment ctermfg=LightCyan
"Wrap lines by window width
set wrap

Comment out any unnecessary items above.

1.5  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. Network Settings

2.1 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 checked by referring to the "/etc/hostname" file.
Refer to the "/etc/hostname" file with the "cat" command, and if the "Lepard" configuration value is displayed as shown below, the host name check is complete.

2.2 Set IP address to network interface

The IP address is set to DHCP (dynamic IP address) when Debian 10 is installed, so set a fixed IP address.
Modify the "/etc/network/interfaces" file to set the IP address, and then restart the network interface (ens33 in this case).
The network interface name will vary depending on the environment in which the setup was performed, so check the interface name first.
The command to check network information is "ip addr". Running this command will display the network interface name and IP address information.

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:f3:3d:d3 brd ff:ff:ff:ff:ff:ff
inet brd scope global dynamic ens33
valid_lft 157298sec preferred_lft 157298sec
inet6 fe80::20c:29ff:fef3:3dd3/64 scope link
valid_lft forever preferred_lft forever

In the above case, "ens33" is the network interface name.

2.3 Setting up a static IP address

We proceed assuming the following information necessary for the network configuration and the parameters to be configured this time.

・IP address
・subnet mask
・default gateway
・DNS server

IP addresses are set by modifying the "/etc/network/interfaces" file.

The default values are as follows
#This file describes the network interfaces available on your system
#and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

#The loopback network interface
auto lo
iface lo inet loopback

#The primary network interface
allow-hotplug ens33
iface ens33 inet dhcp

Change as follows
#The primary network interface
allow-hotplug ens33
#iface ens33 inet dhcp  ←comment-out
#network interface settings
iface ens33 inet static   ←add
address  ←add
netmask  ←add
gateway   ←add
dns-nameservers ←add

2.4 Enable static IP address

3. Set server time synchronization

In this section, we will configure "timesyncd," a service that automatically adjusts the server time.

3.1 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.

Edit the configuration file.

The default values are as follows
#NTP= 2.debian.pool.ntp.o rg

Change this to a time server in Japan as follows

3.2 Reflection of timesyncd service settings

If no error is output, 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.

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, limit the number of users who can execute the su command as much as possible, because if the login information of any one of the users is known, the root user privilege can be taken away with the su command after unauthorized access.
Allow only users belonging to the wheel group to be authorized to execute su.

4.1 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.

4.2 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.

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 not used anymore, so it is commented out.
If you use it in Japan, it should be a mirror with jp.

6. Make the locate command available

To search for a specific file on the entire Linux system, use the find command, but find's options are somewhat confusing.
The locate command can extract all files with a given 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. The "locate" command can be used here.

6.1Installing the locate package

If the locate package name appears in the execution result as shown above, the installation has been verified.

6.2 Create database

6.3 Executing the locate command

As an example, search for all files named "sshd".

A list of filenames containing sshd is now displayed.

7. Locale Settings

This is the language setting of the Linux system; if you selected Japanese as the locale when you installed Debian, you do not need to change it since the environment is originally Japanese.
If your environment is "English locale" and you prefer to use Japanese locale, please do so.

7.1 Check current locale

Check the locale set in the system. Use the "localectl status" command to check the locale.

In the above case, "C.UTF-8" is the locale, which means C locale (POSIX locale).

7.2 Changed to Japanese locale

In Debian, a list of locales can be found with the command "localectl list-locales". Run it to see which locales are available on your system.

Two locales are displayed. Since "ja_JP.UTF-8" is the locale for Japanese, we will set the "ja_JP.UTF-8" locale.
To set the locale, use the "localectl set-locale" command. Execute as follows

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

8. Time zone settings.

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

8.1 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.

8.2 Change time zone to Japan

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

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 package, run the "apt update" command. Run the command as follows

To update a package, run the "apt upgrade" command.

Copied title and URL