linux (redhat) stupid question..

hi,

I am new to linux and yesterday I installed redhat 8.0 and choose the personal desktop package (with addition the development tools : gcc C compilers)

my purpose to install linux is to use it for shell scripting & C programming ONLY....BUT somehow I cant execute the file I ve made...

so if I create either shell script or C program and then compiles it, it compiled properly, I can see the executables in my directory, but when I run it...by typing <executablename> <arguments> (for example), it give me error...bash: no such command (something like that, I cant remember) --> this happen for both shell or C program...

anyone know what is the solution for this? do I need to actually install full packages of redhat?

is mandrake 9.0 has such a problem? how issit compare to redhat 8.0? is the installations as easy as redhat?

thanks in advance for any help or advice,

Ferdinand
 
yes.. this its one of the first things that a newcomer to linux notice..


different to DOS..


Linux and Unix only execute programs that are on the search path, i mean..

on DOS
if you cd to \programs and you have an executable there, you just type the name of the executable and it works, why ? because DOS look for the executable first on the directory where you are located, if it cant find it there, then it search every directory of the PATH variable.

In Unix/Linux, when you invoke a program and you dont specify the excecutable path, it search only on the directories that the PATH environment variable has.

so..

first you have to remember that every directory has 2 special directory files.. those are the:

. (dot)
and
.. (dot dot)

-----------
Note: Confirm this!! do a "dir" on DOS and you will see something like:

09/20/2002 10:30 AM DIR .
09/20/2002 10:30 AM DIR ..

also type "ls -la" on unix/linux and you will see:

drwxr-xr-x 48 root root 12288 Oct 12 18:48 .
drwxrwxrwx 10 root root 4096 Oct 1 09:00 ..
--------------

the first directory (.) contains the name of the directory where you are located, the second (..) contains the name of the previous directory..

so when you do:

cd ..

you change to the previous directory because .. (dot dot) its replaced by the name of the previous directory

and when you:

cd .

it seems to do nothing.. but it really changes again to the current directory..

so if the . (dot) file contains the name of the current directory.. one way to solve your problem its:

Edit your .profile or the /etc/profile file and add the . directory to the PATH, this way, when you execute something it will also look for it on your current directory (add ":." at the end of the PATH variable, you will need to exit your session and login again to apply the profile or "source the profile" but this its a different story, just log out and login again.)

Other way to solve this its:

invoke the program using the complete path, i mean if your program its on /home/joe and its called "test", type /home/joe/test to execute instead of only "test".. i know this its horrible.. but if we said before that the "." (dot) directory contains the name of the current directory and you are on /home/joe then:

./test

its the same than:

/home/joe/test

right ?

try it..

BTW: dont forget that in order to execute a file, it has to have execution permissions..
 
Last edited:
hi all,

thanks for all the reply bzImage, VERY HELPFUL!!

now I can get the executables executed properly THANKS :)
anyone know how to add gnuc for my compiler (only have gcc atm)

and how is it to read/write into floppy drive/cdrom?
I cant seem to find my CDROM and FLOPPY Drive....to be honest I dont know why people hate windows *wink* ^_^

once again, is Mandrake 9 better than Redhat 8? from personal desktop (use only for C & shell programming) point of view...

thanks,

Ferdinand
 
feyang said:
hi all,

thanks for all the reply bzImage, VERY HELPFUL!!

now I can get the executables executed properly THANKS :)
anyone know how to add gnuc for my compiler (only have gcc atm)

and how is it to read/write into floppy drive/cdrom?
I cant seem to find my CDROM and FLOPPY Drive....to be honest I dont know why people hate windows *wink* ^_^

once again, is Mandrake 9 better than Redhat 8? from personal desktop (use only for C & shell programming) point of view...

thanks,

Ferdinand
gcc its gnu c, you already have it.. or maybe i dont understand what you mean..

How to read write on floppy/cdrom ?


well.. different from DOS, unix/linux has no drive names (like a: or c: or d:, etc). It has mount points and devices..

I mean..

You need to have a directory to link your floppy or cd device..

Using mount, you can link your floppy or cd device to this directory..

By default this directory already exist (but you can create one for this if you wish), its called /mnt

/mnt means "mount", so this its the mount mount for the removable media, on some linux distributions inside /mnt you have different directories, each for each kind of media, eg:

/mnt/floppy
/mnt/cdrom

on some other distribuitions or Unix flavors, you only have /mnt, but this its trivial since you can mount a removable device on any directory no matter whats its the name.

First:

type

"mount"

what do you see ?

maybe something like this:


cut here --

/dev/hda1 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hda6 on /hall type ext2 (rw,usrquota)
/dev/hdd1 on /hall1 type ext2 (rw,usrquota)
/dev/hdb1 on /ddata type xfs (rw)
/dev/hde2 on /rdata type xfs (rw)
/dev/sda1 on /mdata type ext3 (rw)
/dev/sdb2 on /vdata type ext3 (rw)
/dev/sdb3 on /xdata type rawd (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)

cut here --

since this its the output of my home server your output of the mount command will be different, but i can use a line or two of this output to show my point..

ok.. the mount command tells me for example that:


/dev/hda6 on /hall type ext2 (rw,usrquota)


this means:

the device (/dev/) first IDE hard disk (hda) filesystem 6, its mounted on the directory /hall, this filesystem its of type ext2 and its mounted in read write mode, it also have quotas. When you enter the /hall directory you really are entering this hard disk and this filesystem.

so the second IDE hard disk its: /dev/hdb
the third IDE hard disk its: /dev/hdc

the first partition (or filesystem) of the second IDE hard disk its: /dev/hdb1

the second partition of the first SCSI disk (sda) its: /dev/sda1

Do you get it ?

So, in order to mount a removable media, you need to have:

a device name, a mount point, and a filesystem type

Then, what its the device name of the floppy ?

Well it depends on the floppy media, its not the same a floppy of 1.4 MB than a floppy of 720KB, its not the same 5 1/4 than 3 1/2, right ?

you can see all the different floppis devices supported by linux typing:

ls /dev/fd*

but, in order to make things more easy, you can use /dev/fd0 to refer to the first floppy drive, /dev/fd1 to the second floppy drive, and so on:

so if you type:

mount /dev/fd0 /mnt

it will try to mount the fist floppy device on the /mnt/directory

IT MUST HAVE a recognized filesystem type, like DOS or ext2 or similar.

but since most newer kernels include support for DOS fs on the configuration you must have no problems mounting DOS floppys.

and in order to make the things even more easy, there its a file /etc/fstab, this its the filesystem table, this its used to mount by default a device, for instance:

if on /etc/fstab exists the following line:

/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0

this means:

the device: /dev/cdrom
will mount on: /mnt/cdrom
its of type: iso9660
options: noauto,owner,ro (no automount, owner permissions, read only)
the next 0 0 parts are on the order and fsck flags, dont bother now about this.

so if i type:

mount /mnt/cdrom

or

mount /dev/cdrom

(just the mount point or directory without device or just the device without mount point, it will read the fstab file and automatically make the right descitions on where and what filesystem mount)..

so:

in order to mount your floppy type:

mount /dev/fd0

in order to mount your cd type:

mount /dev/cdrom

where it is mounted ?

type :

mount

how can i use it ?

change to the mounted directory (cd /mnt/cdrom or /mnt/floppy)

HEY!!! i can eject my cd !!

yes, a mounted cdrom cant be ejected until its umounted, type:

umount /dev/cdrom

or

umount /mnt/cdrom

do dis-mount

HEY!!!, when i type that it tells me something a device busy.. !!

Yes you cant unmount /mnt/cdrom if a process or you are on this directory, you must exit all processes that use this mounted device and change to another directory to do it..

HEY!! but i can extract my floppy whitout dis-mounting!!

DONT DO THAT.. always dis-mount (umount) a device before you extract it from the computer, or the device will become corrupt, this its very common with floppy media.

is Mandrake 9 better than Redhat 8?

Its a different kernel the mandrake 9 than the Redhat 8 ?

NO, its the same thing!!, maybe mandrake has a newer or more recent version or the kernel or viceversa, but you can allways get the LATEST kernel form ftp.kernel.org, build it yourserlf and thats it.

But Mandrake has xyz application!! or Redhat has zyw application:

Get the source code of the application, compile it your self and thats it!!

All this :

its this linux better than this one ? makes no sense.

What the linux distros does ?

Lets take an example:

RedHat.

They select a kernel version based on stability and features (not allways the latest kernel version or the one with most features), they select a graphical environment like KDE or GNOME based on the same thing. they compile it, burn a CD, package then and thats it. here its Redhat xx.xx.

Its the same thing with any other linux distribuitions, they dont make the code!!, the code its free, they just compile it and package it..

if a program version dont exists on one distribuitions, this DONT MEAN THAT YOU CANT GET THE SOURCE AND COMPILE IT YOURSELF.

So everything its the same thing.

But if you wish to wait 2 weeks to wait for the latest KDE or GNOME release, then wait for Redhat 10 or Suse 15 or Mandrake 17

You want it now ?

go to www.kde.or or www.gnome.org, get the source, compile it, use it..
 
pokopiko,

thanks alot, very useful post, get both my CDROM & Floppy disk working now... ^_^

I'll stick with redhat since it's not giving me any problem so far (I am giving myself a problem ;p)

is there anyway to change the write access to a file? I am going to modify my profile (in /etc dir), but the file is read only, I ve tried doing chmod a+rwx, didnt work...

thanks for all the help,

Ferdinand
 
Your profile its not on /etc, on /etc its the system wide profile, your profile its on your home directory.

when you log in to the system it first executes /etc/profile and later the user profile.

your profile (if you are using bash) its .bash_profile and its on your home directory, modify this..

in order to change the permissions of the /etc/profile file you need to be the "root" user.
 
jesus & i thought linux & mandrake was supose to be easy.lol
at least with ms os you only have to point & click.
but still want to try it out.
parrot man
 
Define Easy ..

Now Define Powerfull..

What you prefer ?

Easy or Powerfull ?

Windows its Easy.

Unix/Linux its Powerfull.

To use Unix/Linux you must know computer sciences, to use windows you don need to.

To use Unix/Linux you must think..
 
Top