Each operating system implies interaction with files. Often the user has to face the need to rename a file. At first glance, there is nothing easier, but in the OS based on the Linux kernel, there are several ways to do the presented operation. In this article, we will talk about three of them.
Method 1: File Manager
Renaming a Linux file for an inexperienced user will be easier with a GUI file manager. This will greatly facilitate the task, as the user will be able to visually control the process. It's also ideal for those people who have just switched from Windows to Linux, as the technology is almost identical.
So, to rename a Linux file in the file manager, you need to:
- Launch the file manager itself (in this case, Nautilus, which is distributed in distributions with the Gnome graphical environment).
- Go to the folder where the requiredfile.
- Click on the file with the right mouse button (RMB).
- In the context menu, select "Rename".
- Enter a new name.
- Press the Enter key.
As mentioned above, renaming a Linux file in the file manager of the system is almost the same as the same operation in Windows. The main difference lies in the graphical interface and in the arrangement of some elements.
Method 2: Console File Manager
There are several ways to rename a Linux file, as discussed above. Now the next one will be dismantled. If you use the server version of the system, then most likely you have already installed the MC console file manager for yourself, however, this program can also be easily used in the Linux desktop using the Terminal for these purposes. Now let's understand in detail how to rename a file in MC in Linux.
So, first of all, you need to enter the file manager itself. It is done with the help of the executed "mc" command. If this program is not installed in the system, then you can install it using the command entered in the "Terminal":
|sudo apt install mc|
After opening the program in the "Terminal" will show a list of all directories in the home directory. At this stage, you need to find the desired file. By the way, if you use the "Terminal" to launch MC, then there is the ability to gothrough directories with the mouse, double-clicking on the desired one with the left button. If you have a Linux server, you need to use the arrows on the keyboard to navigate and the Enter key to navigate.
When you have the desired file in front of your eyes, you need to select it and press the F6 key. A "window" will appear in front of you, if you can call it that, in which you need to enter a new file name in the second field. Please note that you must first specify the path where the file will be moved. The home directory is selected by default.
Method 3: Linux Console
Finally, we will look at how to rename a file in the Linux console (the local analogue of the "Command line" in Windows).
We will understand with an example. Let's say that in the "Documents" folder, which is located in the home directory, there is a file called "Old Document", our task is to rename it to "New Document". To do this:
- Open the console by searching for "Terminal".
- Go to the desired folder using the cd command. In our case, you need to run the command: "cd /home/Username/Documents".
- Rename the file with the mv command. It is also recommended to use the -v option to display the operation log. In our example, the command would look like this: "mv -v "Old Document" "New Document".
This was the third way to rename a Linux file. By the way, afterall done actions "Terminal" can be closed.