Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Cannot execute my own programs

  1. #1
    Join Date
    Apr 2011
    Location
    Tuscany
    Posts
    15

    Default Cannot execute my own programs

    Hi
    It is a bit strange but I can't execute the programs I wrote.
    This is the code:
    Code:
    alex@suse:~/Desktop> cat HelloWorld.c
    #include<stdlib.h>
    #include<stdio.h>
    
    int main(){
            printf("Hello World!");
            exit(EXIT_SUCCESS);
    }
    I can compile it:
    Code:
    alex@suse:~/Desktop> !gcc
    gcc -Wall -pedantic -g ./HelloWorld.c -o HelloWorld
    The permission bits look ok:
    Code:
    alex@suse:~/Desktop> ll
    total 20
    -rwxr-xr-x 1 alex users 10499 Apr 26 14:16 HelloWorld
    -rw-r--r-- 1 alex users    98 Apr 26 14:10 HelloWorld.c
    But I can' execute it:
    Code:
    alex@suse:~/Desktop> ./HelloWorld
    bash: ./HelloWorld: Permission denied
    
    alex@suse:~/Desktop> exec ./HelloWorld
    bash: /home/alex/Desktop/HelloWorld: Permission denied
    bash: exec: /home/alex/Desktop/HelloWorld: cannot execute: Permission denied
    I also tried to execute it as root, the output is the same.

    Maybe one or more of the bash flags are set incorrectly?

    Code:
    alex@suse:~/Desktop> set -o
    allexport       off
    braceexpand     on
    emacs           on
    errexit         off
    errtrace        off
    functrace       off
    hashall         on
    histexpand      on
    history         on
    ignoreeof       off
    interactive-comments    on
    keyword         off
    monitor         on
    noclobber       off
    noexec          off
    noglob          off
    nolog           off
    notify          off
    nounset         off
    onecmd          off
    physical        off
    pipefail        off
    posix           off
    privileged      off
    verbose         off
    vi              off
    xtrace          off
    alex@suse:~/Desktop> set +o
    set +o allexport
    set -o braceexpand
    set -o emacs
    set +o errexit
    set +o errtrace
    set +o functrace
    set -o hashall
    set -o histexpand
    set -o history
    set +o ignoreeof
    set -o interactive-comments
    set +o keyword
    set -o monitor
    set +o noclobber
    set +o noexec
    set +o noglob
    set +o nolog
    set +o notify
    set +o nounset
    set +o onecmd
    set +o physical
    set +o pipefail
    set +o posix
    set +o privileged
    set +o verbose
    set +o vi
    set +o xtrace

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Cannot execute my own programs

    Is your /home on an external disk, mounted on demand or a network mount? Do:

    mount

    and paste the output here. You may have this filesystem mounted noexec (explicitly or implicitly due to other mount options, e.g. user).

  3. #3
    Join Date
    Jul 2010
    Location
    Adelaide, Australia
    Posts
    961

    Default Re: Cannot execute my own programs

    It could be possible that your home folder is mounted with noexec option. What is the output of the
    Code:
    mount
    command?
    Desktop: Gigabyte GA-Z270-HD3 - Core i7 7700K - openSUSE Leap 42.2 KDE
    Laptop: HP EliteBook 8770W - Core i7 3940XM - openSUSE Leap 42.2 KDE

  4. #4
    Join Date
    Apr 2011
    Location
    Tuscany
    Posts
    15

    Default Re: Cannot execute my own programs

    Code:
    alex@suse:~> mount
    devtmpfs on /dev type devtmpfs (rw,relatime,size=2034100k,nr_inodes=204392,mode=755)
    tmpfs on /dev/shm type tmpfs (rw,relatime)
    devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
    /dev/sda6 on / type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    proc on /proc type proc (rw,relatime)
    sysfs on /sys type sysfs (rw,relatime)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    /dev/sda5 on /boot type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    /dev/sda7 on /home type ext4 (rw,nosuid,nodev,noexec,relatime,user_xattr,acl,barrier=1,data=ordered)
    fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
    /dev/sdb2 on /mnt/backup type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    /dev/sdb6 on /mnt/ubuntu type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb7 on /mnt/ubuntu/home type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb4 on /mnt/windows7 type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    securityfs on /sys/kernel/security type securityfs (rw,relatime)
    gvfs-fuse-daemon on /home/alex/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)

  5. #5
    Join Date
    Jul 2010
    Location
    Adelaide, Australia
    Posts
    961

    Default Re: Cannot execute my own programs

    Quote Originally Posted by _x_e_l_A_l_e_x_ View Post
    Code:
    alex@suse:~> mount
    devtmpfs on /dev type devtmpfs (rw,relatime,size=2034100k,nr_inodes=204392,mode=755)
    tmpfs on /dev/shm type tmpfs (rw,relatime)
    devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
    /dev/sda6 on / type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    proc on /proc type proc (rw,relatime)
    sysfs on /sys type sysfs (rw,relatime)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    /dev/sda5 on /boot type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    /dev/sda7 on /home type ext4 (rw,nosuid,nodev,noexec,relatime,user_xattr,acl,barrier=1,data=ordered)
    fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
    /dev/sdb2 on /mnt/backup type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    /dev/sdb6 on /mnt/ubuntu type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb7 on /mnt/ubuntu/home type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb4 on /mnt/windows7 type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    securityfs on /sys/kernel/security type securityfs (rw,relatime)
    gvfs-fuse-daemon on /home/alex/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
    Your home folder is being mounted with the noexec permission. What is the output of:
    Code:
    cat /etc/fstab
    ?
    Desktop: Gigabyte GA-Z270-HD3 - Core i7 7700K - openSUSE Leap 42.2 KDE
    Laptop: HP EliteBook 8770W - Core i7 3940XM - openSUSE Leap 42.2 KDE

  6. #6
    Join Date
    Apr 2011
    Location
    Tuscany
    Posts
    15

    Default Re: Cannot execute my own programs

    Code:
    alex@suse:~> cat /etc/fstab
    UUID=174480e6-309c-42c7-a66a-248b9284426a /                    ext4       data=journal,acl,user_xattr 1 1
    UUID=54b41216-7efe-498e-a19b-d914381c1f57 /boot                ext4       data=journal,acl,user_xattr 1 2
    UUID=6330890b-3b27-4ad8-997a-80a1dac065b4 /home                ext4       user,acl,user_xattr   1 2
    /dev/disk/by-id/ata-WDC_WD5000AAKS-00YGA0_WD-WCAS84837814-part5 swap                 swap       defaults              0 0
    proc                 /proc                proc       defaults              0 0
    sysfs                /sys                 sysfs      noauto                0 0
    debugfs              /sys/kernel/debug    debugfs    noauto                0 0
    usbfs                /proc/bus/usb        usbfs      noauto                0 0
    devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
    /dev/disk/by-id/ata-WDC_WD5000AAKS-00YGA0_WD-WCAS84837814-part2 /mnt/backup          ntfs-3g    user,users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0
    /dev/disk/by-id/ata-WDC_WD5000AAKS-00YGA0_WD-WCAS84837814-part6 /mnt/ubuntu          ext4       user,acl              1 2
    /dev/disk/by-id/ata-WDC_WD5000AAKS-00YGA0_WD-WCAS84837814-part7 /mnt/ubuntu/home     ext4       user,acl              1 2
    /dev/disk/by-id/ata-WDC_WD5000AAKS-00YGA0_WD-WCAS84837814-part4 /mnt/windows7        ntfs-3g    user,users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0

  7. #7
    Join Date
    Jul 2010
    Location
    Adelaide, Australia
    Posts
    961

    Default Re: Cannot execute my own programs

    Try changing this line:
    Code:
    UUID=6330890b-3b27-4ad8-997a-80a1dac065b4 /home                ext4       user,acl,user_xattr   1 2
    to this:
    Code:
    UUID=6330890b-3b27-4ad8-997a-80a1dac065b4 /home                ext4       user,acl,user_xattr,exec   1 2
    Notice the exec option. That should allow you run run executables on the /home partition. Then restart.
    Desktop: Gigabyte GA-Z270-HD3 - Core i7 7700K - openSUSE Leap 42.2 KDE
    Laptop: HP EliteBook 8770W - Core i7 3940XM - openSUSE Leap 42.2 KDE

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: Cannot execute my own programs

    Or just remove the "user" option since it looks like a non-removable disk and there is no need for users to be able to initiate a mount, it will be mounted at boot time.

  9. #9
    Join Date
    Apr 2011
    Location
    Tuscany
    Posts
    15

    Default Re: Cannot execute my own programs

    Code:
    alex@suse:~/Desktop> mount
    devtmpfs on /dev type devtmpfs (rw,relatime,size=2034100k,nr_inodes=204392,mode=755)
    tmpfs on /dev/shm type tmpfs (rw,relatime)
    devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
    /dev/sda6 on / type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    proc on /proc type proc (rw,relatime)
    sysfs on /sys type sysfs (rw,relatime)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    /dev/sda5 on /boot type ext4 (rw,relatime,user_xattr,acl,barrier=1,nodelalloc,data=journal)
    /dev/sda7 on /home type ext4 (rw,nosuid,nodev,relatime,user_xattr,acl,barrier=1,data=ordered)
    fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
    /dev/sdb2 on /mnt/backup type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    /dev/sdb6 on /mnt/ubuntu type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb7 on /mnt/ubuntu/home type ext4 (rw,nosuid,nodev,noexec,relatime,acl,barrier=1,data=ordered)
    /dev/sdb4 on /mnt/windows7 type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    securityfs on /sys/kernel/security type securityfs (rw,relatime)
    gvfs-fuse-daemon on /home/alex/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
    It works now!
    Code:
    alex@suse:~/Desktop> ./HelloWorld 
    Hello World!
    Thank you

  10. #10
    Join Date
    Nov 2010
    Location
    Ελλάδα(Αθήνα)-Россия (г. Красноярск)
    Posts
    1,711

    Default Απ: Re: Cannot execute my own programs

    You try to run a program in terminal-a C program.
    I want to give you some ideas. I like to see people to develop with terminal.
    Try to run programs in Kwrite first or in Compiler DevC/C++

    I speak about this program
    Code:
    alex@suse:~/Desktop> cat HelloWorld.c
    #include<stdlib.h>
    #include<stdio.h>
    
    int main(){
            printf("Hello World!");
            exit(EXIT_SUCCESS);
    }
    That was my first program when I start object oriented programming.
    Πάντα Φιλικά, Στάμος.
    Desktop: openSUSE Leap 15.3||x86_64||Gnome 3.14 & KDE 5||AMD Ryzen 7 8 core||Nvidia GTX 1080 Ti Gaming Edition
    Γλώσσες Προγραμματισμού: C++, Qt developing.
    http://bit.ly/fT8Hfi

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •