Renaming files and directories
Table of Contents
Renaming files and folders
How to rename a file from terminal in Linux?
Using vifm
vifm (a tool that works with vim shortcuts) is an alternative to this. Using vifm, we can change the name of a file or folder using `cw` (change word).
Other options:
In order to rename a file in Linux you can use either of two approaches
Copy the existing file with a new name and delete the old file
- Create a copy of the existing file with the new desired name and then delete the old file.
This creates a copy of the same file with a new name in the same location.$ cp oldfile newfile
This will delete the old file keeping the newfile intact.$ rm oldfil
Using mv command
-
Rename a file by moving it with the mv command.
Rename by moving
$mv old-file-name new-file-name
This just moves the old file, to a new name.
-
Rename a directory on Linux, use the
mv
command and specify the directory to be renamed as well as the destination for your directory.mv <source_directory> <target_directory>