Having issues in shell scripting

Q.There is something wrong with the script /home/bob/update_shell.sh. Find out the issue and fix it.

This script should update the bob’s home directory and default shell if valid command-line arguments are provided but it is not working correctly.

update_shell.sh code==>

new_shell=$2
user_name=$1
usermod -s $user_name $new_shell

unable to run the same???

1 Like

./update_shell.sh teak /bin/sh
bob
usermod: no changes
usermod: user bob is currently used by process 203

and script looks like this
bob@caleston-lp10:~$ cat update_shell.sh
new_shell="$2"
user_name="1" USER=(whoami)
echo $USER
sudo usermod -s $new_shell $USER
sudo usermod -d “/home/”$user_name $USER

Hi Navin, looks like your command syntax is wrong.
it should be usermod -s $new_shell $user_name

thank you vijin.palazhi

Hello Vijin,

I had the same issue. I had updated the order in which the new shell and user name appeared in the script as per the usermod command. It still did not work for me. I am sure I used the format
usermod -s $new_shell $user_name

I even skipped the variable name part and user the “Read Input” method but still did not work. Had to skip the last question :stuck_out_tongue: