Advanced MacOS and Linux Commands

With macOs and Linux, you have a gigantic amount of command-line utilities built-in that you can utilise to your need. Not only this but also hundreds and thousands of easy access and installed third-party tools which work seamlessly with macOS and Linux command line. While this all so fascinating, the most challenging part is you have more than one tool available for any job you have to do with command line. No worries, they got you covered as well with the command like, vi.

Ifconfig

With the ifconfig you are able to see and configure any settings for your network connections. If you are on macOS or Linux, feel free to run this command and see what you get?

Just for the heads up, macOS and Linux use some sort of unique terms to define your network connections such as wLan0, wLan1 and vice-versa says that it has wireless 802.11 NICs. There are also eth0, eth1,en0 etc say about wired Ethernet NICs as well as lo meaning loopback.

For instance, you can disable a NIC with the following command like ifconfig eth0 down.

You can also change your IP address of a wireless NIC to something other than yours until your PC is rebooted.

Iwconfig

This iwconfig is one of the most powerful tool of the macOS and Linux. This is basically your go to command line if you are working with many wireless settings and so on. If you type this command, you will get all sorts of details about your wireless NICs. One of the example case we can do something like – sudo iwconfig wlan0 essid “SomeotherSSID”. This will change your SSID to another SSID.

Ps

With the Windows users, the most common way of seeing all the processes running in the system is typically via the task manager. What is about macOS and Linux?

This is where you use the ps command to view all the processes running in your system. This is one of the oldest commands that provide you with the details and customisable information about all the processes running on your system.

You are to typically use this command along with some sort of Switch command. One of the most common use is – ps aux command. This aux command is actually comprised of three different switches. a = processes for every users in the system, u = shows you the owner of the process, x = any processes that is not attached to the terminal.

One of the unfortunate moments you will have with this command since this command will begin to show a huge amount of output. Yet, do not be discouraged to try it out as we are going to learn some ways to make this output easier.

One of the easiest ones is the ps | less . These tools make it easier for you to scroll up and down the output. You can also user more here as well. Which one to use depends on your scenario and requirements. These two are ideal for power users and programmers.

The outputs you can get with the ps aux command

Let’s look at some of the output ps aux will provide and what they are.

USER shows you who is running the process and PID stands for Process ID number associated with the process. As you can imagine, %CPU is he percentage of CPU power consumed by the process. %MEM is a similar one, albeit it stays for the percentage of memory the process is using.

VSZ will give you the sum of the total pages memory in kilobytes and RSS gives the sum of the total physical memory in kilobytes of course.

TTY shows the terminal that is taking the process’s output.

STAT is a more complex output including S for waiting, l for multi-threaded, R for running and + for the foreground process.

START  will show you the time when the process was started, whereas TIME shows the time elapsed since the process started. COMMAND stays for the name of the executable which created the process.

When can you use the ps command?

The most common tech use of the ps is, when one has to kill a certain process associated by a PID. You do that by using the kill command. Something like – kill 43565 will kill or terminate the process, something like Windows end task with power and attitude.

As you can see, this is a tremendously useful command to have under your belt especially if you are working in the field of networking and low-level computing.