xud6的笔记本

linux

A 18 post collection


apt限制同时下载数量

 •  Filed under linux, debian

Queue-Mode 设置选项

默认值为 host 对每个host发起一个连接。当设为access时,对每个URI类型发起一个连接。由于大部分为http,因此也大致满足要求

永久设置

echo 'Acquire::Queue-Mode "access";' >/etc/apt/apt.conf.d/75download

临时设置

apt -o Acquire::Queue-mode=access upgrade

centos 8 自动更新

 •  Filed under centos, centos8, linux

安装dnf-automatic

dnf install dnf-automatic

编辑/etc/dnf/automatic.conf

apply_updates = yes

启动定时器

systemctl enable --now dnf-automatic.timer

树莓派启动优化

 •  Filed under 树莓派, linux

关闭蓝牙

编辑/boot/config.txt添加

dtoverlay=disable-bt

或pi3B+对应选项
关闭蓝牙串口服务

sudo systemctl disable hciuart

关闭avahi

sudo systemctl disable avahi-daemon

关闭启动时彩虹屏幕

编辑/boot/config.txt添加

# Disable the rainbow splash screen
disable_splash=1

树莓派4 OTG 以太网设置

 •  Filed under linux, 树莓派

编辑/boot/config.txt增加

dtoverlay=dwc2,dr_mode=peripheral

编辑/boot/cmdline.txt增加

modules-load=dwc2,g_ether

编辑/etc/modprobe.d/g_ether.conf写入

options g_ether use_eem=0 dev_addr=1a:55:89:a2:69:41 host_addr=1a:55:89:a2:69:42 idVendor=0x04b3 idProduct=0x4010

树莓派Kiosk(展台模式)设置

 •  Filed under linux, 树莓派

安装Raspbian Buster lite

启用SSH

boot分区下新建名称为ssh的空文本

添加WiFi信息

boot分区下新建wpa_supplicant.conf

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="NETWORK-NAME"
    psk="NETWORK-PASSWORD"
}

设置自动启动

sudo raspi-config

菜单中选择

Boot Options

    Desktop CLI

        Console Autologin

更换自动登录用户

nano /etc/systemd/system/getty@tty1.service.d/autologin.conf

替换 pi

设置local

sudo raspi-config

选择

安装最小GUI组件

sudo apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox -y

安装Chrome

sudo apt-get install --no-install-recommends chromium chromium-l10n -y

安装中文字体

sudo apt-get install fonts-wqy-zenhei

sudo apt-get install fonts-wqy-microhei

配置Openbox

sudo nano /etc/xdg/openbox/autostart

添加

xset -dpms			# turn off display power management system
xset s noblank		# turn off screen blanking
xset s off			# turn off screen saver

# Remove exit errors from the config files that could trigger a warning
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences

# wait for server startup
sleep 5

# Run Chromium in kiosk mode
chromium  --noerrdialogs --disable-infobars --lang=zh-CN --kiosk $KIOSK_URL --arc-play-store-auto-update=off

配置环境

sudo nano /etc/xdg/openbox/environment

添加

export KIOSK_URL=https://url.url

自动启动xserver

使用自动登录的用户
检查~/.bash_profile是不是存在

ls -la ~/.bash_profile

如果不存在创建~/.bash_profile

touch ~/.bash_profile

编辑~/.bash_profile

nano ~/.bash_profile

添加

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor

应用更新

source ~/.bash_profile

重启

sudo reboot

selinux 常用命令

 •  Filed under linux, centos, centos7, selinux

查看是否有被selinux阻挡

sudo cat /var/log/audit/audit.log | grep denied

boolean

查看boolean状态

sudo sestatus -b

sudo sestatus -b | grep -i sendmail

设置boolean

sudo setsebool -P $boolean名 $1或0

常用boolean

boolean名 意义
httpd_can_network_connect 允许httpd反向代理
httpd_can_sendmail 允许httpd发送邮件

semanager

安装semanager

sudo yum install -y policycoreutils-python

Centos 8

sudo yum install -y policycoreutils-python-utils

获取系统中的可用label

sudo semanage fcontext -l |grep {SOMETHING}

给文件设置label

sudo semanage fcontext -a -t httpd_sys_content_t /path/to/file
restorecon -v /path/to/file

给文件夹设置label

sudo semanage fcontext -a -t httpd_sys_content_t "/path/to/dir(/.*)?"
restorecon -R -v /path/to/dir

Centos 清理旧内核

 •  Filed under centos7, centos, linux

Centos 7

sudo yum install yum-utils -y && sudo package-cleanup --oldkernels --count=1 -y

Centos 8

dnf remove --oldinstallonly --setopt installonly_limit=1