Creating script to change ownership directory on RHEL4U3 at startup
Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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)
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.
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.
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.
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?
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.
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.