su komutu kullanıcı/hesap değiştirmek için kullanılır. Örneğin “mehmet” isimli hesapla terminale girdiniz ve çeşitli işlemler yapıyorsunuz. Daha sonra belirli bir işlemi yapmak için “ali” adlı hesaba geçmeniz gerekti. Bunun için su ali yazıp şifresini girmeniz yeterli. Eğer “ali” diye herhangi bir kullanıcı belirtmezseniz varsayılan olarak root kullanıcısı hesabı seçilir ve sizden root şifresi istenir.
sudo bir komutu başka bir kullanıcı olarak çalıştırmak için kullanılır. Herhangi bir kullanıcı belirtilmemişse root kullanıcısı varsayılan olarak seçilir.
su means change user, as in, start a shell as that user. You can specify which user,such as su someuser. You are then prompted for someuser’s password. If you don’t specify a user, su defaults to the root user. So when you type su, it is asking for the root password.
sudo means, run a command as another user, and sudo -i means, run a login shell as another user. You can specify which user, but if you don’t, it defaults to root. Instead of expecting the password of the other user like su does, sudo applies a security policy. The default security policy is to check the file /etc/sudoers. The default version of that file includes this:
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
which means that, if the user is in the sudo group, it can run any command as any user. If sudo -i works for you, it’s probably because your own account is in the sudo group. But before sudo executes the command, it asks for your password again—not the password of the root user.
https://unix.stackexchange.com/questions/559201/why-cannot-i-become-root-via-su\


Leave a Reply