linux-admin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

linux-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
    apt
    with flags like
    -y
    for non-interactive mode.
  • User Management: Create, modify, or delete users with commands like
    useradd
    ,
    usermod
    , and
    userdel
    , including options for home directories and shells.
  • Disk/Filesystem: Partition disks with
    fdisk
    , format filesystems using
    mkfs
    , and mount/unmount with
    mount
    and
    umount
    , supporting formats like ext4.
  • Sysctl: Adjust kernel parameters dynamically, e.g., for networking or security, by editing
    /etc/sysctl.conf
    and applying with
    sysctl -p
    .
  • Log Management: Query and filter system logs using
    journalctl
    , with options like
    --since
    for time-based searches and persistent storage in
    /var/log
    .
  • 软件包管理(apt):更新软件源、安装/卸载软件包并管理依赖,使用
    apt
    命令及
    -y
    等参数实现非交互模式。
  • 用户管理:使用
    useradd
    usermod
    userdel
    等命令创建、修改或删除用户,包括配置主目录和Shell的选项。
  • 磁盘/文件系统:使用
    fdisk
    进行磁盘分区,
    mkfs
    格式化文件系统,
    mount
    umount
    挂载/卸载分区,支持ext4等格式。
  • 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
sudo
for root privileges. Example 1: To install a package and add a user, use a sequence like:
sudo apt update; sudo apt install nginx -y; sudo useradd webuser -m
. Example 2: For disk management and log check, run:
sudo fdisk /dev/sda; sudo mkfs.ext4 /dev/sda1; sudo mount /dev/sda1 /mnt; sudo journalctl -u nginx --since "1 hour ago"
.
通过脚本中的Shell命令或AI调用本技能。所有命令需以
sudo
前缀获取root权限。示例1:安装软件包并添加用户,可执行如下序列命令:
sudo apt update; sudo apt install nginx -y; sudo useradd webuser -m
。示例2:进行磁盘管理并检查日志,执行:
sudo 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
$LINUX_API_KEY
for authentication. Ensure the AI agent prefixes commands with
sudo
and handles output parsing, e.g., check for
apt
success via exit codes.
在Ubuntu 24.04的Bash环境中执行命令。远程访问可使用SSH;核心功能无需API密钥,但如果与监控API等外部工具集成,需设置
$LINUX_API_KEY
等环境变量进行身份验证。确保AI代理在命令前添加
sudo
前缀,并处理输出解析,例如通过退出码检查
apt
命令是否执行成功。

Error Handling

错误处理

Check command exit codes immediately; for example, after
sudo apt install package
, verify with
if [ $? -ne 0 ]; then echo "Installation failed"; fi
. Parse errors from stdout/stderr, e.g.,
apt
errors like "E: Unable to locate package" indicate missing repos—run
sudo apt update
first. For sysctl, if a parameter fails, check
/var/log/syslog
for details. Use
try-catch
in scripts:
command_output=$(sudo apt update 2>&1)
if [[ $command_output == *"ERROR"* ]]; then echo "Handle error"; fi
立即检查命令退出码;例如执行
sudo apt install package
后,可通过
if [ $? -ne 0 ]; then echo "安装失败"; fi
验证结果。解析标准输出/错误中的错误信息,例如
apt
报错"E: Unable to locate package"表示软件源缺失,需先执行
sudo apt update
。对于sysctl命令,如果参数设置失败,可查看
/var/log/syslog
获取详细信息。在脚本中使用
try-catch
逻辑:
command_output=$(sudo apt update 2>&1)
if [[ $command_output == *"ERROR"* ]]; then echo "处理错误"; fi

Graph 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环境。
  • 冲突:无明确冲突项。