Debian 常用指令

网络管理

建立网络接口配置文件

cd /etc/sysconfig/
cat > ifconfig.eth0 << "EOF"
ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
EOF

IP 地址

nano /etc/network/interfaces

DNS

cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf

domain <Your Domain Name>
nameserver <IP address of your primary nameserver>
nameserver <IP address of your secondary nameserver>

# End /etc/resolv.conf
EOF

系统主机名

echo "<lfs>" > /etc/hostname

IP:域名

cat > /etc/hosts << "EOF"
# Begin /etc/hosts

127.0.0.1 localhost
127.0.1.1 <FQDN> <HOSTNAME> 
<192.168.1.1> <FQDN> <HOSTNAME> [alias1] [alias2 ...] 
::1 localhost ip6-localhost ip6-loopback 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 

# End /etc/hosts 
EOF

 

软件包

安装
apt-get update            #更新软件包库数据
apt-get -y install foo    #安装“foo”包的最新版本及其依赖项
卸载
apt-get remove foo                       #仅卸载"foo"包
apt-get -y autoremove foo	             #卸载 Debian 11不再需要的"foo"包及其依赖项
删除
apt-get -y purge foo                #删除"foo"包配置和数据
apt-get -y autoremove --purge foo	#删除"foo"包配置、数据及其所有依赖项
更新
apt-get upgrade         #更新并安装已安装软件包的最新版本而不删除任何其他软件包
apt-get dist-upgrade	#更新并安装已安装软件包的最新版本,同时根据需要删除其他软件包
查询
dpkg --list  
apt-cache show foo 
配置
nano /etc/yum.repos.d    

ssh

远程登录
nano /etc/ssh/sshd_config            #打开 sshd_config文件
#port 22                             #找到此行,如下图1
port 22                              #更改为此行,如下图2(去掉开头"#")
#PermitRootLogin prohibi-password    #找到此行,如下图3
PermitRootLogin yes                  #更改为此行,如下图4(去掉开头 "#","yes"代替"prohibi-password"

#PasswordAuthentication yes          #找到此行
PasswordAuthentication yes           #更改为此行(去掉开头"#"),如下图5 
systemctl restart sshd  

Docker 安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
apt-get purge docker-ce
rm -rf /var/lib/docker

 

 


      Revision #50
      Created 27 July 2022 20:07:59 by 余海
      Updated 30 July 2022 19:14:23 by 余海