A linux systemunix relabel Command Guide for Beginners (with Examples)

If you perform with information on the control range in A linux systemunix, renaming information is one of the most prevalent projects you may end up associated with. We’ve already mentioned the mv command that allows you to do this. And here, in this guide, we will talk about another such device, known as relabel.

But before we begin with that, it’s value referring to that all illustrations in this content have been examined on an Ie8 18.04 LTS device.

Linux relabel command

As suggested by its name, the rename control in A linux systemunix allows you to relabel information. Following is its syntax:

rename [options] appearance alternative computer file...

And here’s how the tool’s man web page describes it:

rename will relabel the specified information by changing the first incident of appearance in their name by alternative.

Note that if you don’t have the relabel control set up, you can get it using the following command:

sudo apt set up rename

Following are some Q&A-styled illustrations that should provide you with a better concept on how the relabel control performs.

Q1. How to use relabel command?

Basic utilization isn’t exactly simple, I must say, but it’s not obscure. Let’s say you have a computer file known as ‘test.txt’ and you want to relabel it to ‘new.txt’. Then here’s how you use the relabel control to do this.

rename 's/test/new/' analyze.txt

By standard, the relabel control just renames the computer file which is approved as feedback, even if it’s a representational weblink. However, if you want the device to not relabel representational hyperlinks, but act on their objectives instead, then use the -s control range choice.

So if symlink.txt is a representational weblink that indicates primary.txt, then the following control will ensure the relabel function happens for primary.txt:

rename -s 's/root/new/' symlink.txt

Q3. How to create a dry run with rename?

Suppose you only want to see the ultimate modify that’ll occur with a relabel control, without actually holding it out, then use the -n control range choice. For example, the following command:

rename -n 's/new/test/' new.txt

produced the following output:

rename(new.txt, analyze.txt)

but did not actually relabel new.txt to evaluate.txt.

Q4. How relabel manages overwriting of files?

By standard, the relabel control does not execute function if it requires overwriting an current computer file. However, you can power the device to overwrite using the -f control range choice.

For example, the following command:

rename 's/new/test/' new.txt

produced the following output:

new.txt not renamed: analyze.txt already exists

But when the -f control was used:

rename -f 's/new/test/' new.txt

The function finished efficiently and analyze.txt got over-written.


The relabel control does not provide too many choices, and we’ve already mentioned some of the primary ones here. After you’re done these, visit the tool’s man page to discover more about it.

Post Author: Hack3rN3ws

Leave a Reply

Your email address will not be published. Required fields are marked *