usermod -l newusername pi
Namun ada error:
usermod: user pi is currently used by process 2104
KARENA???:
ps -lp 2104
will give you some information about what the process is. You can check that andkill 2104
.Note you'll have to do this logged in as root, or some other user with the permissions to do it. It probably will not work viasudo
, etc.You'll also have to rename the home directory.SOLUSI LAINIf you're in the console of the pi there is a way to get around this without having to make another user (or set a pw on root):Assuming nothing else is running with your username other then the shell on the console - no X session, no ssh login, etc:exec sudo -s cd / usermod -l newname -d /home/newname -m oldname
The reason this works:
sudo -s
tellssudo
that instead of just running the command as another user, it should run a new shell as the given userexec
tells the shell that instead of spawning off a new process when it runs a command (hence leaving the shell process running as the logged in user), that the shell should overwrite itself with the new process. This means that when theexec
command ends the shell is gone. In the case of a login shell, that equates to disconnecting from the login.- the
cd /
is optional. At a minimum, things get a bit confusing if you move a directory you're in (your login starts out sitting in the userpi
home directory). Sometimes this will cause a fail, so it's better to be safe than sorry.
Therefore with
exec sudo -s
you're overwriting your shell with a new shell that has been created as a different user (the root user in this case).
P.S. be sure to give
usermod -d
a full (hard link) path or you'll end up moving the account's home to somewhere you don't expect and have a bogus directory entry in passwd
.
SOLUSI LAIN:
sudo passwd root
[enter new ridiculous root password. Remember it.]- Log/ssh into pi as root using ridiculous password.
usermod -l newname -d /home/newname -m oldname
ls -al /home/
[See that you've changed the user & home folder. Yay. Oh.. gotta change the group...]groupmod --new-name newname oldname
ls -al /home/
[See that user, group & home folder are changed. Yay!]exit
(Now log in as newname. Yay!) But wait.... Now you should reset root so others can't brute-force your ridiculous password.sudo passwd -l root
(Oh, and if you REALLY care... edit/etc/ssh/sshd_config
, setting "PermitRootLogin no", and restart that service.)
Then you'll have to change any additional changes in any scripts/setups that refer to 'pi'..
Reff:
http://raspberrypi.stackexchange.com/questions/12827/change-default-username
Tidak ada komentar:
Posting Komentar