È possibile scoprire chi ha effettuato l'accesso al server dalla riga di comando? Sì, è possibile utilizzare alcuni comandi Linux. Esaminiamo come rilevare i nomi utente registrati nel server Linux.
3 comandi per scoprire chi ha effettuato l'accesso al server
w comando
Il comando w stampa informazioni utili su quanti utenti hanno effettuato l'accesso all'interno del server e quali sono i loro processi in esecuzione. Esempio:
[[email protected]:~]w 21:36:01 up 274 days, 17:33, 1 user, load average: 0.19, 0.24, 0.29 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT ultrauser pts/0 111.111.111.111 20:46 0.00s 0.02s 0.00s sshd: ultrauser [priv] [[email protected]:~]
Per visualizzare maggiori informazioni su un determinato utente, puoi eseguire questo comando:
w user
Dove utente è il nome utente. Esempio:
[[email protected] ~]$ w webtech 23:39:16 up 54 min, 1 user, load average: 0,48, 0,48, 0,41 USER TTY [email protected] IDLE JCPU PCPU WHAT webtech tty2 22:45 54:28 14:38 2.52s /opt/google/chrome/chrome --type=renderer --enable-features=*AutofillCreditCardSigninPromo<AutofillCr [[email protected] ~]$
che comanda
who command è un altro comando che può aiutare a scoprire chi ha effettuato l'accesso al server.
Esempio di output:
[[email protected]:~]who ultrauser pts/0 2017-01-29 20:46 (111.111.111.111) [[email protected]:~]
Puoi anche usare l'opzione -a per stampare tutte le informazioni complete. Esempio di output:
[[email protected]:~]who -a system boot 2016-04-30 05:03 run-level 3 2016-04-30 05:03 LOGIN tty1 2016-04-30 05:03 7200 id=1 LOGIN tty2 2016-04-30 05:03 7202 id=2 LOGIN tty3 2016-04-30 05:03 7204 id=3 LOGIN tty4 2016-04-30 05:03 7206 id=4 LOGIN tty5 2016-04-30 05:03 7208 id=5 LOGIN tty6 2016-04-30 05:03 7210 id=6 ultrauser + pts/0 2017-01-29 20:46 . 13648 (111.111.111.111) pts/1 2017-01-27 08:45 24158 id=ts/1 term=0 exit=0 pts/2 2016-09-16 15:08 32364 id=ts/2 term=0 exit=0 pts/3 2017-01-04 17:09 15024 id=ts/3 term=0 exit=0 pts/2 2016-07-22 08:45 22855 id=/2 term=0 exit=0 pts/1 2016-10-03 16:41 25856 id=/1 term=0 exit=0 pts/4 2017-01-03 16:52 25470 id=ts/4 term=0 exit=0 pts/5 2017-01-03 13:31 26228 id=ts/5 term=0 exit=0 [[email protected]:~]
Ci sono molte opzioni da passare al comando who:
-a, --all same as -b -d --login -p -r -t -T -u -b, --boot time of last system boot -d, --dead print dead processes -H, --heading print line of column headings -l, --login print system login processes --lookup attempt to canonicalize hostnames via DNS -m only hostname and user associated with stdin -p, --process print active processes spawned by init -q, --count all login names and number of users logged on -r, --runlevel print current runlevel -s, --short print only name, line, and time (default) -t, --time print last system clock change -T, -w, --mesg add user's message status as +, - or ? -u, --users list users logged in --message same as -T --writable same as -T --help display this help and exit --version output version information and exit
comando utenti
Il comando users stampa i nomi di accesso degli utenti che sono attualmente accesi al sistema, ma ordinati e su un'unica riga. Il comando users legge le informazioni dal file utmp.
Esempio di output:
[[email protected]:~]users ultrauser johndoe linuxuser2 alterego34
Come vedi, il comando "utenti" è molto semplice e non puoi ottenere troppe informazioni.
Comando con il dito
Sebbene finger command non sia un comando per scoprire chi ha effettuato l'accesso al server, può aiutarti a recuperare le informazioni sull'utente se hai bisogno di conoscere maggiori dettagli.
Esempio di output:
[[email protected]:~]finger ultrauser Login: ultrauser Name: John Bonachon Directory: /home/ultrauser Shell: /bin/bash On since Sun Jan 29 20:46 (EST) on pts/0 from 111.111.111.111 No mail. No Plan.
Come puoi vedere, l'uso del comando finger può aiutarti a scoprire ulteriori informazioni come il tipo di shell utilizzata, la home directory, il nome reale, il nome utente di accesso e l'ultima volta che è stato visto online.
Riferimenti:
- Linux che comanda
- Comando Linux w