How to rename a file in Terminal?

Use:

mv "old location" "new location"

mv /home/user/my_static /home/user/static

That command is used for moving and renaming files and directories.


A simple way to rename files and folders is with the mv command (shortened from “move”). Its primary purpose is moving files and folders, but it can also rename them since the act of renaming a file is interpreted by the filesystem as moving it from one name to another.

The syntax is:

mv (option) file1.ext file2.ext

where “file1.ext” is the “old” name of the file, and “file2.ext” the new name.

And to remove, you can use the command:

rm -f filename

Hope that helped.

Tags:

Files