Basics of CLI (Command Line Interface)
April 03, 2021
• 2 min read
CLI is an essentail thing that should know by every developer. It helps to run/execute commands which are provided by the operating system.
Where to run the commands
- For Linux: Your default terminal
- For windows users: You can use WSL or Git Bash to execute the basic commands, download the git for all platforms https://git-scm.com/downloads
- For Mac Users: Almost all of the commands you use in the macOS terminal are extremely similar to the ones Linux uses.
Hello to CLI
# hello world echo hello world # know who you are whoami
This command give you a list of all files that a folder contains.
ls accepts many options,
-l is one of them, it gives much more details of the files.
It is used to change directory/folder where
cd .. indicates the parent directory.
# to move to hello folder cd hello # to back to the previous folder cd ..
You can create folder/directory with this command
# to create a folder name react mkdir react ## to crate mutiple folders mkdir react nodeJS ## too create nested folders (react folder inside project folder) use the flag -p mdkir -p project/react
To remove a directory we use rmdir. But the condition is the folder must be empty.
# to remove react folder rmdir react
To remove files and folder we use this command with -rf flag. Which means forcefully and recursively.
# this will remove all files and folders of the project folder rm -rf project
This commmand is for creating files
# to create a txt file touch secret.txt
For moving and renaming files and folders we use this command.
mkdir react projects # to move the react folder into the projects folder mv react projects
# to rename a file touch secret.txt mv secret.text open.text # this will rename the file secret to open
These are the most basic commands of Command-Line that every developer should know. I hope you may find this helpful.