Shell script won't run cd command

cd is a shell builtin. you should use this:

#! /bin/bash
gnome-terminal --working-directory=/home/username/Desktop/CCA/ -e './Adventure'

The error

Failed to execute child process "cd" (No such file or directory)

arises because cd is one of the SHELL BUILTIN COMMANDS and not an executable that you physically find on your Hard Disk.

To run it or the others built-in commands in you script you need to pass all the line to a bash invocation

 gnome-terminal -e '/bin/bash -c "cd ~/Desktop/CCA/; ./Adventure" '   

If there are no other internal command that you have to execute you can set the working directory for the gnome terminal, as just answered here:

gnome-terminal --working-directory=/home/username/Desktop/CCA/ -e './Adventure'

Ad nauseam: there are some alternatives:

If you are just in a terminal you can either do

  • an alias like
    alias Star_My_Game="cd ~/Desktop/CCA; ./Adventure "
    and put it in your .bashrc or in ~/.bash_aliases so that you will be able to run with the single command Start_My_Game in each shell you will be (It's more cosy to choose a simpler/short name than Start_My_Game...)

  • or a script that you can make executable (chmod u+x MYscript) and put in your path (tipically ~/bin is a good candidate).

I suppose you can put a link on your desktop that execute the terminal and modify the starting behaviour. From gnome help

  1. Select Edit ▸ Profile Preferences ▸ Title and Command.

  2. Check Run a custom command instead of my shell.

  3. In the text box, type the command or the desired shell.

  4. The command will be passed to the terminal exactly as you write it, including any arguments that you specify. Environment variables will be inherited from the terminal as it is a child process of the terminal.

    Open a new Terminal tab or window to see how the custom shell or command executes