Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    To prevent setting currentuser (sometime) with multiline users, use $(who | awk 'NR==1{print $1}') instead. Commented Feb 12, 2018 at 12:31
  • I am trying to change /usr to my user: chown -R $currentuser:$currentuser /usr - does not work - still shows root:root Commented Dec 23, 2019 at 3:34
  • (1) who is not guaranteed to produce any output.  (2) If it does, there is no guarantee that the first line of output identifies the current user.  What if somebody ssh’ed into your system?  What if you are ssh’ed into some other system? (3) logname seems to be more reliable. Commented Jun 27, 2022 at 6:16