root user faces "Permission denied". How to find the cause? - root

I wonder how one investigates the cause of denied access in a case like that:
uid=0(root) gid=0(root) groups=0(root)
root#host:/tmp# chown root .mount_app
chown: cannot access '.mount_app': Permission denied
root#host:/tmp# ls -la .mount_flameshot
ls: cannot access '.mount_app': Permission denied
root#host:/tmp# stat -c "%U" .mount_app
stat: cannot stat '.mount_app': Permission denied
Addiotional Info:
In this specific case the file is somehow related to snap.

Related

Symfony run process scp with www-data user permission/key problems

Calling a scp-command in symfony ($process->run()), will end up in a errormessage.
The command "scp -r /var/www/html//media/* user#server:/var/www/tmp/" failed.
Exit Code: 1(General error) Working directory: /root
Output: ================ Error
Output: ================ Permission denied, please try again. Permission denied, please try again.
user#server: Permission denied (publickey,password)
as the www-data user is a nologin user without own keys, how can this get be done?

Not able to create directory under /var/log as root user

What could be the reason for the following erorrs. I ran the script as a root user. I believe the root user must be having super user permissions. It was failing with the following error
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
(base) [root#localhost ~]# cat /tmp/hadoop-service-startup.log
STARTING NAMENODE
WARNING: HADOOP_NAMENODE_OPTS has been replaced by HDFS_NAMENODE_OPTS. Using value of HADOOP_NAMENODE_OPTS.
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTING SECONDARY NAMENODE
WARNING: HADOOP_SECONDARYNAMENODE_OPTS has been replaced by HDFS_SECONDARYNAMENODE_OPTS. Using value of HADOOP_SECONDARYNAMENODE_OPTS.
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTING DATANODE
WARNING: HADOOP_DATANODE_OPTS has been replaced by HDFS_DATANODE_OPTS. Using value of HADOOP_DATANODE_OPTS.
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTED DAEMONS
4884 Jps
STARTING RESOURCEMANGER
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTING NODEMANGER
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTING HISTORYSERVER
WARNING: /var/log/hadoop does not exist. Creating.
mkdir: cannot create directory ‘/var/log/hadoop’: Permission denied
ERROR: Unable to create /var/log/hadoop. Aborting.
COMPLETE
STARTED DAEMONS
5012 Jps
You may be having a permissions issue. Try changing the permissions doing the following
sudo chown -R hadoop /var/log/hadoop/
If thy doesn’t work, you could try to work around it by changing the location of the Hadoop logs to a different location

How to move a file out of /usr/local if I get Permission Denied?

I would like to move the file.txt FROM usr/local/file.txt TO /usr/local/folder/file.txt.
However, every time I try I get a permission denied reply.
I have tried:
sudo mv ~/usr/local/file.txt /usr/local/folder/file.txt
When I got permission denied, I also used chmod and set a 777 just to try and still get permission denied.
What can I do?
Try this:
Check whether you have write access to the folder with
ls -l
Then you can try changing the ownership of the folder to your current user.
sudo chown -R your_username /path/to/folder
See this.

fuser returns Cannot Permission denied

If I run fuser -n tcp 80 on ubuntu 14.0.4 which is running in a docker image, I get:
Cannot stat file /proc/25/fd/0: Permission denied
Cannot stat file /proc/25/fd/1: Permission denied
Cannot stat file /proc/25/fd/2: Permission denied
Cannot stat file /proc/25/fd/3: Permission denied
Cannot stat file /proc/25/fd/4: Permission denied
Cannot stat file /proc/25/fd/5: Permission denied
etc.
80/tcp: 24
If I run whoami it returns root.
Why can I not run this command?
That should be because of AppArmor.
It is a Linux Security Module implementation of name-based access controls. AppArmor confines individual programs to a set of listed files and posix 1003.1e draft capabilities.
You can see various workarounds in issue 7276 or issue 6800.
docker run -itd --cap-add=SYS_PTRACE --security-opt=apparmor:unconfined mytomcat7image

Permission denied for a "drw-r--r--" directory

I have a log/ directory with read permission for all : drw-r--r--
paul#ns387656:/var$ ls -l
...
drw-r--r-- 9 root root 4096 May 22 14:49 log
...
But when I want to access it with the cd command I have a "Permission denied"
paul#ns387656:/var$ cd log
-sh: cd: log: Permission denied
And I don't know why...
Ideas ?
Thx
You need execute permission to change into a directory.
Also the owner is listed first. In this case the owner is root and root has read and write permission. Group and Others have only read permission.
Try this:
sudo chmod a+rx log
This adds read/execute permission for owner, group, and others.

Resources