You are reading the article Watch Network Traffic In Mac Os X Via Command Line With Nettop updated in December 2023 on the website Achiashop.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Watch Network Traffic In Mac Os X Via Command Line With Nettop
nettop has a wide variety of uses, but it can be particularly helpful when trying to determine what is using the Macs internet connection and networking interfaces, what is communicating with what and how much data is being transferred, and it’s also just a great utility for network troubleshooting. Command line tools aren’t for everyone though, and for users who would like to view similar network information in a more traditional OS X app format, the free Mac app
Using nettop to Monitor Network Traffic & ConnectionsMac OS X includes an excellent command line network utility called “nettop” that allows users to monitor all network activity, traffic, and routes from a Mac to the outside world, both through local (LAN) and wide area (WAN) connections. If you’re unfamiliar with networking tools like this, you can think of nettop as a network centric task manager, displaying active networking connections, sockets and routes, their respective names and process id, the state of the connection and whether the connection is established, waiting, or listening, and information about individual process data transfer. It’s a bit like the standard ‘top’ and ‘htop’ commands which show process and resource information, but rather than showing CPU and RAM usage, it will show live network transfer information like packets sent and received, packet size, and total data transferred.nettop has a wide variety of uses, but it can be particularly helpful when trying to determine what is using the Macs internet connection and networking interfaces, what is communicating with what and how much data is being transferred, and it’s also just a great utility for network troubleshooting. Command line tools aren’t for everyone though, and for users who would like to view similar network information in a more traditional OS X app format, the free Mac app Private Eye is an excellent GUI tool that provides similar information.
Getting started with nettop is easy enough. Open Terminal from /Applications/Utilities, and at the command prompt, type “nettop” to immediately see active network connections and traffic:
nettop
Use the down arrow key to scroll down and you’ll soon start to identify processes that you’ll recognize by name, coinciding with apps or processes that are currently in use.
To see the most amount of information, you’ll want to increase the size of the window as large as possible, hit the green maximize button and consider decreasing the font size of the terminal window if you can’t see all that you want to. Hitting the “p” button to put the output displayed by nettop into human readable format is also very helpful for most of us.
Once in nettop you can adjust the output a bit to see more or less information for specific processes and their network communications. Basic nettop commands are:
p – changes to and from human readable format (i.e.: kilobytes and megabytes rather than pure byte count)
d – show delta count (i.e.: active change in packet count rather than total packets
Up & Down arrow keys – navigate up and down in the list
Right & Left arrow keys – expand or collapse specific process or routing groups
q – quit out of nettop
Formatting is easy to follow, despite what the pasted sample block looks like below:
You can also use nettop to just view routing table information if you don’t want to see specific sockets and processes
nettop -m route
The routing information will show the connections from hardware to destination IP, for example, you may see en0 (wi-fi) to the local network IP to a remote server, and you will also see loopback information.
Using the -m flag you can also limit nettop to only show TCP or UDP sockets, with nettop -m tcp and nettop -m udp
There are other ways to see similar information from the command line, including lsof, open_ports, and then, branching away from the command line a bit you can use GeekTool with lsof to have a list of live network connections printed directly over the OS X desktop wallpaper.
For the mobile world with iOS, you can find some similar information with the free networking scanning Fing app, it’s quite a bit more limited but still useful enough to have around on the iPhone and iPad.
Related
You're reading Watch Network Traffic In Mac Os X Via Command Line With Nettop
How To Install Command Line Tools In Mac Os X (Without Xcode)
Mac users who prefer to have a more traditional Unix toolkit accessible to them through the Terminal may wish to install the optional Command Line Tools subsection of the Xcode IDE. From MacOS Monterey, Big Sur, Catalina, Mojave, High Sierra, Sierra, OS X El Capitan, Yosemite, Mavericks onward, this is now easily possible directly and without installing the entire Xcode package first, no developer account is required either.
The Command Line Tool package gives Mac terminal users many commonly used tools, utilities, and compilers, including make, GCC, clang, perl, svn, git, size, strip, strings, libtool, cpp, what, and many other useful commands that are usually found in default linux installations. We’ve included the full list of new binaries available through the command line toolkit below for those interested, or you can just see for yourself after you have installed the package, which we’ll walk through here.
This guide is geared towards MacOS Monterey 12, macOS Big Sur 11, macOS Catalina, macOS Mojave 10.14.x, 10.13 High Sierra, 10.12 Sierra, OS X 10.11 El Capitan, OS X 10.10 Yosemite, and Mac OS X 10.9, and newer releases. Mac users running prior versions of Mac OS X can continue to directly install Command Line Tools and gcc (without Xcode) through a package installer available through the Apple Developer website as described here.
Installing Command Line Tools in Mac OS X
Launch the Terminal, found in /Applications/Utilities/
Type the following command string:
Wait for the Command Line Tools package download to complete, it’ll be about 130MB and installs fairly quickly depending on your connection speed
The installer goes away on its own when complete, and you can then confirm everything is working by trying to use one of the commands that were just installed, like gcc, git, svn, rebase, make, ld, otool, nm, whatever you want from the list below. Assuming the installation went uninterrupted, the command will execute as expected. This also means you can compile and install things from source code directly without having to use a package manager. Enjoy your new unix command line toolkit!
What Installs with Command Line Tools and WhereFor those interested in knowing the details of what is installed on their Mac and where it’s going, the entire command line toolkit package gets placed in the following directory:
/Library/Developer/CommandLineTools/
You can browse through that directory if you want to, or you can just have awareness of it just in case you want to modify or adjust any of the package at a later time.
Note that directory is the root /Library of Mac OS, not a user ~/Library directory.
If you want to see the 61 new commands available to you, they’re all in /Library/Developer/CommandLineTools/usr/bin/ but we have also listed them alphabetically below for convenience:
yacc
Troubleshooting “not currently available” errorGetting an error message that says “Can’t install the software because it is not currently available from the Software Update server”? Well you’re in luck, because that error message probably indicates you already have Xcode installed on the Mac.
From Mac OS X 10.9 onward, if Xcode is already installed in Mac OS X then Command Line Tools becomes installed as well (you can check this by trying to run gcc or make from the terminal). Accordingly, this tutorial is aimed at users who do not want to install the broader Xcode development package, and would rather only have the command line utilities installed instead. Yes, that means you can uninstall the entire Xcode app and only install the command line tools if you want to, since for many users and sysadmins that’s the only reason they installed Xcode to begin with.
Related
How To Spoof Your Mac Address In Mac Os X
A MAC address is a unique identifier assigned to your network card, and some networks implement MAC address filtering as a method of security. Spoofing a MAC address can be desired for multiple reasons, and it is very easy to spoof your MAC address in macOS Monterey 12, macOS Big Sur 11, macOS Catalina, macOS Mojave 10.14, macOS High Sierra, Sierra 10.12, El Capitan, Yosemite 10.10, Mac OS X 10.4, 10.5, 10.6, 10.7, OS X 10.8, and OS X 10.9. For the purpose of this article, we are going to assume you want to spoof your Mac’s wireless MAC address, meaning your wi-fi card.
Without further ado, here’s a three step process on how you can spoof and change the MAC address in macOS and Mac OS X.
1: Get the Current Network Interface 2: Retrieving your current MAC address
You’re going to want your current wireless MAC address so you can set it back without rebooting. Launch the Terminal app and type the following command:
You’ll know see something like:
ether 00:12:cb:c6:24:e2
And the values after ‘ether’ makeup your current MAC address. Write this down somewhere so you don’t forget it. If you do, it’s not the end of the world, you’ll just have to reboot to reset it from a change.
Note, it’s possible that your Mac has the wi-fi card on en0 or en1, so you may need to adjust the string according to your network interface as detailed above.
Spoofing a MAC address in MacOSTo spoof your MAC address, you simply set that value returned from ifconfig to another hex value in the format of aa:bb:cc:dd:ee:ff. You can generate a random one if need be.
For this example, we will set our wireless MAC address to 00:e2:e3:e4:e5:e6 by issuing the following command:
sudo ifconfig en1 ether 00:e2:e3:e4:e5:e6
If the wi-fi interface is en0 the command would be like this instead:
sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx
The sudo command will require that you enter your root password to make the change.
Again, you need to make sure your network interface is identified correctly, so if you run into any issues you can confirm that wi-fi is using en1 or en0.
Verifying the Spoofed MAC address workedIf you want to check that the spoof worked, type the same command as earlier:
Now you will see:
ether 00:e2:e3:e4:e5:e6
Meaning your MAC address is now the value you set it to. If you want to further verify the spoof, simply login to your wireless router and look at the ‘available devices’ (or attached devices) list, and your spoofed MAC address will be part of that list.
If you want to set your MAC address back to its real value, simply issue the above ifconfig commands with the MAC address that you retrieved in step 1. You can also reboot your Mac.
Enjoy!
other readers point out that Dee Brown’s trick works in 10.5.7 and above too. Thanks Dee!
Update: If you’re still having problems with MAC address spoofing in Leopard or Snow Leopard, the above method still works but try disassociating with any wireless network BUT keep your wireless Airport on (as mentioned above) – an easy way to do this is to type the following in the command line:
airport -z
Note that you have to have the ‘airport’ command setup to work for users, you can do that by copy and pasting this command into the Mac Terminal:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
Once disassociated from the network you should be able to spoof your MAC address as usual
Updated 2/28/2012: For Mac OS X Lion, the Airport interface is now called “Wi-Fi” and thus the command to spoof a MAC address in OS X 10.7, OS X 10.8 Mountain Lion, and OS X Mavericks, is:
sudo ifconfig en0 Wi-Fi aa:bb:cc:dd:ee:ff
For some computers Wi-Fi may be the interface but you spoof by specifying “ether” instead.
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff
Remember to disassociate from any network beforehand with “airport -z” while keeping the card active. If you continue to have problems or receive a “bad value” message, try turning the wireless NIC off and on again using the following:
sudo ifconfig en0 down
Now re-enable the NIC:
sudo ifconfig en0 up
Then proceed to spoof the MAC address:
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff
Reenabling the network card may cause it to join the last available wireless network.
The MAC address should stay spoofed until reboot, but you can always check what your MAC address is in the GUI or command line with networksetup -listallhardwareports if you’re curious about the current status.
Related
Compress & Optimize Images Easily With Imageoptim For Mac Os X
If you’re at all concerned about the file size of images you should grab ImageOptim, a free image compression tool that is so ridiculously simple it’s basically foolproof, while still being extremely effective. The app works to compress images without reducing image quality, which is achieved by bundling several compression tools, including the popular PNGCrush, PNGOUT, AdvPNG, Zopfli extended OptiPNG, JPEGrescan, jpegtran, JPEGOptim, and gifsicle, and using those tools to find the optimum compression parameters, in addition to stripping color profile information, EXIF, and other metadata out from the raw files. ImageOptim supports a variety of file formats, including PNG, GIF, JPG, and animated GIFs, here’s a quick look at the interface:
The simplicity is deceptive in that it doesn’t demonstrate just how handy this app is, or just how effective the optimization is. Let’s cover usage and a few tricks to get the most out of it…
Optimizing Image Files with ImageOptim for Mac
Head over to the developer website and grab ImageOptim (free) and uncompress the archive, if you intend on using it often, drag the chúng tôi into your /Applications/ directory
Launch ImageOptim and have the window somewhere visible from the Finder windows
Start compressing image files with a drag & drop into the apps window to begin compression, or use the “Open” option from the File menu to select files manually
Any image opened within the ImageOptim app will immediately shrink down losslessly, this is done by stripping the exif data and other useless details that (should) have no impact on the image quality, while reducing file size. No additional steps are needed, though if you’re looking beyond a single file compression you can use a few tricks to speed up the process of groups of pictures.
How well does it work? That varies, but on average the image size savings are about 15-35%, making it a useful and must-have tool for web designers, developers, publishers, bloggers, app developers, or anyone else that wants to reduce image file size and bandwidth requirements. Some files can be dramatically compressed though, and there are instances where poorly optimized original files can be squeezed down as much as 50-60%, depending on what is actually causing the file to be unnecessarily large. ImageOptim is particularly effective for uncompressed files, but you should have success with just about any image document you throw at it. The app will report savings for each individual image, and also show you the net compression if you toss a bunch of files at it:
Bulk Compress Images with Drag & DropYou can bulk optimize images by using a large drag & drop. The best way I’ve found to do this is to launch the ImageOptim app first and have the icon sitting in your Dock while it’s active, then navigate to the folder containing images you want to compress, select them all, then use a drag and drop onto the icon to start the process. JPG and GIF files will compress extremely fast, but PNG files can take quite a bit longer to optimize, and in all cases the amount of time it takes to compress the image varies depending on the picture resolution and the total file size to begin with. For huge batch compressions, this really is one of the easiest ways, other than using the wildcard command line trick we’ll discuss next for Terminal users.
Using Wildcards to Batch Compress from the Command LineFor command line users, use the “open” command to pass wildcards to ImageOptim for easy scripting and bulk image compression like so:
open -a chúng tôi ~/Pictures/SaveToWeb/*.jpg
Of course, compressing a single file is possible using this trick too:
open -a chúng tôi ~/FileName.PNG
It’s possible to use a vary wide wildcard to compress every single image file on a drive, but that is really not recommended unless you know exactly what you’re doing and why.
ImageOptim is an excellent tool for web workers and for those wanting to compress images, but remember that just because ImageOptim should be lossless doesn’t mean that it always is. Additionally, many users find the EXIF data that is attached to image files to be useful, whether for it’s GPS coordinates, camera shooting details like manufacturer and camera settings, or for a variety of other reasons. Using the optimization tricks through ImageOptim strips all EXIF data, making a file effectively blank beyond the raw photo data itself, which can also be the intention for many users.
Great find from @MacGeekPro on Twitter, don’t forget to follow @OSXDaily too!
Related
Configd: Fixing High Cpu Usage Problems With The Configd Process In Mac Os X
configd is a system configuration daemon that runs behind Mac OS X, most users will never notice or see the core OS X process running in the background of their Macs. With that said, configd can sometimes act up and cause unusual CPU spikes and fan activity making your Mac sound like a wind tunnel. Odd configd behavior is easily diagnosed by launching Activity Monitor, sorting by the “% CPU” option, and seeing the ‘configd’ root user process sitting at the top taking up somewhere between 20-95% CPU. If that behavior lasts for a minute or so it’s usually not a big deal, temporary spikes can be normal so just let it run and ignore it, but there are times where configd can go inexplicably errant and it’ll sit around 50% CPU utilization or more for hours for no obvious reason – that is what we’re looking to resolve here.
Resolve configd High CPU Usage with Force Relaunch via Terminal
We’re going to forcibly relaunch configd by giving it a swift kick in the pants using the all-powerful ‘killall’ command. Because configd is a system process, it will instantly relaunch once it has been killed, and in every instance where configd is going crazy with processor utilization this trick solves the problem.
Launch Terminal (sitting within /Applications/Utilities/ as usual) and type the following command:
sudo killall configd
You’ll need to enter an administrator password to execute the command as super user, thus the sudo prefix. Running the command without sudo is ineffective because the process is owned by root (super user).
If you kept Activity Monitor open and sorted by CPU, you’ll find ‘configd’ disappears and when it relaunches it’s no longer sitting at the top of the list and no longer eating up inordinate amounts of CPU. Searching for the process should now find it consuming somewhere between 0% and 1% of CPU.
If you still have problems with configd after using the killall command, jump to the bottom of this article to learn more about troubleshooting configd issues.
Dealing with configd without TerminalIf you aren’t comfortable with the command line, there are two other options:
Quit all running Mac applications, which you can do manually or by using this self-made app to quit everything in OS X
Reboot the Mac
Rebooting the Mac has the same effect as killing the configd process directly, though it’s obviously a bit more intrusive to your workflow. Quitting every application can help if the configd error is caused by an apps errant behavior, more on that in a moment.
Diagnosing specific configd problems and learning about configdApple officially describes configd as follows:
The configd daemon is responsible for many configuration aspects of the local system. configd maintains data reflecting the desired and current state of the system, provides notifications to applications when this data changes, and hosts a number of configuration agents in the form of loadable bundles.
That excerpt is taken from the manual page on configd, which can be accessed by typing the following into terminal:
man configd
You can read that directly on your Mac through the command line, or through the web using the Developer Library link here.
If you want to attempt to diagnose why configd went crazy in the first place, you can look around in the following two locations for configd bundles and plist files, which may provide some hints as to what is going wrong and why:
/Library/Preferences/SystemConfiguration/
Another option is to choose to re-run configd in verbose mode with the following command:
sudo /usr/libexec/configd -v
This will export verbose information to the OS X System Console, which can be read either from the Console app or through the command line as well. Comparing that information to what is found in the aforementioned system directories can be very helpful in diagnosing a precise cause.
General experience has shown that some apps and processes cause configd issues more often than others, some of which may include Java and Java based services like CrashPlan, certain printers where there are unresolved printing errors, and improper network configurations where a network connection is repeatedly attempting and failing. This is why sometimes quitting all apps is effective at resolving the issue, because it may end the failing repetition which is causing configd to go haywire, and in some cases where killing configd doesn’t solve the problem then removing the culprits plist file can resolve the issue once and for all. Your individual experiences and results may vary.
Related
How To Upgrade Ubuntu From The Command Line
Ubuntu’s Update Manager makes it relatively easy to upgrade your installation to a new major release. The utility’s graphical interface guides you through a step-by-step wizard that should be easy to follow.
But there are times when you cannot use a graphical utility – for example, on servers you don’t have access to a graphical interface. In this case you are forced to use the command line to upgrade Ubuntu.
However, this is not the only scenario where this is useful. The command line interface usually lets you see more about what is going on. Most command line utilities output a lot of text while they work. Consequently, you might prefer this method if you want to see the details of the upgrade as it happens. You can also more easily spot potential errors if they arise.
do-release-upgrade Command Line Switch “-d”The utility to upgrade Ubuntu from a previous version to an upgraded version is called do-release-upgrade. It’s actually a script written in the Python programming language.
Normally, the script will upgrade from one stable release (or LTS – Long-Term Support) to the next. For example, it might update Ubuntu 16.04 to Ubuntu 18.04. However, when a new LTS version appears, you cannot upgrade to it until its first point release. What this means is that if you’re currently using 16.04.5, you can’t upgrade to 18.04. You have to wait until 18.04.1 is launched. It’s recommended to actually wait for the first point release. The first new LTS release might still hide nasty bugs, but if you really need the new LTS, as soon as it comes out you can use a command line switch to force the utility to upgrade. So if 18.04 just came out, you can upgrade with
sudo
do-release-upgrade-d
before 18.04.1 comes out. Otherwise, if 18.04.1 is already available, use the command without the switch:
sudo
do-release-upgrade How to Upgrade Ubuntu with do-release-upgrade CommandBefore the upgrade it’s recommended that you temporarily disable any third-party repositories, such as PPAs or entries you added in “/etc/apt/sources.list” or “/etc/apt/sources.list.d/.” If you know you didn’t add any repositories from other providers except Ubuntu, you can, of course, skip this step.
Some packages from these repositories might interfere in unexpected ways with new packages from the next Ubuntu release. Afterwards, run sudo apt update to refresh package information. Then, use a command such as sudo apt autoremove nginx to remove programs you have installed from third-party providers.
If the do-release-upgrade command is not available on your system, install it with
sudo
apt
install
update-manager-coreIt’s usually installed by default though.
Your software packages have to be up to date before upgrading to a new Ubuntu release. Update all packages on your system.
sudo
apt update
&&
sudo
apt upgrade
Upgrading to Short-Term Support Ubuntu (Optional)Even numbers, such as 18.04, indicate a long-term support release (LTS). Odd numbers, such as 19.04, indicate a development, short-term support release. If you’re currently on an LTS version and want to upgrade to the next LTS, skip the steps in this section. But if you’re currently on an LTS version, such as 18.04, and want to upgrade to 18.10 or 19.04 (whichever is the next available), edit this file:
sudo
nano
/
etc/
update-manager/
release-upgradesChange Prompt=lts to Prompt=normal. Press Ctrl + X, then y followed by Enter to save the file.
If You’re Upgrading Your Local ComputerAlthough you can open a terminal emulator on your graphical desktop, this presents a problem. When the graphical server gets upgraded, it might get restarted. This would, in turn, make you lose your terminal session, so it’s better to log out from your graphical session. Afterward, press Alt + Ctrl + F2 or Alt + Ctrl + F3 and log in on the TTY console before starting the upgrade script below.
Start Ubuntu UpgradeSimply start the upgrade script.
sudo
do-release-upgradeNow, carefully follow the steps in the wizard. They will be slightly different depending on your upgrade scenario. For example, when connected to an SSH session, you will get an extra step like the one in the following image.
In later steps you will almost certainly be asked what to do with configuration files that have changed in new package versions.
If you have changed the mentioned configuration file, you might want to type “N” to keep your changes. The same is true if your server provider has made changes to those files. This is something that you will have to investigate yourself. If you or your provider didn’t make any special changes, type “Y” to pull in the updated configuration file.
ConclusionThe upgrade process is not complicated, but complications may arise. It usually depends a lot on how “clean” your system is (no third-party repositories). After the upgrade utility finishes its job, all you have to do is reboot your machine. Normally, the script will give you the option to reboot, but if it doesn’t, you can just run:
sudo
systemctl rebootor simply:
sudo
rebootProvided you don’t run into any upgrade bugs or bugs with new software installed, everything will work perfectly once the machine is rebooted.
Alexandru Andrei
Fell in love with computers when he was four years old. 27 years later, the passion is still burning, fueling constant learning. Spends most of his time in terminal windows and SSH sessions, managing Linux desktops and servers.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.
Update the detailed information about Watch Network Traffic In Mac Os X Via Command Line With Nettop on the Achiashop.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!