Tuesday, May 7, 2024
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 127883  / 2 Years ago, thu, january 20, 2022, 11:17:45

I've two partitions on my windows OS and I've installed Ubuntu within windows.



Partition 1 : Windows and Linux OS



Partition 2 : Common storage files (called under the name New Volume)



I am looking at running a shell script that is placed in partition 2. I am able to run the shell when it is placed in the /home/... hierarchy of Ubuntu but I am unable to do so when it is placed in partition 2 which is being treated as an external disk by the OS.



I just want to know how can I actually change my working directory to a directory that is placed on an external disk which is mounted. What is the cd command to make the terminal look into a directory of the mounted disk?


More From » command-line

 Answers
5

I'm not quite sure what exactly is your problem, since you're mentioning cd yourself, but just to confirm: to change a working directory in terminal, you use cd command:



cd /path/to/directory


External disks are usually mounted under /media, so to get to your disk, you can type



cd /media/


then press Tab, which will show you files and sub-directories in that directory. Type a few first letters of the sub-directory you need and press Tab again. When the full path is entered, press Enter. Easy.



To run a shell script from that disk, the easiest would be to use something like



cd /media/MyDriveName/somedir/somesubdir
bash scriptname.sh


Note that you're invoking bash and passing it the name of the script, instead of running the script directly, like this:



cd /media/MyDriveName/somedir/somesubdir
./scriptname.sh


the first version don't need the executable bit to be set on the script file.


[#43310] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
imonove

Total Points: 82
Total Questions: 113
Total Answers: 106

Location: Saint Vincent and the Grenadines
Member since Wed, Nov 3, 2021
3 Years ago
;