This is done by simply running the who
command (without any options). Consider the following example:
$ who
himanshu tty7 2012-08-07 05:33 (:0)
himanshu pts/0 2012-08-07 06:47 (:0.0)
himanshu pts/1 2012-08-07 07:58 (:0.0)
List all local users
You can list all the local users by doing a simple cat of the passwd (/etc/passwd) file.
cat /etc/passwd
List only real users
Let’s assume that the real users on the system have a home directory at /home.
cat /etc/passwd | grep '/home' | cut -d: -f1
List all users
If you need to get a list of all the users that have access to the system across many authentication services such as NIS, LDAP etc, then the command is getent
.
You can use the cut
, grep
and awk
commands to modify and format the output as described in the previous commands.
getent passwd | cut -d: -f1
getent passwd | awk " { print $1 }"
for the rest, see https://unix.stackexchange.com/questions/269617/linux-equivalent-to-powershells-one-to-many-remoting/269626 ; I advise focusing in one question at a time here in the future. Get also familiar with our FAQ, asking for tutorial is off-topic. – Rui F Ribeiro Feb 13 '18 at 13:30