Getting changing ownership of '/var/log/logstash': Operation not permitted - linux

I am running following command
$ chown -R logstash.logstash /usr/share/logstash
$ chmod 777 /usr/share/logstash/data
I'm getting below error
chown: changing ownership of '/var/log/logstash': Operation not permitted
Can anyone pls help!

You need to run these commands with sudo for ex
$ sudo chown -R logstash.logstash /usr/share/logstash
$ sudo chmod 777 /usr/share/logstash/data
Read more about sudo

Related

Accidently ran `sudo chown root#root -R /.` instead of `sudo chown root#root -R ./`

I wanted to change tho permission of a file structure and accidently ran
sudo chown root#root -R /.
instead of
sudo chown root#root -R ./
is there anyway i can undo that?
I don't have a backup of my system. If there is nothing a can do I'll just install a different os since all the relevant data is backed up.

How to change directory permissions like made with 'sudo mkdir' in linux

I created the directory with "mkdir" command, after that I need to change permissions as if I made it with "sudo mkdir".
I've searched for the chmod command, but it doesn't seem to be what I'm looking for.
Is it possible to do this with a single command in terminal?
you can use the chown command to change the owner and group of the directory, and the chmod command to set the permissions.
sudo chown root:root /path/to/directory && sudo chmod 755 /path/to/directory

How can I get "sudo chmod +x my_script.sh" to work? (operation not permitted) (Fedora 30)

I am attempting to make a file my_script.sh executable by using the sudo chmod +x my_script.sh command. I created the file my_script.sh with sudo gedit my_script.sh I did my writing in the file, then I used chattr +i /etc/resolv.conf to save the change.
I then attempted the sudo chmod +x my_script.sh command, but received the output chmod: changing permissions of '/rw/config/vpn/qubes-vpn-handler.sh': Operation not permitted. I've looked all over the web and on these forums and have found a number of posts offering solutions about changing ownership, etc. However, these all meet with the same result. I'm including some examples below, in case they're helpful:
[user#---]$ sudo chmod +x my_script.sh
chmod: changing permissions of 'my_script.sh': Operation not permitted
[user#---]$ sudo chmod +x my_script.sh
chmod: changing permissions of 'my_script.sh': Operation not permitted
[user#---]$ sudo rm my_script.sh
rm: cannot remove 'my_script.sh': Operation not permitted
[user#---]$ sudo chmod 0754 my_script.sh
chmod: changing permissions of 'my_script.sh': Operation not permitted
[user#---]$ sudo chown user my_script.sh
chown: changing ownership of 'my_script.sh': Operation not permitted
[user#---]$ sudo chmod u+x my_script.sh
chmod: changing permissions of 'my_script.sh': Operation not permitted
[user#---]$ sudo rm my_script.sh
rm: cannot remove 'my_script.sh': Operation not permitted
[user#---]$ sudo chmod -R a+x /[directory containing my_script.sh]
chmod: changing permissions of 'my_script.sh': Operation not permitted
If anyone can render assistance I would be most grateful.
It is because of the chattr +i have a look at the man page : https://linux.die.net/man/1/chattr.
It prevents any user including the root from modifying or deleting a file. You can do chattr -i to change that.

chmod: changing permissions of ‘my_script.sh’: Operation not permitted

when I'm trying to make shell script that error is shown ,what i must do ??
[rehamadel#localhost bin]$ sudo vi my_script.sh
[sudo] password for rehamadel:
[rehamadel#localhost bin]$ ls -l my_script.sh
-rw-r--r--. 1 root root 52 Jul 30 19:25 my_script.sh
[rehamadel#localhost bin]$ chmod u+x my_script.sh
chmod: changing permissions of ‘my_script.sh’: Operation not permitted
Resolving the operation not permitted error:
sudo chmod u+x my_script.sh
You created the file via:
sudo vi my_script.sh
# editing
This means, the owner and group of the file is root. You are not allowed to change files of it by default. You need to change permission (chmod does it) or change the owner:
sudo chown you:yourgroup my_script.sh
This should do it. Save the trouble, without creating the file via sudo.
You've created file my_script.sh with the root user as the owner (because you used sudo), which is why you're not permitted to change the permissions as yourself.
Thus, use sudo chmod u+x my_script.sh, but note that that will make the file only executable for the root user.
To make the file executable by everyone, use sudo chmod a+x my_script.sh.
I faced this error because I uploaded the files via winscp and was trying to change permission on Linux window.
I was able to change permissions via winscp.

chmod. Changing permission of file

I have remote server with Debian and I need to edit readonly file fcgid.conf on server. When I use sudo:
sudo su chmod 755 fcgid.conf
it responses:
-bash: sudo: command not found
Also I tried cmod +x:
chmod +x fcgid.conf
And got:
chmod: changing permissions of `fcgid.conf': Operation not permitted
Owner of file is root user and I don't know how to get permission to edit this file.
Sudo is not installed with Debian in the case you have defined a root password in the installation.
Either install sudo with
$ apt-get update
$ apt-get install sudo
and make a sudo rule and add your user into the group:
$ adduser USERNAME sudo
$ visudo
enter:
%sudo ALL = (ALL) ALL
and then run again
$ sudo chmod +x fcgid.conf
see also here: How to properly configure sudoers file, on debian wheezy?
or you try
$ su root
and then
$ chmod +x fcgid.conf
Both methods provide that you know the root/admin password...

Resources