Linux Basic Commands

Linux Basic Commands

  1. To create a file in Linux :

'touch' command in Linux is used to create an empty file .

The basic syntax is :

touch [filename]

  1. To view or edit file in Linux :

vim or touch editors are used to view or edit the content of file .

The basic syntax is :

vim[filename]

a. VIM :

  1. Create or Edit a File: vim [filename]

  2. Type or edit content. // click "i" to enter in insert mode of file

  3. Save: Esc, :w, Enter.

  4. Exit: Esc, :q, Enter. (To save and exit: Esc, :wq, Enter.)

b. Nano :

  1. Create or Edit a File: nano [filename]

  2. Type or edit content.

  3. To Save: Ctrl + O, Enter.

  4. Exit: Ctrl + X.

  1. To view what's written in a file :

cat command is used to view content of a file

The basic syntax is :

cat [filename]

  1. To change the access permissions of files :

chmod is used to change the access permissions of file

The basic syntax is :

chmod 777 [filename]

  1. To check which commands you have run till now :

History command is used to check commands that have run till now .

  1. To create a directory/ Folder :

mkdir command is used to create empty directory/folder

  1. To remove a directory/ Folder :

rm -r : Recursively removes files and directories

rmdir : Removes empty directories.

  1. To Show only top three lines from the file :

The 'head' command is used to show only the top three lines of a Linux file

syntax: head -n 3 [filename]

  1. To Show only bottom three lines from the file :

The 'tail' command is used to show only the bottom three lines of a Linux file

syntax: tail -n 3 [filename]

  1. To find difference in 2 files of linux :

    The 'diff' command is used to show differences between two files in linux .

    syntax: diff file1 file2