Skip to content

Permissions & Ownership

In Linux, every file and directory has a set of permissions and an owner that determine who can read, modify, or execute it. Understanding this is important when working in WSL or macOS, especially while running scripts, sharing files, or managing simulation folders.

File Permissions

You can view permissions by listing files with:

ls -l

Example output:

-rwxr-xr--  1 user  staff  2048  beam_solver.py

Here’s what it means:

  • r – read permission
  • w – write permission
  • x – execute permission

They are grouped in three sets:

  1. Owner – the user who created the file
  2. Group – users belonging to the same group
  3. Others – everyone else

So, in the example:

  • The owner can read, write, and execute (rwx)
  • The group can read and execute (r-x)
  • Others can only read (r--)

Changing Permissions

Use the chmod command to modify permissions:

CommandDescriptionExample
chmod +x filenameAdd execute permissionchmod +x run_simulation.sh
chmod 644 filenameRead/write for owner, read-only for otherschmod 644 notes.txt
chmod 755 filenameOwner full access, others can read/executechmod 755 mesh_convert.py
chmod 777 filenameGive read, write, and execute access to everyonechmod 777 beam_solver.py
sudo chmod -R u+rwX folder_nameRecursively give read, write, and execute (for directories) access to the current user onlysudo chmod -R u+rwX codes

Explanation for sudo chmod -R u+rwX codes

This command is especially useful when you’re working with project directories (like codes, mesh, or results) that might have restricted permissions.

  • sudo – runs the command with admin rights.
  • chmod – modifies permissions.
  • -R – applies changes recursively to all subfolders and files.
  • u+rwX – gives the user (owner) read (r), write (w), and execute (X) permissions — where X applies execute permission only to directories or files that already have it.

This ensures you have full access to edit and open your project files without changing permissions for everyone. It’s a safer alternative to chmod 777, as it doesn’t make files globally writable.

Changing Ownership

Ownership defines who controls the file or directory. You can view it with ls -l and change it using:

sudo chown new_owner filename

Example:

sudo chown joe beam_solver.py

Summary

Permissions and ownership ensure that your files are both secure and accessible. For simulation workflows, it’s important that your geometry, mesh, and solver files have proper read and execute permissions. If you ever face access issues, using

sudo chmod -R u+rwX project_folder

is a quick and safe way to restore full access to your working directory.