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 5 |
# apt install -y locate Check the package # dpkg -l | grep locate ii locate 4.9.0-5build1 amd64 maintain and query an index of a directory tree |
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 5 |
# hostnamectl set-hostname Lepard Confirmation of setting results # cat /etc/hostname Lepard |
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.
Check network information
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# 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 noprefixroute valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:4a:bb:5c brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.11.83/24 brd 192.168.11.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe4a:bb5c/64 scope link valid_lft forever preferred_lft forever |
ens33:: network interface name
192.168.11.83 : IP addres
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/50-cloud-init.yamll" 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/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak Create a new installer configuration file # vi /etc/netplan/51-cloud-init.yaml network: ethernets: ens33: 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 9 10 11 12 13 |
# vi /etc/systemd/timesyncd.conf Add to the end [Time] #NTP= #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 #ConnectionRetrySec=30 #SaveIntervalSec=60 NTP=ntp.jst.mfeed.ad.jp FallbackNTP=ntp.nict.jp |
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: Tue 2024-04-30 05:27:27 UTC Universal time: Tue 2024-04-30 05:27:27 UTC RTC time: Tue 2024-04-30 05:27:27 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: Tue 2024-04-30 14:28:22 JST Universal time: Tue 2024-04-30 05:28:22 UTC RTC time: Tue 2024-04-30 05:28:21 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes NTP service: active RTC in local TZ: no |
As above, it is in Japan.