Using the Linux Rename Directory Function

Using the Linux Rename Directory Function
Page content

One of the most important qualities of any operating system is that we should be able to understand how to use it, and utilize it to our best advantage. By default, files and folders are assigned pre-determined or default titles, and these are fine for operating system-related data and processes – but what about files and folders that we might create ourselves?

Most operating systems will offer the facility to name new files that are created, just as new folders for storing them can be given custom names. For instance, knowing where a particular digital image is stored is made a lot easier if a custom name is assigned (“my great photo.jpg”, for instance) and a folder with a meaningful name (such as “my great photos are here”) rather than the default “photo.jpg” for the filename and “Pictures” for the directory name.

Linux distributions offer various tools for assigning and changing names for files and folders both in the GUI and the command line. We’ll use Ubuntu as an example distro for the sections below.

Creating and Renaming Files and Directories in the GUI

Ubuntu provides an excellent and simple method for creating and renaming files and directories in the GUI (also known as the graphical user interface) which is ideal for newcomers to the platform. This method is also quicker than opening the Terminal.

For instance, if you wanted to create a new directory within Pictures – perhaps to store images of the GIF file format – you could do this by opening Places > Pictures and right-clicking in an empty space in the directory window. Right-clicking opens the context menu, and this offers various functions depending on where it is used. In this situation you should see the Create Folder option which will create a new folder called “untitled folder”. You can rename this directory as needed by replacing the default name. If you miss-typed the name of the folder, simply right-click the icon and select Rename to assign the new name of “GIFs”.

Meanwhile, new files can be created in a very similar manner. Again using the right-click function to display the context menu, select Create Document > Empty File to create a blank file. You will immediately be given the opportunity to name the file, as well as assign a file extension; to create a blank GIF document, for instance, name the file “blank.GIF” and tap Enter to confirm the change. If you make a mistake here simply right-click the icon and use Rename.

Using the Terminal to Rename Files and Folders

While all of the above might seem ideal to newcomers to Linux Ubuntu, the Terminal method is just as simple.

Begin by opening the Terminal via Accessories > Applications and using cd to browse to the location where you wish to create a new directory; for instance, you would create a new directory in Pictures using the path:

cd Pictures

(Remember that Linux is case-sensitive, so you will need to capitalize the “P”.)

Creating a new directory is very simple and uses the make directory (mkdir) command; we would create a new folder called GIFs using this short command:

mkdir GIFs

Using the Terminal to Rename Files and Folders

If you notice that an error has occurred with the naming of the directory, you can use the move command (mv) to rename it:


Creating and renaming files is very similar. To create a new file in the Terminal, first use the cd function to open the GIF folder:

cd GIF

There are various ways of creating a new file in Linux Ubuntu, but if we are looking for a Terminal-based method that is comparable to the GUI method above, using the touch command allows us to create an empty file:

touch blanks.gif

Like directories, files can also be renamed using the move command:

mv blanks.gif blank.gif

Which Method is For You?

There is little that is complicated about renaming files or directories in Linux. Both the GUI and command line methods offer a simple and straightforward means of assigning new names, while the creation of new files and folders is kept equally simple.

Of course, each of these methods has its individual advantages and disadvantages; some might prefer the command line for the precision with which new directories and names can be assigned, while others might enjoy the ease of GUI method and the power of creating and renaming via the contextual menu available by right-clicking.

Ultimately, the way in which you use your Linux computer is entirely up to you, but make sure that you are familiar with the details of each method before you rule either out!


Author’s own experience.

Screenshots provided by author.