• Newsticker

    Rabu, 30 Mei 2018

    How To View System Users in Linux on Ubuntu

    Introduction

    A fundamental part of system administration is configuring and managing users and groups. Part of this task involves monitoring the log in capabilities of all system entities.
    In this guide, we will introduce the basic ideas behind user management and authentication logging.
    We will be exploring these concepts on an Ubuntu 12.04 VPS, but you can follow along on any up-to-date Linux distribution.
    Part one will cover how to view system users and find out who is logged into the system.

    How To View Available Users on a VPS

    Every user on a Linux system, whether created as an account for a real human being or associated with a particular service or system function, is stored in a file called "/etc/passwd".
    The "/etc/passwd" file contains information about the users on the system. Each line describes a distinct user.
    Have a look by entering:
    less /etc/passwd
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/bin/sh
    bin:x:2:2:bin:/bin:/bin/sh
    sys:x:3:3:sys:/dev:/bin/sh
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/bin/sh
    . . .
    Each line is broken up into fields. These fields are delimited by the colon (:) character.
    The only field that we are really interested in at the moment is the first one. Each is an independent username.
    We can get this list without wading through the entire "/etc/passwd" by typing:
    cut -d : -f 1 /etc/passwd
    root
    daemon
    bin
    sys
    sync
    games
    . . .
    You probably recognize "root" as the administrative user. Towards the end, you may see the user you are logged in as.
    In between, you will probably see a number of other users whose usage seems at least somewhat clear. For instance, "www-data" is configured as the owner of web server processes.
    This is done to separate functional privileges. That way, if an account is compromised or misused, the affect will be isolated.

    How To View Available Groups on a VPS

    The corresponding file for discovering system groups is "/etc/group".
    We can see the whole file by typing:
    less /etc/group
    root:x:0:
    daemon:x:1:
    bin:x:2:
    sys:x:3:
    adm:x:4:
    tty:x:5:
    disk:x:6:
    . . .
    You can see that many of the group names mirror the users we discovered on our system. This is part of a configuration scheme called "user private groups", or UPG.
    User private groups create a private group for each user and set that group as the primary group. The umask is then changed from 022 to 002.
    This allows for more flexibility in shared directories by setting a flag called setgid, which gives files inside the directory the same group owner as the directory itself. This configuration is useful, but outside of the scope of this article.
    Once again, we can pare down the information from the "/etc/group" file by using the cut command:
    cut -d : -f 1 /etc/group
    root
    daemon
    bin
    sys
    adm
    tty
    disk
    . . .
    The output will be a list of each group on the system, one per line.

    How To Find Which Users Are Logged In

    Many times, it will be more useful to find out which users are active on your system.
    The "w" command is a simple way to list all of the currently logged in users, their log in time, and what the command they are currently using:
    w
    19:37:15 up  5:48,  2 users,  load average: 0.33, 0.10, 0.07
    USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
    root     pts/0    rrcs-72-43-115-1 19:15   38.00s  0.33s  0.33s -bash
    demoer   pts/1    rrcs-72-43-115-1 19:37    0.00s  0.47s  0.00s w
    The first line contains system uptime information. The following lines describe who is logged in.
    An alternative that provides similar information is "who":
    who
    root     pts/0        2013-09-05 19:15 (rrcs-72-43-115-186.nyc.biz.rr.com)
    demoer   pts/1        2013-09-05 19:37 (rrcs-72-43-115-186.nyc.biz.rr.com)

    Conclusion

    User authentication on Linux is a relatively flexible area of system management. There are many ways of accomplishing the same objective with very simple tools.
    You should now know how to find out where your server stores its user and group information. You can also see who is logged in at any given time.
    In the next part, we will discuss how to restrict access to logins.
    >Introduction
    A fundamental part of system administration is configuring and managing users and groups. Part of this task involves monitoring the log in capabilities of all system entities.
    In this guide, we will introduce the basic ideas behind user management and authentication logging.
    We will be exploring these concepts on an Ubuntu 12.04 VPS, but you can follow along on any up-to-date Linux distribution.
    Part one will cover how to view system users and find out who is logged into the system.

    How To View Available Users on a VPS

    Every user on a Linux system, whether created as an account for a real human being or associated with a particular service or system function, is stored in a file called "/etc/passwd".
    The "/etc/passwd" file contains information about the users on the system. Each line describes a distinct user.
    Have a look by entering:
    less /etc/passwd
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/bin/sh
    bin:x:2:2:bin:/bin:/bin/sh
    sys:x:3:3:sys:/dev:/bin/sh
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/bin/sh
    . . .
    Each line is broken up into fields. These fields are delimited by the colon (:) character.
    The only field that we are really interested in at the moment is the first one. Each is an independent username.
    We can get this list without wading through the entire "/etc/passwd" by typing:
    cut -d : -f 1 /etc/passwd
    root
    daemon
    bin
    sys
    sync
    games
    . . .
    You probably recognize "root" as the administrative user. Towards the end, you may see the user you are logged in as.
    In between, you will probably see a number of other users whose usage seems at least somewhat clear. For instance, "www-data" is configured as the owner of web server processes.
    This is done to separate functional privileges. That way, if an account is compromised or misused, the affect will be isolated.

    How To View Available Groups on a VPS

    The corresponding file for discovering system groups is "/etc/group".
    We can see the whole file by typing:
    less /etc/group
    root:x:0:
    daemon:x:1:
    bin:x:2:
    sys:x:3:
    adm:x:4:
    tty:x:5:
    disk:x:6:
    . . .
    You can see that many of the group names mirror the users we discovered on our system. This is part of a configuration scheme called "user private groups", or UPG.
    User private groups create a private group for each user and set that group as the primary group. The umask is then changed from 022 to 002.
    This allows for more flexibility in shared directories by setting a flag called setgid, which gives files inside the directory the same group owner as the directory itself. This configuration is useful, but outside of the scope of this article.
    Once again, we can pare down the information from the "/etc/group" file by using the cut command:
    cut -d : -f 1 /etc/group
    root
    daemon
    bin
    sys
    adm
    tty
    disk
    . . .
    The output will be a list of each group on the system, one per line.

    How To Find Which Users Are Logged In

    Many times, it will be more useful to find out which users are active on your system.
    The "w" command is a simple way to list all of the currently logged in users, their log in time, and what the command they are currently using:
    w
    19:37:15 up  5:48,  2 users,  load average: 0.33, 0.10, 0.07
    USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
    root     pts/0    rrcs-72-43-115-1 19:15   38.00s  0.33s  0.33s -bash
    demoer   pts/1    rrcs-72-43-115-1 19:37    0.00s  0.47s  0.00s w
    The first line contains system uptime information. The following lines describe who is logged in.
    An alternative that provides similar information is "who":
    who
    root     pts/0        2013-09-05 19:15 (rrcs-72-43-115-186.nyc.biz.rr.com)
    demoer   pts/1        2013-09-05 19:37 (rrcs-72-43-115-186.nyc.biz.rr.com)

    Conclusion

    User authentication on Linux is a relatively flexible area of system management. There are many ways of accomplishing the same objective with very simple tools.
    You should now know how to find out where your server stores its user and group information. You can also see who is logged in at any given time.
    In the next part, we will discuss how to restrict access to logins.

    Sumber: https://www.digitalocean.com/community/tutorials/how-to-view-system-users-in-linux-on-ubuntu

    Tidak ada komentar:

    Posting Komentar

    Agama

    Jaringan

    Android

    Linux

    Catatan

    Mikrotik