In your quest to migrate to the Linux operating system, you’ve found the command line interface a must-know skill. Fortunately, Jack Wallen is here to help you with the basics.
I’m going to help you learn a bit more about Linux. If you’re new to the operating system, there are quite a few fundamental tasks you’re going to need to know how to do. One such task is renaming files and folders.
You might think there’s a handy rename command built into the system. There is, but it’s not what you assume. Instead of renaming a file or folder, you move it from one name to another, with the mv command. This task couldn’t be any easier.
SEE: Linux: The 7 best distributions for new users (free PDF) (TechRepublic)
For instance, if you have a file named script.sh and you want to rename it backup.sh. For that you’d issue the command:
mv script.sh backup.sh
The first file name is the original and the second is the new name–simple. For folders, it’s the same thing. If you have a folder named “project” and you want to rename it “python_projects.” For that, you’d issue the command:
mv projects python_projects
One nice thing about the mv command (besides its simplicity) is that it does retain the original directory attributes, so you don’t have to worry about reassigning things like permissions and ownership. Even if you issue the command with sudo privileges, it won’t shift the directory ownership to root.
Another handy feature is that you don’t have to leave the file in the same directory. If you have script.sh in your home directory and you want to rename it to “backup.sh” and move it to /usr/local/bin/ at the same time. Once again, that’s as simple as:
sudo mv script.sh /usr/local/bin/backup.sh
The reason why you have to use sudo is because the /usr/local/bin directory is owned by root, so your standard user won’t have permission to move the file into the directory.
And that’s all there is to renaming files and folders from the Linux command line. Enjoy that new skill.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
Also see

Image: Jack Wallen