Customize your WLAN Pi
In this article, I will show you how you can customize your WLAN Pi and make it your own! Feel free to comment and tell me how you guys customize yours.
CREATE YOUR OWN USER
Note: I would also recommend you to change the default password for the wlanpi account.
In order to create a new user, you need to ssh into the WLAN. By default, if you connect the WLAN Pi to your laptop via the USB connection, this should establish an Ethernet over USB connection and your laptop should receive an IP address in the 192.168.42.0/24 IP address subnet.
You can now ssh into the WLAN Pi from your laptop using the default username and password:
- Username: wlanpi
- Password: wlanpi
Once connected, we will create a new user and give this new user some privileges.
- Use the following command to create a new user: sudo adduser username
- In the following prompts, specify which password you want to use for this user
- Use the following command to give this user sudo privileges: sudo usermod -aG sudo username
- Finally, try to connect using this new username and password: su – username
Finally, we will modify the user PATH so we can get access to some basic commands such as ifconfig, iwconfig or iw.
- In the home directory of the user, open the .profile file using the following command: sudo nano .profile
- Modify this file by adding the following line at the end of the .profile file: PATH=$PATH:/sbin:/usr/sbin
- Save and close the .profile file
- Once back in the shell, reload the profile using this command: source .profile
- You should now be able to use the ifconfig command
CHANGE THE HOSTNAME OF THE WLAN PI
The name of the WLAN Pi is configured under the /etc/hostname file. In order to change the hostname permanently, you will have to modify this file:
- Open the file using the following command: sudo nano /etc/hostname
- Modify the hostname to your liking
- Save and close the /etc/hostname file
- Reboot the WLAN Pi
One more thing you need to do here. You need to change the hostname used for dns resolutions. If you don’t, you will realize that it takes longer for sudo commands to execute. To do so, open the /etc/hosts file and replace “wlanpi” by your new name:
127.0.0.1 localhost SemFioPi ::1 localhost SemFioPi ip6-localhost ip6-loopback fe00::0 ip6-localhost ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
CREATE YOUR ALIASES
On linux, an alias allows you to create your own command shortcut. For example, instead of typing ls –color=auto, you could create the following alias : alias ls=’ls –color=auto’. Then when you type ls, it will execute the full command line.
Everyone has their own set of aliases they like to use. Here I will just share the ones I use. Feel free to use them as well and feel free to create your own.
In order to create your aliases, you need to do the following:
- ssh back to the WLAN Pi using your new user: ssh francois@192.168.42.1
- Once connected to the WLAN Pi, modify the .bashrc file using the following command: nano .bashrc
- Add your aliases at the end of this .bashrc file
- Save and close the .bashrc file
- Reload your bash profile using the following command: source .bashrc
- Validate that your aliases have been applied using the alias command.
# Francois' Personal Aliases alias l='ls -pG -l' alias la='l -a' alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias cate='cat -e' alias cl='clear' alias h='history' alias j='jobs' alias fg1='fg %1' alias fg2='fg %2' alias fg3='fg %3' alias fg4='fg %4' alias n='nano' alias sn='sudo nano' alias mtr='sudo mtr' alias grep='grep --color=auto' alias ifcw0='ifconfig wlan0' alias ifcw1='ifconfig wlan1' alias ifce0='ifconfig eth0' alias iw0='iwconfig wlan0' alias iw1='iwconfig wlan1' alias mv='mv -i' alias rm='rm -i' alias cp='cp -i' alias mtr='sudo mtr'
CUSTOMIZE YOUR PROMPT
You can also customize your prompt to your liking. You can go wild here. I actually like it simple. I like the default prompt. I just changed the colors for fun!
In order to change the look of your prompt, you can do the following:
- From the WLAN Pi and from your user home directory, open the .bashrc file using the following command: nano .bashrc
- Inside the .bashrc file, scroll down until you find the PS1 variable. Then replace the value of that PS1 variable with whatever you would want to use.
- Save and close the .bashrc file
- Reload your bash profile using the following command: source .bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;202m\]\u\[\033[00m\[@\[\033[36m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
CHANGE THE PICTURE DISPLAYED WHEN BOOTING
scp francois@192.168.2.2:/home/wlanpi/NanoHatOLED/BakeBit/Software/Python/wlanprologo.png .
Then you need to replace the image that’s currently on the WLAN Pi with your new image, freshly created. You won’t be able to do it in one shot because you don’t have the permission to do so over scp.
scp WLANPi-SemFio-StartUp.png francois@192.168.42.1:~/
Second, you need to ssh back into the WLAN Pi.
And finally, you need to replace the old image with the new one. I used the following command to do so: sudo cp WLANPi-SemFio-StartUp.png /home/wlanpi/NanoHatOLED/BakeBit/Software/Python/wlanprologo.png
Note: It is very important here that you use the same destination name. The picture name will still be the same as before (wlanprologo.png) but its content will be different. I tried to do it a different way by changing the configuration files of the NanoLED program, but it didn’t work properly.
Then, you can reboot your WLAN Pi, you should see the new picture when the WLAN Pi boots.
IDEAS
If you manage multiple WLAN Pi, you could also create a Python script that you could run on multiple WLAN Pi to speed up their configurations and customizations.
In order to improve this customization, I would like to create a Python script that automates all of these tasks. I will then be able to run the script every time I update my WLAN Pi to a newer image and I will be able to retrieve my customizations.
Please share how you like to customize yours!
Thank you for reading!