Copy file using sudo access
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
How I can copy file or folder for other user.
New file or folder must have his name.
I have sudo access for cp command
USER1 ALL=(ALL) NOPASSWD: /bin/cp
I am trying following command:
USER1@ySERVERNAME:HOME_PATH$ sudo -i -u USER2 cp file1 file2
I got an error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
How can I solve it?
14.04 command-line sudo chown cp
add a comment |Â
up vote
1
down vote
favorite
How I can copy file or folder for other user.
New file or folder must have his name.
I have sudo access for cp command
USER1 ALL=(ALL) NOPASSWD: /bin/cp
I am trying following command:
USER1@ySERVERNAME:HOME_PATH$ sudo -i -u USER2 cp file1 file2
I got an error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
How can I solve it?
14.04 command-line sudo chown cp
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How I can copy file or folder for other user.
New file or folder must have his name.
I have sudo access for cp command
USER1 ALL=(ALL) NOPASSWD: /bin/cp
I am trying following command:
USER1@ySERVERNAME:HOME_PATH$ sudo -i -u USER2 cp file1 file2
I got an error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
How can I solve it?
14.04 command-line sudo chown cp
How I can copy file or folder for other user.
New file or folder must have his name.
I have sudo access for cp command
USER1 ALL=(ALL) NOPASSWD: /bin/cp
I am trying following command:
USER1@ySERVERNAME:HOME_PATH$ sudo -i -u USER2 cp file1 file2
I got an error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
How can I solve it?
14.04 command-line sudo chown cp
14.04 command-line sudo chown cp
edited Feb 21 at 9:44
![](https://i.stack.imgur.com/1MIVg.jpg?s=32&g=1)
![](https://i.stack.imgur.com/1MIVg.jpg?s=32&g=1)
Yaron
8,54271838
8,54271838
asked Feb 21 at 7:38
Hayk Hovhannisyan
61
61
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
Solution:
You should remove the -i
from the sudo
command:
sudo -u USER2 cp file1 file2
Explanation:
The problem you are facing is that your sudo
access is limited to /bin/cp
and using sudo -i
required extra sudo
permissions which you don't have.
As specify in the the error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
When using sudo -i -u USER2 cp
The command you are running is /bin/bash -c cp
which you don't have sudo
permissions for. As you are limited to the command which you have sudo
permission for: /bin/cp
.
More info: man sudo
-i, --login
Run the shell specified by the target user's password
database entry as a login shell. This means that login-
specific resource files such as .profile or .login will be
read by the shell. If a command is specified, it is passed
to the shell for execution via the shell's -c option. If no
command is specified, an interactive shell is executed. sudo
attempts to change to that user's home directory before
running the shell. The command is run with an environment
similar to the one a user would receive at log in. The
Command environment section in the sudoers(5) manual
documents how the -i option affects the environment in which
a command is run when the sudoers policy is in use.
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Solution:
You should remove the -i
from the sudo
command:
sudo -u USER2 cp file1 file2
Explanation:
The problem you are facing is that your sudo
access is limited to /bin/cp
and using sudo -i
required extra sudo
permissions which you don't have.
As specify in the the error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
When using sudo -i -u USER2 cp
The command you are running is /bin/bash -c cp
which you don't have sudo
permissions for. As you are limited to the command which you have sudo
permission for: /bin/cp
.
More info: man sudo
-i, --login
Run the shell specified by the target user's password
database entry as a login shell. This means that login-
specific resource files such as .profile or .login will be
read by the shell. If a command is specified, it is passed
to the shell for execution via the shell's -c option. If no
command is specified, an interactive shell is executed. sudo
attempts to change to that user's home directory before
running the shell. The command is run with an environment
similar to the one a user would receive at log in. The
Command environment section in the sudoers(5) manual
documents how the -i option affects the environment in which
a command is run when the sudoers policy is in use.
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
add a comment |Â
up vote
2
down vote
Solution:
You should remove the -i
from the sudo
command:
sudo -u USER2 cp file1 file2
Explanation:
The problem you are facing is that your sudo
access is limited to /bin/cp
and using sudo -i
required extra sudo
permissions which you don't have.
As specify in the the error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
When using sudo -i -u USER2 cp
The command you are running is /bin/bash -c cp
which you don't have sudo
permissions for. As you are limited to the command which you have sudo
permission for: /bin/cp
.
More info: man sudo
-i, --login
Run the shell specified by the target user's password
database entry as a login shell. This means that login-
specific resource files such as .profile or .login will be
read by the shell. If a command is specified, it is passed
to the shell for execution via the shell's -c option. If no
command is specified, an interactive shell is executed. sudo
attempts to change to that user's home directory before
running the shell. The command is run with an environment
similar to the one a user would receive at log in. The
Command environment section in the sudoers(5) manual
documents how the -i option affects the environment in which
a command is run when the sudoers policy is in use.
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Solution:
You should remove the -i
from the sudo
command:
sudo -u USER2 cp file1 file2
Explanation:
The problem you are facing is that your sudo
access is limited to /bin/cp
and using sudo -i
required extra sudo
permissions which you don't have.
As specify in the the error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
When using sudo -i -u USER2 cp
The command you are running is /bin/bash -c cp
which you don't have sudo
permissions for. As you are limited to the command which you have sudo
permission for: /bin/cp
.
More info: man sudo
-i, --login
Run the shell specified by the target user's password
database entry as a login shell. This means that login-
specific resource files such as .profile or .login will be
read by the shell. If a command is specified, it is passed
to the shell for execution via the shell's -c option. If no
command is specified, an interactive shell is executed. sudo
attempts to change to that user's home directory before
running the shell. The command is run with an environment
similar to the one a user would receive at log in. The
Command environment section in the sudoers(5) manual
documents how the -i option affects the environment in which
a command is run when the sudoers policy is in use.
Solution:
You should remove the -i
from the sudo
command:
sudo -u USER2 cp file1 file2
Explanation:
The problem you are facing is that your sudo
access is limited to /bin/cp
and using sudo -i
required extra sudo
permissions which you don't have.
As specify in the the error:
Sorry, user USER1 is not allowed to execute '/bin/bash -c cp file1 file2' as USER2 on SERVERNAME.
When using sudo -i -u USER2 cp
The command you are running is /bin/bash -c cp
which you don't have sudo
permissions for. As you are limited to the command which you have sudo
permission for: /bin/cp
.
More info: man sudo
-i, --login
Run the shell specified by the target user's password
database entry as a login shell. This means that login-
specific resource files such as .profile or .login will be
read by the shell. If a command is specified, it is passed
to the shell for execution via the shell's -c option. If no
command is specified, an interactive shell is executed. sudo
attempts to change to that user's home directory before
running the shell. The command is run with an environment
similar to the one a user would receive at log in. The
Command environment section in the sudoers(5) manual
documents how the -i option affects the environment in which
a command is run when the sudoers policy is in use.
edited Feb 21 at 7:45
answered Feb 21 at 7:40
![](https://i.stack.imgur.com/1MIVg.jpg?s=32&g=1)
![](https://i.stack.imgur.com/1MIVg.jpg?s=32&g=1)
Yaron
8,54271838
8,54271838
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
add a comment |Â
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
as I understand "file1" file need to have read permission, otherwise ti will give permission error: cp: cannot open âÂÂfile1â for reading: Permission denied
â Hayk Hovhannisyan
Feb 21 at 7:56
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
@HaykHovhannisyan - If I've solved your question, please accept my answer
â Yaron
Feb 21 at 8:01
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1008281%2fcopy-file-using-sudo-access%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password