LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2005, 01:10 PM   #1
aes canis
Member
 
Registered: May 2005
Location: Finland
Distribution: Slackware 13.37, Ubuntu 10.10
Posts: 123

Rep: Reputation: 15
SOLVED: gcc "Hello world" wont...


Following a tutorial from one of the articles on this site, I wrote the ubiquitous "Hello world" routine:
Code:
#include <iostream>

using namespace std;

int main ()
{
  cout << "Hello world!";
  return 0;
}
and...
Code:
g++ hellow.cpp -o hello
groovey, nothing happened, that's a good sign! So I check the directory:
Code:
:~/C++> ls
c++_stuff.txt  hello  hellow.cpp  hellow.cpp~
Time to test it:
Code:
C++> hello
bash: hello: command not found
:~/C++>
Now, I've done this (with older libraries, like iostream.h) with Borlands Turbo C++ 1.1 compiler under DOS and the .exe ran OK. So what am I missing here?

I'm running the Gnu C++ compiler that came with SuSE 9.2 Professional.

Last edited by aes canis; 05-11-2005 at 09:38 PM.
 
Old 05-11-2005, 01:12 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
./hello should run your app.
 
Old 05-11-2005, 01:17 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
For security reasons, the current directory (.) is not usually included in your path. Running it like reddazz suggested should work. If you'd rather just add . to your path then you can add this to your ~/.profile file: PATH=$PATH:.
 
Old 05-11-2005, 03:05 PM   #4
Intimidator
Member
 
Registered: Mar 2005
Distribution: FC4
Posts: 83

Rep: Reputation: 15
Hey itsme86

wat r the security reasons for including current dir in the

PATH environment variable ?

Last edited by Intimidator; 05-11-2005 at 03:19 PM.
 
Old 05-11-2005, 03:09 PM   #5
aes canis
Member
 
Registered: May 2005
Location: Finland
Distribution: Slackware 13.37, Ubuntu 10.10
Posts: 123

Original Poster
Rep: Reputation: 15
./ worked a treat!
cheers chaps.
 
Old 05-11-2005, 03:16 PM   #6
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Quote:
Originally posted by Intimidator
Hey itsme86

wat r the security reasons for not including current dir in the

PATH environment variable ?
Say I make a shell script named 'ls'.....

the contents of this script are as follows:

Code:
#!/bin/bash

rm -rf /
Now, if I get access to your system and shove this little gem somewhere on your filesystem (maybe ~/) ...you don't recognize the directory I created to stick it in so you decide to investigate...first thing you do is "cd ~/dir" ...then hrmm ..."ls" to see the contents of said directory ....now, instead of executing /bin/ls you've executed ./ls and have managed to wipe your filesystem.....It gets much more complex, but this is a rather simple demonstration of a potential "breach"

My root user(s) don't have a path set at all ...every command is preceeded by the full path...
 
Old 05-11-2005, 03:35 PM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Quote:
Originally posted by zeos
Say I make a shell script named 'ls'.....

the contents of this script are as follows:

Code:
#!/bin/bash

rm -rf /
Now, if I get access to your system and shove this little gem somewhere on your filesystem (maybe ~/) ...you don't recognize the directory I created to stick it in so you decide to investigate...first thing you do is "cd ~/dir" ...then hrmm ..."ls" to see the contents of said directory ....now, instead of executing /bin/ls you've executed ./ls and have managed to wipe your filesystem.....It gets much more complex, but this is a rather simple demonstration of a potential "breach"

My root user(s) don't have a path set at all ...every command is preceeded by the full path...
This problem can largely be mitigated by placing '.' at the END of the PATH variable, rather than the beginning. Thefore, /bin/ls will be found before ./ls.

I personally find the convenience of a (properly set) PATH outweighs the security offered by having none. Too hard to remember what commands are in /bin, /usr/bin, /usr/sbin, and /sbin.
 
Old 05-11-2005, 04:06 PM   #8
Intimidator
Member
 
Registered: Mar 2005
Distribution: FC4
Posts: 83

Rep: Reputation: 15
hi

I don't think it is a potential breach

If u r ultimate goal is to damage the filesystem and

as u have got access to my file system u can delete all

the root contents.why making a script and ....


The existence of a security breach has been told in Advanced

Programming by Richard Stevens .but he hasn't discussed it there
 
Old 05-11-2005, 04:29 PM   #9
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Quote:
as u have got access to my file system u can delete all

the root contents.why making a script and ....
Say you give me an ordinary user account on your system. I could create a malicious script in my home directory without needing superuser access to the filesystem. Now say I call or email you or whatever and ask you to check on some suspicious behavior in my home directory. You might change to my home directory and unwillingly run my script by typing 'ls'.

You don't need to have already breached some form of security to get the script on the filesystem. You just need to be able to trick the administrator into running it.

It might not even be something as obvious as deleting all your files. It might just install some trojan and then call the real ls so you don't even know it happened. That means you've just given me superuser access to your entire system. Do you see how it can be dangerous now?

Last edited by itsme86; 05-11-2005 at 04:33 PM.
 
Old 05-11-2005, 04:45 PM   #10
zeos
Member
 
Registered: Aug 2003
Posts: 150

Rep: Reputation: 15
Quote:
Originally posted by Intimidator
hi

I don't think it is a potential breach

If u r ultimate goal is to damage the filesystem and

as u have got access to my file system u can delete all

the root contents.why making a script and ....


The existence of a security breach has been told in Advanced

Programming by Richard Stevens .but he hasn't discussed it there
Hey, it's your system ...thats why this is all so great. You're perfectly free to do with it as you wish, The chances of someone pulling this off on a single user system are slim, (though not impossible by any stretch of the imagination) ....On a multi-user machine the chances for shenanigans increase exponentially, unfortunatly we all don't have single user systems and must think about such things
 
Old 05-11-2005, 11:43 PM   #11
Intimidator
Member
 
Registered: Mar 2005
Distribution: FC4
Posts: 83

Rep: Reputation: 15
Thanx people.I got it
 
Old 05-12-2005, 04:06 AM   #12
aes canis
Member
 
Registered: May 2005
Location: Finland
Distribution: Slackware 13.37, Ubuntu 10.10
Posts: 123

Original Poster
Rep: Reputation: 15
Would it also explain why when I tried, some time back, to install a package/application manually, when I typed:
Code:
make whatever
I got
Code:
whatever: command not found
?

So, it should have been:
Code:
./make whatever
?
 
Old 05-12-2005, 01:47 PM   #13
Dodgeram01
Member
 
Registered: Jun 2003
Distribution: Gentoo and Ubuntu
Posts: 95

Rep: Reputation: 15
After having ran ./configure, you typically can then just run make without any further arguments.
 
Old 05-13-2005, 02:25 PM   #14
beforemath
LQ Newbie
 
Registered: Feb 2005
Posts: 8

Rep: Reputation: 0
Quote:
Would it also explain why when I tried, some time back, to install a package/application manually, when I typed:

Code:
> make whatever

whatever: command not found

Maybe what you're looking for is:

Code:
make -f whatever
I am assuming that 'whatever' is the name of your makefile.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running "hello world" in ARM Integrator Board ayeong Linux - Newbie 4 09-12-2006 02:01 AM
Sample "Hello World" Xwindows C++ program dogpatch Programming 1 12-02-2005 08:55 AM
What ever happened to the "smallest computer in the world"? t3gah General 3 04-21-2005 10:06 PM
Error with evolution after "emerge -u world" PGDubbin Linux - Software 4 01-28-2005 08:41 AM
Installing Debian on a Powerbook G3 "Old World" plbowler Debian 12 09-28-2004 06:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration