You are here
Home > Redhat > linux basic commands

linux basic commands

Directory Related Commands

 
  Command

 
  Syntax

 
  Example

 
  Description

 
  Mkdir

 
  Mkdir <Directory Name>

  Mkdir sample

  To create a Directory

  Mv

  Mv <ExistDir> <NewDir>

  Mv sample backup

  To rename a Directory

 
  Cd

  Cd <Directory Name>

 
  Cd backup

 
  To change a Directory

 
  Cd ..

  Cd ..

  Cd ..

  To move into Parent Dir

 
  Cd

  Cd <Enter Key>

 
  Cd <Enter Key>

 
  To move into home Dir

 
  Cd

 

 

  To move into root Dir

 
  Cd –

 

 

 

 
  Pwd

 

 

  To print working Directory

 
  Rmdir

  Rmdir <directory Name>

  Rmdir backup

 
  To remove a Directory

 

Note :

All commands are case sensitive. All commands are should be in small character.

To remove a Directory follow the given below conditions

    1. Directory should be empty

    2. Move into the parent directory ie cd ..

    3. Then use rmdir <Directory Name>

File related commands

 

 
  Command

 
  Syntax

  Example

  Description

  Touch

  Touch <File name>

  Touch workfile

  To create a Empty file

  Vi

  Vi <File name>

  Vi workfile

  To create new file & edit

  Cp

 
  Cp <Source File> <Dest File>

  Cp workfile backfile

  To create duplicate file

  Mv

  Mp <Source File> <Dest File>

  Mp workfile sampletxt

  To rename a file

  Rm

  Rm <File name>

  Rm sampletxt

  To remove a file

 

 

 

  It also remove folder

  Ls

 

 

  It lists all files and folders

  Ls –l

 

 

  It lists with all details

  Ls –al

 

 

  It lists all hidden files

sa
Vi commands

 

  <Esc> + i

  Insert mode to insert the contents

  <Esc> + a

  To append the the contents

  <Esc> + A

  To append at the end of line

 
  <Esc> + o

  To insert newline above the line

  <Esc> + O

 
  To insert newline below the line

  <Esc> + $

  To move the cursor end of the line

 
  <Esc> + : + w

  To safe and continue

  <Esc> + : + wq!

  To safe and exit the file

  <Esc> + : + q!

  To quit without save the file

  <Esc> + x

  To delete a character

  <Esc> + dd

  To delete a line

 
  <Esc> + 5dd

  To delete 5 lines

  <Esc> + /

  To find a string

  <Esc> + n

 
  To find the string continuously

  <Esc> + : + 5

  To move the cursor on 5th line

 
  <Esc> + y

 
  To copy the content into the buffer

 
  <Esc> + p

 
  To paste the content

Leave a Reply

Top