When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.
Computer & Technology RelatedPost here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.
I need a good explanation for why the ./ command is used when running scripts etc in unix - struggling to find anything on the web - can anyone explain it??
Unix looks through the path to find the command. So if your current directory ( . ) is not there it wont find the command. Or worse will find a command that is not the one you want.
So ./command insures that you are running the one in the current directory and MUST be used if the path does not contain the current directory.
'cos if someone writes a program called ls (for instance) that does something nice and malicious, and dumps it somewhere, if you're in that somewhere, have . in your path, there's a good chance you'll run that malicious ls instead of /bin/ls
If you're root.... 'ls' could give root permissions to another user, then invoke the real ls (of course) so as not to raise suspicion.