Find the answer to your Linux question:
Results 1 to 10 of 10
we all know that we can use su to change as root from terminal to work on important files. is there is any possibility to switch as another normal user ...
  1. #1
    Just Joined!
    Join Date
    Aug 2006
    Location
    London Uk
    Posts
    93

    is it possible to change between users from terminal

    we all know that we can use su to change as root from terminal to work on important files.

    is there is any possibility to switch as another normal user from the terminal.
    for ex:
    if we have two normal users: user1 and user2

    if i am logged in as user1, is it possible to change as user2 if know user2's password.

    thanks.

  2. #2
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    Yep, the same su command will do it:
    Code:
    $ su user2
    Password:
    Stand up and be counted as a Linux user!

  3. #3
    Just Joined!
    Join Date
    Aug 2006
    Location
    London Uk
    Posts
    93
    thanks very much...that works

  4. #4
    Just Joined!
    Join Date
    Aug 2006
    Location
    London Uk
    Posts
    93
    i have a doubt...if i change to another user in terminal...then i am able to do operations related to the changed user only in terminal but the graphical interface still points to the old user and i am not able to operations related to the changed user lets say in gnome.

  5. #5
    Banned jan1024188's Avatar
    Join Date
    Jul 2006
    Location
    EU, SLOVENIA
    Posts
    1,549
    if you change the user in terminal you would be able to do anything with that user in terminal.To change user in GUI (Graphical user interface) log out and log in as diferent user

    i hope that helps

  6. #6
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Quote Originally Posted by raghavan20
    i have a doubt...if i change to another user in terminal...then i am able to do operations related to the changed user only in terminal but the graphical interface still points to the old user and i am not able to operations related to the changed user lets say in gnome.
    launch GUI from terminal...
    for file browser
    $ nautilus

    <=== { casper } ===>
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  7. #7
    Just Joined!
    Join Date
    Aug 2006
    Location
    London Uk
    Posts
    93
    casper your answer sounded interesting,,,but when i tried to launch nautilus, it says.
    Code:
    Xlib: connection to ":0.0" refused by server
    Xlib: No protocol specified
    
    (nautilus:3272) Gtk-WARNING **: cannot open display:
    i then tried to open a file belonging to the changed user from terminal in kwrite...it displays the following...
    Code:
    Xlib: connection to ":0.0" refused by server
    Xlib: No protocol specified
    
    kwrite: cannot connect to X server:0.0

  8. #8
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,228
    Ah, no. You have to be in X already. So with X running as user1, if you open an xterm (or Konsole, or GNOME Terminal, or whatever), change user, and run a graphical application, it will run as the changed user.
    DISTRO=Arch
    Registered Linux User #388732

  9. #9
    Just Joined!
    Join Date
    Aug 2006
    Location
    London Uk
    Posts
    93
    alright...i will explain again what i did
    l logged in to X as user1, opened terminal, used su user2, tried to launch nautilus and it gave up the error i posted earlier.

  10. #10
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Location
    Riverton, UT, USA
    Posts
    1,001
    Right, that's due to something called xauthority. By default, only the user who's logged into the X session has the authority to launch X clients. You can pass your authority to others using the xhost command. As user1,
    Code:
    $ xhost user2
    will allow user2 to use your X server, or
    Code:
    xhost+
    allows anyone and everyone to use it. See the xhost manpage for more details.

    My preference is to install the sux package and just use sux instead of su to switch users, and sux takes care of all the authority stuff.
    Stand up and be counted as a Linux user!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...