Struggling with permissions in your Node.js project on Ubuntu? This guide will help you solve `Permission Denied` errors effectively. --- This video is based on the question https://stackoverflow.com/q/76245648/ asked by the user 'Simple Fellow' ( https://stackoverflow.com/u/1366415/ ) and on the answer https://stackoverflow.com/a/76245661/ provided by the user 'Zac Anger' ( https://stackoverflow.com/u/5774952/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: not able to access the source folder permissions denied despite using chmod and chown Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Introduction When working on your Node.js project in a Linux environment like Ubuntu, you may encounter frustrating Permission Denied errors. These errors can block your access to source folders and files, making it impossible to run or modify your project effectively. This guide will guide you through understanding and resolving common permission issues that arise when you shift ownership from the root user back to your regular user account. The Problem In this scenario, a user created a Node.js project while logged in as the root user. Upon switching to their regular account (sam), they were unable to access the src folder, encountering permission denied messages instead. Despite attempts to change ownership and adjust permissions using chmod and chown, the problem persisted. This can be a common pain point for many developers, so let's break down the solution step-by-step. Understanding Ownership and Permissions Before we dive into the resolution, it’s crucial to understand how Linux handles file ownership and permissions. Ownership Each file or directory in Linux has an assigned owner and group. Command chown can change the owner of a file or directory. Notably, if you don't specify the group when using chown, it will only change the owner. Permissions Permissions determine who can read, write, or execute a file or directory. The command chmod is used to change these permissions. Different modes apply for files and directories; for example, directories need execute permissions to allow access. Steps to Resolve the Issue Now that we understand the basics, let’s go over the specific steps needed to fix the permission issues in your Node.js project. 1. Change Ownership Correctly First, the ownership change command needs to incorporate the group information properly. Use the following command: [[See Video to Reveal this Text or Code Snippet]] This command does two things: Changes the owner to sam. Changes the group to sam, thus granting your user account full access. 2. Set Proper Permissions Next, you need to set the right permissions for files and directories within src. Different permissions are required for directories vs. files: For directories, you should use: [[See Video to Reveal this Text or Code Snippet]] For non-directory files, apply: [[See Video to Reveal this Text or Code Snippet]] This ensures that files are readable and writable by the owner and readable by the group and others. 3. Checking Permissions After performing these commands, it’s imperative to check if everything was set correctly. Use the following command to verify: [[See Video to Reveal this Text or Code Snippet]] You should no longer see Permission denied errors when listing the directory contents. Conclusion By following the outlined steps, you should be able to resolve the Permission Denied errors you are experiencing in your Node.js project. Ensuring that file ownership and permissions are set correctly is vital for smooth development on Linux systems. Remember, if issues persist, revisit each step to confirm that the commands have executed properly. Happy coding!