Debian--Tips

A.Using

1.提示用户不在 sudoers 文件中

  1. 切换 root 用户 su
  2. 文件添加可写权限 chmod +w /etc/sudoers
  3. 修改 sudoers 文件 vi /etc/sudoers
  4. 添加用户权限
    找到 root ALL=(ALL:ALL) ALL ,在下一行添加 wu ALL=(ALL:ALL) ALL

2.更换国内源

  1. 文件 /etc/apt/sources.list 添加可写权限
  2. 注释原有源,添加国内源,源见附录

3.使用 shutdown、poweroff等命令提示

  1. 查看命令所在位置
    whereis shutdown 通常在 /usr/sbin 下
  2. 查看环境变量
    echo $PATH 若不包含 /usr/sbin 目录,则继续
  3. 导入路径
    export PATH=$PATH:/sbin 仅此次生效,重启还原
  4. 将路径写入用户环境变量
    vim ~/.bash_profile 写入 PATH=$PATH:/sbin

4.设置 terminal快捷键

  1. 桌面上点击右键 -> 设置 ->键盘 -> 快捷键 -> 自定义快捷键
  2. 进入Keyboard后,点击最下面的 + 号
    • 名称:terminal
    • 命令:gnome-terminal
  3. 点击编辑,在键盘中输入要设置的快捷键

5.笔记本设置合盖不休眠

sudo vim /etc/systemd/logind.conf

#修改: #HandleLidSwitch=suspend
#修改后: HandleLidSwitch=ignore

B.Error

1.缺失wifi驱动

apt install firmware-iwlwifi

C.Common tools

1.使用 ifconfig 命令

sudo apt install net-tools

附录

1.Debian 10 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Debian 10 buster

# 中科大源

deb http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

deb-src http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

# 官方源

deb http://deb.debian.org/debian buster main contrib non-free
deb http://deb.debian.org/debian buster-updates main contrib non-free
deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free

deb-src http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free
deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free

# 网易源

deb http://mirrors.163.com/debian/ buster main non-free contrib
deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

deb-src http://mirrors.163.com/debian/ buster main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

# 阿里云

deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main

deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security buster/updates main

2.Debian 11 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 阿里云镜像站
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

# 腾讯云镜像站
deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb https://mirrors.tencent.com/debian-security/ bullseye-security main
deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main
deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib

# 网易镜像站
deb https://mirrors.163.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye main non-free contrib
deb https://mirrors.163.com/debian-security/ bullseye-security main
deb-src https://mirrors.163.com/debian-security/ bullseye-security main
deb https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.163.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.163.com/debian/ bullseye-backports main non-free contrib

# 华为镜像站
deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contrib
deb https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
deb-src https://mirrors.huaweicloud.com/debian-security/ bullseye-security main
deb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib

# 清华大学镜像站
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

# 中科大镜像站
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free

Visual Studio--Tips

A.Info

1.多线程MT和多线程MD

多线程MT加载的是静态运行时库,属于C语言版本;
而多线程MD版本加载是动态运行时库,属于微软版本。
在工程属性窗体中选择配置属性,C++选项的代码生成多线程调试 DLL (/MDd)和多线程调试 DLL (/MTd)是Debug版本,后面没有d的是Release版本。

问题1) 选择/MD,不选/MT?

  • 程序就不需要静态链接运行时库,可以减小软件的大小;
  • 所有的模块都采用/MD,使用的是同一个堆,不存在A堆申请,B堆释放的问题;
  • 用户机器可能缺少我们编译时使用的动态运行时库
  • 如果我们软件有多个DLL,采用/MT体积增加太多,则可以考虑/MD + 自带系统运行时库

问题2) 选择/MT,不选择/MD?

  • 有些系统可能没有程序所需要版本的运行时库,程序必须把运行时库静态链接上。
  • 减少模块对外界的依赖。
  • 多个模块,必须选择相同的运行时库。

B.Error

1.std::bad_alloc at memory location 0xxxxxxx

分析1) 在分配内存空间时,内存空间不够时就会抛出该异常。

  • 在程序中加入delete和clear及时释放内存,并且对原始数据进行分割处理。

分析2) 在32位(x86)模式下,程序所能申请的最大内存上限是2GB。

  • 要申请2GB以上的内存,要更改一下项目CPU启动的模式;打开项目的属性页,找到属性配置—链接器—系统,将「使用大地址」一栏选上「是」。