Debian11基本配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Debian11基本配置相关的知识,希望对你有一定的参考价值。

参考技术A 1、查看用户 id 信息

2、将 www 用户添加到 sudo 组:
从图中看到几个问题:

使用 timedatectl set-timezone 修改系统时区,然后再用 date 查看修改是否生效:

请参考 Debian 11 “bullseye” 安装笔记

1debian11基本配置

1、Debian完整镜像下载

1、 准备工作:最小化debian系统,添加一个100g的sata硬盘,网络适配器类型选择NAT,本机可以上网

2、 配置好apt源,挂载光盘,修改网卡ip地址的模式为dhcp即可,查看是否获取到了ip地址

root@vss:~# ping www.baidu.com
PING www.a.shifen.com (220.181.38.150) 56(84) bytes of data.
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=1 ttl=53 time=17.9 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=2 ttl=53 time=17.8 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 17.818/17.871/17.924/0.053 ms

3、 安装所需的组件

root@vss:~# apt install vim bash-completion net-tools -y
root@vss:~# apt install aptitude -y

4、 挂载之前添加的100G硬盘

#创建文件夹
root@vss:~# mkdir /iso
#查看分区挂载
root@vss:~# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   40G  0 disk 
├─sda1   8:1    0  7.8G  0 part /
├─sda2   8:2    0    1K  0 part 
├─sda5   8:5    0  2.9G  0 part /var
├─sda6   8:6    0  976M  0 part [SWAP]
├─sda7   8:7    0  580M  0 part /tmp
└─sda8   8:8    0 27.8G  0 part /home
sdb      8:16   0  100G  0 disk 
sr0     11:0    1 1024M  0 rom  
#格式化分区
root@vss:~# mkfs.ext4 /dev/sdb
#挂在磁盘
root@vss:~# vim /etc/fstab
#在最后一行添加
/dev/sdb        /iso                                      ext4  defaults        0   0
#使挂在生效
root@vss:~# mount -a
#查看挂在
root@vss:~# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   40G  0 disk 
├─sda1   8:1    0  7.8G  0 part /
├─sda2   8:2    0    1K  0 part 
├─sda5   8:5    0  2.9G  0 part /var
├─sda6   8:6    0  976M  0 part [SWAP]
├─sda7   8:7    0  580M  0 part /tmp
└─sda8   8:8    0 27.8G  0 part /home
sdb      8:16   0  100G  0 disk /iso
sr0     11:0    1 1024M  0 rom  
root@vss:~#

5、 安装下载工具

#安装下载工具
root@vss:/iso# aptitude install jigdo-file -y
root@vss:/iso# jigdo-lite  https://mirrors.tuna.tsinghua.edu.cn/debian-cd/11.2.0/amd64/jigdo-dlbd/debian-11.2.0-amd64-DLBD-1.jigdo

Jigsaw Download "lite"
Copyright (C) 2001-2009  |  jigdo@
Richard Atterer          |  atterer.org
Copyright (C) 2016-2019
Steve McIntyre <93sam@debian.org> 
Loading settings from `/root/.jigdo-lite

Downloading .jigdo file
--2022-01-16 16:17:08--  https://mirrors.tuna.tsinghua.edu.cn/debian-cd/11.2.0/amd64/jigdo-dlbd/debian-11.2.0-amd64-DLBD-1.jigdo
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 869555 (849K) [application/octet-stream]
Saving to: ‘debian-11.2.0-amd64-DLBD-1.jigdo’

debian-11.2.0-amd64-DLBD-1.jigdo    100%[==================================================================>] 849.17K   815KB/s    in 1.0s    

2022-01-16 16:17:09 (815 KB/s) - ‘debian-11.2.0-amd64-DLBD-1.jigdo’ saved [869555/869555]

-----------------------------------------------------------------
Images offered by `https://mirrors.tuna.tsinghua.edu.cn/debian-cd/11.2.0/amd64/jigdo-dlbd/debian-11.2.0-amd64-DLBD-1.jigdo:
  1: Debian GNU/Linux 11.2.0 "Bullseye" - Official amd64 DLBD Binary-1 20211218-11:13 (20211218) (debian-11.2.0-amd64-DLBD-1.iso)

Further information about `debian-11.2.0-amd64-DLBD-1.iso:
Generated on Sat, 18 Dec 2021 12:55:10 +0000

-----------------------------------------------------------------
If you already have a previous version of the CD you are
downloading, jigdo can re-use files on the old CD that are also
present in the new image, and you do not need to download them
again. Mount the old CD ROM and enter the path it is mounted under
(e.g. `/mnt/cdrom).
Alternatively, just press enter if you want to start downloading
the remaining files.
Files to scan:   #回车
-----------------------------------------------------------------
The jigdo file refers to files stored on Debian mirrors. Please
choose a Debian mirror as follows: Either enter a complete URL
pointing to a mirror (in the form
`ftp://ftp.debian.org/debian/), or enter any regular expression
for searching through the list of mirrors: Try a two-letter
country code such as `de, or a country name like `United
States, or a server name like `sunsite.
Debian mirror [https://mirrors.tuna.tsinghua.edu.cn/debian/]: #回车  #也可以手动指定源  https://mirrors.tuna.tsinghua.edu.cn/debian/

6、注意

下载好镜像大约为45G

2、配置apt源

#源配置文件
root@vss:~# vim  /etc/apt/sources.list

# deb cdrom:[Debian GNU/Linux 11.2.0 _Bullseye_ - Official amd64 DLBD Binary-1 20211218-11:13]/ bullseye contrib main
#本地镜像源
deb cdrom:[Debian GNU/Linux 11.2.0 _Bullseye_ - Official amd64 DLBD Binary-1 20211218-11:13]/ bullseye contrib main
#默认网络源
deb http://security.debian.org/debian-security bullseye-security main contrib
deb-src http://security.debian.org/debian-security bullseye-security main contrib

# bullseye-updates, to get updates before a point release is made;
# see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports
# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
# deb http://deb.debian.org/debian/ bullseye-updates main contrib
# deb-src http://deb.debian.org/debian/ bullseye-updates main contrib

3、root用户,开启ssh登录

#修改34行为允许root登录
root@vss:~# vim /etc/ssh/sshd_config
34 PermitRootLogin yes
#重启SSH服务生效
root@vss:~# systemctl restart ssh

4、网卡

#安装DNS包使DNS永久生效
root@vss:~# apt install resolvconf -y
#网卡配置  静态地址
root@vss:~# vim  /etc/network/interface
<==================================================================>
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
auto ens3
iface lo inet loopback

allow-hotplug ens3
iface ens3 inet static
address 10.10.70.119
netmask 255.255.255.0
gateway 10.10.70.254
dns-nameserver 192.168.1.25
<==================================================================>
#重启网卡服务
root@vss:~# systemctl restart  networking.service
#查看DNS配置
root@vss:~# cat /etc/resolv.conf
nameserver 192.168.1.25
#查看IP地址
root@vss:~# ip add
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 
       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:2d:de:ae brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.1.25/24 brd 192.168.1.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe2d:deae/64 scope link 
       valid_lft forever preferred_lft forever

5、vim

#解决vim 右键进入visual模式
#右键自动粘贴
root@vss:~# vim /usr/share/vim/vim81/defaults.vim
#修改79行
79   set mouse=r
#解决文件高亮
#修改第24行
root@vss:~# vim /etc/vim/vimrc
24 syntax on

6、开启别名

#别名配置文件
root@vss:~# vim /root/.bashrc 
#取消注释以下行  
# You may uncomment the following lines if you want `ls to be colorized:
 export LS_OPTIONS=--color=auto
 eval "$(dircolors)"
 alias ls=ls $LS_OPTIONS
 alias ll=ls $LS_OPTIONS -l
 alias l=ls $LS_OPTIONS -lA

# Some more alias to avoid making mistakes:
 alias rm=rm -i
 alias cp=cp -i
 alias mv=mv -i

7、设置时区为 亚洲/上海

#设置时区为亚洲/上海
root@vss:~# timedatectl set-timezone Asia/Shanghai 
#查看当前时间时区
root@vss:~# timedatectl
               Local time: Thu 2022-02-17 17:43:18 CST
           Universal time: Thu 2022-02-17 09:43:18 UTC
                 RTC time: Thu 2022-02-17 09:43:18
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

以上是关于Debian11基本配置的主要内容,如果未能解决你的问题,请参考以下文章

Debian 11 安装,超详细!

配置Debian11服务器允许root用户远程SSH登录

debian wifi配置

Debian-基础设置(Basic)

debian安装网络自动设置失败

debian11 xfce fcitx不能输入中文的解决