Ubuntu Permissions Diagnostic

System Information:

Operating System: Linux
PHP Version: 8.3.6
Web Server User: moonbase2
Current User ID: 1000
Current Group ID: 1000
Script Path: /var/www/html/CLCI/ubuntu_permissions_fix.php
Working Directory: /var/www/html/CLCI

Configuration Paths:

PRIVATE_DIR: /opt/lampp/private/
JOBS_FILE: /opt/lampp/private/jobs.json
APPLICATIONS_DIR: /opt/lampp/private/applications/

Directory Status:

Private Directory (/opt/lampp/private/):
  Exists: Yes
  Permissions: rwxr-xr-x (0755)
  Owner UID: 33
  Group GID: 33
  Readable: Yes
  Writable: Yes

Applications Directory (/opt/lampp/private/applications/):
  Exists: Yes
  Permissions: rwxr-xr-x (0755)
  Owner UID: 33
  Group GID: 33
  Readable: Yes
  Writable: Yes

Critical Files Status:

Jobs File (/opt/lampp/private/jobs.json):
  Exists: Yes
  Size: 147 bytes
  Permissions: rw-r--r-- (0644)
  Owner UID: 33
  Group GID: 33
  Readable: Yes
  Writable: Yes

Clock In File (/opt/lampp/private/clockInData.json):
  Exists: Yes
  Size: 133 bytes
  Permissions: rw-r--r-- (0644)
  Owner UID: 33
  Group GID: 33
  Readable: Yes
  Writable: Yes

Clock Out File (/opt/lampp/private/clockOutData.json):
  Exists: Yes
  Size: 133 bytes
  Permissions: rw-r--r-- (0644)
  Owner UID: 33
  Group GID: 33
  Readable: Yes
  Writable: Yes

Credentials File (/opt/lampp/private/credentials.txt):
  Exists: No
  Parent directory exists: Yes
  Parent directory writable: Yes

Write Permission Tests:

Testing write to private directory...
✓ SUCCESS: Can write to private directory
✓ Test file cleaned up

Testing jobs file access...
✓ Jobs file is readable
  Current content length: 147 characters
✓ Jobs file is writable

Ubuntu Fix Commands:

If you see permission issues above, run these commands on your Ubuntu server:

# Fix ownership (replace 'www-data' with your web server user if different)
sudo chown -R www-data:www-data /opt/lampp/private/

# Fix directory permissions
sudo chmod 755 /opt/lampp/private/
sudo chmod 755 /opt/lampp/private/applications/

# Fix file permissions (if files exist)
sudo chmod 664 /opt/lampp/private/jobs.json
sudo chmod 664 /opt/lampp/private/*.json
sudo chmod 664 /opt/lampp/private/*.txt

# Alternative: Make directory writable by web server group
sudo chgrp www-data /opt/lampp/private/
sudo chmod g+w /opt/lampp/private/

Common Web Server Users by Distribution:

To find your web server user, run: ps aux | grep -E '(apache|nginx|httpd)' | grep -v grep