unlink: practical examples of this command for Linux

unlink

El unlink command is quite an interesting tool for some tasks. Although it is installed by default in your GNU / Linux distro, it is very likely that you did not know it until now. The reason is that maybe it is not as popular as rm, but it works for things similar to this one. That is, with unlink you can delete files that you have on your system one by one. You may think that this is something absurd, and that you have rm for that, but you can do more than that ...

But first we will see what it is and then you will see its applications with some practical examples. The first thing to say is that it is a tool in the GNU coreutils package, therefore one of the basic tools provided by GNU for Linux, although if you remember, in LxA I already talked about another complementary package to have some extra Unix tools that do not come in this package . This is the moreutils package.

With unlink you can delete your files one by one. If you use several files, it will give you an error for not accepting so many parameters. You can check that you have it installed and obtain information with:

unlink --help

unlink --version

To delete a file, simply use the following command followed by the name of your file. For example, if you want to delete notes.txt:

unlink notas.txt

Also, if that file were a symbolic link, the file from which the link was made will not be deleted. So this tool is very simple to use and practical in some cases. The downside is that you can't delete many files or entire directories at once like rm, but it can help you prevent accidentally deleting data that you don't want to delete. For example, if you used rm *, it could remove all the files in a directory and maybe some of the files there you wanted to remain. Without many files it is impractical to do it with unlink, but if it is a directory with three or four files, getting used to using unlink could save you scares ...


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

bool (true)