Run shell on a removable disk in linux

Posted on 2011-05-09
Last Modified: 2012-05-11
I want to run a shell program in USB disk.
By chown, ownership of the file has been taken, but failed to change the file to executable with chmod +x. Why?
Question by:fxp007
    LVL 31

    Assisted Solution

    Did you do

    chmod +x /path/file

    You can copy the file first to your local directory and try it again.

    You don't even need the file to be executable to run it.  Suppose on the first line of the script it says, #!/bin/bash, you know it is running with bash.  All you need to do is

    bash /path/filename

    This would run your script.
    LVL 12

    Assisted Solution

    I guess the USB drive has been mounted with noexec option and that is causing the problem.

    Could you please show us output of below given command.

    # mount

    Or you can use the way as farzani told You can copy the file first to your local directory and try it again.

    LVL 30

    Accepted Solution


    It seems that there was no eexecute permisson assignd to the mount.
    - Mount the USB stick
    - execute the mount command

    you should see something like that
    /dev/sdc1  /media/disk type vfat (rw,nosuid,nodev, shortname=winnt,uid=0)

    If you see something like "noexec" this will cause nothing in ths volume be executed. Please try to remount the volume manually.

    LVL 38

    Assisted Solution

    > I want to run a shell program in USB disk
    For borne shell/bash script, you can do
    bash /path-to-usb-script
    sh /path-to-usb-script

    For csh/tcsh script:
    csh /path-to-usb-script

    It will run the script for you with or without executable bit.
    Actually, the script calls the shell command that specify at the first line (#!/bin/bash).

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now