12

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?

muru
  • 193,181
  • 53
  • 473
  • 722
Vamsi Emani
  • 2,565
  • 5
  • 22
  • 23

2 Answers2

18

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.

Sergey
  • 43,339
  • 13
  • 106
  • 107
  • 1
    The reason that the execute bit is important is that if the partition is FAT or NTFS ( the only two disk based filesystems Windows understands ), it does not support permissions, so you can't set the execute bit. – psusi Sep 27 '11 at 17:44
2

Please give us the result of this (press ctrl + alt + T to open a terminal ) terminal command:

mount 

to copy the result please select the command result text from terminal then copy, then paste here...

dlin
  • 3,740
  • 3
  • 29
  • 45
marcobra
  • 302
  • 2
  • 6