共有 54 篇文章
📅 最近更新
2022-08-09
- 2024-09-18
oh-my-zsh主题显示执行时间
oh-my-zsh主题显示执行时间
进入主题目录~/.oh-my-zsh/themes
在想要修改的主题文件中添加如下代码:
1function preexec() {
2 timer=${timer:-$SECONDS}
3}
4
5function precmd() {
6 if [ $timer ]; then
7 timer_show=$(($SECONDS - $timer))
8 if [[ $timer_show -ge $min_show_time ]]; then
9 RPROMPT='%{$fg_bold[red]%}(${timer_show}s)%f%{$fg_bold[white]%}[%*]%f %{$reset_color%}%'
10 else
11 RPROMPT='%{$fg_bold[white]%}[%*]%f'
12 fi
13 unset timer
14 fi
15}
16
17autoload -Uz add-zsh-hook
18add-zsh-hook preexec preexec
19add-zsh-hook precmd precmd
2022-08-09
- 2024-09-18
概念和相关文件
在 Linux 用户系统中存在两类组。第一类是主要用户组(主组),第二类是附加用户组(附属组)。
- 主组:也被称为primary group、first group或initial login group,用户的默认组,用户的gid所标识的组。
- 附属组:也被称为Secondary group或supplementary group,用户的附加组。
存储文件
- 用户帐户及相关信息都存储在
/etc/passwd
文件中, - 用户组信息存储在
/etc/shadow
和/etc/group
文件。
id命令
通过id
命令查看用户的主组和附属组
2022-08-09
- 2024-09-18
赋予用户组操作usb设备的权限
创建用户组并添加用户到用户组
1# 创建用户组
2groupadd usbfs
3# 查看usbfs用户组的id
4# usbfs:x:1001:
5cat /dev/group | grep usbfs
6# 把akvicor添加到用户组
7useradd -G usbfs akvicor
8 # 或
9vim /etc/group
10 # 修改 usbfs:x:1001:
11 # 为 usbfs:x:1001:akvicor
添加访问权限
1# 进入目录
2cd /etc/udev/rules.d
3# 创建配置文件
4vim xxx.rules
5# 写入信息到配置文件
允许用户组usbfs
访问usb设备
2022-08-09
- 2024-09-18
Debian安装说明
Debian 源
1wget https://paste.akvicor.com/api/106
Debian 12 + i3
修改时区
1# 修改时区
2ln -sf /usr/share/zoneinfo/Etc/GMT-8 /etc/localtime
3# 同步硬件时间
4hwclock -w
配置源
1curl https://paste.akvicor.com/api/101 > /etc/apt/sources.list
2# 注释掉不需要用到的源,如 bookworm-proposed-updates(介于stable和testing之间), bookworm-backports(新特性移植到旧版本)
3
4apt update
5apt upgrade
6reboot
安装基础工具
1apt install apt-transport-https ca-certificates
2apt install vim curl wget git gcc g++ make screen bc jq zsh
添加基础bash命令
1# 添加ll命令.bashrc
2alias l='ls -al --color=auto'
3alias ll='ls -alh --color=auto'
笔记本电源操作
1vim /etc/systemd/logind.conf
2 HandleLidSwitch=ignore # 合上屏幕
3 HandlePowerKey=ignore # 电源按键
修改启动展示信息
ssh登录信息
2022-08-08
- 2024-09-18
1# 查看当前临时端口的范围
2sysctl net.ipv4.ip_local_port_range
3cat /proc/sys/net/ipv4/ip_local_port_range
4# 暂时性修改临时端口的范围
5echo 1024 65535 > /proc/sys/net/ipv4/ip_local_port_range
6sysctl -w net.ipv4.ip_local_port_range="1024 64000"
7# 永久性修改临时端口范围
8vim /etc/sysctl.conf # 编辑此文件并添加下面一行内容
9net.ipv4.ip_local_port_range = 1024 65535
2022-08-01
- 2024-09-18
xset
:用于设置显示器的各种用户属性选项。如果想要持久化设置,可以将设置写入.xinitrc
文件中。
dpms(Display Power Manage System)和屏保是互相作用的,这两个值谁设的小谁生效。
2022-07-14
- 2024-09-18
编辑
1apt install apt-transport-https ca-certificates
2vim /etc/apt/sources.list
Debian 11
1# Official & Contrib & Non-free
2deb https://deb.debian.org/debian bullseye main contrib non-free
3deb-src https://deb.debian.org/debian bullseye main contrib non-free
4
5deb https://deb.debian.org/debian-security bullseye-security main contrib non-free
6deb-src https://deb.debian.org/debian-security bullseye-security main contrib non-free
7
8deb https://deb.debian.org/debian bullseye-updates main contrib non-free
9deb-src https://deb.debian.org/debian bullseye-updates main contrib non-free
10
11# Backports
12deb https://deb.debian.org/debian bullseye-backports main contrib non-free
13deb-src https://deb.debian.org/debian bullseye-backports main contrib non-free
Debian 12
1# apt install apt-transport-https ca-certificates
2
3deb https://deb.debian.org/debian/ bookworm contrib main non-free non-free-firmware
4deb-src https://deb.debian.org/debian/ bookworm contrib main non-free non-free-firmware
5
6deb https://deb.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
7deb-src https://deb.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
8
9deb https://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware
10deb-src https://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware
11
12deb https://deb.debian.org/debian-security/ bookworm-security contrib main non-free non-free-firmware
13deb-src https://deb.debian.org/debian-security/ bookworm-security contrib main non-free non-free-firmware
2022-07-14
- 2024-09-18
安装SSH服务
1apt-get install openssh-server
修改SSH配置文件
1vim /etc/ssh/sshd_config
配置项
1# 监听端口
2Port 22
3
4# 监听地址
5ListenAddress 0.0.0.0
6
7# 是否允许root用户登录
8PermitRootLogin yes
9
10# 允许密码认证
11PasswordAuthentication yes
12
13# 允许密钥认证
14PubkeyAuthentication yes
15
16# 客户端保活
17ClientAliveInterval 60
18ClientAliveCountMax 3
Message of the Day
内容放在vim /etc/motd
,可以用 UpdateMotd 动态生成的内容,也可以直接使用landscape-common
2020-01-03
- 2024-09-18
Ubuntu Error: ENOSPC:System limit for number of file watchers reached
2019-09-29
- 2024-09-18
突然发现root登录的xshell的终端提示符显示的是-bash-4.2# 而不是root@主机名 + 路径的显示方式。搞了半天也不知道为什么出现这种情况。今天终于搞定这个问题,