Thursday, May 2, 2024
23
rated 0 times [  23] [ 0]  / answers: 1 / hits: 123226  / 3 Years ago, thu, may 13, 2021, 5:14:37

This is a question that I would expect to quickly get an answer from google. However somehow google is failing me. Let's assume I'm logged in to a terminal session and I would like temporarily work as another non-root user whose password I know without leaving my session. When logged as this user I want the home directory, etc, for this user set up correctly until I log out. How do I do that?



I tried



su -- username


and then keying in the password, it did not produce any error but I saw no visible changes of the command prompt it would still say myname@myhost. The home directory also was that of myname and not the new login I tried to login as.



I'm - as it's apparent now - quite inexperienced in linux/Ubuntu, so any info is welcome.


More From » command-line

 Answers
3

To which user you want to change to?



The problem is that you are trying to "su" into a user that does not have a shell assigned to it. Most of the users such as mysql, pulse, etc, created by the system or by some packages when you install software does not have a shell assigned.



You can check if a user has a shell assigned by looking into the /etc/passwd file, just look at the end of the line of each user, if it says /bin/false it means that it does not have a shell assigned, if it has something like /bin/bash or any other shell, then you should be able to "su" into that user.



When i say "shell assigned" it basically means that it has "shell access"



still if the user does not have shell access, you can always execute commands as that user with



 sudo -u user command

[#34253] Friday, May 14, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
barted

Total Points: 424
Total Questions: 103
Total Answers: 101

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
barted questions
;