Web
Analytics
Linux Basic Commands | Angular | ASP.NET Tutorials

For Consultation : +91 9887575540

Stay Connected :

Linux Basic Commands

  1. To Check presenet working directory

pwd

 

  1. To see the content of a directory

Syntax: ls <option> <arguement>

Options:

-l =Long list including Attributes

-a= All files and directories including hidden

-d= To check particular file or directory is present

-R= recursively , to see the contents in a tree structure

 

 

  1. To see Tree structure of nested directories

 

ls -R/opt

  1. To see a list of all file or directories starting with a particular letter

ls i*

5.To see the attributes of a file and directory

ls -ld student.txt

  1. Creating file and adding data into file

cat <option> <arguement>

 

6.1 To create a file with some data

cat > salesreport

This file contains the sales report of the data

(Now press Ctrl+D) to save the Data

6.2 To Read Contents of a file

cat salesreport

//This will show Output

6.3 To append Contents to a file

cat >> salesreport

//Pass some Contents

To see Output

cat salesreport

//Show Added contents

6.4 To merge contents of two files into a third  new file

 

cat salesreport marketreport >> completereport

//File completereport will be created and merged contents will be added

6.5 To create a empty file with touch command

Syntax : touch <filename>

//Creating a single empty file using touch command

touch file1

To check if the file has been created

ls -ld file1

6.6 To create multiple files using touch command

touch file1 file2 file3

//To see files are created or not

ls -ld file*

6.7 To change timestamp(modification date and time) of a file or directory

Syntax: touch <option> <arguement> <file or directory Name>

6.7.1 To change the current date and Time

touch file1

//To check timestamp has been changed or not

ls -ld file1

6.7.2 To change to a different date and time

Syntax: touch -t YYYYMMDDhhmm <file or directory Name>

 

Example : touch -t 201706120725 file1

//To seemodification

ls -ld file1

  1. Creating Directory

Syntax: mkdir<option><directory Name>

7.1 Create a   single directory

mkdir yogeshsharma

7.2 Create multiple directories

mkdir yogeshsharma yogeshsharma1 yogeshsharma2

//To see all directory Name

ls -d yogesh* //See only directory name start with yogesh

7.3 To create nested directories(sub Directories in directory)

mkdir -p yoge1/yoge2/yoge3

//To check nested directories has been created

ls -R yoge1

//If file is exists into another directory then specify complete path

7.4 Directory Navigation

Syntax: cd <arguement>

//To go into a directory

cd file1

//To back one lavel , type cd press spacebar and then dot dot

cd ..

7.5 To Go back two lavels

cd ../..

7.6 To go previous working directory

cd –

7.7 To go to current logged in user’s home directory

cd

pwd

  1. Copying file and directory

Syntax: cp <option> <source> <destination>

 

8.1 To copy a file

cp completereport yogesh1

8.2 To copy a directory

Syntax: cp -r directory /destination

  1. Moving file and directories

Syntax: mv <option> <source> <destination>

mv datafor.txt yogesh1

9.1 Renaming files and directories

Syntax: mv <oldfilename> <newfilename>

 

mv marketreport mark

 

  1. Deleting an empty directory

Syntax: rmdir <directory Name>

10.1 Deleting an file or directory

Syntax: rm <option> <file or directory Name>

options:

-r = recursive

-f = forcefully

 

Example : rm mark

10.2 To delete a file forcefully

rm -f marketreport

10.3 To delete a directory

rm -rf yogesh3

  1. To view System Date and Time

date

11.1: To change system date and Time

date -s “MM/DD/YYYY hh:mm:ss”

11.2 To view Calender

cal

11.3 To see past current and next month

cal -3

11.4 To see Current year Calender

cal -y

11.5 To see december month 2012 calender

cal 12 2012

11.6 To see full year calender of month 2009

cal 2009

  1. To view help of command

Syntax: man <command name>

Example: man mkdir