linux

Learn Linux Basic commands

Learn Basic Linux for beginners:

 

linux

What is Linux?
Linux is an open source operating system based on UNIX. It is mainly used as servers where applications and databases are hosted.

 

Assumption for audience  : Totally new to Linux

This topic will cover basic Linux command that can be used on day to day basis.

 

Lets start:

If you are using a Mac/linux laptop/OS, then you can just open a “terminal” window and can start executing commands. For windows machine, we need to install any linux utility like, “Git Bash” . After installing, just run it.

Here I am using windows machine, so I will demo using git bash

 

Basic commands :

 

pwd

This command will print the path of the folder you are working with. 

$ pwd
/c/Users

ls

This command will list all the files and folders present in the directory you are working with.

$ ls
'All Users'@ 'Default User'@ desktop.ini Tania/
Default/ defaultuser0/ Public/

Some other ls commands

ls -a : This will list all files and folders along with hidden files also.

ls –ltr : This will list the files by the order of creation date. Latest on the top.

 

cd

This command will get into a specific folder.  One can provide the full path of the different folder of relative path.

For example: In below case,  linux folder is within the c:/test folder and we can just use cd linux to get into that folder.

$ ls
file.xml
folder1 
linux/
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test
$ cd linux
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux

Use below command when we have to navigate to specific folder. Here we provide full path.

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ cd c:/test/log/
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/log

 

cd ..

This command is used to go back to the parent folder.

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ cd ..
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/

 

mkdir

This command is used to create a new directory in the folder

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ mkdir folderone
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls
folderone/

rmdir

This command is used to delete a directory in the folder

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ rm folderone
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls

touch

This command is used to create a new file

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ touch a.txt
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls
a.txt

 

cp

This command is used to copy a file from one location to another. It takes two parameters: first one is source and other one is destination. So it will be cp sourcefilepath destinationfilepath

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls
a.txt
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ cp a.txt c:/test/
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ cd c:/test
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test
$ ls
a.txt

mv

This command is used to rename  a file . It takes two parameters: curentName and new name

So it will be mv currentName  newname

 

Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls
a.txt
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ mv a.txt b.txt
Tania@LAPTOP-EB5SRC2O MINGW64 /c/test/linux
$ ls
b.txt

 

Leave a Comment

Your email address will not be published. Required fields are marked *