Some Basic Shell commands

Before we dive into Git commands, it would be better for us to become familiar with some of the basic shell commands. Here, I will be presenting some of the basic shell commands using Git Bash.

If you have not installed Git in your PC yet, you can visit the link provided below for complete guidance about the installation of Git.

Basic Shell commands for directory management

ls

‘ls’ command is used to list files and directories.

Image for post
Image for post
‘ls’ command displays all the files present in the current directory
Image for post
Image for post
‘ls -l’ command is used to show folders in table format
Image for post
Image for post
‘ls -la’ command is used to show all the files and folders, including hidden files of the directory

cd

‘cd’ command is used to change directory.

Image for post
Image for post
‘cd’ command is used in order to change the directory
Image for post
Image for post
‘cd ..’ command is used to move back to parent directory. Here, ‘..’ is used as alias of the parent directory.

mkdir

‘mkdir’ command is used to make a directory.

Image for post
Image for post

pwd

‘pwd’ command is used to represent the path for your current directory.

Image for post
Image for post

start

‘start’ command in Windows is used to open a file or directory.

Image for post
Image for post
‘start .’ is used to open file or directory. Here, ‘.’ represents alias of the current directory.

Basic Shell commands for file management

clear

‘clear’ command is used to clear terminal.

Image for post
Image for post
In the above image, clear command is being demonstrated.
Image for post
Image for post
Above image represents the Terminal after ‘clear’ command is executed.

— help

‘ — help’ command is used to display help file of a particular command.

Image for post
Image for post
Usage of ‘ — help’ command.

touch

‘touch’ command is used to create a new file

Image for post
Image for post
Demonstration of ‘touch’ command for creating a .txt file

echo

‘echo’ command is used to print certain values in terminal.

Image for post
Image for post
‘echo’ command being used for printing a string message as Hello everyone.

>

‘>’ is used to write to a file

Image for post
Image for post
Here, in the above image ‘>’ sign is being used in order to write string content to the file named as anotherFile.txt

cat

‘cat’ command is given in order to list the contents of the file.

Image for post
Image for post
In the above image, ‘cat’ command is being to list the contents of the file.

>>

‘>>’ is used to append into a file.

Image for post
Image for post
In the above image, ‘>>’ command is being used to append into the file named anotherFile.txt and ‘cat’ command is being used to view the contents present in the file.

nano

‘nano’ command is used to edit file.

Image for post
Image for post
In the above image, we are using nano command to edit ‘trial.txt’ file.
Image for post
Image for post
After nano command is executed, here in GNU we can add in lines of text as per our requirement.
Image for post
Image for post
Now, to save the file you can press ‘ctrl+s’ in your keyboard and to exit GNU, you can press ‘ctrl+x’ in your keyboard.
Image for post
Image for post
Now, we can use ‘cat’ command to view our files.

rm

‘rm’ command can be used in order to remove files.

Image for post
Image for post
In the above image, ‘rm’ command is being used to remove the file named ‘anotherFile.txt’.
Image for post
Image for post
In the above image, ‘rm -rf folderToRemove’ is being used to remove folder. ‘rm -rf’ deletes folder along with all the files present inside it.
Image for post
Image for post
The above image represents the user manual of ‘rm’ command. Here, from the above image we can understand the purpose of ‘-rf’ which is present in ‘rm’ command.

So, all the mentioned commands are some Basic Shell Commands that you need to know. Besides, if you are new to Git, you can read the blog provided below and get started with Git.

Written by

Cloud Computing | Data Science | Mobile Application Development | Artificial Intelligence | Python Programming | Soft Skills | Many more…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store