250724-Ubuntu20.04桌面版系统-配置看板-界面功能参数配置

ToDoList

  • 电源-屏幕锁屏取消-设置为永不/一直亮屏
  • 软件更新策略调整(从不提醒)
  • 侧边栏自动隐藏(外观/侧边栏设置)
  • sudoers 用户增加mes mes ALL=(ALL:ALL) NOPASSWD: ALL
  • 网卡名称调整为enp0s25
  • 运行box.sh脚本,系统参数配置

Ubuntu20.04ip脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

#sudo bash -c 'cat <<EOF > /etc/udev/rules.d/10-rename-network.rules
#SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="", NAME="enp0s25"
#EOF'

# 获取参数作为 IP
# 固定IP地址(01-network-manager-all.yaml)
sudo bash -c 'cat <<EOF > /etc/netplan/01-network-manager-all.yaml
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s25:
dhcp4: no
dhcp6: no
addresses: [192.168.10.$1/24]
gateway4: 192.168.10.1
nameservers:
addresses: [8.8.8.8, 114.114.114.114]
EOF' _ $1

Ubuntu20.04ip2脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

sudo mkdir -p /etc/udev/rules.d/
sudo touch /etc/udev/rules.d/10-rename-network.rules

sudo bash -c 'cat <<EOF > /etc/udev/rules.d/10-rename-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="", NAME="enp0s25"
EOF'

# 获取参数作为 IP
# 固定IP地址(01-network-manager-all.yaml)
sudo bash -c 'cat <<EOF > /etc/netplan/01-network-manager-all.yaml
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s25:
dhcp4: no
dhcp6: no
addresses: [192.168.10.$1/24]
gateway4: 192.168.10.1
nameservers:
addresses: [8.8.8.8, 114.114.114.114]
EOF' _ $1

Ubuntu20.04box.sh脚本

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/sh

# 更新为阿里云
sudo bash -c 'cat <<EOF > /etc/apt/sources.list

# aliyun
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF'

# 禁用内核更新
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
# 锁定内核
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
sudo apt-mark hold linux-image-generic linux-headers-generic

sudo apt update

# 禁用内核更新
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
# 锁定内核
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
sudo apt-mark hold linux-image-generic linux-headers-generic

sudo timedatectl set-timezone Asia/Shanghai
sudo cat /etc/timezone

# sudo mkdir -p /root/snap/chromium/common/chromium/BrowserMetrics

sudo apt install language-pack-zh-hans -y
sudo locale-gen zh_CN.UTF-8
sudo update-locale LANG=zh_CN.UTF-8

export LANG=zh_CN.UTF-8

sudo apt-get install vim -y && sudo apt-get remove vim -y
sudo apt install fonts-wqy-zenhei fonts-wqy-microhei fonts-noto-cjk -y
sudo apt install -y fontconfig
sudo apt install -y fonts-dejavu-core fonts-liberation

sudo apt install fonts-wqy-zenhei fonts-wqy-microhei fonts-noto-cjk -y
sudo apt install -y git
sudo apt install net-tools -y
sudo apt install openssh-server -y
sudo apt install -y fontconfig
sudo apt install -y fonts-dejavu-core fonts-liberation

# 禁用自动更新
sudo sed -i 's/APT::Periodic::Update-Package-Lists "1";/APT::Periodic::Update-Package-Lists "0";/g' /etc/apt/apt.conf.d/10periodic
sudo sed -i 's/APT::Periodic::Unattended-Upgrade "1";/APT::Periodic::Unattended-Upgrade "0";/g' /etc/apt/apt.conf.d/10periodic

# 禁用无人值守升级
sudo sed -i 's/APT::Periodic::Update-Package-Lists "1";/APT::Periodic::Update-Package-Lists "0";/g' /etc/apt/apt.conf.d/20auto-upgrades
sudo sed -i 's/APT::Periodic::Unattended-Upgrade "1";/APT::Periodic::Unattended-Upgrade "0";/g' /etc/apt/apt.conf.d/20auto-upgrades

# 禁用 apt-daily 服务和计时器
sudo systemctl stop apt-daily.service
sudo systemctl disable apt-daily.service
sudo systemctl mask apt-daily.service
sudo systemctl daemon-reload
sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer
sudo systemctl mask apt-daily.timer
sudo systemctl daemon-reload

# 禁用 unattended-upgrades 服务
sudo systemctl disable unattended-upgrades

# 禁用 Snap 自动更新
sudo snap refresh --hold

# 禁用自动更新
sudo systemctl stop apt-daily.service
sudo systemctl disable apt-daily.service
sudo systemctl kill --kill-who=main apt-daily.service
sudo systemctl disable apt-daily.timer
sudo systemctl mask apt-daily.timer
sudo systemctl stop unattended-upgrades.service
sudo systemctl disable unattended-upgrades.service

sudo systemctl daemon-reload

# Ubuntu自动登录和开机锁屏取消
## 禁用自动锁屏:
# gsettings set org.gnome.desktop.screensaver lock-enabled false
# gsettings set org.gnome.desktop.lockdown disable-lock-screen true

# 禁用内核更新
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
# 恢复内核更新
sudo apt-mark unhold linux-generic linux-image-generic linux-headers-generic

sudo sed -i 's/1/0/' /etc/apt/apt.conf.d/10periodic
sudo sed -i 's/2/0/' /etc/apt/apt.conf.d/10periodic

sudo sed -i 's/1/0/' /etc/apt/apt.conf.d/20auto-upgrades
sudo sed -i 's/2/0/' /etc/apt/apt.conf.d/20auto-upgrades

sudo apt remove update-notifier -y

# 禁用屏幕休眠
# gsettings set org.gnome.desktop.session idle-delay 0

sudo mkdir -p /home/mes/.config/autostart
sudo mkdir -p /home/mes/.ssh

sudo touch /home/mes/.config/autostart/chromium.desktop
sudo touch /home/mes/.ssh/authorized_keys

# 写入文件内容
sudo cat <<EOF > /home/mes/.config/autostart/chromium.desktop
[Desktop Entry]
Type=Application
Exec=sh -c "sleep 15 && /usr/bin/google-chrome-stable --disable-background-networking --start-maximized --disable-infobars --password-store=basic --kiosk 'http://120.86.188.226:8081/hmi/a3886ab468c84417a24df00fcf56a253/zlg63v?pageId=LJ-A '"
EOF

sudo chown -R mes:mes /home/mes/.config/autostart/chromium.desktop
sudo chmod a+x /home/mes/.config/autostart/chromium.desktop

sudo mkdir -p /etc/gdm3/

sudo cp -f /etc/gdm3/custom.conf /etc/gdm3/custom.conf.backup-$DATE
sudo touch /etc/gdm3/custom.conf

# 写入文件内容
sudo cat <<EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable=True
AutomaticLogin=mes
EOF

# Linux优化-Ulimit
# 写入文件内容

sudo bash -c 'cat <<EOF > /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF'

# >> 表示 追加 到文件末尾,不会破坏原有内容
sudo bash -c 'cat <<EOF > /etc/systemd/system.conf
[Manager]
DefaultLimitNOFILE=1048576
EOF'

# >> 表示 追加 到文件末尾,不会破坏原有内容
sudo bash -c 'cat <<EOF > /etc/sysctl.conf
net.ipv4.ip_forward = 1
fs.file-max = 1048576
fs.inotify.max_user_instances=512
fs.inotify.max_user_watches=262144
EOF'

# >> 表示 追加 到文件末尾,不会破坏原有内容
#sudo bash -c 'cat <<EOF >> /etc/sudoers
#mes ALL=(ALL:ALL) NOPASSWD: ALL
#EOF'

# 安装chrome谷歌浏览器
# 安装chrome谷歌浏览器
sudo wget -O google-chrome-stable_current_amd64.deb --no-check-certificate http://xx.xx.xx.xx:9000/Ubuntu20.04/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt update
sudo apt-get install google-chrome-stable -y

# 谷歌浏览器取消登录密钥环**然后重启系统,首次打开 Chrome 时会提示创建新密钥环,直接留空密码并继续即可
rm -rf /home/mes/.local/share/keyrings/*
sudo rm -rf /home/mes/.local/share/keyrings/*

# 调整电视连接显示配置
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/g' /etc/systemd/logind.conf

sudo apt autoremove -y

# 固定IP地址(01-network-manager-all.yaml)
#sudo bash -c 'cat <<EOF > /etc/netplan/01-network-manager-all.yaml
#network:
# version: 2
# renderer: NetworkManager
# ethernets:
# enp0s25:
# dhcp4: no
# dhcp6: no
# addresses: [192.168.10.$1/24]
# gateway4: 192.168.10.1
# nameservers:
# addresses: [8.8.8.8, 114.114.114.114]
#EOF'


# 配置密钥允许
sudo bash -c 'cat <<EOF >> /home/mes/.ssh/authorized_keys

EOF'


# ubuntu 启动时,默认30秒的时间能调整为5S
#sudo vim /etc/default/grub
#找到这一行:
#GRUB_TIMEOUT=30
sudo bash -c 'cat <<EOF > /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5
GRUB_RECORDFAIL_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
EOF'

sudo update-grub

# enp0s25网卡名字调整统一
sudo mkdir -p /etc/udev/rules.d/
# sudo touch /etc/udev/rules.d/10-rename-network.rules

#sudo bash -c 'cat <<EOF > /etc/udev/rules.d/10-rename-network.rules
#SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="", NAME="enp0s25"
#EOF'

#
sudo apt autoremove -y
# sudo reboot
# sudo systemctl restart systemd-logind

250724-Ubuntu-Linux-netplan-ifconfig网卡名字调整

我能将这个网卡名字调整到enp0s25吗

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.0.197 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::19d7:fdf9:9247:539 prefixlen 64 scopeid 0x20<link>
ether 00:e0:4d:03:5e:6f txqueuelen 1000 (以太网)
RX packets 41902 bytes 56368729 (56.3 MB)
RX errors 0 dropped 54 overruns 0 frame 0
TX packets 16055 bytes 1453031 (1.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 636 bytes 49767 (49.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 636 bytes 49767 (49.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether cc:3d:82:d2:4e:ca txqueuelen 1000 (以太网)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

在 Ubuntu 20.04 里,网络接口名称默认是由 systemd-networkd / udev 的“Predictable Network Interface Names”机制决定的,也就是
enp0s25 这种格式。但你现在看到的是 eno1,说明系统可能禁用了该机制,或者主板/BIOS 提供了特定的 eno1 名称。


你可以改成 enp0s25,但需要注意以下几点:

1. 确认当前命名机制

运行以下命令确认当前命名策略:

1
sudo dmesg | grep -i 'renamed from\|eth\|enp\|eno'

或者:

1
udevadm test-builtin net_id /sys/class/net/eno1

2. 方法一:使用 GRUB 开启 Predictable Names(推荐)

编辑 GRUB 配置:

1
sudo vim /etc/default/grub

找到这一行:

1
GRUB_CMDLINE_LINUX=""

改成:

1
GRUB_CMDLINE_LINUX="net.ifnames=1 biosdevname=0"

说明:

  • net.ifnames=1 开启 systemd 的命名机制
  • biosdevname=0 关闭 Dell 的 biosdevname 工具(如果存在)

保存后更新 GRUB:

1
sudo update-grub

然后重启:

1
sudo reboot

重启后,接口名可能会变成 enp0s25(取决于硬件总线拓扑)。


3. 方法二:手动创建 udev 规则(强制改名)

如果你知道硬件路径(比如 enp0s25 是 PCI 设备 0000:00:19.0),可以强制改名:

1
2
3
4
sudo vim /etc/udev/rules.d/10-rename-network.rules

sudo mkdir -p /etc/udev/rules.d/
sudo touch /etc/udev/rules.d/10-rename-network.rules

添加如下内容:

1
2
3
4
5
6
7
8
sudo vim /etc/udev/rules.d/10-rename-network.rules

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:e0:4d:03:5e:6f", NAME="enp0s25"


SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:e0:4d:03:5e:6f", NAME="enp0s25"


替换 00:e0:4d:03:5e:6f 为你网卡的实际 MAC 地址

然后重启:

1
sudo reboot

4. 验证是否成功

重启后运行:

1
ip link

或:

1
ifconfig -a

确认是否已变为 enp0s25


⚠️ 注意事项

  • 改名后,Netplan、NetworkManager 或其他网络配置文件中引用的接口名也要同步修改。
  • 如果你使用的是 Netplan,路径通常是 /etc/netplan/*.yaml,记得改成 enp0s25

Idea-文件夹隐藏-Idea File Ignore

在 JetBrains 系列 IDE(IntelliJ IDEA、PyCharm、WebStorm 等)中,.idea 目录就是项目的配置文件夹,默认情况下它已经是一个*
*隐藏文件夹(以点开头),但如果你在文件管理器或者 IDEA 的“Project”视图中仍然能看到它,可以通过以下方式进一步隐藏**:


✅ 方法一:在 IDEA 的 Project 视图中隐藏 .idea 目录

  1. 打开 IDEA。
  2. 点击顶部菜单:File > Settings(macOS 是 IntelliJ IDEA > Preferences)。
  3. 进入:Editor > File Types
  4. 在右侧的 “Ignored Files and Folders” 列表中,点击 + 按钮。
  5. 输入:.idea,然后点击 OK
  6. 应用并重启 IDEA。

这样 .idea 目录就不会再出现在左侧 Project 树中,但仍然存在,不影响项目运行。


✅ 方法二:在文件管理器中隐藏(Linux / macOS)

  • Linux(如 Ubuntu)

    1
    mv .idea .idea_hidden  # 改名隐藏(不推荐,会影响 IDEA 识别)

✅ 推荐:用 .hidden 文件方式隐藏(不影响 IDEA): 在项目根目录下创建 .hidden 文件,内容写:

1
.idea

这样大多数文件管理器(如 Nautilus)会自动隐藏 .idea

  • macOS Finder: 打开终端,进入项目目录:

    1
    chflags hidden .idea

✅ 方法三:在 .gitignore 中忽略(防止提交到 Git)

确保 .gitignore 文件中有:

1
.idea/

✅ 总结

目的 方法
不在 IDEA 中显示 File Types > Ignored Files
不在文件管理器中显示 .hiddenchflags hidden
不提交到 Git .gitignore 添加 .idea/

你可以根据需要选择其中一种或多种方式。

idea如何把node_modules目录隐藏

当前模型仅对图片中的文字进行识别,切换 K1.5 获取更好的视觉理解能力

JetBrains IDE(如 IntelliJ IDEA、WebStorm、PyCharm) 中隐藏 node_modules 目录,有两种常用方法:


✅ 方法一:在 Project 视图中隐藏(推荐)

  1. 打开 IDEA。
  2. 点击顶部菜单:File > Settings(macOS:IntelliJ IDEA > Preferences)。
  3. 进入:Editor > File Types
  4. 在右侧的 “Ignored Files and Folders” 列表中,点击 + 按钮。
  5. 输入:node_modules,点击 OK
  6. 应用并重启 IDEA。

✅ 这样 node_modules 不会在左侧 Project 树中显示,但仍存在于磁盘,不影响运行和调试。


✅ 方法二:在 .gitignore 中忽略(防止 Git 提交)

确保项目根目录下的 .gitignore 文件包含:

1
node_modules/

⚠️ 注意事项

  • 不要手动删除或重命名 node_modules,否则依赖会失效。
  • 隐藏后,IDE 仍会正确解析依赖(如 import 语句),不影响开发。

✅ 总结

目的 方法
不在 IDEA 中显示 File Types → Ignored Files → 添加 node_modules
不提交到 Git .gitignore 添加 node_modules/

两种方法可叠加使用,互不影响。

ile Types → Ignored Files → 添加 node_modules 这个无效

如果 “File Types → Ignored Files” 添加 node_modules 后无效,说明你可能遇到的是 IDEA 的 Project 视图缓存问题 或 *
*node_modules 被显式标记为 Source/Resource**。可按以下步骤强制生效:


强制隐藏 node_modules 的 3 种方法


🔧 方法 1:手动标记为 Excluded(100% 有效)

  1. Project 视图 中,右键 node_modules 文件夹。
  2. 选择 Mark Directory as → Excluded
    • 图标会变红,且立即从 Project 树隐藏。
    • 可随时 Mark Directory as → Cancel Exclusion 恢复。

效果等同于隐藏,且不影响依赖解析。


🔧 方法 2:清除缓存并重启

如果 “Ignored Files” 已添加但无效,可能是缓存未刷新:

  1. 点击菜单:File → Invalidate Caches / Restart
  2. 选择 Invalidate and Restart
  3. 重启后检查是否隐藏。

🔧 方法 3:检查 Project Structure(排除误设为 Source)

  1. Ctrl+Alt+Shift+S 打开 Project Structure
  2. 进入 Modules → Sources
  3. 确保 node_modules 未被标记为 Source 或 Resource(蓝色/黄色文件夹)。
  4. 如果有,点击 Excluded 图标,或右键 Remove

总结

场景 解决方案
Excluded 无效 右键 node_modulesMark as Excluded
缓存问题 File → Invalidate Caches / Restart
误设为 Source Project Structure → Modules → 取消 Source 标记

推荐优先使用方法 1(Mark as Excluded),立即生效且无副作用。

没有这个Mark as Excluded选项

IntelliJ IDEA Mark as Excluded 选项不存在

如果你在当前版本的 IntelliJ IDEA 中 右键 node_modules 文件夹时找不到 “Mark Directory as → Excluded” 选项
,可能是由于以下原因:


原因 1:你使用的是“Project Files”视图或其他非标准视图

IDEA 的 Project 视图 有多个模式,如:

  • Project
  • Project Files
  • Packages
  • Problems

只有在 “Project”“Packages” 视图下,才会显示完整的 Mark Directory as 菜单。

✅ 解决方法:

点击 左侧 Project 窗口顶部的小齿轮图标 → 选择 “Project” 视图模式 → 再右键 node_modules,即可看到 “Mark
Directory as → Excluded”
选项 。


原因 2:node_modules 被识别为 Library Root

如果 node_modules 被 IDEA 自动识别为 Library Root(图标带一个小书本),它就不会出现在 Mark Directory as 的菜单中。

✅ 解决方法:

  1. 打开 File → Project Structure(或快捷键 Ctrl+Alt+Shift+S)
  2. 左侧选择 Modules
  3. 右侧找到 node_modules取消勾选 “Library Root” 或将其从 Sources 中移除
  4. 点击 OK
  5. 回到项目视图,右键 node_modules → Mark Directory as → Excluded 就会出现 。

原因 3:使用的是非 Java 项目(如纯前端项目)

在纯前端项目(如 Vue、React)中,IDEA 可能不会自动提供完整的目录标记选项。

✅ 解决方法:

  • 手动进入 Project Structure → Modules → 添加一个空模块 → 然后手动 Excluded node_modules 目录 。

✅ 总结:快速操作步骤

步骤 操作
1 确保使用 Project 视图(非 Project Files)
2 如果仍无选项,进入 Project Structure → Modules
3 node_modules 从 Sources/Library 中移除
4 右键 → Mark Directory as → Excluded

如仍有问题,可截图当前 Project 视图结构,我可以帮你进一步判断。

原因 2:node_modules 被识别为 Library Root 如果 node_modules 被 IDEA 自动识别为 Library Root(图标带一个小书本),它就不会出现在Mark Directory as 的菜单中。

✅ 解决方法: 打开 File → Project Structure(或快捷键 Ctrl+Alt+Shift+S) 左侧选择 Modules 右侧找到
node_modules,取消勾选 “Library Root” 或将其从 Sources 中移除 点击 OK 回到项目视图,右键 node_modules → Mark Directory
as → Excluded 就会出现 这个找不到

最新版 IDEA / WebStorm / PyCharm 等 JetBrains IDE 中,
node_modules 一旦被识别成 JavaScript Library(图标带小书本),确实不会出现在 “Mark Directory as” 菜单里,也不会在
Modules → Sources 里显示,因为它根本不是 Source / Resource / Excluded 那一套机制管理的,而是 Library Root


✅ 正确做法:从 JavaScript Library 里移除 node_modules

  1. 打开设置
    File → Settings(macOS:IntelliJ IDEA → Preferences
  2. 进入 JavaScript Libraries 设置
    Languages & Frameworks → JavaScript → Libraries
  3. 在右侧列表里找到 node_modules 这一条
    你会看到它被标记为 “Global”“Project” 类型,图标也是书本。
  4. 选中它 → 点击右侧的 ➖ Remove(或 Disable)
  5. Apply → OK

🔄 完成后的效果

  • node_modules 图标会从 “小书本” 变成 普通文件夹
  • 此时再右键它,就能看到完整的 “Mark Directory as → Excluded” 选项了
  • 标记为 Excluded 后,IDE 会立即把它从 Project 视图隐藏,但磁盘文件仍在,运行、调试、npm 命令不受影响。

✅ 一句话总结

在 IDEA 中,node_modules 被当成 JavaScript Library
时,必须从 Settings → Languages & Frameworks → JavaScript → Libraries 里移除,才能用 “Mark as Excluded” 隐藏。

250723-Linux-内核更新-禁用内核更新-配置指定内核启动

锁定内核

1
2
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
sudo apt-mark hold linux-image-generic linux-headers-generic

内核脚本库

1.显示系统全部内核

1
sudo dpkg --get-selections | grep linux

2.完全删除系统内核

1
2
sudo apt-get remove --purge linux-modules-5.4.0-42-generic
sudo apt-get remove --purge linux-modules-5.15.0-71-generic -y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sudo apt-get remove --purge  -y linux-headers-5.15.0-139-generic
sudo apt-get remove --purge -y linux-hwe-5.15-headers-5.15.0-139
sudo apt-get remove --purge -y linux-image-5.15.0-139-generic
sudo apt-get remove --purge -y linux-modules-5.15.0-139-generic
sudo apt-get remove --purge -y linux-modules-extra-5.15.0-139-generic

sudo dpkg --get-selections | grep linux
sudo apt-get remove --purge -y linux-modules-extra-5.15.0-139-generic linux-modules-5.15.0-139-generic linux-image-5.15.0-139-generic linux-headers-5.15.0-139-generic linux-hwe-5.15-headers-5.15.0-139
sudo update-grub

sudo apt-get remove --purge -y linux-modules-5.15.0-60-generic -y
sudo apt-get remove --purge -y linux-modules-5.15.0-46-generic -y

sudo apt-get remove --purge -y linux-image-5.15.0-60-generic -y
sudo apt-get remove --purge -y linux-image-5.15.0-46-generic -y

sudo apt-get remove --purge -y linux-image-unsigned-5.15.0-46-generic -y
sudo apt-get remove --purge -y linux-modules-5.15.0-46-generic -y

3.再次用以下命令查看是否删除干净

1
dpkg --get-selections | grep linux

Ubuntu设置开机默认内核及删除多余内核
Ubuntu一更新就会启动新的内核,进入系统后总会发现驱动不好用了。所以可以对内核进行下设置,使得主机进入我们想要的内核版本,也可以删除掉多余的内核。

Ubuntu设置开机默认内核
#不删除内核情况下,更改要进入的内核

1
sudo gedit /etc/default/grub

(1)找到GRUB_DEFAULT = “0”
grub菜单如下:

1
2
3
4
5
6
7
8
- Ubuntu
- Advanced options for Ubuntu
* Ubuntu, with Linux 5.13.0-30-generic
* Ubuntu, with Linux 5.13.0-30-generic (recovery mode)
* Ubuntu, with Linux 5.11.0-27-generic
* Ubuntu, with Linux 5.11.0-27-generic (recovery mode)
- Windows 10
- System setup

(注意:每层菜单的索引都是从0开始)
GRUB菜单中的 Ubuntu为0,
Advanced options for Ubuntu为1,Windows 10为2,System setup为3。
Advanced options for Ubuntu菜单中的Ubuntu, with Linux 5.13.0-30-generic选项为0,
Ubuntu, with Linux 5.13.0-30-generic (recovery mode)为1,依次类推……

(2)想要进入5.11.0-27内核,则更改GRUB_DEFAULT = “1> 2”
‘>’ 符号来指定有一个子菜单(注意符号 > 和数字 2之间有空格)。

(3)更新GRUB配置文件

1
sudo update-grub

Ubuntu删除多余内核
#查看已安装的内核

1
dpkg --get-selections | grep linux-image

#找出系统已经安装的内核版本

1
dpkg --get-selections|grep linux

#卸载不需要的内核

1
2
sudo apt-get remove 内核名称
sudo apt autoremove

#修改 /boot/grub/grub.cfg文件,删除启动项

1
sudo gedit /boot/grub/grub.cfg

Ubuntu关闭自动更新
#关闭自动更新

1
sudo apt-mark hold linux-image-5.11.0-27-generic

验证内核

1
uname -r

选择内核启动

  1. 如果您的系统中有多个内核版本,您可以在启动时选择要启动的内核版本。查看当前系统中内核的启动顺序:

    bash

    1
    grep 'menuentry' /boot/grub/grub.cfg

    找到您想要设置为默认启动的内核条目,然后修改 /etc/default/grub 文件中的 GRUB_DEFAULT
    配置项,将其设置为对应的内核启动项。例如,如果您想要设置 Ubuntu, with Linux 5.8.0-43-generic 为默认启动项,您可以这样设置:

    bash

    1
    sudo sed -i 's/GRUB_DEFAULT=0/GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.8.0-43-generic"/g' /etc/default/grub

    然后再次更新 GRUB 并重启:

    bash

    1
    2
    sudo update-grub
    sudo reboot

请按照这些步骤操作,您应该能够成功将 Ubuntu 20.04 的内核版本调整到 5.8.0-43-generic。如果在操作过程中遇到任何问题,可以参考相关博客文章获取更详细的指导。

250723-ubuntu-Linux-wget下载运行bash脚本-wgetBox-wget盒子

安装运行脚本

  • 下载DEB谷歌浏览器文件
  • 配置SSH PUB KEY
  • 配置禁用更新/UTF-8/字体/ShangHai
  • 配置sudoers 管理员账号
  • sudo apt update && sudo apt upgrade -y

wget 直接直接远程脚本

  • wget 本身不会自动给文件加可执行权限,Linux 默认新文件权限是 644-rw-r--r--)。

  • 如果你希望直接下载并运行,可以这么写:

    1
    wget -qO- https://example.com/myscript.sh | sudo bash

但这会直接执行远程脚本,安全性取决于你对来源的信任程度。

在 Ubuntu 里,用 wget 下载脚本后立即获得“可执行权限”,只需在下载命令后再执行一次 chmod +x 即可。下面给出几种常见写法:


✅ 推荐:分两步

1
2
3
4
5
# 1. 下载脚本
wget https://example.com/myscript.sh

# 2. 赋可执行权限
chmod +x myscript.sh

✅ 一行完成(用 && 串联)

1
wget https://example.com/myscript.sh && chmod +x myscript.sh

✅ 一行完成(用 ; 保证即使 wget 失败也执行 chmod)

1
wget https://example.com/myscript.sh; chmod +x myscript.sh

⚠️ 注意

  • wget 本身不会自动给文件加可执行权限,Linux 默认新文件权限是 644-rw-r--r--)。

  • 如果你希望直接下载并运行,可以这么写:

    1
    wget -qO- https://example.com/myscript.sh | sudo bash

但这会直接执行远程脚本,安全性取决于你对来源的信任程度。

250723-ubuntu-Linux wget下载运行bash脚本

安装运行脚本

  • 下载DEB谷歌浏览器文件
  • 配置SSH PUB KEY
  • 配置禁用更新/UTF-8/字体/ShangHai
  • 配置sudoers 管理员账号
  • sudo apt update && sudo apt upgrade -y

wget 直接直接远程脚本

  • wget 本身不会自动给文件加可执行权限,Linux 默认新文件权限是 644-rw-r--r--)。

  • 如果你希望直接下载并运行,可以这么写:

    1
    wget -qO- https://example.com/myscript.sh | sudo bash

但这会直接执行远程脚本,安全性取决于你对来源的信任程度。

在 Ubuntu 里,用 wget 下载脚本后立即获得“可执行权限”,只需在下载命令后再执行一次 chmod +x 即可。下面给出几种常见写法:


✅ 推荐:分两步

1
2
3
4
5
# 1. 下载脚本
wget https://example.com/myscript.sh

# 2. 赋可执行权限
chmod +x myscript.sh

✅ 一行完成(用 && 串联)

1
wget https://example.com/myscript.sh && chmod +x myscript.sh

✅ 一行完成(用 ; 保证即使 wget 失败也执行 chmod)

1
wget https://example.com/myscript.sh; chmod +x myscript.sh

⚠️ 注意

  • wget 本身不会自动给文件加可执行权限,Linux 默认新文件权限是 644-rw-r--r--)。

  • 如果你希望直接下载并运行,可以这么写:

    1
    wget -qO- https://example.com/myscript.sh | sudo bash

但这会直接执行远程脚本,安全性取决于你对来源的信任程度。

250722-Git-LF will be replaced by CRLF the next time Git touches it问题解决

问题描述

LF will be replaced by CRLF the next time Git touches it

这个警告是 Git 在 Windows 系统上常见的行尾符(line ending)转换提示。它的意思是:

当前工作区中的文件 nokia 使用的是 Unix 风格的行尾符(LF),但 Git 检测到你在 Windows 系统上工作,默认会在下次提交或检出时将其转换为
Windows 风格的行尾符(CRLF)。


✅ 如何解决这个问题(两种方式):

方式一:保持 LF(推荐)

如果你希望保持 Unix 风格(LF),避免 Git 自动转换为 CRLF,可以这样做:

  1. 取消自动转换(项目级): 在项目根目录下运行:

    1
    git config core.autocrlf false
  2. 创建或修改 .gitattributes 文件(推荐): 在项目根目录下创建或编辑 .gitattributes 文件,添加以下内容:

    1
    * text=auto eol=lf

这会强制所有文本文件使用 LF 作为行尾符,无论你在哪个系统上。

  1. 重新标准化文件(可选): 如果你已经有一些文件被转换为 CRLF,可以运行:

    1
    git add --renormalize .

方式二:接受 CRLF(不推荐)

如果你不关心行尾符,允许 Git 自动转换为 CRLF,可以忽略警告或运行:

1
git config core.autocrlf true

🔍 总结建议

目标 操作建议
保持 LF(推荐) .gitattributes 中设置 * text=auto eol=lf
接受 CRLF git config core.autocrlf true

📌 补充说明

  • LF:Unix/Linux/macOS 默认行尾符(\n
  • CRLF:Windows 默认行尾符(\r\n
  • Git 的 core.autocrlf 设置只在本地生效,不会影响远程仓库。

如果你是团队协作项目,强烈建议使用 .gitattributes 统一行尾符,避免跨平台冲突。

250722-ChromePlugins-谷歌插件-ChromeReloadPlus-自动刷新插件-打包插件与安装打包插件

查找扩展程序路径

1
C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default\Extensions\

插件会有对应的版本,需要进入版本文件夹,然后复制该完整路径。

1753177540186

img

打包扩展程序

点击左上角“打包扩展程序”,在可以输入上一步需要打包扩展程序的完整路径(也可以通过店家“浏览”,然后在打开的文件浏览器中选择扩展程序路径),然后点击“打包扩展程序”

img

1753177573638

查看打包文件

打包文件在选择打包插件的上一级目录下,如下图所示。

img

1753177602679

解压文件

将上一步修改文件扩展名后的文件进行解压。

img

3.1.3 安装扩展程序

在chrome浏览器扩展程序页面点击“加载已解压扩展程序”,然后选择解压扩展程序的路径,然后点击“选择文件夹”。

img

3.1.4 完成安装

img

1753178211902

250722-Git代码库迁移脚本命令(git 仓库迁移 git clone --mirror git push --mirror)

使用 git clone –mirror 可以整体搬移或复制一个 Git 仓库,包括所有的分支、标签和远程配置。以下是具体步骤:

操作脚本命令

1
2
3
4
git clone --mirror https://github.com/user/source-repo.git
cd source-repo.git
git remote set-url --push origin https://github.com/user/new-repo.git
git push --mirror

1,克隆源仓库

使用 git clone –mirror 命令来克隆源仓库。这个命令会创建一个裸仓库,包含所有的 Git 数据。
git clone –mirror
例如:

1
git clone --mirror https://github.com/user/source-repo.git

2,进入克隆的仓库目录

克隆完成后,进入到新创建的仓库目录。这个目录通常以 .git 结尾。

1
cd source-repo.git

3,设置新的远程仓库

使用 git remote set-url 命令来设置新的远程仓库 URL。
git remote set-url –push origin

例如:

1
git remote set-url --push origin https://github.com/user/new-repo.git

4,推送到新的远程仓库

使用 git push –mirror 命令将所有的分支和标签推送到新的远程仓库。

1
git push --mirror

通过这些步骤,我们可以将一个 Git 仓库完整地复制到另一个远程位置。请确保在执行这些操作之前,你有相应的权限访问和推送到目标仓库。

250718-Ubuntu安装FTP服务vsftpd

安装vsftpd:

1
sudo apt update sudo apt install vsftpd

vsftpd服务将在安装过程完成后自动启动。通过打印服务状态进行验证:

1
sudo systemctl status vsftpd

输出如下所示,表明vsftpd服务处于活动状态并正在运行:

1
2
3
4
5
6
7
* vsftpd.service - vsftpd FTP server
Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2018-10-15 03:38:52 PDT; 10min ago
Main PID: 2616 (vsftpd)
Tasks: 1 (limit: 2319)
CGroup: /system.slice/vsftpd.service
`-2616 /usr/sbin/vsftpd /etc/vsftpd.conf

配置vsftpd

可以通过编辑/etc/vsftpd.conf
文件来配置vsftpd服务器。大多数设置在配置文件中都有详细记录。有关所有可用选项,请访问官方vsftpd
页面。

在以下各节中,我们将介绍配置安全的vsftpd安装所需的一些重要设置。

首先打开vsftpd配置文件:

1
sudo vim /etc/vsftpd.conf

1.FTP访问

我们仅允许本地用户访问FTP服务器,找到anonymous_enablelocal_enable指令,并验证您的配置是否与以下行匹配:

/etc/vsftpd.conf

1
2
anonymous_enable=NO
local_enable=YES

2.启用上传

取消注释write_enable设置以允许对文件系统进行更改,例如上载和删除文件。

/etc/vsftpd.conf

1
write_enable=YES

3.chroot

为防止FTP用户访问其主目录之外的任何文件,请取消注释chroot设置。

/etc/vsftpd.conf

1
chroot_local_user=YES

默认情况下,为了防止安全漏洞,启用chroot后,如果用户锁定的目录可写,则vsftpd将拒绝上传文件。

启用chroot时,请使用以下方法之一允许上传。

方法1. -推荐的允许上传的方法是保持chroot的状态,并配置FTP目录。在本教程中,我们将在用户主目录内创建一个ftp
目录,该目录将用作chroot和一个可写的uploads目录,用于上传文件。 /etc/vsftpd.conf

1
2
user_sub_token=$USER
local_root=/home/$USER/ftp

方法2. -另一个选项是在vsftpd配置文件中添加以下指令。如果必须将用户的可写访问权限授予其主目录,请使用此选项。
/etc/vsftpd.conf

1
allow_writeable_chroot=YES

4。被动FTP连接

vsftpd可以使用任何端口进行被动FTP连接。我们将指定端口的最小和最大范围,然后在防火墙中打开该范围。

将以下行添加到配置文件:

/etc/vsftpd.conf

1
2
pasv_min_port=30000
pasv_max_port=31000

5.限制用户登录

要仅允许某些用户登录FTP服务器,请在文件末尾添加以下几行:

/etc/vsftpd.conf

1
2
3
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

启用此选项后,您需要通过将用户名添加到/etc/vsftpd.user_list文件(每行一个用户)来明确指定哪些用户可以登录。

6.使用SSL / TLS保护传输

要使用SSL / TLS加密FTP传输,您需要具有SSL证书并配置FTP服务器以使用它。

您可以使用由受信任的证书颁发机构签名的现有SSL证书,也可以创建自签名证书。

如果您有指向FTP服务器IP地址的域或子域,则可以轻松生成免费的 Let’s Encrypt
SSL证书。

我们将使用openssl命令生成个自签名SSL证书

以下命令将创建一个有效期为10年的2048位私钥和自签名证书。私钥和证书都将保存在同一文件中:

1
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

创建SSL证书后,打开vsftpd配置文件:

1
sudo vim /etc/vsftpd.conf

查找rsa_cert_filersa_private_key_file指令,将它们的值更改为pam文件路径,并将ssl_enable指令设置为YES

/etc/vsftpd.conf

1
2
3
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES

如果没有另外指定,则FTP服务器将仅使用TLS建立安全连接。

重新启动vsftpd服务

完成编辑后,vsftpd配置文件(不包括注释)应如下所示:

/etc/vsftpd.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
user_sub_token=$USER
local_root=/home/$USER/ftp
pasv_min_port=30000
pasv_max_port=31000
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

保存文件,然后重新启动vsftpd服务,以使更改生效:

1
sudo systemctl restart vsftpd

打开防火墙

如果您正在运行 UFW防火墙,则需要允许FTP通信。

要打开端口21(FTP命令端口),端口20(FTP数据端口)和30000-31000(被动端口范围),请运行以下命令:

1
2
sudo ufw allow 20:21/tcp
sudo ufw allow 30000:31000/tcp

为避免被锁定,请打开端口22

1
sudo ufw allow OpenSSH

通过禁用和重新启用UFW重新加载UFW规则:

1
2
sudo ufw disable
sudo ufw enable

要验证更改,请运行:

1
2
3
4
5
6
7
8
9
10
11
sudo ufw status
Status: active

To Action From
-- ------ ----
20:21/tcp ALLOW Anywhere
30000:31000/tcp ALLOW Anywhere
OpenSSH ALLOW Anywhere
20:21/tcp (v6) ALLOW Anywhere (v6)
30000:31000/tcp (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)

创建FTP用户

要测试我们的FTP服务器,我们将创建一个新用户。

  • 如果您已经有要授予FTP访问权限的用户,请跳过第一步。
  • 如果在配置文件中设置了allow_writeable_chroot=YES,请跳过第三步。

创建一个名为newftpuser的新用户:

1
sudo adduser newftpuser

将用户添加到允许的FTP用户列表:

1
echo "newftpuser" | sudo tee -a /etc/vsftpd.user_list

创建FTP目录树并设置正确的权限

1
2
3
4
sudo mkdir -p /home/newftpuser/ftp/upload
sudo chmod 550 /home/newftpuser/ftp
sudo chmod 750 /home/newftpuser/ftp/upload
sudo chown -R newftpuser: /home/newftpuser/ftp

如上一节所述,用户将能够将其文件上传到ftp/upload目录。

至此,您的FTP服务器已正常运行,您应该能够使用可以配置为使用TLS加密的任何FTP客户端(例如 FileZilla
)连接到服务器。

禁用shell程序访问权限

默认情况下,在创建用户时,如果未明确指定,则该用户将具有对服务器的SSH访问权限。

要禁用外壳程序访问,我们将创建一个新的外壳程序,该外壳程序将仅打印一条消息,告知用户其帐户仅限于FTP访问。

创建/bin/ftponly shell并使其可执行:

1
2
echo -e '#!/bin/sh\necho "This account is limited to FTP access only."' | sudo tee -a  /bin/ftponly
sudo chmod a+x /bin/ftponly

将新外壳追加到/etc/shells文件中的有效外壳列表中:

1
echo "/bin/ftponly" | sudo tee -a /etc/shells

将用户外壳更改为/bin/ftponly

1
sudo usermod newftpuser -s /bin/ftponly

使用相同的命令来更改仅希望授予FTP访问权限的所有用户的外壳。