Command line essentials for MacOS and Linux

Learning to get things done with command line is one of the essential tasks of people working in the IT industry of various fields. This is not because they don’t have GUI (Graphical User Interface) available to them but due to the efficiency of getting things done that comes in with command line.

This is not the only reason. There are also operating systems where you are only able to communicate with the system via the command line only since there is no GUI or anything of that sort. For instance, server and some distro of Linux.

The following commands that we are going to learn are given in a random order so feel free to just dive in.


Grep is one of the most powerful commands that you can use on both mac and Linux. This command sets a sort of like a filter on your command line. With this, you are allowed to search through any text files or output of the command for a specific set information you need or to filter out any unnecessary information that serves no purpose to you.

Of course, we are not going to just hang around here with some abstract theory here. Let’s see some in action.

Finding any sort of process is a way easier with the grep command if you combine it with the ps command. The ps command allows you to see all the processes running in the system with highly detailed overview, such as which user is running the process, when the process was started, how long the process has been running and so on.

For example, let’s say I have a Libre Office document running and for some reason I want to kill it. Now the thing is, I don’t know what the PID (process ID) is. How would I go on about finding out the PID? I would run this following command: Ps aux | grep libre and hit enter.

This will immediately brought up the Libre Office PIDs in no time. Now here, we will see the PID that we need to kill. With this powerful grep command, you can find any sort of text from a string and will show you the line it is in.

Let’s see another use case. Let’s say, I want to see if any of my NICs is using a number of IP address. You can get the kind of information you need with the combination of ifconfig and grep. Such as: ifconfig | grep This will bring up the up details with the line from the output of ifconfig where it shows the IP address being used.

You can do super powerful things with the grep command. This was just a little sneak peek.


dd is one of the most essential and advance commands you want to use if you have a situation where you want to copy or create an exact, bit-by-bit image of any kind of block storage like mass storage devices. For instance, your hard drive volumes, pen drive, optical media etc. The syntax in its simplest form look something like this: dd if=<source block device> of=<destination image file location>.

This is enough to get you started. You can learn this by reading and practicing it on an exhausting level. Yet, be very careful before you hit the enter button. This command is also called “Disk Destroyer” if you are not careful with it and start using it like one of those “cool newbies” who just “oh, I will just learn on the go and playing around, I don’t need any theory”. You will be doomed if you have that attitude with dd command. There are a lot use cases of dd than we can cover here.

We will see some of the major operations like these.

  1. If you want to copy one hard drive to another, you can use dd. Don’t run these, just get familiar. For example, dd if=/dev/sda of=/dev/sdb will do the trick.
  2. You can backup the thumb drive with: dd if=/dev/sdc of=/home/username/desktop/backupThumb.bak.
  3. Wipe an entire disk with command like – dd if=/dev/urandom of=/dev/sdb.

Note this was some of the infant example to solely get you familiar with the syntax. There is more to consider than just running these commands. Do an online search on these commands or get a book or that sort to know about them in depth.