Command Line For Beginners

Aug 28, 2020

Command Line For Beginners

What is Command Line Interface (CLI)?

Command Line Interface (CLI) in Windows or a Terminal in Mac OS is a text-based user interface (UI) used to view and manage computer files by typing commands directly to a computer’s operating system. It is a user interface that is navigated by typing commands at prompts, instead of using a mouse. It is available in all Windows OS and Mac OS.

Before the mouse was invented users interacted with the operating system using a keyboard. Users typed lines of commands using a keyboard to carry out any task or operation. Back in that old technological era where graphical user interface was not invented, this was the only means to communicate with the machine.

The Command Line Interface features a black box with white text. Usually, the user types the command after the prompt. The output of the system can be a text message, table or list.


History of command line:

Back then, people had only a keyboard as an input device and the computer screen could only display text information. Before Windows was created, the most common operating system was DOS. DOS stands for Disk Operating System. Back in the day’s DOS was used to start a computer compared to as we do today on a Windows PC/Laptop. The only difference was that DOS was not a graphical operating system but rather purely textual. That meant in order to run programs or manipulate the operating system user had to manually type in commands. When Windows was first created it was actually a graphical user interface that was created in order to make using the DOS operating system easier for a novice user. Newer versions kept coming and DOS was finally phased out. Though the newer operating systems do not run on DOS, they do have something called the command prompt, which has a similar appearance to DOS.


What can Command Line Interface do?

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

Yes, using a command line interface requires you to memorize a list of various commands but has been proven to be most valuable. Command line can perform all the tasks that we perform using a graphical user interface today much quicker and efficiently.

Users who use Microsoft Windows may find a task such as renaming 100+ files in a folder, a very time consuming task. However, renaming 100+ files in a directory can be done in less than a minute with a single command in the command line.


How to open a command line in Windows and Mac OS?

Open a Windows command line window by following the steps below.
1. Click Start.
2. Type cmd and press Enter.

In macOS, the Terminal application provides a command line for running text-based commands and scripts. To access the command line in macOS, follow these steps.

Command line using Finder:

1. The macOS Terminal application is located in the folder /Applications/Utilities. To run the Terminal app from the Finder, follow these steps.
2. In the Dock at the bottom of your screen, click the Finder icon.
3. On the left side of the screen, under the Favorites section, click the Applications selector in macOS. selector.
4. After clicking Applications, click the Utilities shortcut in the section to the right.
5. Utilities folder icon in macOS.
6. Look for the Terminal icon and double-click it.
7. When you open the terminal, you will see the name of the current folder. If you want to know the full path to the current folder, you can type pwd and see the full path.

List of commands:

1. Listing files and folders: To list files and folders of your directory.

Windows Mac OS
dir ls

After pressing enter you will see list of all the files and folders in your directory.

2. Move to Directory: To change your current directory to some other directory.

Windows Mac OS
cd “enter the path to your folder” cd “enter the path to your folder”

After pressing enter if the path entered is correct your current path will change to new path.

3. Moving Back To Root Directory: To move back to root directory from any directory.

Windows Mac OS
cd cd /

After pressing enter you will be moved to the disk root directory.

4. Moving back a directory: To go one directory up.

Windows Mac OS
cd.. cd ..

After you press enter your current directory will change to parent directory.

Note: In Windows there is no space between “cd” and “..” whereas in Mac Os these is space between “cd” and “..”


5. Create a directory: To create a new directory in the current directory.

Windows Mac OS
mkdir NewDirectory mkdir NewDirectory

After you press enter it will create directory “NewDirectory” inside your current directory.

6. Rename a Directory: To rename a directory.

Windows Mac OS
rename oldName newName mv oldName newName

This will rename the directory from your oldName to newname.

7. Remove a Directory: To remove a directory it needs to be first emptied and then removed.

Windows Mac OS
rmdir DirectoryName rm -r DirectoryName

8. Check the path: To check your current path.

Windows Mac OS
echo %path% echo “$PATH”

This command will display the current path.

Things To Remember:

1. Whenever you delete a file it is not moved to recycle bin.
2. Whenever working with a file or directory with a space, surround it in quotes. For example, the directory My Files would be “My Files” when typed.
3. If you need help with any of command, type /? after the command in windows and (command) – help in Mac Os .

CLI Advantages:

•It does not require Windows to run.
•A computer that is only using the command line takes a lot less of the computer’s system resources than a GUI.
•You don’t need a computer with high resolution to run CLI.
•If the user knows the command than CLI is much faster than any other interface.

CLI Disadvantages:

•If the user does not know all the commands of CLI it can be confusing.
•If there is a spelling error in the commands it won’t be executed.

You should now have a good understanding of how to navigate the command line, create directories and files, rename directories and files, and delete. There are hundreds of other commands that can be used at the command line.

Ready to start your digital journey?

Let's work together to conquer the digital space

Office Address

6th Floor, Office Number 603, Ashok Premises Old Nagardas Crossroad, opposite Saraswati Towers, Andheri East, Mumbai, Maharashtra 400069

@ 2024, iDigitize I All Rights Reserved I Designed, Developed & Managed By iDigitize Infotech LLP