How do I stop using root privileges?

132

Solution 1

User privileges are associated with processes. In this case, your superuser privileges are associated with the shell that ran when you did sudo su. You need to exit that shell. To do that use the aptly-named exit command.

If you haven't messed with the prompt definitions, superuser status is indicated by a # in the prompt instead of the user's $.

Solution 2

When you su, a new login shell is started for the root user; to drop root privilege and go back to your usual login, simply logout or hit Control-D.

Share:
132

Related videos on Youtube

Quazmai
Author by

Quazmai

Updated on September 18, 2022

Comments

  • Quazmai
    Quazmai over 1 year

    I'm given the following method written in pseudo-code

    for i=1 to floor(n/2)
        if arr[i] != 0 then
           for(j=2 to floor(n/i)
             arr[i*j] = 0
    

    I need to find the output and to prove that it's indeed the output.

    So far I tried to write the code in Java and to try different inputs and array sizes but to no avail. Putting it here if it's of any help:

    public class Checking
    {
        private static int method(int[] A,int n)
        {
            for (int i=1;i<=java.lang.Math.floor(n/2);i++)
            {
                if(A[i] != 0)
                {
                    for(int j=2;j<=java.lang.Math.floor(n/i);j++)
                    {
                        A[i*j]=0;
                        System.out.println("The index ofA["+i*j+"] became "+A[i*j]);
                    }
                }
    
                //System.out.print(", "+A[i]);
            }
    
            for (int i=1;i<=java.lang.Math.floor(n/2);i++)
            {
                System.out.print(", "+A[i]);
            }
    
            return 0;
        }
    
        public static void main(String[] args)
        {
            int[] A = {-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
            System.out.println(method(A,20));
        }
    }
    

    Thank you.

    • Isaac Rabinovitch
      Isaac Rabinovitch about 11 years
    • TheWildHealer
      TheWildHealer over 4 years
      What's your question? Does your code give an error? In that case, include the error message. Does it give a wrong output? In that case, include expected and actual outputs and how they differ.
  • Brian Peterson
    Brian Peterson about 11 years
    Thanks a lot. Immediately after writing my question, I tried "su my_name", because I realized it stands for substitute user. I also thought it worked, until I tried "exit" as you suggested, haha.
  • Alex.K.
    Alex.K. over 9 years
    Also you can use hot key combination 'Ctrl+D' to to exit superuser shell.
  • Quazmai
    Quazmai over 4 years
    Hi, thank you for the answer, but missing the first index is intentional, as the pseudo-code dictates (was weird for me too). The rest is fixed but still my question remains unsolved :(
  • Ioannis Barakos
    Ioannis Barakos over 4 years
    The pseudo-code explains how to update the array. The second loop (starting from index 0) shows how to print the array. So you use the pseudo code to update A but you need some code to print All the array date. I updated the answer with a simplest print solution for arrays