Errors can be quite intimidating, particularly when they involve permissions or access issues. One such error that developers might come across is the “EACCES permission denied unlink ‘/usr/local/bin/code'” error. In this blog post, we’ll break down this error, delve into its causes, and provide a comprehensive guide to resolving it. By the time you’re finished reading, you should have a solid grasp of this error and how to address it effectively.

Understanding the EACCES Permission Denied Error

‘EACCES permission denied’ is an error message related to file access and permissions in Unix-based operating systems, such as Linux and macOS. This error occurs when a process attempts to perform an action on a file or directory but lacks the required permissions to do so. The action could involve reading, writing, executing, or deleting the file.

In the context of the error message “EACCES permission denied unlink ‘/usr/local/bin/code'”, the error is specifically related to the process of unlinking, which means removing a file or directory. The file in question is ‘/usr/local/bin/code’, which is likely a symbolic link to the Visual Studio Code binary.

Common Causes of the Error

The EACCES permission denied error can arise for several reasons. When it comes to unlinking ‘/usr/local/bin/code’, the most prevalent causes include:

Insufficient Privileges

The user attempting to unlink the file may not have the necessary permissions to do so. This is usually because the user is not the owner of the file or does not belong to the group that owns the file.

Read-Only File System

The file system containing the file might be mounted as read-only, which prevents any write or delete operations. This can happen intentionally or due to a configuration error.

Incorrect File Ownership or Permissions

The file’s ownership or permissions may be incorrectly set, preventing the user from performing the desired action.

Resolving the EACCES Permission Denied Unlink Error

To fix the “EACCES permission denied unlink ‘/usr/local/bin/code'” error, follow the steps outlined below. These steps should help you identify the cause of the problem and apply the appropriate solution.

Check User Privileges

The first step is to verify if the user attempting to unlink the file has sufficient privileges. You can check the current user by running the following command in the terminal:


If you’re not logged in as the root user or a user with administrative privileges, you might not have the necessary permissions to unlink the file. To fix this, you can either log in as a user with the required privileges or use the ‘sudo’ command to execute the unlink command with elevated privileges:

sudo unlink /usr/local/bin/code

Inspect File System Mount Options

If you still encounter the error, the next step is to check if the file system containing the file is mounted as read-only. You can use the ‘mount’ command to display information about all mounted file systems:


Locate the file system containing ‘/usr/local/bin/code’ in the output, and check if it’s mounted with the ‘ro’ (read-only) option. If it is, you’ll need to remount the file system with read-write permissions:

sudo mount -o remount,rw /path/to/mount/point

Replace ‘/path/to /mount/point’ with the actual mount point of the file system.

Examine File Ownership and Permissions

If the file system is not mounted as read-only, you should check the ownership and permissions of the ‘/usr/local/bin/code’ file. To do this, use the ‘ls’ command with the ‘-l’ option:

ls -l /usr/local/bin/code

The output will display the file’s ownership and permissions, like this:

lrwxrwxrwx1rootroot53Apr1012:30 /usr/local/bin/code-> /usr/share/code/bin/code

In this example, the file is owned by the ‘root’ user and belongs to the ‘root’ group. The permissions are set to ‘rwx’ (read, write, and execute) for the owner, group, and others.

If the ownership or permissions are not set correctly, you can use the ‘chown’ and ‘chmod’ commands to modify them. To change the file’s owner and group, run:

sudo chown owner:group /usr/local/bin/code

Replace ‘owner’ and ‘group’ with the desired owner and group names. To change the file permissions, use the ‘chmod’ command:

sudo chmod permissions /usr/local/bin/code

Replace ‘permissions’ with the desired permissions in numeric or symbolic format, such as ‘755’ or ‘u=rwx,g=rwx,o=rx’.

Investigate File Locks

In some cases, the file may be locked by another process, preventing the unlink operation. To check for file locks, you can use the ‘lsof’ command:

sudo lsof /usr/local/bin/code

If a process is locking the file, the command will display information about the process, including its process ID (PID). To unlock the file, you can either terminate the locking process using the ‘kill’ command or wait for it to release the lock on its own.

sudo kill PID

Replace ‘PID’ with the actual process ID from the ‘lsof’ output.

Reinstall Visual Studio Code

If none of the previous steps resolved the issue, you might want to consider reinstalling Visual Studio Code. This can help ensure that the ‘/usr/local/bin/code’ symbolic link is correctly set up and that the file permissions and ownership are properly configured.

To uninstall Visual Studio Code, follow the instructions specific to your operating system and package manager. After uninstalling, download the latest version from the official website ( and install it following the provided installation guide.


The “EACCES permission denied unlink ‘/usr/local/bin/code'” error is a common issue related to file permissions and access on Unix-based operating systems. By following the steps outlined in this blog post, you should be able to identify the cause of the problem and apply the appropriate solution. Understanding the underlying causes of this error will not only help you resolve it but also avoid similar issues in the future.

Disclaimer: The code snippets and examples provided on this blog are for educational and informational purposes only. You are free to use, modify, and distribute the code as you see fit, but I make no warranties or guarantees regarding its accuracy or suitability for any specific purpose. By using the code from this blog, you agree that I will not be held responsible for any issues or damages that may arise from its use. Always exercise caution and thoroughly test any code in your own development environment before using it in a production setting.

Leave A Comment