sudo nmap -F -O | grep "Running: " > /tmp/os; echo "$(cat /tmp/os | grep Linux | wc -l) Linux device(s)"; echo "$(cat /tmp/os | grep Windows | wc -l) Window(s) devices"

How many Linux and Windows devices are on your network?

Shows how many Windows and Linux devices are on your network. May add support for others, but that's all that are on my network right now.
Sample Output
3 Linux device(s)
2 Window(s) devices

These Might Interest You

  • Find installed network devices. Show Sample Output

    sudo lshw -C network
    cantormath · 2012-06-07 10:32:49 0
  • Is there somebody that uses Windows a lot that keeps messing up your Linux machine? Press Ctrl+Alt+F1-F6 and run this command after logging into a text shell!

    export PS1="C:\\>"; clear
    ThePCKid · 2011-06-18 17:52:42 0
  • If you use Linux in a Windows domain and there are N days to expiry, this is how you can change it without resorting to a windows machine.

    smbpasswd -r <domain-server> -U <user name>
    greppo · 2009-08-12 07:46:48 0
  • Mount a Windows share. Usually the IP is needed for the $ip_or_host option. Getting hostnames working on a local network never seems to work.

    sudo mount -t cifs //$ip_or_host/$sharename /mnt
    sb · 2009-11-23 14:24:02 0
  • Doesn't work so well if you connect from windows. Linux only sends LF where windows wants CRLF. The alternative command works better with windows, however it uses script and a named pipe.

    bash -i 2>&1 | tee /dev/stderr | nc -l 5000
    pykler · 2010-10-20 18:32:12 0
  • You can read, add, delete and modify Windows permissions from Linux using smbcacls from the smb-client package. Show Sample Output

    smbcacls //server/sharename file -U username
    drossman · 2009-02-16 18:52:14 0

What Others Think

Believe there is an error, nmap output is sent to /tmp/os, while the cat is done on /tmp/network. Both files must be the same.
wizel · 436 weeks and 1 day ago
This will work if you substitute /tmp/network for /tmp/os in your command.
mattmartini · 436 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: