3

So I am the user david and according to ls -la the file permissions are 700 and the owner is david. I can not understand why I am not allowed to write to the file. The stat command returns something interesting that there are 2 Access: one for 700 and one for 500. The 500 would explain why I can't write to the file but why doesn't that show up when I do ls -la? Also I am not able to sudo anything since I do not know the password for david

david@traverxec:~/bin$ ls -la
total 16
drwx------ 2 david david 4096 Mar  1 17:43 .
drwx--x--x 5 david david 4096 Oct 25 17:02 ..
-r-------- 1 david david  802 Oct 25 16:26 server-stats.head
-rwx------ 1 david david  363 Oct 25 16:26 server-stats.sh
-rw-r--r-- 1 david david    0 Mar  1 17:43 test
david@traverxec:~/bin$ stat server-stats.sh 
  File: server-stats.sh
  Size: 363             Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 10901       Links: 1
Access: (0700/-rwx------)  Uid: ( 1000/   david)   Gid: ( 1000/   david)
Access: 2020-03-01 17:27:22.389179535 -0500
Modify: 2019-10-25 16:26:29.049613415 -0400
Change: 2019-10-27 16:24:21.437108121 -0400
 Birth: -
david@traverxec:~/bin$ echo "test" >> server-stats.sh 
-bash: server-stats.sh: Operation not permitted
david@traverxec:~/bin$ id
uid=1000(david) gid=1000(david) groups=1000(david),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev)

Edit: I am able to make files within the directory. I'm not too sure but it doesn't seem like it is mounted from somewhere else... hmmm

david@traverxec:~/bin$ touch test
david@traverxec:~/bin$ ls -la
total 16
drwx------ 2 david david 4096 Mar  1 17:43 .
drwx--x--x 5 david david 4096 Oct 25 17:02 ..
-r-------- 1 david david  802 Oct 25 16:26 server-stats.head
-rwx------ 1 david david  363 Oct 25 16:26 server-stats.sh
-rw-r--r-- 1 david david    0 Mar  1 17:43 test
david@traverxec:~/bin$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       3.9G  1.5G  2.3G  40% /
david@traverxec:~/bin$ findmnt -T .
TARGET SOURCE    FSTYPE OPTIONS
/      /dev/sda1 ext4   rw,relatime,errors=remount-ro
david@traverxec:~/bin$ 
14
  • 5
    It's much better to use copy-paste instead of screenshots. It makes question more accessible.
    – rush
    Mar 1, 2020 at 20:52
  • 1
    Check if you have any issues with mount itself (e.g. in case of disk / FS errors the mount might be remounted with read-only permission). E.g. mount.
    – rush
    Mar 1, 2020 at 20:54
  • 5
    Please don't post pictures of text. It's very hard to read on a smaller screen. Mar 1, 2020 at 21:10
  • 3
    "there are 2 Access: one for 700 and one for 500" -- I only see permissions of 0700 in your stat output. Where do you get permissions of 0500? The timezone offset in the last accessed time? Mar 1, 2020 at 21:15
  • 2
    Is the immutable bit set? Run lsattr server-stats.sh if it’s set ‘i’ will appear it the output attributes. Mar 1, 2020 at 22:55

1 Answer 1

1

Answer: The file is marked as immutable which means that not even root can modify this file

david@traverxec:~/bin$ lsattr server-stats.sh 
----i---------e---- server-stats.sh

Fix: This fix won't work for me since I do not have root/sudo access but here it is for anyone else

sudo chattr -i server-stats.sh
1
  • Can you copy it, and rename the directory? Mar 2, 2020 at 18:20

You must log in to answer this question.

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