First of all, I'm totally new in this Linux world. So, please consider this when you read. I got a 10 to 20 lines of bash code which I need to run periodically. Now yesterday, I've been trying to put those lines in a single bash file so that I can just run them in a single command. But I got stuck at a point because the code contains some operations that can only run with a shell login, like 'cd /root' for instance. Now, every time I run them I need to login to a shell using 'sudo -s' after some point. Here is a part of my codes.
cd ~ cp -Rf $worthy_folders /root/ sudo -s cd /root sudo chown -R root:root $worthy_folders
Obviously I can not write them in a bash file as they are. That just prompts me for password and need to press several enter. And also the 'sudo cd' doesn't work. So, my question is, there a way to write those commands in a single bash file and just run them?