Custom Shell

Of course you can start minicom every time you log in to the Pi-Bus driver. But wouldn't it be easier to start minicom automatically once you log in? This is easily done by setting up a custom shell. Setting up such a custom shell is fairly easy. It also prohibits the Pi-Bus Driver user to do things with the system he/she isn't allowed to do.

Setting Up A Custom Shell

First of all you'll have to tell the system that you want to use minicom as a shell. Use the sudo nano /etc/shells command to add the following line at the end of the file.

/usr/bin/minicom

Now use the commnad sudo adduser sbbus to create a new user for the system by the name of sbbus. You will be asked for some extra information. Here's what you'll have to enter:

Enter new UNIX password: <password of your choice>
Retype new UNIX password: <password of your choice>
passwd: password updated successfully
Changing the user information for sbbus
Enter the new value, or press ENTER for the default
       Full name []: sbbus
       Room number []:
       Work Phone []:
       Home Phone []:
       Misc []:
Is the information correct? [Y/n]: Y

Now the user sbbus has been created change the details of this account with the following commands:

sudo usermod -d /home/pi -g pi -aG dialout -s /usr/bin/minicom sbbus
sudo rm -rf /home/sbbus

This command changes the home folder of the user sbbus to your default home folder. It adds the user sbbus to your own group, which enables you to read/write files created by the user sbbus and vice versa. It also adds the user sbbus to the dialout user group, which enables the user to use the serial port. And finally it will change the user's shell to minicom, which is what we were after.

Multiple Log-ins

Even though Linux is a multi user platform, a UART can only be controlled by just one user or one process. Therefore multiple log-ins to user sbbus are not possible because the first one will claim the UART. If you do try to login as user sbbus while the UART is locked by someone else you'll get the next errors:

Device /dev/ttyAMA0 is locked.
Connection to [yourcomputer] closed.

If you're unable to log-out the other user, who has claimed the UART, you can log-in to the normal shell and kill the minicom process with the following command:

sudo killall minicom

This will terminate the session of the other user, giving you the chance to login as user sbbus again.