Essential Linux Commands for Every User

Ankit Verma - Feb 18 - - Dev Community

Essential Linux Commands for Every User

Linux is a powerful and flexible operating system, widely used by developers, system administrators, and tech enthusiasts. Knowing the right commands can help you navigate, manage files, and optimize system performance. Here’s a list of some of the most useful Linux commands, categorized for ease of reference.

1. Basic Navigation Commands

  • pwd – Print the current working directory.
  • ls – List files and directories in the current directory.
  • cd <directory> – Change to the specified directory.
  • mkdir <directory> – Create a new directory.
  • rmdir <directory> – Remove an empty directory.

2. File Management Commands

  • touch <filename> – Create a new empty file.
  • cp <source> <destination> – Copy files or directories.
  • mv <source> <destination> – Move or rename files.
  • rm <filename> – Remove a file.
  • rm -r <directory> – Remove a directory and its contents.

3. Viewing and Editing Files

  • cat <filename> – Display file contents.
  • less <filename> – View file content page by page.
  • nano <filename> – Open a file in the nano text editor.
  • vim <filename> – Open a file in the Vim text editor.
  • grep '<text>' <filename> – Search for text inside a file.

4. System Monitoring Commands

  • top – Display active processes and system resource usage.
  • htop – A more user-friendly alternative to top (requires installation).
  • df -h – Show disk space usage in a human-readable format.
  • du -sh <directory> – Show the size of a directory.
  • free -m – Display available and used RAM in megabytes.

5. User Management Commands

  • whoami – Show the current logged-in user.
  • id – Display user ID (UID) and group ID (GID).
  • who – List currently logged-in users.
  • passwd – Change the current user's password.
  • sudo useradd <username> – Create a new user.
  • sudo userdel <username> – Delete a user.

6. Process Management Commands

  • ps aux – Display active processes.
  • kill <PID> – Terminate a process using its Process ID.
  • killall <process_name> – Terminate all processes with a given name.
  • pkill <pattern> – Kill processes matching a name pattern.

7. Networking Commands

  • ip a – Show network interfaces and IP addresses.
  • ping <host> – Test connectivity to a remote host.
  • curl -I <URL> – Fetch HTTP headers from a website.
  • wget <URL> – Download a file from the internet.
  • netstat -tulnp – Show open ports and active connections.

8. Package Management Commands

For Debian-based systems (Ubuntu, Debian):

  • sudo apt update – Update package lists.
  • sudo apt upgrade – Upgrade installed packages.
  • sudo apt install <package> – Install a new package.

For RHEL-based systems (CentOS, Fedora):

  • sudo yum update – Update all packages.
  • sudo yum install <package> – Install a package.

9. Permission and Ownership Commands

  • chmod <permissions> <filename> – Change file permissions.
  • chown <user>:<group> <filename> – Change file owner and group.
  • ls -l – Display detailed file permissions and ownership.

10. Archiving and Compression Commands

  • tar -cvf archive.tar <directory> – Create a tar archive.
  • tar -xvf archive.tar – Extract a tar archive.
  • gzip <file> – Compress a file using gzip.
  • gunzip <file.gz> – Decompress a gzip file.
  • zip -r archive.zip <directory> – Create a zip archive.
  • unzip archive.zip – Extract a zip archive.

These Linux commands are essential for managing files, processes, users, and system resources efficiently. Whether you’re a beginner or an experienced user, mastering these commands will significantly enhance your productivity. Keep practicing, and soon you’ll be navigating Linux like a pro!

. . . . . . . . . .