Skip to content

Latest commit

 

History

History
195 lines (137 loc) · 2.9 KB

README.md

File metadata and controls

195 lines (137 loc) · 2.9 KB

Basic Linux Commands for Day-to-Day Usage.


Introduction to Linux Commands

  • What are Linux Commands?
    • Instructions that users can give to the Linux operating system through the command line interface (CLI).
    • Essential for navigating, managing files, and interacting with the system.

Navigating Directories

  • pwd (Print Working Directory)
    Displays the current directory you're in.

    $ pwd

    Example output: /home/user

  • ls (List)
    Lists files and directories in the current directory.

    $ ls

    Example output: Documents/ Downloads/ Pictures/

  • cd (Change Directory)
    Changes the current directory.

    $ cd /home/user/Documents

Managing Files

  • touch
    Creates an empty file or updates a file's timestamp.

    $ touch newfile.txt
  • cp (Copy)
    Copies files or directories.

    $ cp file1.txt /home/user/Backup/
    $ cp -r /home/user/Documents/project /home/user/Backup/
  • mv (Move/Rename)
    Moves or renames files or directories.

    $ mv oldname.txt newname.txt
  • rm (Remove)
    Deletes files and folders.

    $ rm file1.txt
    $ rm -rf folder/

Viewing File Content

  • cat
    Displays the contents of a file.

    $ cat file.txt
  • less
    View file content one screen at a time.

    $ less largefile.txt
  • head / tail
    Shows the first/last 10 lines of a file.

    $ head file.txt
    $ tail file.txt

System Monitoring Commands

  • top
    Displays a real-time view of running processes.

    $ top
  • df (Disk Free)
    Shows available disk space on file systems.

    $ df -h
  • free
    Displays available and used memory.

    $ free -h

Searching & Finding Files

  • find
    Search for files in a directory hierarchy.

    $ find /home/user -name "file.txt"
  • grep
    Searches for a pattern within files.

    $ grep "error" logfile.txt

Basic Networking Commands

  • ping
    Checks the connectivity to another machine.

    $ ping google.com
  • ifconfig / ip
    Displays or configures network interfaces.

    $ ifconfig
    $ ip addr show

File Permissions

  • chmod
    Changes file or directory permissions.

    $ chmod 755 script.sh
  • chown
    Changes file ownership.

    $ chown user:user file.txt

Package Management (Ubuntu Example)

  • apt-get update
    Updates the package lists.

    $ sudo apt-get update
  • apt-get install
    Installs a package.

    $ sudo apt-get install vim

Explore further

  1. More on ls and cp
  2. File Permissions