Why with "sudo" command some tasks can't be done? For example:
Code: Select all
$ sudo cat /dev/null > sources.list
bash: sources.list: Permission denied
Code: Select all
$ sudo cat /dev/null > sources.list
bash: sources.list: Permission denied
Code: Select all
sudo sh -c 'cat /dev/null > sources.list'
Code: Select all
su -c 'cat /dev/null > sources.list'
Thanks.peter_irich wrote:sudo has no effect to redirection. It is possible to bypass, but I not remember how, I prefer use root with "su -".
Peter.
Code: Select all
sudo su
Code: Select all
exit
That won't work properly for Debian buster because PATH won't include the sbin directories (although it will work for the specific example given in the OP). And using both sudo and su together is just silly.theblueplll wrote:Code: Select all
sudo su
Code: Select all
sudo -i
Code: Select all
su -
Code: Select all
dai@Buster:~$ sudo su
[sudo] password for dai:
root@Buster:/home/dai# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root@Buster:/home/dai# exit
exit
dai@Buster:~$ sudo -i
root@Buster:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root@Buster:~# exit
logout
dai@Buster:~$
Agree, it is pointless, "su" logs you in as root, and "sudo", gives the logged in user root permissions, assuming sudoers ,etc is all set up correctly.And using both sudo and su together is just silly.
That is the main point and reason for using "sudo", if one uses sudo , they do not need to type "exit", they stop being sudo, after they run the command.Just rememberwhen you're finished to log out of being rootCode: Select all
exit
AND be careful what you do there is no "you shouldn't do this" warning in LInux when using the terminal LoL
Code: Select all
man su
Code: Select all
man sudo
Code: Select all
How to use su and sudo on Debian correctly
Yes, of course, sudo will set PATH & IFS. Thanks for the correction.Dai_trying wrote:Both sudo su and sudo i give me same results on my Buster Xfce installation.
I did not know this.Head_on_a_Stick wrote:That won't work properly for Debian buster because PATH won't include the sbin directories (although it will work for the specific example given in the OP). And using both sudo and su together is just silly.theblueplll wrote:Code: Select all
sudo su
To attain a root shell with the correct PATH & IFS set then use eitherOrCode: Select all
sudo -i
Code: Select all
su -
Code: Select all
:~$ su
Password:
su: Authentication failure
Code: Select all
sudo -i