• HWIKI

    Build. Break. Explain.

    Basic Linux commands : Guide

    Linux is a powerful operating system used by millions of people around the world for server management, development and much more. Knowing the basic commands is essential for navigating effectively in a Linux environment. Here's a summary of the essential commands every beginner should know.

    1. File system navigation

    • pwd: Displays the path to the current directory.

      bash
      $ pwd
      

      Example output: /home/user

    • ls: Lists files and directories in the current directory.

      bash
      $ ls
      
    • cd [path]: Changes directory.

      bash
      $ cd /home/user/Documents
      
    • cd .. : Up one directory.

      bash
      $ cd .
      

    2. File and directory management

    • touch [filename]: Creates an empty file.

      bash
      $ touch fichier.txt
      
    • mkdir [folder_name]: Creates a directory (folder).

      bash
      $ mkdir new_folder
      
    • rm [file_name]: Deletes a file.

      bash
      $ rm file.txt
      
    • rm -r [folder_name]: Deletes a directory and its contents.

      bash
      $ rm -r folder_delete
      
    • cp [source] [destination]: Copies a file or directory.

      bash
      $ cp fichier.txt /home/user/Documents/
      
    • mv [source] [destination] : Moves or renames a file/directory.

      bash
      $ mv fichier.txt /home/user/Documents/
      

    3. Displaying file contents

    • cat [filename]: Displays the contents of a file.

      bash
      $ cat fichier.txt
      
    • head [filename]: Displays the first lines of a file.

      bash
      $ head fichier.txt
      
    • tail [filename]: Displays the last lines of a file.

      bash
      $ tail fichier.txt
      
    • less [filename]: Navigates within a long file.

      bash
      $ less fichier.txt
      

    4 User management and permissions

    • whoami: Displays current user name.

      bash
      $ whoami
      
    • sudo [command]: Executes a command with root rights.

      bash
      $ sudo apt update
      
    • chmod [permissions] [filename]: Changes file permissions.

      bash
      $ chmod 755 script.sh
      
    • chown [user] [filename]: Changes the owner of a file or directory.

      bash
      $ chown user fichier.txt
      

    5. Process management

    • ps : Displays a list of running processes.

      bash
      $ ps
      
    • top: Displays processes in real time.

      bash
      $ top
      
    • kill [PID]: Terminates a process (replace [PID] with the process identifier).

      bash
      $ kill 1234
      

    6. System and disk management

    • df -h: Displays available and used disk space.

      bash
      $ df -h
      
    • du -h [path]: Displays the size of files in a directory.

      bash
      $ du -h /home/user
      
    • free -h : Displays memory usage.

      bash
      $ free -h
      
    • uptime: Displays time since last boot and system load.

      bash
      $ uptime
      

    7. Network

    • ``ifconfig`** : Displays network interfaces and their configurations.

      bash
      $ ifconfig
      
    • ping [address]: Sends packets to test network connectivity.

      bash
      $ ping google.com
      
    • wget [URL]: Downloads a file from a URL.

      bash
      $ wget http://example.com/fichier.txt
      

    8. Useful tips

    • man [command]: Displays a command's manual.

      bash
      $ man ls
      
    • history: Displays the history of previous commands.

      bash
      $ history
      

    Conclusion

    This guide covers the basic Linux commands that every novice user should master. To go further, consult the manuals (man) to learn more about each command and explore the many possibilities offered by Linux.