chmod. Changing permission of file - file-permissions

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...

Related

How to add sudo user on solaris?

I am using Solaris 11 , I have added user to sudo user file ( /etc/sudoers) , still its prompting for password.
arcsys#solaris:~$ sudo -l
User arcsys may run the following commands on solaris:
(ALL) NOPASSWD: /usr/bin/cat
(ALL) ALL
arcsys#solaris:~$ sudo cat /etc/sudoers
Password:
I am not able to understand that what is wrong here?
Any help is appreciated.
The command you need to execute is:
sudo /usr/bin/cat /etc/sudoers
sudo is strict when you have configured the full path to the program(s)
As root, run:
visudo
and check to make sure your username is added
root ALL=(ALL:ALL) ALL
arcsys ALL=(ALL:ALL) ALL
Save, and quit, then run:
sudo "command"
The system will prompt you for YOUR password. If you have the proper access, it will run. If not, you will need to run visudo either as root, or by running sudo visudo.

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

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

Not able to create a directory using sudo -u username mkdir /var/log/test

I am unable to create a directory using sudo priveleges from root user and If I login to user , I can create an directory under /root using sudo. Also I have added to allow all commands in /etc/sudoers file and the details are below:
[root#linux home]# cat /etc/sudoers | grep tes
test ALL= NOPASSWD: ALL
Error
[root#linux home]# sudo -u test mkdir /var/log/test3
mkdir: cannot create directory ‘/var/log/test3’: Permission denied
Any Ideas ?
Thanks
By running 'sudo -u test', you're giving yourself lower privileges than the roor user because you're running the command as the user 'test', not 'root'. From the root user, you can just run:
mkdir /var/log/test3
Read man sudo for more info.
Or:
Run visudo and uncomment the wheel group, then add the user test to the wheel group.
If you don't mind me asking, why do you need to create a directory as a certain user from the root user? Especially since the directory you're making will not be user specific?
Also, in the sudoers file , you should what added test ALL=(ALL) NOPASSWD: ALL, not test ALL= NOPASSWD: ALL

AWS EC2 Permissions Denied /usr/local/bin cURL

I am trying to follow this documentation and install docker machine on my EC2 instance. However, the curl command:
curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine
quits with the error:
-bash: /usr/local/bin/docker-machine: Permission denied
I tried to curl into the home directory, hoping that it would change the permissions on the directory and then copy it to destination, but it didn't work.
How can I by-pass this? Clearly, the ec2-user is lacking the root privileges on some directories.
-v When given the -v (validate) option, sudo will update the user's cached credentials, authenticating the user's password if necessary.
For the sudoers plugin, this extends the sudo timeout for another 5
minutes (or whatever the timeout is set to by the security policy) but
does not run a command. Not all security policies support cached
credentials.
ec2-user is in sudoers list by default.
[ec2-user ~]$ sudo -v
[ec2-user ~]$
Try this:
sudo bash -c "curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine"
If you want to make the saved file an executable for all:
sudo chmod a+x /usr/local/bin/docker-machine

How to make a script with commands requiring mix of sudo & sudo -u username permissions?

I want to make a script that runs some commands with sudo permission & some commmands with sudo -u username permission.
Currently,
I run script using sudo permission, which executes each command in the script with sudo permission. But what I want to do is run some commands with normal user permissions. For example: If I create a directory then I don't want to be created by super-user. Otherwise it becomes difficult to delete it from file manager until I open file manager in root mode.
#!/bin/bash
# this declares that current user is a sudoer
sudo tee /etc/sudoers.d/$USER <<END
END
# write the content of your script here
sudo npm install hexo-cli -g
mkdir Untitled
sudo apt-get install python
# then to remove the sudo access from the current user
sudo /bin/rm /etc/sudoers.d/$USER
sudo -k
You either run a script as a user, and put some sudo command in it, or you run the script with sudo, and use su to run specific commands within the script as a certain user.

Resources