bash - how to change directory from inside unix shell -




change(){ read -p "enter username" q sudo su $q cd /home/$q pwd  } change 

without using sudo able change directory, when sudo su, cd not work ? possible reason behind , solution

when run sudo su $q, logging in $q. then, script waits until sudo su command exits, before continuing execute. rest of script execute after type exit-- including change of directories.

if wish su end in different directory, first change directory, , then run sudo su command.





wiki

Comments

Popular posts from this blog

elasticsearch - what is the equivalent data type for geo_point in hibernate search? -

firebase - How to wait value in Ionic 2 -

Jenkins: find build number for git commit -