Skip to content

Linux Whiz

One stop shop for linux knowledge.

FraudLabs Pro
Menu
  • Home
  • Blog
  • VPS Links
  • Web Host Tools
Menu

How to Check and Change Folder Permissions in Ubuntu Using SSH

Posted on July 17, 2026July 17, 2026 by Think

How to Check and Change Folder Permissions in Ubuntu Using SSH

If you’re managing an Ubuntu server, you’ll often need to check or change folder permissions. This is especially important when setting up a website, FTP/SFTP users, or troubleshooting “Permission denied” errors.

In this guide, you’ll learn how to:

  • Check folder permissions
  • Check file ownership
  • Change permissions
  • Change ownership
  • Apply permissions recursively
  • Troubleshoot common permission problems

Step 1: Connect to Your Server

Connect to your server using SSH:

ssh username@your-server-ip

Replace username with your server username and your-server-ip with your server’s IP address.


Step 2: Check Folder Permissions

To view the permissions on a folder, use:

ls -ld /path/to/folder

Example:

ls -ld /var/www/html

Example output:

drwxr-xr-x 5 www-data www-data 4096 Jul 16 20:15 /var/www/html

Understanding the Output

  • d — Directory
  • rwx — Owner permissions (Read, Write, Execute)
  • r-x — Group permissions (Read and Execute)
  • r-x — Other users’ permissions (Read and Execute)

The next two fields show the owner and group of the directory.


Step 3: Check Folder Ownership

To see who owns a directory:

stat /path/to/folder

Example:

stat /var/www/html

Example output:

Owner: www-data
Group: www-data

You can also list files with ownership information:

ls -l

Step 4: Change Folder Permissions

Use the chmod command to change permissions.

Give the owner full access

chmod 755 /path/to/folder

Permission breakdown:

  • Owner: Read, Write, Execute
  • Group: Read, Execute
  • Others: Read, Execute

Give the owner and group full access

chmod 775 /path/to/folder

Permission breakdown:

  • Owner: Read, Write, Execute
  • Group: Read, Write, Execute
  • Others: Read, Execute

Give everyone full access (Not Recommended)

chmod 777 /path/to/folder

⚠️ Warning: Avoid using 777 on production servers. It allows anyone to modify the folder and can create serious security risks.


Step 5: Change Folder Ownership

If another user needs control of a directory, use chown.

Example:

sudo chown ftpuser:ftpuser /path/to/folder

This changes both the owner and group to ftpuser.


Step 6: Change Ownership Recursively

To change ownership of a folder and everything inside it:

sudo chown -R ftpuser:ftpuser /path/to/folder

The -R option applies the change to all files and subfolders.


Step 7: Change Permissions Recursively

Apply permissions to an entire directory tree:

chmod -R 755 /path/to/folder

Or, if group members also need write access:

chmod -R 775 /path/to/folder

Step 8: Check Your Current User

To see which user you’re logged in as:

whoami

To view your user ID and group memberships:

id

Example output:

uid=1001(ftpuser) gid=1001(ftpuser) groups=1001(ftpuser),27(sudo)

Common Permission Values

PermissionMeaningTypical Use
755Owner can read, write, execute; others can read and executeWebsite folders
775Owner and group can read, write, executeShared directories
700Only the owner has accessPrivate directories
644Owner can read/write; others can readWebsite files
600Only the owner can read/writeSensitive files
777Everyone has full accessTesting only (not recommended)

Typical Web Server Permissions

For Apache or Nginx websites:

sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;

This configuration allows the web server to access your website while keeping permissions secure.


Troubleshooting “Permission Denied”

If you receive a “Permission denied” error:

  1. Check the folder owner:ls -ld /path/to/folder
  2. Verify your current user:whoami
  3. Check your group memberships:id
  4. If needed, change ownership:sudo chown -R username:username /path/to/folder
  5. Update the permissions:chmod -R 755 /path/to/folder

Conclusion

Understanding Linux file permissions is essential for managing websites, FTP/SFTP users, and applications on Ubuntu. Using ls, stat, chmod, and chown together allows you to quickly diagnose and fix most permission-related issues while keeping your server secure.

By following the steps in this guide, you’ll be able to confidently manage directory ownership and permissions from the command line.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to Check and Change Folder Permissions in Ubuntu Using SSH
  • Must-Have Apps on Cloudron: From Productivity to Privacy
  • World Monitor Script
  • Hostkoala.com Review
  • Configserver.com closing down permanently on 31 August 2025.

Krebs Security

  • Microsoft Patches a Record 570 Security Flaws
    by BrianKrebs
  • Lessons Learned from CISA’s Recent GitHub Leak
    by BrianKrebs
  • Felons, Fraudsters Flog Offensive Cybersecurity Startup
    by BrianKrebs
  • FBI Seizes NetNut Proxy Platform, Popa Botnet
    by BrianKrebs
  • Scattered Spider Hackers Plead Guilty on Day 1 of Trial
    by BrianKrebs
  • Dedicated (7)
  • Reviews (1)
  • Service VS Service (3)
  • Uncategorized (2)

XTtreme Computing Forum

  • BSD Release: OPNsense 26.7
  • Sheetz is quitting VMware, migrating 11,000 virtual machines
  • Distribution Release: OSINT VM 2026.5
RackNerd Large Mobile Banner
©2026 Linux Whiz | Design: Newspaperly WordPress Theme