A command line interface (CLI) is a text-based way to control a computer: you type a command, and the operating system carries it out or returns the result as text. Windows, macOS, and Linux all include a CLI, and it is also the most common way to manage remote web servers.
The sections below explain how a CLI works, where it came from, and how the shell interprets your commands. They also show basic commands for the Windows Command Prompt and for Bash and zsh on Linux and macOS, then compare the CLI with a graphical user interface (GUI) so you know when each one is the better choice.
What is a CLI and how does it work?
A command line interface (CLI) is a program that lets you control a computer by typing text commands instead of clicking icons, buttons, and menus. You type a command at a prompt, press Enter, and the computer performs the task or prints the result as text.
Every major operating system includes a CLI. Windows offers Command Prompt and PowerShell, macOS has the Terminal app, and Linux distributions include a terminal app such as Terminal on GNOME or Konsole on KDE Plasma. Web servers are also commonly managed through a CLI over a secure remote connection.
Most commands have three parts:
- Command: the instruction to perform, such as ls to list files.
- Option: a flag that changes how the command behaves, such as -a to include hidden files.
- Argument: the target the command acts on, such as a folder or file name.
For example, in ls -a ~/Desktop, ls is the command, -a is the option, and ~/Desktop is the argument. A program called the shell reads this text, interprets it, and asks the operating system to carry it out.
People use the CLI for tasks such as:
- Managing files and folders in bulk.
- Administering remote servers over SSH (Secure Shell).
- Automating repetitive work with scripts.
- Running developer tools such as Git, package managers, and WP-CLI for WordPress.
To practice, start with these essential Linux commands; many of the basics, such as ls, cd, and mv, work the same way in the macOS Terminal.
Where did the CLI come from?
The CLI is the oldest way to interact with a computer through a screen. In the 1960s and 1970s, most users worked with a keyboard and a text-only display, and the CLI remained the standard interface into the 1980s on operating systems such as MS-DOS.

Users typed a command for every task, because there was no other way to communicate with the computer. The result was either text output or an action, such as copying a file. Typing the exact command mattered: a wrong command could delete the wrong files or close a program before the work was saved, and this is still the main drawback of the CLI.
After the mouse was invented, point-and-click interaction gave people a new way to use computers. Operating systems adopted the graphical user interface (GUI), which represents commands as icons, buttons, and menus. A GUI is easier for most people to learn, so everyday computing moved away from the CLI.
Today, the GUI is the standard way to use a computer, but Windows, macOS, and Linux still include a CLI alongside it. For example, Mac users can type cal in Terminal to print the current month’s calendar or open the Calendar app to view it.
What is a shell and how does it work with the CLI?
A shell is the program that interprets the commands you type in a CLI. It reads each command, works out what it asks for, and instructs the operating system to perform the task. The terminal app is the window you type in, while the shell is the program running inside it.
A shell can handle many types of tasks, such as:
- Working with files and directories
- Opening and closing programs
- Managing computer processes
- Running repetitive tasks as scripts
The most widely used shells are Command Prompt (cmd.exe) and PowerShell on Windows, Bash on most Linux distributions, and zsh, the default shell on macOS.
Windows: Command Prompt and PowerShell
Windows includes two shells: Command Prompt (cmd.exe), the successor to the MS-DOS command line, and PowerShell, a more advanced shell and scripting language. On Windows 11 version 22H2 and later, both open in the Windows Terminal app by default.
To open Command Prompt, press Windows+R, type cmd, and press Enter. You can also search for Command Prompt in the Start menu.
Depending on what you need, type in either a single command or a combination. You can also type commands that run within a sequence (one command is executed after another).
The Command Prompt is so robust that it can manage many things within the Windows operating system:
- Changing directories, listing directories, content, etc
- Handling networking like displaying IP networks settings
- Managing files like renaming, moving, etc
- Managing media like formatting and renaming volumes
The following examples use Command Prompt syntax:
- Changing directory
To navigate to a specific directory or folder in the command prompt, use CD [path]. Make sure you add space before the intended path. For example:CD C:\Program Files
- Renaming a file
To rename a file within a specific folder, use REN [drive:][path] [source] [target].If you mention the location, that means the renamed file will be saved in the same folder. For example:REN d:untitled.txt untitled1.txt
- Deleting a file
To delete a file in the command prompt use DEL [filename]. If you want to add the options like force deletion, you can add it before the file name. For example:DEL /F untitled.txt
- Renaming a Volume Disk
To edit the name of a specific volume disk, use LABEL [drive:][new volume name]. Keep in mind that you can use up to 32 characters on NTFS volume and 11 on FAT volume. For example:LABEL d:MyData
Linux and macOS: Bash and zsh
Bash (Bourne Again SHell) is the GNU Project’s shell and the default shell on most Linux distributions. Other popular Unix shells include zsh, ksh (KornShell), and tcsh. Zsh is the default shell on current versions of macOS, but basic commands such as ls, cd, mv, and rm work the same way in Bash and zsh. On Windows, you can run Bash through the Windows Subsystem for Linux (WSL).
In most Linux distributions, you open the shell through a terminal app, usually called Terminal on GNOME desktops and Konsole on KDE Plasma. On macOS, go to Applications > Utilities > Terminal, or search for Terminal with Spotlight.
You can type commands one at a time, or save a sequence of commands in a file and run them together. A file like this is called a shell script.
The following examples work in the macOS Terminal and in most Linux terminals:
- List all files in a folder
To know what files under a specific folder, use ls.
The default command will exclude the hidden files. To show all files, you can add -a. For example:ls -a

- Change directory
To move to a specific directory, use cd destination. For example:cd ~/Desktop

- Rename file
To rename a file within a specific folder, use mv source destination. Keep in mind, that you need to make sure the name of the file and the extension. For example:mv ~/Desktop/untitled.rtf ~/Desktop/untitled1.rtf

- Delete a file
To delete a file in the specific folder use rm filename. To avoid deleting the wrong file, make sure you move to the right folder destination first. For example:
rm untitled.rtf

Type every command exactly, including spaces and letter case. Linux file systems are case-sensitive, so ls and LS are different commands, and Notes.txt and notes.txt are different files.
To stop a running command, press Control+C. The same shortcut works in the Windows Command Prompt.
CLI vs GUI: which one should you use?
A CLI is faster and more precise for repetitive, technical, and remote tasks, while a GUI is easier to learn and better for visual and occasional tasks. Most people use both: a GUI for everyday computing and a CLI when they need speed, automation, or access to a server.
| Attribute | CLI | GUI |
|---|---|---|
| Input | Typed text commands | Mouse, touch, or keyboard on icons, buttons, and menus |
| Learning curve | Steeper: you need to know command names and syntax | Gentler: options are visible on screen |
| Repetitive tasks | Fast: one command or script can process hundreds of files | Slow: each action is usually repeated by hand |
| Automation | Commands can be saved and rerun as scripts | Limited and depends on the app |
| Precision | Targets exact files, paths, and settings | Limited to what the interface exposes |
| Error risk | A typo can run the wrong action, often without confirmation or undo | Confirmation dialogs and undo reduce mistakes |
| System resources | Light, because output is text only | Heavier, because graphics need more memory and processing power |
| Remote server access | Common over SSH, even on slow connections | Needs a remote desktop or a web-based control panel |
| Discoverability | Low: you rely on help pages such as man or help | High: features are visible in menus |
Verdict: use a GUI for everyday, visual, or one-off tasks, especially while you are learning. Use the CLI to manage servers, automate repetitive work, or run developer tools, and test destructive commands such as rm or DEL on a copy of your files first.
The CLI doesn’t bypass operating system security. Administrative commands need elevated privileges, such as sudo on Linux and macOS or an administrator terminal on Windows, and protections such as macOS System Integrity Protection limit what even the root user can change.
The difference is easiest to see with bulk work. Moving a large amount of content from one WordPress site to another through the dashboard means exporting, importing, and checking items with plugins or by hand. With the WordPress Command Line Interface (WP-CLI), developers can run the same operations as commands and repeat them across sites in a script.
WP-CLI runs on the server where WordPress is installed, so check that your web hosting service includes SSH access before you plan a command-line workflow.

How can you start using the CLI?
The quickest way to learn the CLI is to use it for small, low-risk tasks on your own computer. Open Terminal on macOS or Linux, or Command Prompt or PowerShell on Windows, and practice listing, opening, and renaming files in a test folder before you run commands that delete or overwrite data.
Once the basics feel natural, use the CLI where it saves the most time: connecting to a web server, running WP-CLI, or scripting a task you repeat every week. Learning how SSH works is a good next step, because SSH is how most people reach a remote server’s command line.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.
