Learn the essential command line basics to navigate, manage files, and execute commands efficiently. Master the CLI with this beginner-friendly guide.
cmd.exe
), PowerShellCommand | Description | Windows | macOS/Linux |
---|---|---|---|
pwd | Print current directory | ❌ | ✅ |
cd | Change directory | ✅ | ✅ |
ls | List files in directory | ❌ | ✅ |
dir | List files in directory | ✅ | ❌ |
Command | Description | Windows | macOS/Linux |
---|---|---|---|
mkdir <folder> | Create a new directory | ✅ | ✅ |
rmdir <folder> | Remove an empty directory | ✅ | ✅ |
rm -r <folder> | Remove a directory and its contents | ❌ | ✅ |
del <file> | Delete a file | ✅ | ❌ |
rm <file> | Delete a file | ❌ | ✅ |
Command | Description | Windows | macOS/Linux |
---|---|---|---|
type <file> | Display file contents | ✅ | ❌ |
cat <file> | Display file contents | ❌ | ✅ |
more <file> | View file one page at a time | ✅ | ✅ |
less <file> | View file with navigation | ❌ | ✅ |
Command | Description | Windows | macOS/Linux |
---|---|---|---|
tasklist | Show running processes | ✅ | ❌ |
ps | Show running processes | ❌ | ✅ |
taskkill /F /IM <process> | Kill a process | ✅ | ❌ |
kill <PID> | Kill a process | ❌ | ✅ |
Command | Description | Windows | macOS/Linux |
---|---|---|---|
ping <domain> | Check network connectivity | ✅ | ✅ |
ipconfig | Display network details | ✅ | ❌ |
ifconfig | Display network details | ❌ | ✅ |
tracert <domain> | Trace network route | ✅ | ❌ |
traceroute <domain> | Trace network route | ❌ | ✅ |
*.txt
- Selects all text files in a directory.?
- Represents a single character in a filename.command1 && command2
- Run command2
only if command1
succeeds.command1 || command2
- Run command2
only if command1
fails.command1 ; command2
- Run both commands regardless of success.>
- Redirect output to a file (echo Hello > output.txt
).>>
- Append output to a file (echo Hello >> output.txt
).|
- Pipe output from one command to another (ls | grep .txt
).cd
.pwd
to check your current location.ls
or dir
.Projects
and navigate into it.Projects
, create a file called notes.txt
using touch
(macOS/Linux) or echo. > notes.txt
(Windows).rm notes.txt
(Linux/macOS) or del notes.txt
(Windows).echo
.cat
(or type
on Windows) to view the content.>
.grep
(or findstr
on Windows) to filter specific content from the file.ps
(Linux/macOS) or tasklist
(Windows) to find its process ID.kill <PID>
(Linux/macOS) or taskkill /F /IM <process>
(Windows).ping google.com
to check internet connectivity.traceroute google.com
(Linux/macOS) or tracert google.com
(Windows) to see network hops.ipconfig
or ifconfig
.