T

TechIdea

Ecosystem

Back to Commands
linux COMMANDS

Linux Commands Cheat Sheet

The most essential Linux terminal commands for developers. Navigate files, search logs, and manage permissions with ease.

ls

Lists directory contents (files and folders).

Syntax

bash
ls
ls -la

Example

bash
ls -la

Pro Tip

`ls -la` lists everything in a long format, including hidden files and file permissions.

Common Mistake

Forgetting the `-a` flag when trying to find hidden files like `.env` or `.git`.

cd

Changes the current working directory.

Syntax

bash
cd <directory>

Example

bash
cd /var/www/html
cd ..

Pro Tip

`cd ..` moves you up one directory. `cd -` moves you back to your previous directory.

Common Mistake

Using `cd /` instead of `cd ~/`. `/` is the root of the entire system, `~/` is the root of your user folder.

mkdir

Creates a new directory (folder).

Syntax

bash
mkdir <folder-name>

Example

bash
mkdir my-new-project
mkdir -p src/components/ui

Pro Tip

Use `mkdir -p a/b/c` to create a deeply nested folder structure instantly.

Common Mistake

Trying to create nested folders without using the `-p` (parents) flag.

rm

Removes files or directories.

Syntax

bash
rm <file>
rm -rf <directory>

Example

bash
rm old-file.txt
rm -rf node_modules

Pro Tip

Always double-check your current directory (`pwd`) before running `rm -rf`.

Common Mistake

Running `rm -rf /` or deleting important directories. `rm -rf` deletes folders forcefully and recursively with no undo!

grep

Searches for a specific pattern of text within files.

Syntax

bash
grep "search_string" <file>

Example

bash
grep "password" config.txt
grep -r "function()" .

Pro Tip

Use `grep -r` to search recursively through all files in the current directory.

Common Mistake

Searching manually through giant log files instead of just using `grep`.

chmod

Changes the file permissions (read, write, execute).

Syntax

bash
chmod <permissions> <file>

Example

bash
chmod +x script.sh
chmod 755 server.js

Pro Tip

`chmod +x` is the easiest way to make a bash script executable.

Common Mistake

Not understanding the numeric values. (4 = read, 2 = write, 1 = execute).

curl

Transfers data from or to a server, typically used to test APIs from the terminal.

Syntax

bash
curl <url>

Example

bash
curl https://api.example.com/health
curl -X POST https://api.example.com/data

Pro Tip

Add the `-i` flag to see the HTTP response headers.

Common Mistake

Forgetting to wrap URLs with complex query parameters in quotes.

Growth Newsletter

Get practical AI tools, SEO tips, and growth guides weekly.

Join creators, students, and businesses scaling with TechIdea.