Getting started with the command line
The command line is a very important tool used by software developers.
In the field of software development; the command line forms part of the development process and so its very important for you to know some of the simple basic commands to start with as a developer.
The command line is a tool for interacting with computers by using commands.
First lets see how humans interact with computers before we touch on the command line basics
Human Computer Interaction
There is a way in which human being communicate and interact with computers;
through clicking of a menu using a mouse and the keying in of digits,letters and characters in the keyboard.
All these processes are called events,
through this events the computer gets an instruction to perform a certain task and thereby responding according to the instruction given
For example
- when you click the file menu in your computer, the computer responds by opening the file menu.
- Typing a word in the search box the computer responds by navigating you to the word.
- when you click on shut down button the computer responds by shutting down
In our case here the mouse and the keyboard is used to navigate through the graphical user interface
what is a graphical user interface?
In a computer , the graphical user interface is user interface through which users interact with system.
The objects in the Graphical user interface include:
- arrows
- icons
- pictures
- buttons
- tabs
- menu bars
Examples
common examples of graphical user interface include
- Microsoft Windows
- macOS
- Ubuntu Unity
But, do you know all the above are also done by using simple text based procedures typed in the command line,
there is no need of using the graphical interface,you simply need to type a simple command for execution
The command line
Now lets get back to our topic
In this article today we are going to cover the command line basics,
what is the command line?
The command line forms an interface by which programs interact through commands.
In the first section above, we saw how one can interact with the programs in the computer through the graphical user interface aided tools such as mouse,
but in here we are using commands to interact with the programs in the computer.
The interface for writing the commands is the command line interface,
found inside the computer having a procedure of opening it.
Things you need to have for you to use the command line
You need to have these two things at hand for you to start using the command line:
- command – know the commands you are going to use
- command line interface – for writing the commands
How do i open the command line interface?
- Linux
- On linux – press (CTRT+ALT+T)
2. Mac
- On Mac open the app folder then find terminal
- Then On windows – (Press the windows logo Key + R then type cmd then enter)
Once you open the command line interface , the interface will be there just waiting or you to type the commands and communicate with the computer
Commands
A Command instructs a computer to perform a specific task without using the graphical interface.
Commands are just simple texts directing the computer what to do.
They simply direct the computer on what to do and what not to do at a particular time.
For what we we are going to cover today;One does not require a special skill to use a command in the computer, since the texts(command),
which are understandable for a communication between the user and the computer.
One only needs to understand the command he/she is typing at a particular moment
your work is to open the command line interface and type in the command and then leave the command to be executed
After execution there will be an output either in the command line interface or the computer
Uses of the command line:
- in making a directory
- creating a new text file
- in deleting a text file
- Navigate through your files and folders in your computer
advantages of using the command line over the graphical user interface
- its easy to use since it is the combination of texts written in the command line interface for execution by the computer
- it is faster as compared to the graphical user interface
- it allows for multitasking
In the software engineering world you will be using command in most cases
How do programmers use the command line?
- to install packages – instead of installing a package directly from the official website one can just install it via the command line which will be executed e.g npm install express
- used to remove packages – this can be done using the command line instead of doing it manually e.g npm uninstall express
- to check the different versions of the packages e.g npm list
- used to upgrade a package e.g npm update express
- to degrade a package e.g npm install express3.xyz
- for remote project collaboration e.g git
- to check on programming language version e.g node -v
Some of the terms here may seem to be weird but don’t worry about them,
these are just but some of the tasks a programmer does with the command line interface
For those getting into programming here are just but some of the commands you should jump start off your mind with the command line basics,
these are easier to memorize and use
Commands
The commands to get started with include:
1 cd –
Used to change directories,
to use just type cd followed by the name of your directory
in my case below i want to change my directory to desktop ill type cd desktop, in using this make sure you type the correct name and spelling.
C:\Users\LENOVO>cd desktop
C:\Users\LENOVO\Desktop>
2. pwd –
Used to print the working directory, just type pwd in my case its desktop see below
C:\Users\LENOVO\Desktop>pwd
/c/Users/LENOVO/Desktop
3. ls –
Used to display the content of the your working directory ,
just type ls ,
the example below shows the content found in my directory called git_test
C:\Users\LENOVO\Desktop\git_test\git_test>ls
README.md hello_world.txt
4. mkdir –
Used to create a new directory type mkdir then the name of the directory eg mkdir test
C:\Users\LENOVO\Desktop\git_test\git_test>mkdir test //makedirectory test
C:\Users\LENOVO\Desktop\git_test\git_test>ls //type ls to show the content
README.md hello_world.txt test //test added
5. touch –
Used to create a new file , type touch followed by the name of your file , e.g touch index.html
C:\Users\LENOVO\Desktop\git_test\git_test>touch index.html //creates file index.html
C:\Users\LENOVO\Desktop\git_test\git_test>ls //show content
README.md hello_world.txt index.html test //index.html added
6 . cd ..
Navigates you back to the previous directory
C:\Users\LENOVO\Desktop\git_test\git_test>cd .. //goes back to git_test
C:\Users\LENOVO\Desktop\git_test>cd .. //goes back to desktop
C:\Users\LENOVO\Desktop>
Now having known the command line basics keep on practicing with other commands.
Check out this guide on Linux Commands