Przejdลบ do treล›ci

๐Ÿงพ Summary

This document provides a comprehensive overview of FreeBSD's shell basics, covering essential concepts and practices for effective shell scripting and command-line usage on FreeBSD systems.

๐ŸŽฏ Key Concepts

FreeBSD uses a traditional BSD userland with some key differences from GNU/Linux systems: - Shell: Default shell is typically sh (POSIX-compliant) or tcsh for root - Userland: BSD-derived tools rather than GNU equivalents - Package Management: Uses pkg for binary packages and ports for source compilation

๐Ÿ”ง Core Components

Shell Environment

FreeBSD systems commonly use: - sh - POSIX-compliant shell (default for scripts) - tcsh - Default root shell in many installations - bash - Available via packages (pkg install bash) - zsh - Available via packages (pkg install zsh)

Filesystem Layout

Key directories differ slightly from Linux: - /usr/local - Local software installations - /usr/ports - Ports collection source - /var/db/pkg - Package database - /etc - System configuration files (symbolic links to /usr/local/etc for some services)

๐Ÿ“‹ Essential Commands

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Package management
pkg install package-name     # Install package
pkg search keyword          # Search for packages
pkg info package-name       # Show package information
pkg remove package-name     # Remove package

# System information
uname -a                   # System information
freebsd-version           # FreeBSD version
sysctl hw.physmem         # Physical memory information

# Service management
service nginx start       # Start service
service nginx stop        # Stop service
service nginx status      # Check service status

๐Ÿ› ๏ธ Common Use Cases

  1. Package Installation: Using pkg for quick software deployment
  2. Ports Compilation: Building software from source with /usr/ports
  3. Service Management: Controlling system services with service command
  4. System Monitoring: Checking resources and performance with BSD tools

๐Ÿ” Troubleshooting Tips

  • Check package availability with pkg search
  • Verify service configuration in /usr/local/etc/
  • Use sysctl for runtime system tuning
  • Consult man pages extensively - FreeBSD documentation is comprehensive