Contents
1. Set root password and use SU command
In the default configuration of Ubuntu, the root user is unavailable because no password has been set.
By setting a password for the root user, transitions using the traditional [su] command will be possible.
1 2 3 4 5 |
$ sudo passwd root [sudo] password for <user name> ← Current user's password New password: ← Enter the password to be set Retype new password: ← again password passwd: password updated successfully |
Switch to root user
1 2 |
$ su - Password:<Password set above> |
2. System Modernization
1 2 |
# apt update # apt upgrade |
3. Make locate command available
The find command is often used to search for specific files throughout the Linux system, but find is somewhat confusing in terms of specifying options.
The locate command can extract all files with a specified filename.
3.1 Installing the locate package
1 2 3 4 |
# apt install -y mlocate Check the package # dpkg -l | grep mlocate ii mlocate 1.1.18-1ubuntu1 all transitional dummy package |
3.2 Example of executing the locate command
1 2 3 4 5 6 7 |
# updatedb # locate sshd /etc/pam.d/sshd /etc/ssh/sshd_config /etc/ssh/sshd_config.d ・・・・ You will see a list of filenames containing sshd as above |
4. vim editor settings
Ubuntu has vim installed by default
4.1 Change vim settings
There may be cases where you do not want to allow vim settings for all users. In such cases, a ".vimrc" file can be created in each user's home directory to change the vim environment for each user.
In this case, we will create a ".vimrc" file in the root user's home directory "/root/" and apply it to all users.
1 |
# vi ~/.vimrc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
※Add the following as the contents of the file 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 " 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 the search term The reverse is [ set nohlsearch ]. set hlsearch " Use incremental search (start searching for matching strings at any time while entering search terms) set incsearch " Display line numbers set number " 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 |
Select the above settings according to your preference.
5. Network Settings
5.1 Host Name Settings
This procedure is not necessary if you have already set the hostname at the time of Ubuntu installation and wish to use the hostname as it is.
To change the hostname, use the "hostnamectl set-hostname" command.
As an example, we set "ubuntu-10" as the hostname.
1 2 3 4 |
# hostnamectl set-hostname ubuntu-10 Confirmation of setting results # cat /etc/hostname ubuntu-10 |
5.2 Set IP address to network interface
If a fixed IP address was specified during Ubuntu installation, this section is not necessary.
To change the IP address, change the " /etc/netplan/00-installer-config.yaml" file, and then restart the network interface (enp0s3 in this environment).
The network interface name will change depending on the environment in which the setup was performed, so check the interface name first.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Check network information # ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> 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 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:4c:cf:57 brd ff:ff:ff:ff:ff:ff inet 192.168.11.83/24 brd 192.168.11.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe4c:cf57/64 scope link valid_lft forever preferred_lft forever |
enp0s3 : network interface name
192.168.11.83 : IP address
5.2.1 Setting up a static IP address
For this example, we will fix the IP address to 192.168.11.63. The required network information is as follows, which is reflected in the configuration file.
Address : 192.168.11.63/24
Default gateway : 192.168.11.1
Name server : 192.168.11.1
IP addresses are configured by changing the " /etc/netplan/00-installer-config.yaml" file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Disable and back up the installer default settings. # mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak Create a new installer configuration file # vi /etc/netplan/01-netcfg.yaml # This is the network config written by 'subiquity' network: ethernets: enp0s3: addresses: - 192.168.11.63/24 nameservers: addresses: - 192.168.11.1 search: - korodes.com routes: - to: default via: 192.168.11.1 version: 2 # Reflect settings # netplan apply |
5.2.2 Disabling IPv6
1 2 3 |
# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf # sysctl -p net.ipv6.conf.all.disable_ipv6 = 1 |
6. Configure server time synchronization
Configure "timesyncd", a service that automatically adjusts the server time.
6.1 Configuration of timesyncd service
Before changing a file, make a backup copy of the original file
1 |
# cp -p /etc/systemd/timesyncd.conf /etc/systemd/timesyncd.conf.org |
Edit configuration file
1 2 3 4 5 6 7 8 |
# vi /etc/systemd/timesyncd.conf [Time] #NTP= #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 [Time] |
↓ change
1 2 3 4 5 6 7 |
[Time] NTP=ntp.jst.mfeed.ad.jp FallbackNTP=ntp.nict.jp #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 |
6.2 Reflection of timesyncd service settings
1 2 3 4 5 6 7 8 9 10 11 |
# systemctl restart systemd-timesyncd Confirmation of time synchronization # timedatectl status Local time: Sun 2023-10-01 04:15:53 UTC Universal time: Sun 2023-10-01 04:15:53 UTC RTC time: Sun 2023-10-01 13:15:53 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no |
If "System clock synchronized: yes" is displayed, the time is synchronized.
6.3 Set time zone to Japan
In the above, Time zone: Etc/UTC (UTC, +0000), so it matches Japan (Asia/Tokyo).
1 2 3 4 5 6 7 8 9 |
# timedatectl set-timezone Asia/Tokyo # timedatectl status Local time: Wed 2022-05-18 09:25:50 JST Universal time: Wed 2022-05-18 00:25:50 UTC RTC time: Wed 2022-05-18 00:25:50 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes NTP service: active RTC in local TZ: no |
As above, it is in Japan.