- To create a file in Linux :
'touch' command in Linux is used to create an empty file .
The basic syntax is :
touch [filename]
- 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 :
Create or Edit a File: vim [filename]
Type or edit content. // click "i" to enter in insert mode of file
Save:
Esc
,:w
, Enter.Exit:
Esc
,:q
, Enter. (To save and exit:Esc
,:wq
, Enter.)
b. Nano :
Create or Edit a File: nano [filename]
Type or edit content.
To Save: Ctrl + O, Enter.
Exit: Ctrl + X.
- To view what's written in a file :
cat command is used to view content of a file
The basic syntax is :
cat [filename]
- To change the access permissions of files :
chmod is used to change the access permissions of file
The basic syntax is :
chmod 777 [filename]
- To check which commands you have run till now :
History command is used to check commands that have run till now .
- To create a directory/ Folder :
mkdir command is used to create empty directory/folder
- To remove a directory/ Folder :
rm -r : Recursively removes files and directories
rmdir : Removes empty directories.
- 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]
- 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]
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