LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices

Reply
 
Search this Thread
Old 02-10-2008, 11:12 PM   #1
Ferianto
LQ Newbie
 
Registered: Jul 2006
Posts: 6

Rep: Reputation: 0
Unhappy 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
 
Old 02-11-2008, 02:49 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
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.
 
Old 02-11-2008, 08:37 PM   #3
Ferianto
LQ Newbie
 
Registered: Jul 2006
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 02-11-2008, 08:47 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
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.
 
Old 02-12-2008, 01:36 AM   #5
Ferianto
LQ Newbie
 
Registered: Jul 2006
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 02-12-2008, 01:46 AM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
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?
 
Old 02-12-2008, 02:08 AM   #7
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
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
 
Old 02-12-2008, 04:20 PM   #8
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
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.
 
Old 02-13-2008, 09:11 PM   #9
Ferianto
LQ Newbie
 
Registered: Jul 2006
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 02-13-2008, 10:01 PM   #10
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Script to change directory gudum35 Linux - General 5 05-31-2006 03:43 PM
change ownership script paul_mat Linux - Software 3 04-07-2006 07:59 PM
script to change directory trout21 Linux - Newbie 9 02-17-2004 12:49 PM
Where is system's startup script directory william43 Linux - Newbie 4 07-11-2003 12:30 AM
Help creating a directory back up shell script WarriorWarren Linux - General 6 04-06-2003 09:56 AM


All times are GMT -5. The time now is 02:05 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration