Command Line Interface or CLI as it usually refers to is an interface/tool that allows interaction with the hardware component of the computer. CLI however, does this through commands written in the console or terminal.
GUI or Graphical User Interface is also an option provided by the computer Operating System for a user to interact with the hardware, GUI is beginner friendly but the CLI, on the other hand, has a steep learning curve.
In this article, you will get introduced to CLI and start to use it to perform basic computer operations you have been performing with GUI. Without much ado let's get started.
Prerequisite
- Basic computer operation knowledge
What you will learn
Create a file
View list of directory
View file content
Delete a file
Create and Deleting directory
Copy file
Move file
Rename file
Navigate through folders/directory
Create a file
Let's create your first file using the console. Open your Command prompt if you are on windows and Terminal for MacBook users.
Write in your console the command below and press enter key to execute. You would notice a blinking underscore; this is because the "copy con {filename}" allows you to add content to your file immediately after you create one. Press Ctrl C to exit editing.
copy con firstfile.txt
This is my firstfile created on Console
View list of Directory
Write the command below in your console and press enter to view all directories and files in the current directory.
dir
View file content
Write the command below to display the content of a file to the console.
type firstfile.txt
Delete a file
To delete a file you write the command below followed by the name of the file you want to delete, since we have created "firstfile.txt" the command below should work fine.
rd firstfile.txt
Creating and deleting a directory
The following commands are for creating and deleting a directory.
// to create directory firstdirectory
md firstdirectory
// to delete directory firstdirectory
rd firstdirectory
Copy file
Copying a file in the console is simple you use the copy keyword and specify where to copy from and where to copy to. If the destination "secondfile.txt" isn't existing the command will create it and copy to destination.
copy firstfile.txt secondfile.txt
//To view the copied content us the command below
type secondfile.txt
Move file
Command moving a file is similar to copying a file. Use the move keyword, the example below will move the "firstfile.txt" to the "firstdirectory" created earlier.
move firstfile.txt firstdirectory
//To cross check if the move was successfully write the dir command, the //firstfile.txt won't be visible again from list because it has been moved
dir
Rename file
Command to rename a file uses the rename keyword. the example renames the "secondfile.txt" to "thirdfile.txt".
rename secondfile.txt thirdfile.txt
Navigate through folders/directory
You use the cd command which means changing the directory to navigate around the folders. Earlier we moved "firstfile.txt" to the directory "firstdirectory" now let's change directory to the firstdirectory and see if the file is actually there
cd firstdirectory
//Then enter dir to view directory content
dir
//To go back to previous directory
cd ..
You have come to the end of the introduction to Command Line Interface for beginners. You have learned to perform basic computer operations with the CLI, like creating a file/directory, deleting a file/directory, moving, renaming, copying a file, and navigating the computer system.
if you do learn one or refresh your memory of one or two things do drop a like and share.
Connect with me on Linkedin. Thank you for your time. have a nice day.
Top comments (0)