SAGARFIVE

Linux File Commands

1

Creating File without data

Single file : touch <filename>.<extension>

 Multiple files : touch <file1> <file2> <file3>…

2

Creating file with minimal data

echo “Hii ! , This is Data” > <filename2>.<extension>

3

Adding extra data to existing file

echo “Hii ! , This is Extra Data” >> <filename2>.<extension>

4

To Replace the existing data :

echo “Hii ! , This is Replacing Data”> <filename2>.<extension>

5

Move file /cut

mv <filename> <folder-location/directory>

6

Copy file

cp <filename> <location where you need to copy>

7

Rename file

mv <filename> <newfilename>

8

Remove file

rm <filename>

9

Find file

find <directory> -name <name-of-file>

10

Locate file (search with keyword without directory)

i) update db : sudo updatedb && locate -e bench-repo

ii) locate <keyword/filename/foldername>

11

File edit using VI Editor (existing file)

vi <filename+extension if its having>

12

Basic VI Editor Keystrokes :

To Enter into Input mode / to add data/txt : type I

To Delete backward : backspace

To add next line : enter

To Save file : Click ESC , and type wq! Enter (means write quite)