Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Unlink Command in Linux (Remove File) - DesignLinux

Jun 11 2020
designlinux 0 Comments
Unlink Command in Linux (Remove File)

The unlink is a command-line utility for removing a single file. It calls directly interfaces with the unlink system function, which removes a specified file. This tutorial shows you how to remove a file in Linux using unlink command.

Removing File with unlink#

Following is the syntax for the unlink command:

unlink FILENAME

Here, you should replace FILENAME with your real file name. This command will not show any output and returns zero on success.

You can use only two options along with unlink command, --help which displays the command help and --version which shows the version information.

The unlink command accept only single arguments, means you can remove only one file. You will get “unlink: extra operand” error if you pass multiple arguments.

The destination target will not deleted when removing symbolic links with unlink.

You should have writing permission on parent directory of the symlink. Otherwise, you will get “Operation not permitted” error.

For instance, if you try to remove the example.com under the /etc/nginx/sites-enabled directly which is owned by root:

unlink /etc/nginx/sites-enabled/example.com

It will show the following error message:

unlink: cannot unlink '/etc/nginx/sites-enabled/example.com': Permission denied

You cannot delete a directory using unlink command. You will get error if you try to remove a directory:

unlink directory_name
unlink: cannot unlink 'directory_name': Is a directory

Conclusion#

This tutorial shown you how to remove file using unlink command. You should take before removing any files.

If you have any questions or suggestion, leave a comment below.

Related

Tags: terminal, unlink

How to Install KVM on Ubuntu 20.04

Prev Post

How to Install Skype on Ubuntu 20.04 LTS

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 3
  • 730
  • 615,102

DesignLinux.com © All rights reserved

Go to mobile version