User has write-only permissions on a file, unable to cat
or vi
but is able to nano
normally. How is this possible?
I was wondering what happens if you only have write-access on a file and this was how I tested it.
# cd /home/tester
# cat hello.txt
Hello World!
# ls -l hello.txt
-rw------- 1 root root 13 Nov 17 01:55 hello.txt
# chmod o+w hello.txt
# ls -l hello.txt
-rw-----w- 1 root root 13 Nov 17 01:55 hello.txt
# su tester
$ cd ~
$ cat hello.txt
cat: hello.txt: Permission denied
$ nano hello.txt
For some reason, nano
is able to read the file (see screenshot). I've confirmed vi
is not. My original hypothesis is that having write only permission allows you to only append the file like echo "Hello" > hello.txt
.
(See this screenshot for the actual commands I ran.)
Update
ls -l "$(type -p nano)"
shows permissions -rwsr-xr-x root root
.
#
suggests you are still root. Are you sure you're tester? Can you dowhoami
right before you use nano? – user147505 Nov 16 '19 at 9:35ls -l "$(type -p nano)"
. – user147505 Nov 16 '19 at 10:37-rwsr-xr-x root root
is the output when I ran this command as trader03/tester. So I assume thats what u meant by suid set, which is the "s" in user? – ministic2001 Nov 16 '19 at 10:40