- How to show current logged in users in Linux
- How to show current logged in users in Linux
- Find out who you are currently logged in as on Linux
- Linux show who is logged on
- Conclusion
- 6 commands to check and list active SSH connections in Linux
- Check active SSH connections
- 1. Using ss command
- 2. Using last command
- 3. Using who command
- 4. Using w command
- 5. Using netstat command
- How to Find What Devices are Connected to Network in Linux
- A. Using Linux command to find devices on the network
- Step 1: Install nmap
- Step 2: Get IP range of the network
- Step 3: Scan to find devices connected to your network
- B. Using GUI tool to find devices connected to network
- 4 Ways to Identify Who is Logged-In on Your Linux System
- 1. Get the running processes of logged-in user using w
- 2. Get the user name and process of logged in user using who and users command
- Users Command
- 3. Get the username you are currently logged in using whoami
- 4. Get the user login history at any time
- How to find out what computers are connected to an access point/router using Linux terminal?
- 4 Answers 4
How to show current logged in users in Linux
All user names are stored in /etc/passwd file and can be displayed with help of cat command or grep command/egrep command:
cat /etc/passwd
grep ‘^userNameHere’ /etc/passwd
grep ‘^tom’ /etc/passwd
Let us see all examples and usage in details.
How to show current logged in users in Linux
- The current time ( 22:11:17 )
- How long the Linux server has been running (18 days)
- How many users are currently logged on Linux (2 users)
- The system load averages for the past 1, 5, and 15 minutes (1.01, 1.04, 1.05)
The following info displayed for each current logged in user:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
- sweta – Login name
- pts/10 – The tty name
- minitx – The remote host/desktop/laptop name
- 22:11 – Login time
- 5.00s – Idle time
- 0.04s – JCPU (it the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.)
- 0.02s – PCPU (it is the time used by the current process, named in the “what” field.)
- vim replicant.py – The command line of their current process
Find out who you are currently logged in as on Linux
Execute the following command:
whoami
Another option is to just type the following id command:
id
Use the whoami and id commands to find out who you are currently logged in as on Linux based system
Linux show who is logged on
Conclusion
This page showed how to find out current logged in users in Linux and what they are doing from the terminal. For more info see man pages using the man command:
man w
man who
man whoami
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
6 commands to check and list active SSH connections in Linux
Table of Contents
How to check active SSH connections in Linux. Show SSH connection history. How to show active ssh sessions in Linux. List all the active SSH connections in Unix. Find out all the currently active ssh connections on any Linux node. Which all tools can be used to list all the active ssh connections in Linux. Show active SSH sessions. Check ssh connection history using log files in Linux.
Some more more articles you may be interested on similar topics:
Check active SSH connections
There are various commands and tools available in Linux which can be used to check active SSH connections or sessions on your Linux node. In this article I will share a list of tools which can be used to get the list of active SSH connections. If you are aware of any more commands to show active ssh sessions then please let me know via comment section.
1. Using ss command
ss is used to dump socket statistics. It allows showing information similar to netstat . It can display more TCP and state information than other tools. We will use grep function to only get the list of active SSH sessions on our local host
From the above example we know that there are three hosts which are currently connected to our node3. We have active SSH connections from 10.0.2.31, 10.0.2.30 and 10.0.2.2
2. Using last command
last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty’s can be given, in which case last will show only those entries matching the arguments.
Using this command you can also get the information about the user using which the SSH connection was created between server and client. So below we know the connection from 10.0.2.31 is done using ‘deepak‘ user, while for other two hosts, ‘root‘ user was used for connecting to node3.
Here I am grepping for a string «still» to get all the patterns with » still logged in «. So now we know we have three active SSH connections from 10.0.2.31, 10.0.2.30 and 10.0.2.2
3. Using who command
who is used to show who is logged on on your Linux host. This tool can also give this information
Using this command we also get similar information as from last command. Now you get the user details used for connecting to node3 from source host, also we have terminal information on which the session is still active.
4. Using w command
w displays information about the users currently on the machine, and their processes. This gives more information than who and last command and also serves our purpose to get the list of active SSH connections. Additionally it also gives us the information of the running process on those sessions.
Using w command you will also get the idle time details, i.e. for how long the session is idle. If the SSH session is idle for long period then it is a security breach and it is recommended that such idle SSH session must be killed, you can configure your Linux host to automatically kill such idle SSH session.
5. Using netstat command
Similar to ss we have netstat command to show active ssh sessions. Actually we can also say that ss is the new version of netstat. Here we can see all the ESTABLISHED SSH sessions from remote hosts to our localhost node3. it is also possible that one or some of these active ssh connections are in hung state so you can configure your host to automatically disconnect or kill these hung or unresponsive ssh sessions in Linux.
Источник
How to Find What Devices are Connected to Network in Linux
Last updated September 30, 2019 By Abhishek Prakash 60 Comments
Brief: This quick trick shows you how to find devices connected to your local network in Linux.
Wireless networks have always been a desirable target for wannabe hackers. Wireless networks are also more vulnerable to hacking than the wired ones.
Forget hacking, do you ever wonder that someone might be leeching off your hard paid wifi network? Maybe a neighbor who once connected to your network and now uses it as his/her own?
It would be nice to check what devices are on your network. This way you can also see if there are some unwanted devices on your network.
So you might end up thinking, “how do I find what devices are connected to my network”?
I’ll show you how to do that in this quick tutorial. Not only it’s a good idea from security point of view, it is also a good little exercise if you have interest in networking.
We will use both, command line and GUI, way for finding out what devices are connected to your local network in Linux. The process is very simple and easy to use even for beginners.
A. Using Linux command to find devices on the network
Step 1: Install nmap
nmap is one of the most popular network scanning tool in Linux. Use the following command to install nmap in Ubuntu based Linux distributions:
You can easily install it in other Linux distributions as well. It should be in the official software repository.
Step 2: Get IP range of the network
Now we need to know the IP address range of the network. Use the ifconfig command to find the IP address in Linux. Look for wlan0 if you are using wifi or eth0 if you are using Ethernet.
$ ifconfig
wlan0 Link encap:Ethernet HWaddr 70:f1:a1:c2:f2:e9
inet addr:192.168.1.91 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::73f1:a1ef:fec2:f2e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2135051 errors:0 dropped:0 overruns:0 frame:0
TX packets:2013773 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1434994913 (1.4 GB) TX bytes:636207445 (636.2 MB)
The important things are highlighted in bold. As you see my IP is 192.168.1.91 and the subnet mask is 255.255.255.0 which means that the ip address range on my network varies from 192.168.1.0 to 192.168.1.255.
You may also use ip a command to know your IP address in Ubuntu and other Linux distributions.
At the same time, I’ll recommend you to read about basic Linux networking commands for more information.
Step 3: Scan to find devices connected to your network
It is advisable to use root privileges while scanning the network for more accurate information. Use the nmap command in the following way:
$ sudo nmap -sn 192.168.1.0/24
Starting Nmap 5.21 ( http://nmap.org ) at 2012-09-01 21:59 CEST
Nmap scan report for neufbox (192.168.1.1)
Host is up (0.012s latency).
MAC Address: E0:A1:D5:72:5A:5C (Unknown)
Nmap scan report for takshak-bambi (192.168.1.91)
Host is up.
Nmap scan report for android-95b23f67te05e1c8 (192.168.1.93)
Host is up (0.36s latency).
As you can see that there are three devices connected to my network. The router itself, my laptop and my Galaxy S2.
If you are wondering about why I used 24 in the above command, you should know a little about CIDR notation. It basically means that the scanning will be from 192.168.1.0 to 192.168.1.255.
B. Using GUI tool to find devices connected to network
When I first wrote this article, there was no GUI tool for this task. Then I saw a Google+ discussion about a new network monitoring tool being developed for elementary OS. I suggested including a periodic device scan feature in this tool and the developer readily agreed.
So, now we have a GUI tool that does this task. It’s called Nutty. Just run install this app and run it. It will periodically scan for new devices on the network and will notify you if there is a new device.
This application is only available for elementary OS, Ubuntu and hopefully, other Ubuntu based Linux distributions. You can find installation instructions on this detailed article on Nutty.
Oh, you can also log in to your router and see the devices connected to your devices. I let you figure the best way to find devices connected to your network.
Like what you read? Please share it with others.
Источник
4 Ways to Identify Who is Logged-In on Your Linux System
This article is written by Hari Haran.
As a system administrator, you may want to know who is on the system at any give point in time. You may also want to know what they are doing. In this article let us review 4 different methods to identify who is on your Linux system.
1. Get the running processes of logged-in user using w
w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:
- Name of the user
- User’s machine number or tty number
- Remote machine address
- User’s Login time
- Idle time (not usable time)
- Time used by all processes attached to the tty (JCPU time)
- Time used by the current process (PCPU time)
- Command currently getting executed by the users
Following options can be used for the w command:
- -h Ignore the header information
- -u Display the load average (uptime output)
- -s Remove the JCPU, PCPU, and login time.
2. Get the user name and process of logged in user using who and users command
who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.
To get a list of all usernames that are currently logged in, use the following:
Users Command
users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version. If the user using, ‘n’ number of terminals, the user name will shown in ‘n’ number of time in the output.
3. Get the username you are currently logged in using whoami
whoami command is used to print the loggedin user name.
whoami command gives the same output as id -un as shown below:
who am i command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.
Also, if you do su to some other user, this command will give the information about the logged in user name details.
4. Get the user login history at any time
last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:
- User name
- Tty device number
- Login date and time
- Logout time
- Total working time
This article is written by Hari Haran. He is working in bk Systems (p) Ltd, and interested in contributing to the open source. The Geek Stuff welcomes your tips and guest articles.
Источник
How to find out what computers are connected to an access point/router using Linux terminal?
I would like to determine what computers are currently connected to my access point/router via the command line in Linux.
How can I do this?
4 Answers 4
You can also try:
arp-scan [network/CIDR] eg: arp-scan 192.168.1.0/24
You may need to install arp-scan — most major distributions have it in their repos.
nmap -A -T4 ‘ip of your network’
If you feel adventurous, you can use arp -a which will try to resolv IP.
This will show you only local host with active connection.
arp is somehow deprecated, now you sould use ip n (n as neighbour).
Depending on Linux version and also on network configuration you need to supply network information for arp-scan so it knows what to scan as you may have (and usually you do) multiple interfaces.
I’d recommend this command options
First of all, you may need sudo because arp-scan uses some services that require root privileges.
—localnet frees you from having to know your IP and it will scan 256 addresses like 192.168.1.0/24 but will handle address for you automagically.
—interface=en1 is the interface it will use in case default en0 is not your active link. To check which interface is active along with other useful information use
If you are using Mac OS X, you will need to install package. To do so, visit Rudix repository, download and install package (you will need administrative privileges and password) and then use like I suggested.
Источник