Pi: Samba: Initial setup

Raspberry Pi change username


Pi username change

log out
sudo passwd root


usermod –l mdp pi

Check home dir

usermod –m –d/home/mdp mdp

Pi Password change

login mdp

Samba - list users

sudo pdbedit -L -v

Unix username:        jimmy
NT username:          
Account Flags:        [U          ]
User SID:             S-1-5-21-356235841-3600951402-867704776-1000
Primary Group SID:    S-1-5-21-356235841-3600951402-867704776-513
Full Name:            
Home Directory:       \\pi\jimmy
HomeDir Drive:        
Logon Script:         
Profile Path:         \\pi\jimmy\profile
Domain:               PI
Account desc:         
Munged dial:          
Logon time:           0
Logoff time:          never
Kickoff time:         never
Password last set:    Sun, 03 Nov 2019 16:48:28 CST
Password can change:  Sun, 03 Nov 2019 16:48:28 CST
Password must change: never
Last bad password   : 0
Bad password count  : 0

Samba - create user

sudo smbpasswd -a jimmy

Samba - restart samba

sudo systemctl restart smbd

Update packages

sudo apt-get update
sudo apt-get upgrade

Lock root user

sudo passwd –l root

Update apt packages

sudo apt-get install samba samba-common-bin

RaspiConfig - Config

sudo raspi-config

<img src="https://i.stack.imgur.com/ercgf.png" />

Print local ip address

hostname -I


The username will be changed to mdp from pi. The home directory will show it as below.

    usermod –m –d/home/mdp mdp

Raspberry Pi change password

So, the username of your Raspberry Pi has been changed. It’s time to change the password for Raspberry Pi. For this;

    Logout from your current account (you are currently in root account)
    Now, login back with the new username ‘mdp’
    Type the command ‘passwd’ and enter the new password when prompted

That’s it. You have changed the Raspberry Pi password too.

What’s next?

You can disable the root account if you want to. But, first, type the command below:

sudo  apt-get update

If it works, then you are good to go. Type the following command to disable root login.

sudo passwd –l root

It’s recommended that you change the password of your Raspberry Pi frequently. It helps you to secure your project from any unwanted interruption. I hope the guide mentioned here is helpful. If you know or want to share any other methods to change the Raspberry Pi credentials, then feel free to write them in the comments section below.