Create New Document

The title of your document (will be displayed as H1)
URL-friendly name (no spaces, use dashes)
Path where to create document (optional, use forward slashes to create subdirectories)

Move/Rename Document

Current location of the document
New path for the document (including the slug)
This only changes the document's path. It does not modify the document's title (H1 heading).

Delete Document

Are you sure you want to delete this document? This action cannot be undone.

Warning: If this is a folder, all contents including subfolders and documents will be deleted.

Message

Message content goes here.

Confirm Action

Are you sure?

Attachments

Allowed file types: jpg, jpeg, png, gif, svg, webp, txt, log, csv, sfd, zip, pdf, docx, xlsx, pptx, mp4 (Max: 10MB)

Document Files

Loading attached files...

Document History

Previous Versions

Loading versions...

Preview

Select a version to preview

Wiki Settings

Language for the user interface
Number of versions to keep per document. Set to 0 to disable versioning.
Maximum allowed file size for uploads in MB.

User Management

Add New User

Leave empty to keep current password
Users with these groups can access restricted sections.

Define path-based access rules for sections of your wiki, then assign users to groups in the Users tab. Rules are evaluated in order. First match wins.

Active Rules

Import markdown files from a ZIP archive. Files will be processed and stored in the appropriate document structure. Directory structure in the ZIP (category/subcategory) will be preserved in the wiki.

Upload a ZIP file containing markdown (.md) files to import.

Create and manage backups of your wiki data. Backups include all documents, images, and configuration files.

Available Backups

Loading backups...

Add/Edit Access Rule

Selected: /

Add Column

Banner

Permission denied

这个问题和之前 sudo cat > file 遇到的错误完全一样

sudo seq 1 100 > long.txt

解决方案

方法一:使用 sudo tee(推荐)

seq 1 100 | sudo tee long.txt

方法二:使用 sudo bash -c

sudo bash -c 'seq 1 100 > long.txt'

方法三:使用 sudo sh -c

sudo sh -c 'seq 1 100 > long.txt'

方法四:先获取 root 权限再执行

sudo -i
seq 1 100 > long.txt
exit

各种方法对比

方法 命令 优点
sudo tee `seq 1 100 sudo tee long.txt`
-c sudo -c 'seq 1 100 > long.txt' 明确、可执行复杂命令
sh -c sudo sh -c 'seq 1 100 > long.txt' 简洁、通用
sudo -i sudo -i 后执行 适合多次操作

实际示例

1. 使用 sudo tee 写入数字序列

# 生成1-100并写入文件
seq 1 100 | sudo tee long.txt

# 生成1-100并追加到文件(-a 选项)
seq 1 100 | sudo tee -a long.txt

# 显示内容的同时写入文件
seq 1 100 | sudo tee long.txt > /dev/null   # 不显示在屏幕
seq 1 100 | sudo tee long.txt               # 显示在屏幕同时也写入文件

2. 使用 -c 执行

# 简单写入
sudo  -c 'seq 1 100 > long.txt'

# 多条命令
sudo  -c 'seq 1 50 > part1.txt; seq 51 100 > part2.txt'

3. 验证结果

# 查看文件内容
sudo cat long.txt

# 查看文件信息
ls -la long.txt

# 统计行数
sudo cat long.txt | wc -l
# 或
sudo wc -l long.txt

为什么会出现这个错误?

Shell 命令执行流程:

用户输入: sudo seq 1 100 > long.txt
         ↓
Shell 解析: 发现 > 重定向
         ↓
Shell 以当前用户身份尝试打开 long.txt(准备写入)
         ↓
如果权限不足 → 立即报错 "Permission denied"
         ↓
sudo seq 命令根本不会执行

关键点:重定向操作(>>>)是在 sudo 之前由 shell 执行的。


权限问题的根本原因

# 检查当前目录权限
ls -ld /opt/bb/
# 输出示例:drwxr-xr-x 2 root root 4096 Jun 28 10:00 /opt/bb/
#          ^^^^^^^^^ 所有者和组都是 root,其他人只有读和执行权限,没有写权限

当前用户没有写权限,所以无法创建或修改文件。


永久解决方案(改变目录权限)

选项1:更改目录所有者

# 将目录所有者改为当前用户
sudo chown $USER:$USER /opt/bb/

# 之后就可以直接使用
seq 1 100 > long.txt

选项2:更改目录权限

# 给所有用户写权限(不推荐用于生产环境)
sudo chmod 777 /opt/bb/

# 更好的做法:给所属组或其他用户适当权限
sudo chmod 775 /opt/bb/

选项3:继续保持使用 sudo

如果目录必须由 root 管理,就继续使用 sudo teesudo -c


最佳实践建议

/opt/bb/ 目录下的操作

# 推荐方式 1:使用 tee
seq 1 100 | sudo tee long.txt

# 推荐方式 2:使用  -c
sudo  -c 'seq 1 100 > long.txt'

# 查看结果
sudo cat long.txt

# 检查文件权限
ls -la long.txt
# 因为是用 root 创建的,文件所有者是 root

临时处理方法

# 使用 sudo -i 切换到 root 环境
sudo -i
cd /opt/bb/
seq 1 100 > long.txt
exit

如果只是偶尔需要写入,推荐这个别名

# 添加到 ~/.rc
alias sudo-write='sudo  -c'

# 使用
sudo-write 'seq 1 100 > long.txt'

Attached Files

Loading attached files...
Search Results