[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedMarch 17, 2023

How to use Unlink Command.

How To Use Unlink Command.

In this article, we will show you how to remove a file in GNU/Linux systems using the unlink command.

 

unlink is a command-line utility for removing a single file.

The syntax of the unlink command is as follows:

unlink filename

Where filename is the name of the file you want to remove. On success, the command doesn’t produce any output and returns zero.

The unlink command accepts only two options, –help which displays the command help and –version which shows the version information.

Be extra cautious when removing files using the unlink command, because once the file is deleted, it cannot be fully recovered.

Unlike the more powerful rm command, unlink can accept only a single argument which means that you can delete only one file. If you try to remove more than one file, you will get “unlink: extra operand” error.

When removing symbolic links with unlink, the file the symlink points to is not removed.

To remove a given file, you need to have writing permissions on the directory containing that file. Otherwise, you will get “Operation not permitted” error.

For example, if you try to remove the file file3.txt under the /opt directory which is owned by root:

unlink /opt/file2.txt

The system will print the following message:

unlink: cannot unlink '/opt/file2.txt': Permission denied

On GNU/Linux systems unlink can never delete a directory . If you try to remove a directory:

unlink dir1

You will get the following message:

unlink: cannot unlink 'dir1': Is a directory

 

Conclusion

Removing files with unlink is a simple process, but you must be careful not to delete relevant data.

Keep reading
How to Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM