You could create a local ls
, such as
#!/bin/bash
/bin/ls -l
/courses/InetSec1/challenge6/get-code
then put this script (you should name it as ls
and run chmod a+x ls
to add execute permission to it) in some directory, such as ~/bin/
, and add this directory to your path by export PATH=$HOME/bin:$PATH
.
After this, if you run that program again, it will run your local ls
, because system()
will run your command under a subshell, and that shell will search command needed to run in $PATH
.
Exactly the answer given in Modify a program I'm not the owner of