Linux Classroom Series – 13/Jul/2020

Changing identities

  • Often, we want to gain superuser previleges to carry out some adminstritative tasks. what are possible ways

    1. Logout and log back in as alternative user
    2. Use the su command
    3. Use the sudo command
  • For experimentation lets create 3 user john, rick, siva

sudo -i # become root user
adduser john
adduser rick
adduser siva

  • Since in AWS password authentications are disabled we will be enabling
vi /etc/ssh/sshd_config
change PasswordAuthentication to yes
service sshd restart
exit

su: Run Shell with Substitute User and Group Id

  • su command will look like
su [-[l]] [user]
  • Execute help for su
man su
su --help
  • Lets try to become john
  • Lets try to becom rick
  • If you want to becom root user and if root user has a password
su -
  • Lets look at file ‘/etc/passwd’
  • With default user (ubuntu) lets execute sudo apt-get update and it works
  • Lets try to execute same command by switching user to john
  • How to give john the permission to execute sudo commands?
    • become ubuntu (default) user
sudo cat /etc/sudoers

  • John is not part of sudoers file so lets add john to sudoers
# login as default user (ubuntu)
sudo visudo

  • If we want to execute any command with sudo on the ubuntu machine user should be part of sudoers file, then user can execute commands with sudo.
  • Sudo is run a command as superuser

chown: Change File Owner and group

  • Lets create a simple file as john
  • I want to change the owner of this file to rick. This is where a linux command chown comes into play
man chown
chown --help
  • Syntax is
chown [owner][:[group]] <file>
  • lets change ownership of a file
  • Now lets see how to change ownership of folder

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%