Awesome terminal tricks for macOS !

How to become a sudo user, that is a root user

This is dangerous and not recommended though since a root user in Linux or Unix has extreme level of privileges. In fact almost most of the work can be done on the mac with a normal sign in, that is a normal administrator login for a single user on macOS.

sudo su -

Enter the password and you’re good to go ! Be careful with what you’d be doing as this may not be reversible.

A super user or root user disadvantage

this is the most destructable command in Unix as well as Linux

    rm -rf /
mkfs.ext3 /dev/hda

Shutdown Your Mac, With or Without a Delay

To shut down your Mac immediately:

sudo shutdown -h now

To restart your Mac immediately:

sudo shutdown -r now

The “now” represents just now, if you want to give delay then you may enter numeric value say +10 at the end, that is after 10 minutes the computer would shut down.

We can even add a time delay (in minutes) if we wished too, this example below is for restarting the machine after 30 minutes

sudo shutdown -r +30

Prevent Mac from sleeping

To prevent mac from sleeping, we can use the below give tool called caffeinate. Its like if you want to keep your machine up and running when you wish to download a huge file over the internet or keep mac on while you’re sleeping


Entering the command on its own will keep the Mac awake until you stop it by pressing Ctrl-C. You can add a time parameter with:

caffeinate -u -t 300

The number represents the number of seconds, so our command above will stop the Mac from going to sleep in the next 5 minutes

Create a file of any size

Now this one is cool, as you can give preferences while searching or creating a file which could be say 1Gb just for an example

mkfile 1gb

note:- the above file doesen’t need to have a file extension, You can specify the file size in bytes (b), kilobytes (k), megabytes (m) or gigabytes (g).

Few useful commands for newbies


uptime is to display, the exact amount of time the machine or a server has been running.


top is a very popular command used by system administrators to monitor the system input and output status


history command shows last 500 entries done on the terminal
Also during any process if you get suck up, then you can always hit Ctrl + Z keys !

That’s it for now, stay tuned for more Linux and Unix tweaks and hacks.