← All writing

Top 10 Linux Commands Every Developer Should Know

· Sourabh G Kulkarni

Master the command line with this essential guide to the top 10 most used Linux commands, complete with practical, real-world examples and copyable command structures.

Top 10 Linux Commands Every Developer Should Know

The terminal is one of the most powerful tools in a developer's arsenal. Whether you are managing cloud servers, deploying containers, configuring CI/CD pipelines, or just developing locally, a strong grasp of the Linux command line is indispensable.

While Linux has thousands of utilities, a small subset of commands handles 90% of daily operations. In this guide, we break down the top 10 most used Linux commands, complete with practical options, real-world examples, and copyable structures.


1. ls (List Directory Contents)

The ls command is used to list files and directories within your current working directory.

Common Syntax & Options

  • ls - Standard list of visible files.
  • ls -l - Long listing format (shows permissions, owner, size, and modification date).
  • ls -a - Lists all files, including hidden files (those starting with a .).
  • ls -la - Combines both options for a complete view.

Practical Example

To view all files in detail, including hidden configuration files (like .env or .git), use:

ls -la

2. cd (Change Directory)

The cd command allows you to navigate through the file system.

Common Syntax & Options

  • cd [path] - Navigate to a specific path.
  • cd .. - Move up one level to the parent directory.
  • cd ~ or just cd - Navigate directly to your user's home directory.
  • cd - - Switch back to the previous directory you were in.

Practical Example

To move two levels up and then enter the etc folder:

cd ../../etc

3. pwd (Print Working Directory)

When navigating a complex system, it is easy to get lost. The pwd command prints the absolute path of your current folder.

Practical Example

Find your exact location to use in configuration files:

pwd

Expected Output: /var/www/my-portfolio-website


4. cat (Concatenate and View Files)

The cat command displays the contents of one or more files directly in the terminal window without opening a text editor.

Common Syntax & Options

  • cat [filename] - Displays file contents.
  • cat -n [filename] - Displays file contents with line numbers.

Practical Example

Quickly view the contents of a configuration or environmental file:

cat -n .env

5. mkdir (Make Directory)

The mkdir command creates new directories.

Common Syntax & Options

  • mkdir [directory_name] - Create a single folder.
  • mkdir -p [parent/child/grandchild] - Create parent folders automatically if they do not exist.

Practical Example

Create a nested project structure in one go:

mkdir -p src/components/ui

6. rm (Remove Files or Directories)

The rm command deletes files and directories. Use with caution, as files deleted via the command line bypass the trash bin and cannot be easily recovered.

Common Syntax & Options

  • rm [filename] - Delete a file.
  • rm -r [directory] - Recursively delete a directory and all of its contents.
  • rm -f [filename] - Force deletion without confirmation prompts.
  • rm -rf [directory] - Force recursive deletion (often used to clear build folders).

Practical Example

Clean up a temporary build directory:

rm -rf dist/

7. cp (Copy Files or Directories)

The cp command duplicates files or directories from a source path to a destination path.

Common Syntax & Options

  • cp [source] [destination] - Copy a file.
  • cp -r [source_dir] [destination_dir] - Copy a directory and all its contents recursively.

Practical Example

Backup your configuration file before editing:

cp nginx.conf nginx.conf.bak

8. mv (Move or Rename)

The mv command serves a dual purpose: moving files/directories to another location, or renaming them.

Practical Example

Rename a draft document:

mv draft.md archive.md

Or move a file to another folder:

mv index.html public/index.html

9. grep (Search Text Using Patterns)

The grep command searches files for lines matching a specified pattern or regular expression. It is essential for log analysis and debugging.

Common Syntax & Options

  • grep "pattern" [filename] - Search for a pattern in a file.
  • grep -i "pattern" [filename] - Perform a case-insensitive search.
  • grep -r "pattern" [directory] - Search recursively through all files in a directory.
  • grep -n "pattern" [filename] - Display the matching lines along with their line numbers.

Practical Example

Find where a specific API route is used in your codebase:

grep -rn "api/v1/users" src/

10. chmod (Change File Permissions)

In Linux, every file and directory has permissions specifying who can read, write, or execute it. The chmod command modifies these permissions.

Common Modes

  • chmod +x [script.sh] - Make a file executable (adds execute permission).
  • chmod 755 [directory] - Give read/write/execute permissions to owner, and read/execute to group and others.
  • chmod 600 [file] - Make a file readable and writable only by the owner (common for SSH keys).

Practical Example

Make a shell deployment script executable so you can run it:

chmod +x scripts/deploy.sh

Pro Tip: Combining Commands with Pipes (|)

One of the core philosophies of Unix/Linux is that each tool does one thing well, and tools can be chained together. Using the pipe character (|), you can redirect the output of one command to be the input of another.

For example, to find all processes running node and filter the list:

ps aux | grep node

By mastering these 10 commands, you will be much faster navigating systems, debugging applications, and automating pipelines. Keep this guide handy next time you open your terminal!