60 Linux Commands you NEED to know (in 10 minutes)

3 min read 2 months ago
Published on Sep 03, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial covers 60 essential Linux commands that every user should know, whether you're a beginner or a seasoned pro. Mastering these commands will enhance your efficiency and productivity while using the Linux terminal.

Step 1: Connecting to Remote Servers

  • ssh: Secure Shell, used to connect to remote servers.
    • Example: ssh user@hostname

Step 2: Navigating the File System

  • ls: List directory contents.
    • Usage: ls -l for detailed listing.
  • pwd: Print the current working directory.
  • cd: Change directory.
    • Example: cd /path/to/directory

Step 3: File and Directory Management

  • touch: Create an empty file.
    • Example: touch filename.txt
  • mkdir: Create a new directory.
    • Example: mkdir new_directory
  • cp: Copy files or directories.
    • Example: cp source.txt destination.txt
  • rm: Remove files.
    • Example: rm filename.txt
  • rmdir: Remove an empty directory.
    • Example: rmdir empty_directory
  • ln: Create a symbolic link.
    • Example: ln -s target_file link_name

Step 4: Viewing and Editing Files

  • cat: Display file contents.
    • Example: cat file.txt
  • nano: Simple text editor.
    • Usage: nano filename.txt
  • vim: Advanced text editor.
    • Usage: vim filename.txt
  • less: View file contents one screen at a time.
    • Example: less file.txt
  • head: View the top lines of a file.
    • Example: head -n 10 file.txt
  • tail: View the bottom lines of a file.
    • Example: tail -n 10 file.txt

Step 5: System Information

  • whoami: Display the current user.
  • uname: Show system information.
    • Usage: uname -a for detailed info.
  • free: Display memory usage.
  • df: Show disk space usage.
  • top: Monitor system processes in real-time.
  • htop: Enhanced version of top (requires installation).

Step 6: User Management

  • useradd: Create a new user.
    • Example: useradd newuser
  • passwd: Change user password.
  • sudo: Execute commands with superuser privileges.
    • Example: sudo command
  • su: Switch user.
  • adduser: Add a user with a home directory.

Step 7: Networking Commands

  • ping: Check connectivity to a host.
    • Example: ping google.com
  • ifconfig: Display network interfaces (may require installation).
  • ip address: Show IP address information.
  • netstat: Display network connections.
  • ss: Socket statistics.
  • iptables: Manage firewall rules.
  • ufw: Uncomplicated Firewall, easier firewall management.
    • Example: ufw enable

Step 8: File Compression

  • zip: Compress files into a ZIP archive.
    • Example: zip archive.zip file1 file2
  • unzip: Extract files from a ZIP archive.
    • Example: unzip archive.zip

Step 9: Searching and Sorting

  • grep: Search for text in files.
    • Example: grep 'search_term' file.txt
  • awk: Pattern scanning and processing language.
  • find: Search for files in a directory hierarchy.
    • Example: find /path -name filename
  • sort: Sort lines of text files.
    • Example: sort file.txt
  • diff: Compare files line by line.
    • Example: diff file1.txt file2.txt

Step 10: System Management

  • systemctl: Control the systemd system and service manager.
    • Example: systemctl restart service
  • reboot: Restart the system.
  • shutdown: Shut down the system.
    • Example: shutdown now

Conclusion

This guide covers vital Linux commands that will streamline your workflow and enhance your command-line skills. Practice regularly to become proficient, and consider exploring more advanced topics as you become comfortable with these basics. For further learning, consider diving into Linux tutorials or courses to deepen your knowledge.