It is usually bad to rename items that reside directly in /
or directly in any of its subfolders (like /usr
). In fact, you should avoid renaming anything outside your home directory unless you are sure you need to do so and that you're doing it correctly. Otherwise, you might rename something critical to the functioning of your Ubuntu system, causing it to stop working (or stop working properly).
If you find yourself asking something like the question above, you should consider posting a new question, where you provide more information about what you want to accomplish, or add details if you've already asked your question.
In the Terminal
To rename a file or folder in the Terminal, use the mv
command (the same command used to move a file or folder from one place to another on the same partition):
mv old-name new-name
If the file or folder resides in a folder where you do not have write permissions (which is often the case when you are not its owner), then you must run run this command as root
with sudo
:
sudo mv old-name new-name
(Or you could use sudo -u username mv old-name new-name
to perform the renaming operation as another non-root
user, if you prefer. Also, please note that if you have write permissions on a directory you don't own, but its sticky bit is set, you won't be able to rename files inside it that are not owned by you, without using sudo
.)
In Nautilus
You can run the file manager, Nautilus, as root
by pressing Alt+F2 and running the command gksu nautilus
. This will let you rename files and folders anywhere and do all sorts of other powerful and dangerous things.
Be careful, and remember that any programs you launch (like by opening documents) from a root
Nautilus window will also run as root
, and make sure to close the window when you're done so you don't later confuse it with a regular, safer Nautilus window.
But please do not rename stuff outside your home directory, unless you really, really know what you are doing. It will probably break your Ubuntu system badly. And it will probably not accomplish whatever you are trying to achieve.
Thanks to richard for helping to clarify the conditions under which a user can rename an item without a Permission denied
error.