Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Delete (Remove) Symbolic Links in Linux - DesignLinux

Jun 12 2020
designlinux 0 Comments
How to Delete (Remove) Symbolic Links in Linux

A symbolic link is also known as symlink or soft link, is a special type of file that serves as a reference to another file or directory. A symlink can point to a file or a directory on the same or a different filesystem or partition. This guide explains how to remove symbolic links in Linux systems.

Before going ahead for removing symbolic link, make sure use have writing permission on parent directory of the symlink. Otherwise, you will get “Operation not permitted” error.

To check symlink and to find the destination directory or file, use ls -l command.

ls -l /home/file.php
lrwxrwxrwx 1 tecnstuff tnsgrp 4 May 2 14:03 /home/file.php -> file_link.php

In above output the first character l shows that the file is symlink and the arrow -> symbol indicates where the symlink points to.

Remove Symbolic Links with rm#

To remove a symbolic link, use the rm command followed by the symbolic link name. Using rm command you can remove given file or directories.

rm SYMLINK_NAME

For example, to delete the /home/file.php symlink, you would run following command:

rm /home/file.php

It will not show output and exits with zero.

If you would like to delete more than one symbolic link, you can pass multiple symlink names as arguments with space separated.

rm SYMLINK_NAME_1, SYMLINK_NAME_2

If you would like to prompt confirmation message before deleting the symlink, you should pass -i option along with rm command:

rm -i SYMLINK_NAME

Type y and press Enter key for confirmation.

You will get following output:

rm: remove symbolic link 'SYMLINK_NAME'?

Ensure that you never use -r option along with rm command while removing symlink. Otherwise it will remove all the contents of the destination directory.

Remove Symbolic Links with unlink#

Unlink command removes the given symlink. It is possible to delete only a single file using unlink.

To remove a symlink using unlink, run the following command followed by the symlink name.

unlink SYMLINK_NAME

For instance, to remove the /home/file.php symlink, you would run following unlink command:

unlink /home/file.php

When removing a symbolic link that points to a directory do not append a trailing slash to the symlink name.

Conclusion#

This tutorial shown you how to remove symbolic links or symlink using rm or unlink command.

If you have any question or feedback, please leave a comment below.

Related

Tags: find, rm, terminal

How to Add Elements to a List in Python (append, extend and insert)

Prev Post

How to Connect NGINX to PHP-FPM Using UNIX or TCP/IP Socket

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
  • 0
  • 65
  • 605,815

DesignLinux.com © All rights reserved

Go to mobile version