Initial configuration for newly installed Ubuntu
winchell cao
Posted on July 29, 2024
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
2. Set a password for the root user
Open a terminal and execute the following command:
sudo passwd root
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
Find the following line:
PermitRootLogin prohibit-password
Change it to:
PermitRootLogin yes
Save and close the file. Then restart the SSH service:
sudo systemctl restart ssh
3. Configure Time and Locale Settings
Set the system timezone:
sudo timedatectl set-timezone Asia/Shanghai
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
Check Docker version
docker version
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
Check docker-compose version
docker-compose --version
Modify the image repository
Open the file using a text editor like
vi /etc/docker/daemon.json
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"]
}
Restart Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
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
November 30, 2024