Most Linux distributions for the Banana Pi come preconfigured with a default username and password. The login information is published on the download website for the operating system images (see Chapter 1, Installation and Setup).
In almost all cases, the credentials are:
Username |
Password |
---|---|
|
|
You might want to create your own user on the system. At the very least, it is highly recommended you change the default password of the default user. This recipe explains the necessary tasks.
We will split this recipe into adding a user, changing a password, and deleting a user.
We are going to use the
useradd
and the passwd
commands to add a new user with the name alice
and the password wonderland
. Choose any other name and password as you wish.
$ sudo useradd -m -s /bin/bash alice
sudo
, enter the default password, that is, bananapi
.$ groups
bananapi
user. To assign alice to these groups, we use the following command:$ sudo usermod -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input,indiecity,spi,gpio alice
Keep in mind, that the groups are separated by a comma and not a space. Also note that depending on your distribution, the list of groups may differ.
You have just created a new user name alice
and assigned the user to all groups that the default bananapi
user is a member of.
Now we are setting a password for our new user alice:
$ sudo passwd alice
wonderland
.wonderland
.passwd: password updated successfully
.You have assigned the password wonderland
to the user alice. Take a look at the following screenshot:
In the preceding screenshot, you see the adding of the user, the group assignment, and the password assignment of the user alice.
Linux and other Unix-like operating systems are so-called multiuser systems. The name implies that these systems are able to handle more than one user simultaneously. Each user has its very own place where their files and configurations belong, the so-called home directory (often abbreviated as ~
).
Most user modifications require root privileges. Therefore, we prefix every command with sudo
.
We are adding a new user by executing the useradd
command. This command takes some parameters. The -m
parameter will tell useradd
to create the home directory automatically (/home/alice
in our case). As the new user wants to be able to log in, we have to set a default shell, which is done by -s
followed by the full path to the shell (the path to Bash in our example). Last but not least, the user must have a name, which is alice in our previous case.
Also, a user can be assigned to different groups, which have different permissions for various tasks. To find out which groups are assigned to the default user, we are using the
groups
command. When executed, it outputs all groups of the current user (that is bananapi). We assign the same groups to our user alice by using the usermod
(user modify) command. The usermod
command modifies information about a user, -a
in combination with -G
adds the user to a so-called supplementary group, which is given as a comma-separated list.
Since each user should have a password, we assign a password by using the passwd
command. You can also change the password of the default user bananapi this way.
Finally, if we want to delete a user, we simply issue the userdel
command.
If you delete a user by the userdel
command, the user's home directory will remain untouched. Thus, if you also want to delete their whole home directory, you will need to use the rm
(remove) command forcing (-f
) and recursive (-r
):
$ sudo rm -rf /home/alice
Another interesting command is the id
command. It provides additional information such as user ID (uid) and the user's associated group IDs (gid). The following screenshot shows group information for the user alice by issuing the id
command:
useradd
, passwd
, usermod
, userdel
, id
, and groups
; for example:$ man useradd
Each manual page contains informative material about these commands.
3.141.195.128