修改hostname

vi /etc/hostname
vi /etc/hosts

修改时区

# 查看时区
timedatectl
timedatectl list-timezones | grep -i shanghai
# 修改时区
sudo timedatectl set-timezone Asia/Shanghai

创建用户

# 创建用户
sudo adduser yzchen

# 添加sudoer
sudo su
chmod +w /etc/sudoers
visudo # 相当于vi /etc/sudoers

## 添加以下行
username ALL=(ALL) ALL

chmod -w /etc/sudoers

ssh免密登录

创建密钥

ssh-keygen

复制公钥到要登录的服务器

ssh-copy-id username@host

bashrc配置

配置语言

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

常用alias

alias quick-push="git add --all && git commit -m 'update' && git push -u origin master"
alias json_pp="json_pp -json_opt pretty,utf8"

Self-hosted

frp

Github - fatedier/frp

frp文档

安装

wget https://github.com/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
tar -zxvf frp_0.37.0_linux_amd64.tar.gz

服务端配置

[common]
bind_port = 7000
# 不启用dashboard可以不配
dashboard_port =7500
dashboard_user = admin
dashboard_pwd = admin

服务端启动,记得在云服务器上放通6000和7000端口

nohup ./frps -c ./frps.ini > frps.log 2>&1 &

客户端配置

[common]
server_addr = 服务器的公网ip
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

客户端启动

nohup ./frpc -c ./frpc.ini > frps.log 2>&1 &

外网访问

ssh -p 6000 your_username@服务器的公网ip

配置开机启动

服务端

sudo cp ./frps /usr/bin/frps
sudo mkdir /etc/frp && sudo cp ./frps.ini /etc/frp/frps.ini
sudo cp ./systemd/frps.service /etc/systemd/system/
sudo systemctl enable frps

客户端

sudo cp ./frpc /usr/bin/frpc
sudo mkdir /etc/frp && sudo cp ./frpc.ini /etc/frp/frpc.ini
sudo cp ./systemd/frpc.service /etc/systemd/system/
sudo systemctl enable frpc

Mac端配置安全链接

需要被安全穿透的服务器配置

[samba]
type = stcp
# 只有 sk 一致的用户才能访问到此服务
sk = your_password
local_ip = 127.0.0.1
local_port = 445

下载客户端,下载darwin_amd64版本,配置frpc.ini如下

[samba-access]
type = stcp
# stcp 的访问者
role = visitor
# 要访问的 stcp 代理的名字
server_name = samba
sk = your_password
# 绑定本地端口用于访问服务
bind_addr = 127.0.0.1
bind_port = 6000

接下来使用smb://localhost:6000即可链接

配置开机启动

下载客户端,复制到/Users/your_username/Applications/

新建frpc.plist文件

sudo vim ~/Library/LaunchAgents/frpc.plist

写入以下内容

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>frpc</string>
    <key>ProgramArguments</key>
    <array>
         <string>/Users/your_username/Applications/frp_0.42.0_darwin_amd64/frpc</string>
         <string>-c</string>
        
<string>/Users/your_username/Applications/frp_0.42.0_darwin_amd64/frpc.ini</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

配置生效

sudo chown root ~/Library/LaunchAgents/frpc.plist
sudo launchctl load -w ~/Library/LaunchAgents/frpc.plist

Samba

服务端安装

sudo apt update
sudo apt install samba

配置

sudo vi /etc/samba/smb.conf
[Data1]
    comment = Data1
    path = /data1
    read only = no
    browsable = no

[Share]
    comment = Share
    path = /data1/Share
    read only = no
    browsable = yes

[Datap]
    comment = Datap
    path = /datap
    read only = no
    browsable = yes
sudo systemctl reload smbd
sudo ufw allow samba

由于小米只支持SMBv1协议,如果想要支持小米电视,还要加上一行

[global]
    server min protocol = NT1

添加用户

sudo smbpasswd -a your_username

客户端连接

# 安装
sudo apt-get install smbclient

# 连接
smbclient -L ip_address -U admin%password

# 进入客户端
smbclient //ip_address/dir_name -U admin%password

# mount
sudo apt update && sudo apt install samba samba-common-bin smbclient cifs-utils
sudo mount.cifs //ip_address/share /home/pi/smb-dir -o user=<name>

Finder链接慢的问题

  1. 取消.DS_Store
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
  1. 取消MacOS自动signing
sudo -s
echo "[default]" >> /etc/nsmb.conf
echo signing_required=no >> /etc/nsmb.conf
exit

Webdav

Github - BytemarkHosting/docker-webdav

docker启动

docker run -d \                                                                                                                                                                  
  --name webdav \
  --restart always \
  -v /data/webdav:/var/lib/dav \
  -e AUTH_TYPE=Digest \
  -e USERNAME=username \
  -e PASSWORD=password \
  --publish host_port:80 \
  bytemark/webdav:2.4

Nextcloud

https://nextcloud.com/install/#instructions-server

https://github.com/docker-library/docs/blob/master/nextcloud/README.md

docker-compose启动

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb:10.5
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - /data/nextcloud-mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD={db_password}
      - MYSQL_PASSWORD={db_password}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud:22.2
    restart: always
    ports:
      - {http_port}:80
    links:
      - db
    volumes:
      - /data/nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD={db_password}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - APACHE_DISABLE_REWRITE_IP=1
      - OVERWRITEHOST={your_host}:{https_port}
      - OVERWRITEPROTOCOL=https
      - OVERWRITECLIURL=https://{your_host}:{https_port}

配置nginx https转发

server {
    listen       {https_port} ssl;
    server_name  nextcloud;

    ssl_certificate      /usr/local/nginx/ssl/cert.pem;
    ssl_certificate_key  /usr/local/nginx/ssl/key.pem;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
    
    # 允许大文件上传
    client_max_body_size 10000m;

    location / {
        proxy_pass http://localhost:{http_port}/;
    }
}

安装Ubuntu客户端

sudo add-apt-repository ppa:nextcloud-devs/client
sudo apt update
sudo apt install nextcloud-client

nextcloudcmd --path {{remote_sync_folder}} --user {{username}} --password {{password}} --trust {{local_sync_folder}} https://{{host}}:{{port}}

SRS

启动服务

docker run -d --name srs \
  -p 1935:1935 -p 1985:1985 -p 8080:8080 \
  registry.cn-hangzhou.aliyuncs.com/ossrs/srs:4 ./objs/srs -c conf/docker.conf

推流

ffmpeg \
  -re \
  -i <input> \
  -c:v libx264 \
  -c:a aac \
  -f flv \
  rtmp://localhost/live/livestream

观看:

  • RTMP: rtmp://localhost/live/livestream
  • HTTP: http://localhost:{port}/players/srs_player.html?autostart=true&stream=livestream.flv&port={port}&schema=http

Jellyfin

docker run -d \
	--restart unless-stopped \
	--name jellyfin \
	-v /data/Jellyfin/config:/config \
	-v /data/Jellyfin/cache:/cache \
	-v /data/Jellyfin/media:/media \
	--net=host \
	-e HTTP_PROXY=socks5://127.0.0.1:1080 \
	-e HTTPS_PROXY=socks5://127.0.0.1:1080 \
	jellyfin/jellyfin:10.8.0

捎刮插件

Photo Hub

Immich

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ['start.sh', 'immich']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/hardware-transcoding
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    command: ['start.sh', 'microservices']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672
    restart: always

  database:
    container_name: immich_postgres
    image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    restart: always

volumes:
  model-cache:

Music

docker run -d \
   --name navidrome \
   --restart=unless-stopped \
   --user $(id -u):$(id -g) \
   -v /data/navidrome/music:/music \
   -v /data/navidrome/data:/data \
   -p 4533:4533 \
   -e ND_LOGLEVEL=info \
   -e ND_BASEURL=/navidrome \
   deluan/navidrome:latest

feishin

Github - feishin

remove from quarantine:

xattr -r -d com.apple.quarantine /Applications/Feishin.app

其他

安装字体

sudo mv your_font.tff /usr/share/fonts/
fc-cache -f -v
fc-list | grep your_font

重装

  • 惠普按F10
  • 联想/戴尔按F12
  • 微星:Del or F11

制作 Windows 安装盘

如何使用 Mac 制作 Windows 10 U 盘启动盘

  1. 格式化 U 盘:GUID Partition Map + FAT32
  2. 下载 Windows ISO
  3. 加载 ISO 文件: hdiutil mount ~/Downloads/Win10_1903_V1_English_x64.iso
  4. 复制到 U 盘
    1. 复制除了install.wim之外的文件: rsync -vha --exclude=sources/install.wim /Volumes/CCCOMA_X64FRE_EN-GB_DV9/* /Volumes/WIN11
    2. 复制 install.wim
      1. brew install wimlib
      2. mkdir /Volumes/WIN11/sources
      3. wimlib-imagex split /Volumes/CCCOMA_X64FRE_EN-GB_DV9/sources/install.wim /Volumes/WIN11/sources/install.swm 3800
  5. 弹出 U 盘

常见问题

  • Ubuntu 进入命令行界面:Ctrl + Alt + F3
  • 安装显卡驱动:sudo ubuntu-drivers autoinstall
  • 网卡 state down:
    • sudo dhclient <interface>
    • sudo vi /etc/netplan/00-installer-config.yaml
network:
  ethernets:
    eno1:
      dhcp4: true
    <interface>:
      dhcp4: true
  version: 2
  • Windows 10 安装后无法连接以太网
    • 通过 Andriod 手机用 USB 共享网络,到 HP 官方下载网络驱动并安装
  • Windows 11 无法安装:This PC can’t run Windows 11
    • This PC can’t run Windows 11 – Bypass/Fix
    • 按 Shift + F10 进入命令行,输入 regedit 打开注册表
    • HKEY_LOCAL_MACHINE\SYSTEM\Setup 路径下创建 Key: LabConfig,并写入 DWORD
      • BypassCPUCheck
      • BypassRAMCheck
      • BypassSecureBootCheck
      • BypassStorageCheck
      • BypassTPMCheck