Summary of general initialization steps for Debian series systems

Preface

This article is mainly for record purpose, so as to save you from installing various software every time you install a new debian virtual machine. Why mention debian virtual machine? Because debian's LXC has already installed most of the basic software as long as it is newly created. The following article assumes that the console is logged in as root user, so I will not type sudo to save a few words.

Note 1: Steps 1 and 2 below can only be performed in the console.

Note 2: Because I installed it locally using the mini image provided by the Debian official website, it basically has no software by default, so I need to install it manually. If it is other deployment environments, such as cloud hosts, the image provided by the vendor by default may have integrated some of the software, so you don’t need to install it separately.

Note 3: Determine whether you need to perform some operations in this article or install some tools based on your actual needs. After all, this article is recorded according to my own needs.

1. Install vim

This is the first priority, the order is as follows:

apt install vim

2. Install and configure ssh server

Install openssh-server:

apt install openssh-server

Allow ssh login using the root account:

vim /etc/ssh/sshd_config

RemovePermitRootLoginThe previous #, and modified toyes

允许普通用户使用用户名及密码登录ssh:

RemovePasswordAuthentication yes前面的#

After the modification is complete, restart the ssh service:

systemctl restart ssh

Or you can restart it using the service command:

service ssh restart

In fact, I recommend logging in directly with the public key, which is safer. However, I need to connect from many terminals, and I don't like to configure each one, so I just log in with the account and password. If you usually manage 1 or 2 terminals, I suggest you log in directly with the public key. I will write another article about the configuration of public key login.

The following operations can be done using an ssh client and directly using copy and paste operations without having to use the difficult-to-use console. :)

3. Configure time zone

This step can be skipped if the installation process has already been configured:

timedatectl list-timezones \\List time zones timedatectl set-timezone your_time_zone \\Change time zone, usually Asia/Shanghai

4. Modify hostname

This step is not necessary. It depends on your needs. There are 3 ways:
usehostnamectlCommand, after modification, it is permanently effective and requires restart:

hostnamectl set-hostname your-hostname

Edit the hostname file directly. The modification is permanent and requires a restart:

vim /etc/hostname

Use the hostname command:
hostname your-hostname It takes effect immediately, but becomes invalid after reboot.

5. Modify IP address

Modification method for debian 11:

vim /etc/network/interfaces

The content is similar to the following:

auto lo auto eth0 #Set the computer to automatically connect to the network at startup iface lo inet loopback allow-hotplug eth0 iface eth0 inet static #static means using a fixed IP address to access the Internet, dhcp means using a dynamic IP address 192.168.9.100 #Set a static IP address, note that it is only address, not IP netmask 255.255.255.0 #Subnet mask gateway 192.168.9.254 #Gateway

If it is a static IP address modification, just change the address after address; if it is DHCP, change static to dhcp, and comment out the two lines of address and netmask.

Modification method for debian 12:

Debian12 network modification is different from previous versions. It no longer uses the vim /etc/network/interfaces method (to be honest, I really hate the behavior of changing the IP address setting method), but uses network-manager:

apt install network-manager

After installing the NetworkManager package, two more commands appear in the command line. One isnmcliA pure command network configuration tool, one isnmtuiA terminal graphical configuration tool.

NetworkManager configuration file path:/etc/NetworkManager/NetworkManager.conf, you need to modify the configuration:managed=falseChange tomanaged=true

6. Modify DNS address

Temporary modification:

vim /etc/resolv.conf

The content is similar to the following:

nameserver 119.29.29.29 # sets the preferred dns. For foreign countries, try to choose 1.1.1.1 or 8.8.8.8 nameserver 8.8.8.8 # sets the backup dns

Just modify as needed.

Permanent modification:

vim /etc/systemd/resolved.conf

Then add a line and modify the DNS address as needed:

DNS=8.8.8.8 114.114.114.114

After configuring steps 5 and 6, you need to restart the network service to take effect:

service networking restart

7. Install common network tools

The command is as follows:

apt install net-tools

Running the above command will install a set of classic network tools, including ifconfig, netstat, route, arp, hostname and mii-tool. These tools are commonly used for tasks such as network interface configuration, routing table viewing, ARP cache management and network troubleshooting.

8. Install DNS troubleshooting tool

apt install dnsutils

Running the above command will install a set of DNS query tools, including dig, nslookup and host. These tools are used to perform DNS query, resolution and diagnosis, and help troubleshoot domain name resolution problems.

9. Configure apt source (only required if the host is in the country)

The default repository source is configured in /etc/apt/sources.listIn, and each software's own source is in/etc/apt/sources.list.d/in the directory.

Here we assume that we use the USTC source of debian12 and use the cat command to add it directly:

cat > /etc/apt/sources.list << EOF deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware EOF

Of course, you can also use vim, whatever you like.

After changing the source, remember to useapt updateCommand update. (The principle of apt is: a list of software package information is saved locally, such as software size, version number, dependencies, etc. The apt update command updates this information list instead of updating the source (updating the source is done by the server). If this list is not updated, an old version of the software package may be installed when installing the software.)

Note that the sources for different versions are different, for example, debian12 corresponds to bookworm, and debian11 corresponds to bullseye.

10. Deploy Docker environment

First, install some necessary packages:

apt update
apt upgrade -y
apt install curl wget gnupg dpkg apt-transport-https lsb-release ca-certificates

Then add Docker's GPG public key and apt source. (Debian system) The command is as follows:

curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list

Last updated and installed:

apt update &&  apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

This is all I have recorded for now, and I will add more if I encounter any later.

Share this article
The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSite MapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       
en_US