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


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 Preview
  • Lets try to becom rick Preview
  • If you want to becom root user and if root user has a password
su -
  • Lets look at file ‘/etc/passwd’ Preview
  • With default user (ubuntu) lets execute sudo apt-get update and it works Preview
  • Lets try to execute same command by switching user to john Preview
  • 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

Preview Preview

  • 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 Preview
  • 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 Preview
  • Now lets see how to change ownership of folder Preview

Leave a Reply

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

About learningthoughtsadmin