To rename a file mv command is used.
Syn: $ mv [old name] [new name]
If the new name already existed the old name will be renamed to new name and new name data will be overridden by old name data.
Ex: $ mv file1 filex
Here also to get confirmation we can use –i option.
Removing a file
To delete a file rm command is used.
Syn: $ rm [file name]
Ex: $ rm file1
To check the differences between the data of two files cmp command is used. But it displays only the first difference.
Syn: $ cmp file1 file2
To display all the differences between the files diff command is used.
Syn: $ diff file1 file2
Note: Comparison between the files of different users is possible only when the present working user has the access permission on the other user.
Removing multiple files
To remove multiple files also rm command is used.
Syn: $ rm file1 file2 file3 file4 …..
Here all the files which are entered will be deleted. If we want confirmation from user to delete the files –i option is used Syn: $ rm –i file1 file2 file3 file4 ….
Ex: $ rm –i file1 file2 file3 file4
Remove file1 y/n? y
Remove file1 y/n? n
Remove file1 y/n?
Remove file1 y/n? x
Here only file1 is deleted. Other than option y if you type any character the file will not be deleted.
Knowing file types
To know the type of the file, file command is used.
Syn: $ file [file name]
It displays the file type like exe, ascii, ZIP file etc.,
Ex: $ file file1
ASCII text
$ file file.zip
ZIP archive