Contents
1. Set the root password and use the SU command
In the default Ubuntu configuration, the root user is disabled because no password is set.
By setting a password for the root user, the traditional [su] command can be used for transitions
1 2 3 4 5 |
$ sudo passwd root [sudo] password for <user> ← Current user's password Enter new UNIX password: ← Enter the root user password to be set Retype new UNIX password: ← Enter your password again passwd: password updated successfully |
Switch to root user
1 2 |
$ su - Password:<The password you have set above> |
2. Modernisation of the system
1 2 |
# apt update # apt upgrade |
3. Make the locate command available
The find command is often used to search for a specific file on the whole Linux system, but find is somewhat confusing in its options.
The locate command is capable of extracting all files with a given filename.
3.1 Install locate package
1 |
# apt install -y mlocate |
1 2 |
# dpkg -l | grep mlocate ii mlocate 0.26-3ubuntu3 amd64 quickly find files on the filesystem based on their name |
3.2 Example of the locate command
1 2 3 4 5 |
# locate sshd etc/pam.d/sshd /etc/ssh/sshd_config /etc/ssh/sshd_config.d ・・・・ |
4. vim editor settings
Ubuntu comes with vim installed by default
4.1 Change vim settings
If you don't want to allow all users to set their own vim preferences, you can create a ".vimrc" file in the user's home directory that allows you to change the vim environment for each user.
This time we will create a ".vimrc" file in the root user's home directory "/root/" and set it to apply to all users.
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 33 34 35 36 37 38 39 40 41 42 43 |
# vi ~/.vimrc ※Add the following to the contents of the file " Paste and copy set clipboard+=autoselect " Using vim's own extensions set nocompatible " Specify the charset set encoding=utf-8 " Specify file encoding set fileencodings=utf-8,iso-2022-jp,sjis,euc-jp " Specify a newline code for automatic recognition set fileformats=unix,dos " Get a backup " No backup taken [ set nobackup ] set backup " Specify the directory from which to take a backup set backupdir=~/backup " Number of generations to keep search history set history=50 " Case insensitive search set ignorecase " If you mix capital letters in your search terms, the search will be case sensitive set smartcase " Highlight words that match your search term set hlsearch " Use incremental search(Start searching for matching strings at any time while entering search terms) set incsearch " Display line numbers Don't show line numbers [ set nonumber ] set number "Making newlines ( $ ) and tabs ( ^I ) visible set list " Highlight the corresponding parentheses when typing set showmatch " No newline marks at the end of files set binary noeol " Enable auto-indent Do not enable [ noautoindent ] set autoindent " Colour coding by syntax No colour coding [ syntax off ] syntax on " Change the colour of the comment text when [ syntax on ]. highlight Comment ctermfg=LightCyan " Wrap lines with window width Do not call back [ set nowrap ] set wrap |
The above settings can be selected according to preference.
5. Network settings
5.1 Host name settings
If you set a hostname when you install Ubuntu and use that hostname, you do not need to follow this procedure.
To change the hostname, use the command "hostnamectl set-hostname".
As an example, here we will set "ubuntu-10" as the hostname.
1 |
# hostnamectl set-hostname ubuntu-10 |
Checking the results of the configuration
1 2 |
# cat /etc/hostname ubuntu-10 |
5.2 Setting IP addresses for network interfaces
If you specified a static IP address during Ubuntu installation, this section is not necessary.
If you want to change the IP address, change the file " /etc/netplan/00-installer-config.yaml" and reboot the network interface (eno1 in this environment).
The name of the network interface will vary depending on your environment, so check the interface name first.
Check network information
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 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: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:b7:36:94 brd ff:ff:ff:ff:ff:ff inet 192.168.11.152/24 brd 192.168.241.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feb7:3694/64 scope link valid_lft forever preferred_lft forever |
eno1:Network interface name
192.168.11.152 : IP address
5.2.1 Setting a static IP address
This time, fix the IP address to 192.168.11.63.
The network information required is as follows, which should be reflected in the configuration file.
subnet mask : 192.168.11.63/24
default gateway : 192.168.11.1
name-server : 192.168.11.1
The configuration of the IP address is done by modifying the file " /etc/netplan/00-installer-config.yaml".
Disable the installer default settings and back them up
1 |
# mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak |
Create a new installer configuration file
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# vi /etc/netplan/01-netcfg.yaml # This is the network config written by 'subiquity' network: ethernets: eno1: addresses: - 192.168.11.63/24 gateway4: 192.168.11.1 nameservers: addresses: - 192.168.11.1 version: 2 |
# Reflect settings
1 |
# netplan applye |
5.2.2 Disable IPv6
1 |
# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf |
1 2 |
# sysctl -p net.ipv6.conf.all.disable_ipv6 = 1 |
6. Configuring server time synchronisation
Configure "timesyncd", a service that automatically sets the server's time.
6.1 Configuring the timesyncd service
Before making any changes to 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 9 10 11 12 13 14 15 |
# vi /etc/systemd/timesyncd.conf [Time] #NTP= #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 [Time] ↓ Change [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 |
# systemctl restart systemd-timesyncd |
Check time synchronisation
1 2 3 4 5 6 7 8 |
# timedatectl status Local time: Tue 2021-12-14 10:46:50 UTC Universal time: Tue 2021-12-14 10:46:50 UTC RTC time: Tue 2021-12-14 10:46:50 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no |
If the message "System clock synchronized: yes" is displayed, time synchronization has taken place.
6.3 Set timezone to Japan
In the above example, the time zone: Etc/UTC (UTC, +0000) is set to Japan (Asia/Tokyo).
1 |
# timedatectl set-timezone Asia/Tokyo |
1 2 3 4 5 6 7 8 |
# timedatectl status Local time: Tue 2021-12-14 19:54:36 JST Universal time: Tue 2021-12-14 10:54:36 UTC RTC time: Tue 2021-12-14 10:54:36 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes NTP service: active RTC in local TZ: no |
As above, this is Japan!