Skip to content

Latest commit

 

History

History
272 lines (213 loc) · 4.29 KB

File metadata and controls

272 lines (213 loc) · 4.29 KB

Basic Linux Commands

File and Directory Management

  • Show the current working directory:

    pwd
  • List all files and directories in the current directory:

    ls
  • List files with detailed information (permissions, owner, size, date modified):

    ls -l
  • List all files, including hidden ones (files starting with .):

    ls -a
  • List files with human-readable sizes (KB, MB, GB):

    ls -lh
  • List all files and directories recursively, including subdirectories:

    ls -R
  • Change to a specified directory:

    cd directory_name
  • Move up one directory level:

    cd ..
  • Move to the root directory:

    cd /
  • Create a new directory:

    mkdir new_folder
  • Create multiple nested directories in one command:

    mkdir -p parent/child/grandchild
  • Delete an empty directory:

    rmdir foldername
  • Delete a specific file:

    rm file.txt
  • Delete a directory and all its contents forcefully:

    rm -rf foldername

File Operations

  • Create an empty file:

    touch filename.txt
  • Display the contents of a file:

    cat filename.txt
  • Create and edit a file (press Ctrl + D to save):

    cat > filename.txt
  • Copy a file to a specified location:

    cp file.txt /path/to/destination/
  • Copy an entire directory and its contents:

    cp -r source_folder destination_folder
  • Move or rename a file or directory:

    mv oldname.txt newname.txt
  • Create a symbolic (soft) link to a file or directory:

    ln -s /path/to/target linkname
  • Create a hard link to a file:

    ln /path/to/file hardlinkname

System Information

  • Show the current system date and time:

    date
  • Display how long the system has been running:

    uptime
  • Show Linux kernel details:

    uname -a
  • Display CPU information:

    lscpu
  • List all connected USB devices:

    lsusb
  • Display PCI hardware information:

    lspci
  • List all storage devices and partitions:

    lsblk

User and Session Information

  • Show the currently logged-in user:

    whoami
  • List all users currently logged into the system:

    who
  • Show detailed user login information:

    who -a
  • Display active users and their running processes:

    w
  • Show user ID and group memberships:

    id

Network and Host Information

  • Show the system hostname:

    hostname
  • Display the system’s IP address:

    hostname -I
  • Show network configuration details (IP, MAC address, etc.):

    ifconfig
  • Display the system’s DNS configuration:

    cat /etc/resolv.conf
  • Show the network routing table:

    route -n

Process and Memory Information

  • List currently running processes:

    ps aux
  • Display real-time system statistics and resource usage:

    top
  • Show memory and swap usage in a human-readable format:

    free -h

Terminal Utilities

  • Clear the terminal screen:

    clear
  • Show the name of the terminal device:

    tty
  • Display command history:

    history
  • Show the calendar for the current month:

    cal
  • Show the calendar for a specific year:

    cal 2025

System Shutdown and Reboot

  • Shut Down the System

    shutdown -P now
  • Restart the System

    shutdown -r now
  • Cancel a Scheduled Shutdown

    shutdown -c
  • Alternative Shutdown Commands

    • poweroff - Turns off the system.
    • init 0 - Shuts down the system.
    • init 6 - Restarts the system.