DEV Community

Cover image for Learning Basic of Command Line
AmeyaKulkarni2001
AmeyaKulkarni2001

Posted on

Learning Basic of Command Line

What is a Command Line?

It's provides a way of interacting with your computer, without the need of a GUI like file explorer.

The command line varies for Windows and Mac, so for explaining, I will use a common platform called Hyper Terminal.

Installation MacOS

  • Download Hyper from the above link and Unzip it.
  • Move it to application folder.

Installation Windows

  • Download Hyper from the above link
  • Run setup.exe
  • Install GitBash, to use Bash.
  • While installing Git Bash make sure you have Git Bash checked in Windows Explore Integration options, and keep all default options, then restart your computer.
  • Now, we have to manage the Hyper Configurations, for that please go to this site
  • Copy the details. Alt Text
  • Now after opening preferences, replace what is in the text file with what you copied in the git gist, now save it.
  • Reopen hyper.
  • Now to check type the following in your hyper terminal
echo $SHELL
Enter fullscreen mode Exit fullscreen mode
  • It should return /bin/bash if it is installed correctly.

What is Bash, Understanding Command Line

Kernel is the base of the computer system on which everything operates(In Layman Language).

Shell is like a cover or shell(pun 😆), which shields or covers the kernel from the user. Shell, provides a interface between user and kernel. It provides two types of interface, GUI which is the File Explorer and Terminal or Command Line.

Bash is a type of shell. BASH = Bourne Again Shell after Mr. Bourne. Bash Shell is a CLI ( Command Line Interpreter) for the Unix System. A lot of systems run on UNIX such as Linux, a lot of servers(such as a node development server), and even MacOS. But, windows uses DOS instead of Bash. This is the reason we aren't directly using the command line provided by windows.

Command Line provides greater control over your computer hardware, it is also easier and faster. We can also view hidden folders with the help of command line.

Command Line Techniques

List

  • It displays all the files at your given location
$ls
Enter fullscreen mode Exit fullscreen mode

For eg- Alt Text

The ~ sign shows where your current location is.

Change Directory

  • It helps in changing your current location, to one location down
$ls
(Shows whrere you can go) 

$cd <where to go>

Enter fullscreen mode Exit fullscreen mode

For eg-
Alt Text

  • We can also go a level above by using
$ cd ..
Enter fullscreen mode Exit fullscreen mode
  • We can also specify the full path of where to go
$cd <Superparent>/<Parent>/<Child>
Enter fullscreen mode Exit fullscreen mode

For eg-Alt Text

Make Directory

  • It is used to make a new directory or folder at the desired location
$mkdir <Directory Name>
Enter fullscreen mode Exit fullscreen mode

For eg- Alt Text

Creating A File

  • It is used to make a file.
$Touch Text.txt
Enter fullscreen mode Exit fullscreen mode

Opening a file

  • For Windows
$start Text.txt
Enter fullscreen mode Exit fullscreen mode
  • For MacOS
$open Text.txt
Enter fullscreen mode Exit fullscreen mode

Delete Files and Folders(Please Use These Commands wisely, as it can delete important files)

  • For Files
$rm Text.txt
$rm * (Removes all the files of the folder)
Enter fullscreen mode Exit fullscreen mode
  • For Folders
$rm -r AllDocs/
Enter fullscreen mode Exit fullscreen mode

Clear Previous Lines

$clear
Enter fullscreen mode Exit fullscreen mode

Exiting The Terminal

$exit
   OR
$logout
Enter fullscreen mode Exit fullscreen mode

Learn More?

If you want to learn more about command line this is what I recommend-

https://www.learnenough.com/command-line-tutorial

Top comments (0)