在mac下使用su由于没有密码无法获得权限,以下是我自己试验得出的解决办法:
使用 passwd root 来修改密码:
我先用passwd root 命令进行密码修改,过程如下:
passwd root
Changing password for root.
Old Password:
New Password:
Retype New Password:
passwd: authentication token failure
以上命令是我一路回车下来的,过程中得Old Password New Password Retype New Password都没有输入任何字符,直接回车的,最后一行提示:认证token失败。
接下来,使用 sudo passwd root 回车得到:
sudo passwd root
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
在Password:行我输入了我想要设置的密码,比如:111111 回车
Changing password for root.
New password:
Retype new password:
这两个输入的也是之前的想要设置的密码 比如:111111回车
然后,命令行就回到了 :~ ,然后输入 su 回车
Password: 输入新的密码 111111 回车
sh-3.2#
使用root完毕,用exit退出即可
到这里,我们的su就获得了权限,恭喜以下自己吧。