To create file in linux is 'touch'
The 'touch' command in Linux is used to create an empty file or update the access and modification timestamps of an existing file. The basic syntax is:
touch [filename]
To write or edit file in linux 'vim' or 'nano' editor is used
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 check which commands you have run till now:
The 'history' command in Linux is used to display a list of previously executed commands in the current shell session
syntax: history
To remove a directory/ Folder
rm -r: Recursively removes files and directories. Use with caution, irreversible. rmdir: Removes empty directories.
syntax: rmdir [dir_name]
rm -r [dir_name]
To read content of text file.
The 'cat' command command is used to concatenate and display file content, used for viewing files.
cat [filename]
To Show only top three lines from the file.
The 'head' command is used to show only the top 3 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 find the differences between two files in Linux
syntax: diff file1 file2