Categories: HomeHow-to'sLinux

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 /
       or
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

caffeinate

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 hello.xyz

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

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

top

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

history

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.

Akash Angle

I am a Full time Linux user who has quit using Windows for unknown reasons, making my life truly open source.

View Comments

Recent Posts

Get the most juice from your ISP/router — setting MTU size & other handy tweaks

This is not an ad-vocation by any means for TP-link branding, however a real life…

7 months ago

How to make any Android phone up-to 3x faster – Developer options unleashed

First of all we need to hit the kernel version on any Android device. You…

7 months ago

systemd-resolve command not found in Ubuntu Desktop

Use resolvectl status instead. It's like something deprecates and suddenly things get broken! In systemd…

12 months ago

How to exclude multiple directories with rsync?

Geeky question: This is what people and friends have tried: rsync -arv --exclude "/home/john/.ccache:/home/ben/build" /home/john…

12 months ago

How to resolve apt-get -f not working

You might encounter this error which appears to be very common on Debian based Distro's…

12 months ago

How to install Broadcom STA wireless drivers on Kali Linux

PS: This article is for only Kali Linux users, that too having a Broadcom Wireless…

1 year ago