If you want to use OS X in a kind of Linux or BSD way, there is way to become the root user. This guide is intended for the advanced users who can understand chmod, chgrp, chown – at minimum. Ordinary users need not to become root
for fun only. The title of this article reflects what we want to mean – Work With root Username on OS X Terminal/iTerm2.
How To Work With root Username on OS X Terminal/iTerm2
OS X has the UNIX inherited Wheel group. This does not exist on Linux by default for philosophical reasons. If we type whoami
, it will print our user name; in case of the author of this article, it will be abhishekghosh
. We want root
. First, for the root
user, no password is assigned by default. This we can evoke on CLI by typing dsenableroot
. You can run man dsenableroot
to read the manual of this dsenableroot
utility. It is very easy to use this tool. A very complicated way exists via graphical user interface. That is the officially written method :
1 | https://support.apple.com/en-in/HT204012 |
root Username on OS X Terminal/iTerm2
But working on that, exactly not give you the output root
when we will run the command whoami
. That can be gained by running this command :
---
1 | sudo -s |
As we are using the Terminal App not the real Terminal, whenever we will open a new shell window, it will always start with the username we used to login to our Mac.
We can add any user to wheel
group with this below syntax and tool :
1 | dscl . append /Groups/wheel GroupMembership abhishekghosh |
It is quite difficult matter to understand – take time to understand what exactly becomes the situation when abhishekghosh
belongs to these groups – admin
, wheel
and staff
. The Kernel is of BSD not Linux, so you should be careful while trying to change the things. Same kinda guide can be written by anyone, knowing the commands is matter to copy-paste on right click, but understanding the philosophical difference between Linux and unix is not exactly so easy. Even you become root
on command line, if you type :
1 | cd ~ && pwd |
root
will actually use abhishekghosh
‘s $HOME
not /
location.