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

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


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.

Update # 1

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

Update # 2

enter image description here

Update # 3

reducing reserved blocks to 0 didn't help

enter image description here

Update # 4

I forgot to mention it earlier but 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.

Update # 5

enter image description here

The blurred out text is of following pattern..


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

Update #6

Output of

cd /var/www/html/test 
sudo trace-cmd record -o /tmp/trace.dat -e all touch blah.html
cd /tmp 
run trace-cmd report


Update 7

I left my computer turned on overnight to download some files in /mnt/SSD2 on the single SSD my computer has, and came back to this in the morning

enter image description here

Upon rebooting I got a busybox initramfs command prompt where running fsck /dev/sda1/ allowed me to use my PC again, but is this connected to permissions issues I'm having? Is my SSD dying? Is it the newly installed kernel which was installed using sudo apt upgrade shortly before the permissions issue started occurring?

  • Just added listing of test directory
    – Ejaz
    Jul 10, 2018 at 16:39
  • First check: Is the partition with this file system mounted writeable? Does it have enough space?
    – Sven
    Jul 11, 2018 at 14:02
  • / has ~8GB of free space. About file system being writable, how do I check that? I am able to edit files in the terminal instance if I run su ejaz command it in.
    – Ejaz
    Jul 11, 2018 at 14:05
  • What kind of packages where upgraded ? Maybe a reboot is necessary ? Jul 13, 2018 at 5:58
  • Maybe you only have <5% of space left on the device ? which would explain why you cannot write as user but as root (via su) ? Could you please add the output of sudo df -h and sudo mount to the post, so we can see what's what? Jul 13, 2018 at 6:00

2 Answers 2


Preface: I don't know anything about snaps.

A standard option for ext filesystems is to reserve 5% of space for root on /

So it looks like, to me, that /var/www/html/ is part of the root partition, which has only 2% space left, looking at the ouput of df. As a standard option, Linux will retain 5% of your partition space of /for root. So that would explain why you cannot edit with your user account, but with su.

To check if this is really the case, you can use tune2fs to see how many reserved block you have

sudo tune2fs -l /dev/sda1

look if Reserved block count: is higher than 0.

Reserved block count: 3034088

You might want modify this, as a short time solution, for example, to 1%

sudo tune2fs -m 1 /dev/sda1

or with -r for the number of blocks (can also be set to 0)

But it would be a good idea to leave the 5% for root and move your data files to a separate partition.

Here is a good explantation why this is a good idea.

Other ways to quickly gain some filespace on /, if you don't have separate partitions for /var, /home, etc:

  • clean up your user homes
  • remove old log files
  • remove old packages / kernels with sudo apt-get update && sudo apt-get autoremove
  • Thanks for the answer. What am I looking for in output of tune2fs -l /dev/sda1 command? It says ... Inode count: 5431296 - Block count: 21693847 - Reserved block count: 1084692 - Free blocks: 1782825 - Free inodes: 3609939 ...
    – Ejaz
    Jul 13, 2018 at 6:31
  • look for reserved blocks as mentioned above. if you have them, then it is as I expected and a clean up will help, as well as reducing the % of reserved blocks Jul 13, 2018 at 6:38
  • I was able to free up 5.6GB in /dev/sda1 but unfortunately it doesn't seem to resolve the issue. Please see the screenshot I've added to the question. It shows 4 vertically stacked terminal windows.
    – Ejaz
    Jul 13, 2018 at 13:50
  • Did you try sudo tune2fs -m 0 /dev/sda1 to temp. disable block reserving ? Jul 13, 2018 at 13:56
  • 1
    You can use sudo tune2fs -m 5 /dev/sda1 to get the default value of 5% back. Regarding the virtualbox suspicion: You can try to add your user to the virtualbox group, like sudo usermod -aG vboxsf ejaz then login/logout. Jul 18, 2018 at 5:43

This will not apply 100% to you, but it is related, and hopefully will point you in the right direction. I suspect, as you say you do, that the problem is about the shared Virtualbox folders. Basically, folders accessed from 2 different OSes, each with their own filesystems/permissions, and since you can't enforce either one 100% or you lose all access from the other...

Yeah Virtualbox is likely trying to walk that tightrope between the two, without falling off on either side.

Anyway the references I found are to the opposite of your setup, Windows host and Ubuntu guest. But the same kinds of permissions shenanigans.

Windows host, Ubuntu guest, permission problems, with solution

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .