267

I have:

  1. /home/user/my_static

  2. /home/user/static/

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

0

2 Answers 2

390

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, 2013 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, 2013 at 18:46
24

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.

0

Not the answer you're looking for? Browse other questions tagged .