> For the complete documentation index, see [llms.txt](https://docs.lado.online/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lado.online/tool/linux_teminal.md).

# Linux Collection

Common command and note

## Note

* ufw is necessary for port control strategy

## Alist & Aria2

{% hint style="info" %}
**It needs&#x20;**<mark style="color:red;">**fullchain**</mark>**&#x20;cert to prevent certification error.**
{% endhint %}

## Nextcloud

```
##maintenancemode
sudo -u www-data php occ maintenance:mode
sudo -u www-data php occ maintenance:mode --on
sudo -u www-data php occ maintenance:mode --off

##repair
sudo -u www-data php occ maintenance:repair
```

## Apache2

{% hint style="danger" %}
HTTP/2 requires more performance and may affect Jellyfin watched status.
{% endhint %}

```
ufw allow 'Apache Full'
# required for speedtest html
apt install apache2 php libapache2-mod-php

##mod
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_wstunnel
sudo a2enmod proxy_http
sudo a2enmod rewrite
sudo a2enmod headers

# 监控进程crontab
* * * * * /bin/bash apachedamon.sh

#监控进程
#!/bin/bash
# Apache httpd进程监控shell

# 如果你在使用RHEL / CentOS / Fedora Linux，使用这个重启命令
#RESTART="/sbin/service httpd restart"

# 如果你在使用 Debian / Ubuntu Linux，把上面的RHEL的注释掉，换用这个
RESTART="/etc/init.d/apache2 restart"

#path to pgrep command
PGREP="/usr/bin/pgrep"

# Httpd daemon name,
# Under RHEL/CentOS/Fedora it is httpd
# Under Debian 4.x it is apache2
#HTTPD="httpd"

# Debian / Ubuntu Linux 下进程名是apache2
HTTPD="apache2"

# find httpd pid
$PGREP ${HTTPD}

if [ $? -ne 0 ] # if apache not running
then
	echo "restart"
	$RESTART # restart apache
fi
```

## DDNS (3322)

```
vi /etc/crontab
//添加一行 每分钟刷新一次
1 * * * * wget "http://用户名:密码@members.3322.org/dyndns/update?system=dyndns&hostname=域名" && rm -r update?system=dyndns*
```

## youtube-dl

```
youtube-dl --proxy socks5://127.0.0.1:1080 url
```

## tc + u32

```
# 1. 清理现有规则
sudo tc qdisc del dev enp3s0 root 2>/dev/null
# 2. 创建 HTB 根节点
sudo tc qdisc add dev enp3s0 root handle 1: htb
# 3. 创建限速类（例如限速 10Mbps）
sudo tc class add dev enp3s0 parent 1: classid 1:1 htb rate 10mbit ceil 15mbit
# 4. 使用 u32 过滤器匹配源端口为 12139 的流量（即用户的下载速度）
sudo tc filter add dev enp3s0 protocol ip parent 1: prio 1 u32 match ip sport 12139 0xffff flowid 1:1
```
