Each operating system implies interaction with files. Often the user has to deal with the need to rename a file. At first glance, nothing is simpler, but there are several ways to perform the presented operation in an OS based on the Linux kernel. In this article we will talk about three of these.
Method 1: File Manager
Renaming a Linux file to an inexperienced user will be easier in the graphical file manager . This will greatly facilitate the task, since the user can visually control the process. In addition, it is ideal for those people who have just switched from Windows to Linux, since the technology is almost identical.
So, to rename the Linux file in the file manager, you need:
- 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 required file is located.
- Right-click on the file (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 no different from the same operation in Windows. The main difference is in the graphical interface and in the location of some elements.
Method 2: Console File Manager
You can rename a Linux file in several ways - this was mentioned above. Now the next one will be sorted out. If you use the server version of the system, then most likely you have installed the console file manager MC for yourself a long time ago, but you can safely use this program in the desktop Linux using the Terminal for these purposes. Now let's take a look at how to rename a file in MC in Linux.
So, the first thing you need to do is enter the file manager itself. It is done using the executed "mc" command. If this program is not installed in the system, then you can install using the command entered in the "Terminal":
After opening the program in the "Terminal" a list of all the directories of the home directory will be displayed. At this point you need to find the file you need. By the way, if you use the "Terminal" to start the MC, that is, the ability to navigate through the directories with the mouse by double-clicking on the left button. If you have a server "Linux", you need to use the arrows on the keyboard for navigation and the Enter key to jump.
When the desired file is in front of your eyes, you need to select it and press the F6 key. You will see a "window", 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. By default, the home directory is selected.
Method 3: Linux Console
Finally, we’ll show you how to rename a file in the Linux console (a local equivalent to the Command Prompt in Windows).
We will deal with an example. Suppose, in the folder “Documents”, which is in the home directory, there is a file called “Old document”, our task is to rename it to “New document”. For this:
- Open the console by writing "Terminal" in the search.
- Browse to the desired folder using the cd command. In our case, execute the command: "cd / home / Username / Documents".
- Rename the file using the mv command. It is recommended that you also use the -v option to display the operation log. In our example, the command will look like this: "mv -v" Old document "" New document ".
This was the third way to rename a Linux file. By the way, after all the actions done, the “Terminal” can be closed.