LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Creating script to change ownership directory on RHEL4U3 at startup (https://www.linuxquestions.org/questions/linux-enterprise-47/creating-script-to-change-ownership-directory-on-rhel4u3-at-startup-620225/)

Ferianto 02-10-2008 11:12 PM

Creating script to change ownership directory on RHEL4U3 at startup
 
Dear IT Experts,

I want to change ownership of /dev/* directory, everytime when I restart the computer.
So, I create a script.

#vi owner

#!/bin/bash

cd /dev
chown -Rf ferianto *


:wq!

#chmod 755 /etc/init.d/owner

I want that this script is run when the computer is restarted. But, I does not work.
The ownership /dev direcroty still for "root", not change to "ferianto".

I also have created link at /etc/rc.3.d :

#ln -s ../init.d/owner /etc/rc3.d/S17owner


I have tried to change the ownership from terminal using command
#chown -Rf ferianto *

It works, but, It will come back to "root" when everytime I restart the computer :( (in case my PC hang so I must reboot it)

I use Redhat Enterprise 4 Update 3.

Does anybody can help me what should I do ?

Please help me...?

Thanks,

Ferianto

Disillusionist 02-11-2008 02:49 AM

First, let me welcome you to Linuxquestions.org

It might help us to know why you are trying to change the ownership of the system device files. These files are owned by root and changing them may very well make your system unstable.

Additionally, what runlevel are you booting into? (Type runlevel at the command prompt)

If you are booting into runlevel 4, then you may find that changing your link to ln -s /etc/init.d/owner /etc/rc4.d/S99owner may set the permissions that you are after.

However, I would strongly suggest that you do not do this on a production machine.

Ferianto 02-11-2008 08:37 PM

Dear Disillusionist,

Thank you very much for your response...

The main aim that I want to change the ownership is because in the Workstation, I want to Run VMware (Windows XP) as guest operating system, meanwhile I use RHEL4U3 as host operating system. In order using all devices through the VMware (Windows XP), I must change the /dev/ directory ownership to the login username (ferianto), because user not allowed to login via root.

I use run level 5.
When I checked directory /etc/rc5.d, I found the other file which has S99xxx, at the prefix. So, how can I create new the link for file "owner" if there has been a file using prefix "S99"? Is there any rule to give the prefix number "Sxx"?

Is the script that I have made before correct for this reason? So , then to run the script ("owner") , I just create the link as you said before.

Please help, me... I am still confused..

Thanks for welcome greeting... ;-)

Thanks,


Ferianto

gilead 02-11-2008 08:47 PM

You don't have to change the ownership of the devices. I haven't changed the ownership of any devices except the network device when I want to run the network card in promiscuous mode.

Are you getting a specific error or are you having problems installing the product? I use VMWare Workstation and the docs here are quite good. I'd recommend you use them before you make changes to the /dev hierarchy.

Ferianto 02-12-2008 01:36 AM

Dear gilead,

Thank you very much for your response...

We installed VmwareWorkstation-6.02-59824.rpm packet at the workstation.

The packet can be installed sucessfully without any error.

In our computer system, we use NIS system, so user home directory was stored
at Network system.

We use Vmware to run Windows XP at Linux (RHEL4) at the same time.

In the workstation, we have 2 hardisk. We install RHEL4 at the first disk and
Windows at another disk.

We can not Finish steps to "create New Virtual Machine" at VMware Wizard menu. I got error messages at "Select Physical Disk Partition" at
"New Virtual Machine Wizard menu". This is the error messages:

"Partitions

device :/dev/hdb
Failed to load partitions for device /dev/hdb : Insufficient permission to access file "


This problem can be solved if I change /dev ownership to username who access the computer (like : ferianto).

This is the reason why I want to change the ownership /dev/ directory.
But, the problem is I must type command "chown -Rf ferianto * " at command prompt everytime the computer reboot to change ownership of /dev directory.
Because I see that RHEL4 always re-create /dev file or give back /dev ownership to root everytime when the computer reboot although I have changed the
ownership before.
That is why I want to make script for it :(

Where should I place the script? Is the script that I have made before correct?

Please help, Me..

Thanks

Ferianto

Disillusionist 02-12-2008 01:46 AM

I agree with Gilead, you should not need to change the permissions on the /dev folder.

The point of using VMWare is that the guest operating system is unaware that it isn't being installed on a physical machine of its own.

It can't see the /dev folder (and wouldn't know what to do with it if it could). VMWare creates a virtual device for each component that gets passed to the guest operating system.

If you are experiencing permissions issues, I would suspect that something was wrong with the installation of VMWare itself.

Was VMWare installed as root?

Disillusionist 02-12-2008 02:08 AM

Ferianto,

The format of your startup script will work.

To test this you can run /etc/init.d/owner (as root)

There is nothing wrong with having more than one script begin with S99 so long as they are uniquely named.

To create your startup script you could type (as root):
Code:

ln -s /etc/init.d/owner /etc/rc5.d/S99owner
At each runlevel the scripts are listed in alphabetical order and then processed one at a time S99 would ensure that it was either the last script or as near as possible.

Any script that begins K will pass "stop" as a variable to the linked script.

Any script that begins S will pass "start" as a variable to the linked script.

As your script does not check the value of $1, it would do the same thing regardless of whether it was linked as a startup or shutdown script.

I still say that this is the wrong solution but it should work.

Regards,

Disillusionist

gilead 02-12-2008 04:20 PM

You should just need to do 2 things. Firstly, check the group ownership of /dev/hdb* - it's probably disk. If so, add the user to the disk group.

Secondly, confirm that the disk group has write access to that device. If so, nothing more should need doing.

Ferianto 02-13-2008 09:11 PM

Dear Dissilusionist and gilead,

Thanks very much for your help..the scripts works...

But, through Mr. Gilead suggestion about changing ownership of /dev/hdb (Windows disk), would you mind tell me how to do that, because I have done this:

# chown -Rf ferianto /dev/hdb1

but I still can not access this disk. Would you mind tell me the steps that you have said before. I am still newbie...sorry for too much questions :)

Thanks I really appreciate you help :-)

Ferianto

gilead 02-13-2008 10:01 PM

It's best to modify /etc/group using vigr and add ferianto to the disk group.

The problem with changing the owner is that the ownership will revert to root on a re-boot. It may be possible to alter your udev rules to avoid this, but I don't recommend it.


All times are GMT -5. The time now is 06:35 PM.