241

I have:

  1. /home/user/my_static

  2. /home/user/static/

How do I rename my_static to static and remove static(2)?

0
355

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.

2
  • 6
    For experienced users this comment is superfluous, but it's worth noting this will also unlink (remove) the original static directory.
    – gertvdijk
    Apr 12 '13 at 18:27
  • 11
    Sometime you may want to back the file up, like a config file, use cp /home/file1 /home/file1.bak you will have 2 files.
    – wlraider70
    Apr 12 '13 at 18:46
20

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.

1
  • 11
    ? This is exactly the same as the since 4 years existing and accepted answer with 148 Upvotes ...
    – pLumo
    Jun 1 '17 at 6:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.