Basic Linux Commands

Introduction

Linux operating systems offer a robust set of command-line tools for comprehensive system administration. These commands, executed in a terminal or shell environment, provide granular control over various aspects of OS management.

Key Areas of Linux OS Management

File and Directory Management

  • ls: Lists files and directories.
  • cd: Changes the current working directory.
  • mkdir: Creates a new directory.
  • pwd: Displays the present working directory.
  • cp: Copies files and directories.
  • mv: Moves or renames files and directories.
  • rm: Deletes files and directories.

Process Management

  • ps: Lists running processes.
  • top: Displays real-time process activity.
  • kill: Sends a signal to terminate a process.
  • bg: Moves a job to the background.
  • fg: Moves a job to the foreground.

User and Group Management

  • useradd: Creates a new user account.
  • userdel: Deletes a user account.
  • passwd: Changes a user's password.
  • groupadd: Creates a new group.
  • groupdel: Deletes a group.

System Configuration

  • chroot: Changes the root directory for a process and its children.

User Permission and Security

  • sudo: Executes commands with the privileges of another user (usually the superuser).
  • su: Switches to another user account (typically the superuser).

Package Management

  • apt-get (Debian/Ubuntu): Installs, updates, and removes software packages.
  • yum (Fedora/CentOS): Installs, updates, and removes software packages.
  • dnf (Recent Fedora versions): Installs, updates, and removes software packages.

Network Management

  • ifconfig: Displays and configures network interfaces.
  • ping: Tests connectivity to a host.
  • traceroute: Maps the network route to a host.
  • ip: Manages network interfaces, routes, and neighbors.

System Information

  • uname: Displays system information (kernel, OS version, etc.).
  • df: Reports disk space usage.
  • du: Estimates file space usage.
  • free: Displays memory and swap usage.

Text Manipulation and Searching

  • cat: Concatenates and displays files.
  • grep: Searches for patterns within files.
  • sed: A stream editor for text transformations.
  • awk: A pattern-matching and text processing language.

File Permissions

  • chmod: Changes file and directory permissions.
  • chown: Changes file and directory ownership.

Importance of Linux Commands

Command-line proficiency in Linux offers several advantages to system administrators and power users:

  • Efficiency: Commands often provide a faster, more direct way to perform tasks compared to graphical interfaces.
  • Automation: Commands can be combined into scripts or shell functions to automate repetitive tasks.
  • Remote Administration: Commands are vital for managing servers and systems over a network (often using SSH).
  • Customization and Control: The command line affords a high degree of control over the operating system.

Learning Resources

  • man pages: Built-in manual pages for each command (e.g., man ls) provide comprehensive information.