Skip to content
My Image

Command Line Basics

Command Line Interfaces (CLI) provide a powerful way to interact with computers, enabling users to perform various tasks efficiently through text-based commands. While CLI may seem intimidating at first, mastering its basics can greatly enhance your productivity and proficiency in managing your system. In this article, we'll explore essential command line commands and their equivalents across three major operating systems: Windows, Linux, and macOS.

Stream NameSymbolDescription
Standard Input (stdin)stdinDefault input stream where commands read input. Usually connected to the keyboard.
Standard Output (stdout)stdoutDefault output stream where commands print normal output.
Standard Error (stderr)stderrStream used for error messages and diagnostic output.

1. Navigation Commands:

CommandLinux/macOSWindowsDescription
pwdpwdcdPrint working directory
lsls [options] [directory]dir [options]List directory contents
cdcd [directory]cd [directory]Change directory
mkdirmkdir [directory]mkdir [directory]Make directory
touchtouch [file]echo > [file]Create new file
rmrm [options] [file]del [file]Remove file
rm -r [directory]rmdir [directory]Remove directory

2. File Manipulation Commands:

CommandLinux/macOSWindowsDescription
mvmv [source] [destination]move [source] [destination]Move or rename file or directory
cpcp [source] [destination]copy [source] [destination]Copy file or directory
catcat [file]type [file]Display file contents
cat [file1] [file2] > [file3]copy [file1] + [file2] [file3]Concatenate files
nanonano [file]-Text editor in CLI (Linux/macOS)
notepad-notepad [file]Text editor in CLI (Windows)

3. Permissions and Users:

CommandLinux/macOSWindowsDescription
ls -lls -l [file]icacls [file]Display file permissions
chmodchmod [mode] [file]icacls [file] /grant [user]:[permissions]Change file permissions (Linux/macOS)
takeown /f [file]Take ownership of file (Windows)

4. Redirection and Piping:

CommandLinux/macOSWindowsDescription
>>>Redirect output to file
>>>>>>Append output to file
|||Pipe output to another command or file
<<<Redirect input from file

These symbols provide various ways to handle input and output streams in the command line interface.

5. Basic Command Line Utilities:

CommandLinux/macOSWindowsDescription
grepgrep [pattern] [file]Select-String [pattern] [file]Search for text patterns (Linux/macOS)
findfind [directory] -name [pattern]Get-ChildItem -Recurse -Filter [pattern]Search for files and directories (Linux/macOS)
wcwc [file]Measure-Object -Line [file]Word count (Linux/macOS)

6. Managing Processes:

CommandLinux/macOSWindows(CMD)Windows(Powershell)Description
pspstasklistGet-ProcessList running processes
killkill [PID]taskkillStop-Process -ID [PID]Terminate a process

Certainly! Here's an updated section including service management commands:

7. Service Management:

CommandLinux/macOSWindows(CMD)Windows(Powershell)Description
serviceservice or system-ctlscStart-Service or Stop-Servicecli service Manager tools

8. Package Management:

CommandLinux/macOSWindowsDescription
aptapt/pkg/yumwingetPackage Manager

9. Environment Variables:

CommandLinux/macOSWindowsWindowsDescription
envenvsetGet-ChildItem Env:List environment variables (Linux/macOS)
$env:exportset or setx$env:Access environment variables (Windows)