linux-admin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineselinux-admin
linux-admin
Purpose
用途
This skill provides tools for administering Ubuntu Server 24.04 LTS, focusing on package management with apt, user account creation and modification, disk and filesystem operations, kernel parameter tuning via sysctl, and log management.
本技能提供用于管理Ubuntu Server 24.04 LTS的工具,重点涵盖基于apt的软件包管理、用户账户创建与修改、磁盘和文件系统操作、通过sysctl进行内核参数调优以及日志管理。
When to Use
使用场景
Use this skill for server setup, maintenance, or troubleshooting on Ubuntu 24.04, such as deploying applications, securing user access, optimizing system performance, or analyzing logs in production environments.
当你在Ubuntu 24.04上进行服务器搭建、维护或故障排查时使用本技能,例如在生产环境中部署应用、保障用户访问安全、优化系统性能或分析日志。
Key Capabilities
核心功能
- Package Management (apt): Update repositories, install/uninstall packages, and manage dependencies using with flags like
aptfor non-interactive mode.-y - User Management: Create, modify, or delete users with commands like ,
useradd, andusermod, including options for home directories and shells.userdel - Disk/Filesystem: Partition disks with , format filesystems using
fdisk, and mount/unmount withmkfsandmount, supporting formats like ext4.umount - Sysctl: Adjust kernel parameters dynamically, e.g., for networking or security, by editing and applying with
/etc/sysctl.conf.sysctl -p - Log Management: Query and filter system logs using , with options like
journalctlfor time-based searches and persistent storage in--since./var/log
- 软件包管理(apt):更新软件源、安装/卸载软件包并管理依赖,使用命令及
apt等参数实现非交互模式。-y - 用户管理:使用、
useradd和usermod等命令创建、修改或删除用户,包括配置主目录和Shell的选项。userdel - 磁盘/文件系统:使用进行磁盘分区,
fdisk格式化文件系统,mkfs和mount挂载/卸载分区,支持ext4等格式。umount - Sysctl:动态调整内核参数(例如用于网络或安全配置),通过编辑并执行
/etc/sysctl.conf使配置生效。sysctl -p - 日志管理:使用查询和过滤系统日志,支持
journalctl等基于时间的搜索选项,日志持久化存储于--since目录。/var/log
Usage Patterns
使用方式
Invoke this skill via shell commands in scripts or AI prompts. Always prefix commands with for root privileges. Example 1: To install a package and add a user, use a sequence like: . Example 2: For disk management and log check, run: .
sudosudo apt update; sudo apt install nginx -y; sudo useradd webuser -msudo fdisk /dev/sda; sudo mkfs.ext4 /dev/sda1; sudo mount /dev/sda1 /mnt; sudo journalctl -u nginx --since "1 hour ago"通过脚本中的Shell命令或AI调用本技能。所有命令需以前缀获取root权限。示例1:安装软件包并添加用户,可执行如下序列命令:。示例2:进行磁盘管理并检查日志,执行:。
sudosudo apt update; sudo apt install nginx -y; sudo useradd webuser -msudo fdisk /dev/sda; sudo mkfs.ext4 /dev/sda1; sudo mount /dev/sda1 /mnt; sudo journalctl -u nginx --since "1 hour ago"Common Commands/API
常用命令/API
- Apt Example: Update and install a package:
sudo apt update sudo apt install vim -y - User Management Example: Add a user with home directory:
sudo useradd newuser -m -s /bin/bash sudo passwd newuser - Disk/Filesystem Example: Create and mount a filesystem:
sudo fdisk -l /dev/sdb # List partitions sudo mkfs.ext4 /dev/sdb1 sudo mount /dev/sdb1 /mnt/data - Sysctl Example: Set a kernel parameter:
echo "net.core.somaxconn=1024" | sudo tee -a /etc/sysctl.conf sudo sysctl -p - Log Management Example: Filter logs for a service:
sudo journalctl -u apache2 --since yesterday sudo journalctl -p err # Show only errors
- Apt示例:更新软件源并安装软件包:
sudo apt update sudo apt install vim -y - 用户管理示例:创建带主目录的用户:
sudo useradd newuser -m -s /bin/bash sudo passwd newuser - 磁盘/文件系统示例:创建并挂载文件系统:
sudo fdisk -l /dev/sdb # 列出分区 sudo mkfs.ext4 /dev/sdb1 sudo mount /dev/sdb1 /mnt/data - Sysctl示例:设置内核参数:
echo "net.core.somaxconn=1024" | sudo tee -a /etc/sysctl.conf sudo sysctl -p - 日志管理示例:过滤指定服务的日志:
sudo journalctl -u apache2 --since yesterday sudo journalctl -p err # 仅显示错误日志
Integration Notes
集成说明
Run commands in a Bash environment on Ubuntu 24.04. For remote access, use SSH; no API keys required for core functions, but if integrating with external tools like monitoring APIs, set env vars like for authentication. Ensure the AI agent prefixes commands with and handles output parsing, e.g., check for success via exit codes.
$LINUX_API_KEYsudoapt在Ubuntu 24.04的Bash环境中执行命令。远程访问可使用SSH;核心功能无需API密钥,但如果与监控API等外部工具集成,需设置等环境变量进行身份验证。确保AI代理在命令前添加前缀,并处理输出解析,例如通过退出码检查命令是否执行成功。
$LINUX_API_KEYsudoaptError Handling
错误处理
Check command exit codes immediately; for example, after , verify with . Parse errors from stdout/stderr, e.g., errors like "E: Unable to locate package" indicate missing repos—run first. For sysctl, if a parameter fails, check for details. Use in scripts:
sudo apt install packageif [ $? -ne 0 ]; then echo "Installation failed"; fiaptsudo apt update/var/log/syslogtry-catchcommand_output=$(sudo apt update 2>&1)
if [[ $command_output == *"ERROR"* ]]; then echo "Handle error"; fi立即检查命令退出码;例如执行后,可通过验证结果。解析标准输出/错误中的错误信息,例如报错"E: Unable to locate package"表示软件源缺失,需先执行。对于sysctl命令,如果参数设置失败,可查看获取详细信息。在脚本中使用逻辑:
sudo apt install packageif [ $? -ne 0 ]; then echo "安装失败"; fiaptsudo apt update/var/log/syslogtry-catchcommand_output=$(sudo apt update 2>&1)
if [[ $command_output == *"ERROR"* ]]; then echo "处理错误"; fiGraph Relationships
关联关系
- Related to: linux cluster skills like "networking" for firewall integration.
- Depends on: None directly, but assumes base Ubuntu setup.
- Conflicts with: None specified.
- 关联技能:与Linux集群技能(如用于防火墙集成的"networking")相关。
- 依赖:无直接依赖,但需基于基础Ubuntu环境。
- 冲突:无明确冲突项。