This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by omoluabidotcom
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
View list of directory
Create a file
View file content
Delete a file
Create and Deleting directory
Copy file
Move file
Rename file
Navigate through folders/directory
View list of Directory
Write the command below and press enter to view all directories and files.
dir
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 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 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 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 it.
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 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 rename the "secondfile.txt" to "thirdfile.txt".
rename secondfile.txt thirdfile.txt
Navigate through folders/directory
You use the cd command which means change directory to navigate around the folders. Earlier we moved "firstfile.txt" to the directory "firstdirectory" now let change direcrory 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 ends of introduction to Command Line Interface for beginner. You have learnT to perform basic computer operation with the CLI, like creating a file/directory, deleting a file/directory, moving, renaming, copying a file, navigating the computer system.
if you do learn one or refresh your memory of one or two thing do drop a like and share.
Connect with me on Linkedin. Thank you for your time. have a nice day.
This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by omoluabidotcom
omoluabidotcom | Sciencx (2022-12-25T10:43:12+00:00) Command Line Interface for Beginners. Retrieved from https://www.scien.cx/2022/12/25/command-line-interface-for-beginners/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.