Initial configuration for newly installed Ubuntu

miss_you_3000

winchell cao

Posted on July 29, 2024

Initial configuration for newly installed Ubuntu

A newly installed Ubuntu system requires some basic initial configuration to ensure security, performance, and usability. Here is a basic initialization guide:

1. Update the System

First, make sure your system packages are up to date.

sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y
Enter fullscreen mode Exit fullscreen mode

2. Set a password for the root user

Open a terminal and execute the following command:

sudo passwd root
Enter fullscreen mode Exit fullscreen mode

Enable Root Login (if necessary)
By default, root login is often disabled in Ubuntu for security reasons. If you need to enable root login, you can edit the SSH configuration file. Open the file using a text editor like

sudo vi /etc/ssh/sshd_config
Enter fullscreen mode Exit fullscreen mode

Find the following line:

PermitRootLogin prohibit-password
Enter fullscreen mode Exit fullscreen mode

Change it to:

PermitRootLogin yes
Enter fullscreen mode Exit fullscreen mode

Save and close the file. Then restart the SSH service:

sudo systemctl restart ssh
Enter fullscreen mode Exit fullscreen mode

3. Configure Time and Locale Settings

Set the system timezone:

sudo timedatectl set-timezone Asia/Shanghai
Enter fullscreen mode Exit fullscreen mode

4. install Docker

To install Docker on your Ubuntu system, follow these steps:

# Check and uninstall the old version of docker
apt-get remove docker docker-engine docker.io containerd runc
# install Docker dependencies
apt-get install ca-certificates curl gnupg lsb-release
# Add the Docker official GPG key
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Add Docker software source
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Install Docker
apt-get install docker-ce docker-ce-cli containerd.io
# Start Docker and add it to the startup items
systemctl start docker
systemctl enable docker
Enter fullscreen mode Exit fullscreen mode

Check Docker version

docker version
Enter fullscreen mode Exit fullscreen mode

install Docker Compose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
cd /usr/local/bin/
chmod 777 docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode

Check docker-compose version

docker-compose --version
Enter fullscreen mode Exit fullscreen mode

Modify the image repository
Open the file using a text editor like

vi  /etc/docker/daemon.json

Enter fullscreen mode Exit fullscreen mode

Adding a mirror repository

{
  "registry-mirrors": ["https://docker.m.daocloud.io", "https://dockerproxy.com", "https://docker.mirrors.ustc.edu.cn", "https://docker.nju.edu.cn"]
}
Enter fullscreen mode Exit fullscreen mode

Restart Docker

sudo systemctl daemon-reload
sudo systemctl restart docker
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
miss_you_3000
winchell cao

Posted on July 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related