Debian 安装后的相应系统设置与调整

  • 启动问题查找
  • 终端设置
  • 服务
  • 启动目标
  • 网卡
  • 常见问题:
  • 硬件驱动目录:
  • 常用命令:
  • TP-LINK 8188 USB 驱动安装
  • BCM 4360 驱动安装
  • 网络管理器 network-manager
  • 时间
  • hwclock
  • 修改 Windows 硬件时钟为 UTC 时间
  • 自动从网络获取时间
  • 1)使用ntpdate方法
  • 安装
  • 手动从网络更新本地时间:
  • 2)使用ntp方法
  • 安装:
  • 配置
  • 测试
  • VIM
  • 串口通信
  • SUDO
  • bash 命令行内编辑


启动问题查找

systemd-analyze time
systemd-analyze blame

终端设置

字体改大:

james@HP800G1:~$ sudo dpkg-reconfigure console-setup
	
	选择
	terminus, 
	14x28

使用sudo

james@HP800G1:~$ sudo visudo

	root    ALL=(ALL:ALL) ALL
	james   ALL=(ALL:ALL) ALL

睡眠

james@HP800G1:~$ systemctl suspend

休眠

james@HP800G1:/etc/systemd$ systemctl hibernate

欢迎信息

james@HP800G1:/etc$ cat motd

	Debian GNU/Linux 
	james@HP800G1:/etc$

服务

  1. SSH
    服务器安装
    apt-get install openssh.server
    欢迎信息更改:
pi@raspberrypi:/etc/ssh $ ls sshd_config 
sshd_config
pi@raspberrypi:/etc/ssh $ cat sshd_config |grep Banner
#Banner Welcome to Raspberry zero
Banner /etc/SSH_Welcome
pi@raspberrypi:/etc/ssh $ cat /etc/SSH_Welcome 
Welcome to Raspbarry Zero
pi@raspberrypi:/etc/ssh $
  1. 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;

启动目标

pi@3B:~ $ systemctl set-default multi-user.target
pi@3B:~ $ systemctl set-default graphical.target

网卡

常见问题:

如遇到无线网卡不工作, 可能是:

  1. 是在BOIS中关闭了无线网卡。
  2. 或在键盘上关闭了无线网卡。
  3. 被命令rfkill关闭
  4. HP笔记本,插入网线时,无线网卡补硬件层面关闭。

硬件驱动目录:

james@HP8440P:/lib/firmware$

常用命令:

ip link
ip addr
iwconfig
iwlist scanning
rfkill list
nmtui

安装驱动intel芯片915驱动

apt-get firmware-linux

安装驱动tp-link无线网卡

apt-get firmware-realtek

安装驱动intel 无线网卡 6200

984  sudo apt-get install iwlwifi

安装网络管理软件,底层用ipupdown, 桌面系统用network-manager, 前端有字符,gnome,kde等, 无线用wireless-tools, wpasupplicant,

apt-get install wpasupplicant
apt-get install wireless-tools
apt-get install network-manager
apt-get install rfkill
james@HP8440P:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 88:ae:1d:a9:26:b3 brd ff:ff:ff:ff:ff:ff
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 7e:9f:29:b0:99:64 brd ff:ff:ff:ff:ff:ff
james@HP8440P:~$ ip addr
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: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 88:ae:1d:a9:26:b3 brd ff:ff:ff:ff:ff:ff
    inet 192.169.3.30/24 brd 192.169.3.255 scope global dynamic noprefixroute enp0s25
       valid_lft 86321sec preferred_lft 86321sec
    inet6 fe80::4c62:72fa:398c:5ceb/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 7e:9f:29:b0:99:64 brd ff:ff:ff:ff:ff:ff
james@HP8440P:~$ iwconfig
-bash: iwconfig: command not found
james@HP8440P:~$ sudo iwconfig
enp0s25   no wireless extensions.

wlo1      IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=off
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off

lo        no wireless extensions.

james@HP8440P:~$ nmcli device show
GENERAL.DEVICE:                         enp0s25
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         88:AE:1D:A9:26:B3
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Ethernet connection 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/5
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.169.3.30/24
IP4.GATEWAY:                            192.169.3.1
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 192.169.3.1, mt = 100
IP4.ROUTE[2]:                           dst = 192.169.3.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:                             192.169.3.1
IP6.ADDRESS[1]:                         fe80::4c62:72fa:398c:5ceb/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100

GENERAL.DEVICE:                         wlo1
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         7E:9F:29:B0:99:64
GENERAL.MTU:                            1500
GENERAL.STATE:                          20 (unavailable)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          10 (unmanaged)
GENERAL.CONNECTION:                     --
james@HP8440P:~$
james@HP8440P:~$ sudo rfkill list
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: yes
2: hp-wifi: Wireless LAN
	Soft blocked: no
	Hard blocked: yes
3: hp-bluetooth: Bluetooth
	Soft blocked: no
	Hard blocked: yes
james@HP8440P:~$ sudo rfkill list
	1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	2: hp-wifi: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	3: hp-bluetooth: Bluetooth
	Soft blocked: no
	Hard blocked: no
	4: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
	james@HP8440P:~$ sudo rfkill block 3
	james@HP8440P:~$ sudo rfkill list
	1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	2: hp-wifi: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	3: hp-bluetooth: Bluetooth
	Soft blocked: yes
	Hard blocked: no
	james@HP8440P:~$ sudo rfkill unblock 3
	james@HP8440P:~$ sudo rfkill list
	1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	2: hp-wifi: Wireless LAN
	Soft blocked: no
	Hard blocked: no
	3: hp-bluetooth: Bluetooth
	Soft blocked: no
	Hard blocked: no
	5: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
	james@HP8440P:~$

TP-LINK 8188 USB 驱动安装

下载:
	rtl8188
	make all
	make install

编译出问题时:

apt-get install linux-headers-$(uname -r)

安装:

lsmod
	modprobe 8188eu
	ip link
	sudo iwconfig

BCM 4360 驱动安装

下载
	broadcom-wl

	make all
	make install	

	插上其它wifi卡后,其它卡正常工作后,再换回BCM 4360卡,正常工作

网络管理器 network-manager

终端配置命令:

james@HP8440P:~$ nmtui

时间

hwclock

运行hwclock得到以下提示:
hwclock: cannot access the hardware 。。。。。

转用:

sudo hwclock -r

修改 Windows 硬件时钟为 UTC 时间

以管理员身份打开 「PowerShell」,输入以下命令:

Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
或者打开「注册表编辑器」,定位到 计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation 目录下,新建一个 DWORD 类型,名称为 RealTimeIsUniversal 的键,并修改键值为 1 即可。

修改 Linux 硬件时钟为本地时间
这里大家可以根据自己 Linux 发行版的方法来修改。我这里给出现在大多数发行版由 timedatectl 来管理时间的修改方法。

在终端中,输入以下命令:

$ timedatectl set-local-rtc 1 --adjust-system-clock

自动从网络获取时间

可选用( 从低到高级排序):
1)systemd-timesynced
2)ntpdate
3) ntp

1)使用ntpdate方法

安装
james@HP800G1:~$ sudo apt-get install ntpdate
手动从网络更新本地时间:

ntpdate 192.169.3.77

pi@raspberrypi:~/solar $ sudo netstat -tlunp |grep ntp
udp        0      0 192.169.3.77:123        0.0.0.0:*                           	6687/ntpd           
udp        0      0 127.0.0.1:123           0.0.0.0:*                           	6687/ntpd           
udp        0      0 0.0.0.0:123             0.0.0.0:*                           6687/ntpd           
udp6       0      0 fe80::449a:77f7:60f:123 :::*                                6687/ntpd           
udp6       0      0 ::1:123                 :::*                                6687/ntpd           
udp6       0      0 :::123                  :::*

2)使用ntp方法

安装:
james@HP800G1:~$ sudo apt-get install ntp
配置

vi /etc/ntp.conf
注释原有服务器记录
添加以下服务器:
server time.asia.apple.com minpoll 10 maxpoll 15
启用服务
james@TB:/etc$ sudo systemctl enable ntp
james@TB:/etc$ sudo systemctl restart ntp

测试

查看服务状态

james@TB:/etc$ sudo systemctl status ntp
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-01-22 20:10:22 CST; 9s ago
Docs: man:ntpd(8)
Process: 882 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
Main PID: 888 (ntpd)
Tasks: 2 (limit: 2114)
Memory: 1.6M
CGroup: /system.slice/ntp.service
└─888 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 115:122

查看时间校对状况

james@TB:/etc$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
hkhkg1-ntp-001. .GPSs. 1 u 20 1024 1 12.684 -872.43 0.000

VIM

##语法高亮:
:syntax on

串口通信

sudo raspi-config
取消串行口登录,使用串行口

ls -l /dev/seri*

serial0 串行口
serial1 是蓝牙口

Mini COM 与硬件串口的互换,Mini COM 是软件实现,不稳定,硬件串口被蓝牙占用,用以下方命令更换
sudo nano /boot/config.txt
添加:
dtoverlay=pi3-miniuart-bt

停止串行口控制台后台:
sudo systemctl stop serial-getty@ttyAMA0.service

sudo systemctl disable serial-getty@ttyAMA0.service

SUDO

Debia的SUDO权限应该在/etc/sudoers.d/内添加配置文件,例如:
#sudo visudo /etc/sudoers.d/010_james-nopassswd

内容:
james ALL=(ALL) NOPASSWD: ALL

注释
用户 登录的主机=(可以变换的身份) 可以执行的命令

Allow root to run any commands anywhere
允许root用户执行任意路径下的任意命令
root ALL=(ALL) ALL

Allows members of the ‘sys’ group to run networking, software,
service management apps and more.
%sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
允许sys中户组中的用户使用NETWORKING等所有别名中配置的命令

Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL

#换源

james@TB:/etc/network$ cat /etc/apt/sources.list

# armv7l 用户:编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi
# deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye 
`

```bash
``

main non-free contrib rpi

# armv7l 用户如果需要开启 multi-arch 使用 arm64 软件源,需要在 `/etc/apt/sources.list` 中加上
deb [arch=arm64] http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch/ bullseye main

# aarch64 用户:编辑 `/etc/apt/sources.list` 文件,用以下内容取代:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

# 对于两个架构,编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
#deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
`
james@TB:/etc/network$ gpg --keyserver  keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
gpg --export --armor 9165938D90FDDD2E | sudo apt-key add -

bash 命令行内编辑

Ctrl-P 向上移动命令列表
Ctrl-N 向下移动命令列表
ESC< 移动到命令列表的第一行
ESC> 移动到命令列表的最后一行

Ctrl-A 移至行首
Ctrl-E 移至行尾
ESC F 向前移动一个单词 //先后按键,不是连着
ESC B 向后移动一个单词

Ctrl-U 从光标处删除至行首
Ctrl-K 从光标处删除至行尾
Ctrl-Y 粘贴回行
Ctrl-D 删除一个字母
ESC D 向前删除一个单词
ESC H 向后删除一个单词 //????