0

I'm running Ubuntu 16.04.4 LTS and facing a problem. All of a sudden I'm unable to edit files that I could before, I cannot run programs due to permission errors.

I'm always logged in as a user ejaz belonging to primary group ejaz and secondary groups root adm cdrom sudo dip www-data plugdev lpadmin sambashare kismet wireshark docker. I have several websites in sub-directories of /var/www/html/ (not in ~/public_html because it is a dev machine with no security/sharing considerations). Taking a website, /var/www/html/test, for example; it belongs to user:group www-data:www-data. Me, logged in as ejaz, am getting permission errors while editing files in test directory. I seem to have correct group permissions to edit this directory.

Output of groups command

~ » groups ejaz                                                                                                                                                              
ejaz : ejaz root adm cdrom sudo dip www-data plugdev lpadmin sambashare kismet wireshark docker

Permissons for test site

/var/www/html » l | grep test
drwxrwxr-x  2 www-data www-data 4.0K Apr  9  2017 test

But any editing results in permission errors

/var/www/html » cd test 

/var/www/html/test » l                                                                                                                                                           
total 16K
drwxrwxr-x  2 www-data www-data 4.0K Apr  9  2017 .
drwxrwxr-x 87 www-data www-data 4.0K Jul 10 06:50 ..
-rw-rw-r--  1 www-data www-data    0 Apr  9  2017 blah.html
-rw-rw-r--  1 www-data www-data   16 Apr  9  2017 .htaccess
-rw-rw-r--  1 www-data www-data   73 Apr  9  2017 index1.html

/var/www/html/test » touch blah.html
touch: cannot touch 'blah.html': Permission denied

Output of id command

/var/www/html/test » id -Gn
ejaz

which is understandable since ejaz is the primary group.

But If I su as ejaz, I'm able to edit the file in terminal and in any program that is launched from that particular terminal instance

Question

Why am I not able to edit the files all of a sudden and how was I able to edit those files before? All I did since yesterday was to run Ubuntu's apt upgrade.

Any help will be greatly appreciated.
Thanks for reading.

Output of sudo mount command

~ » sudo mount                                                                    
[sudo] password for ejaz: 
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=4021496k,nr_inodes=1005374,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=808412k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/var/lib/snapd/snaps/core_4917.snap on /snap/core/4917 type squashfs (ro,nodev,relatime)
/var/lib/snapd/snaps/core_4650.snap on /snap/core/4650 type squashfs (ro,nodev,relatime)
/var/lib/snapd/snaps/core_4830.snap on /snap/core/4830 type squashfs (ro,nodev,relatime)
/var/lib/snapd/snaps/pycharm-community_62.snap on /snap/pycharm-community/62 type squashfs (ro,nodev,relatime)
/var/lib/snapd/snaps/pycharm-community_60.snap on /snap/pycharm-community/60 type squashfs (ro,nodev,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
/var/lib/snapd/snaps/pycharm-community_64.snap on /snap/pycharm-community/64 type squashfs (ro,nodev,relatime)
/dev/sda4 on /mnt/SSD2 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=808412k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

Output of sudo df -h command

~ » sudo df -h                                                                  
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           790M  9.3M  781M   2% /run
/dev/sda1        82G   75G  2.3G  98% /
tmpfs           3.9G  165M  3.7G   5% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0       87M   87M     0 100% /snap/core/4917
/dev/loop1       87M   87M     0 100% /snap/core/4650
/dev/loop2       87M   87M     0 100% /snap/core/4830
/dev/loop4      233M  233M     0 100% /snap/pycharm-community/62
/dev/loop3      240M  240M     0 100% /snap/pycharm-community/60
/dev/loop5      237M  237M     0 100% /snap/pycharm-community/64
/dev/sda4       136G  125G   11G  92% /mnt/SSD2
tmpfs           790M   28K  790M   1% /run/user/1000

enter image description here

reducing reserved blocks to 0 didn't help

enter image description here

I think it is worth mentioning that I often run Windows 7 on this PC using VirtualBox. Windows has access to /var/www/html/ and /mnt/SSD2/ via VirtualBox sharing. I have been running Windows for ~ a year but could that have caused the permissions mess?
Regarding the extent of what Windows does to the shared directories, I exclusively use Widows to run Adobe Photoshop, so Windows essentially reads some images from /mnt/SSD2 or /var/www/html/html and stores images in /mnt/SSD2/*. No huge file manipulation is done in Windows on shared directories, e.g., compressing directories, extracting compressed files, moving directories around, setting permissions etc.

enter image description here

The blurred out text is of following pattern..

/var/www/html/magento_site_1
/var/www/html/magento_site_1/var/session/sess_xxxxxxxxxxxxxxxxxxxxxxxxxx
/var/www/html/magento_site_1
/var/www/html/magento_site_1/var/session/sess_xxxxxxxxxxxxxxxxxxxxxxxxxx
/var/www/html/magento_site_1
/var/www/html/magento_site_1/var/session/sess_xxxxxxxxxxxxxxxxxxxxxxxxxx
/var/www/html/magento_site_1
/var/www/html/magento_site_1/var/session/sess_xxxxxxxxxxxxxxxxxxxxxxxxxx
....

with xxxxxxxxxxxxxxxxxxxxxxxxxx being a random string. The screenshot is complete output.

  • as my experience, there are maybe two other issues: 1- ACL in parents directory,2-: Pernission problem in the mounting directory. please check them. – Hossein Vatani Jul 27 '18 at 7:30
0

This looks suspicious:

/var/www/html/test » id -Gn
ejaz

The id -G command (with uppercase G) should list all the secondary groups, but it seems to be showing only one of them and it's not www-data...

This doesn't happen when you run groups ejaz since there you're asking what are the secondary groups of user ejaz and not the secondary groups currently active. You can try to simply run groups to confirm only ejaz is there and the others are missing.

Try to reset the secondary groups with the newgrp command:

newgrp

Then check id -Gn and groups again to see if it's listing all of them...

You can also try:

newgrp www-data

Which will try to make www-data your primary group. But it's possible this will fail, if it's not properly setting the secondary groups...

(This also explains why using su might help work around this, since then you're resetting the secondary groups again.)

Now, the question is why you're getting this now... Are you getting it when you SSH to the server? Or log in on the console (tty1, which you access with Ctrl+Alt+F1)? Or on the graphical session? Can you check if it affects only one of those?

It's possible there is something in PAM config, but it's hard to tell... Maybe try to dig up in which cases the problem is happening and, if you can narrow it down, post a new question about it. Also maybe look at APT logs to see which packages were touched in this upgrade. Perhaps look at timestamp of PAM config files, to see if any were updated recently...

Good luck!

  • Thanks for the answer. This happens on my local Ubuntu PC with graphical session. – Ejaz Jul 27 '18 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.