View Full Version : "service" command doesn't work under normal user

30th October 2004, 06:32 PM
I'm currently trying to setup my vnc server, but i've noticed that i can only use the command "service" when i have complete root access (logging into xwindows as root), even when i'm in
root under my other user account (using su in console) it doesn't work. Is there a way to run services in my user account as i'm trying to avoid running things as complete root. Ive tried changing the permissions (chmod) for the command service or ownership (chmod) and it still doesnt work.

Any help would be appreciated =)

30th October 2004, 08:28 PM
I belive the command is: /sbin/service type it as root. Some commands require "/sbin/".

30th October 2004, 11:09 PM
You need root access for some services, like getting a web server to listen to port 80. It's only required to start things, however.

What services are you thinking of?

31st October 2004, 01:29 AM
I belive the command is: /sbin/service type it as root. Some commands require "/sbin/".
well you don't need to do that. it is like how your shell works - different users have different PATH variable settings. PATH stores directories containing binary files. when you type "foo" in shell - the shell looks in everydirectory (till first match) contained in PATH variable and executes (or not if it is not found) given binary...


>> Once I have permission, how do I log in as root?

Once you have the root password, you need to log in to get root access. This part is pretty easy. If you're logging in at the start of a session, do the following:

login: root
root@mymachine's password: [enter root password here]

If the password is correct, the system should let you in with Godlike privileges.

The second login scenario occurs when you're already logged in with your regular username and password, and want to shift into root. When this happens, type the following at the command prompt:


You might think this stands for “super user,” but you would be wrong. The command is “switch user,” and can be used to log in to the system as anyone else, providing you know the correct passwords. For example, if you wanted to log in as your buddy Mike, you could su mike, enter Mike's password, and do all sorts of things under his login. You could play a joke and use the passwd command to change Mike's password. Not that you should do this, but it would be kind of funny. (Note: Mike might not agree with the previous statement.)

When you use the su command without specifying a username, the system assumes you want to switch to root, and asks for the root password. Once you enter the correct password, you're logged in as root.

The interesting thing about using su is that it gives you root privileges with your own personal environment variables. This means you'll probably get a prompt that looks something like this:

[root@machinename myname]$

If you check out your path, for example, you'll see that it hasn't changed. Here's what you might see:

[myname@machinename myname]$ su
[root@machinename myname]$ echo $PATH
[root@machinename myname]

This is a pretty skimpy $PATH. If you really want the juice, you'll need to use su -. (That's su followed by a space, then a hyphen):

[myname@machinename myname]$ su -


[root@machinename /root]$ echo $PATH


[root@machinename /root]

Note that your $PATH variable is considerably more complex, giving you much more direct access to the various commands, scripts and programs on your machine. When you're done “rooting around,” here's how you go back to your initial login:


Hit ENTER and you should be back to your plain old regular non-super self.

If you're logging into your system remotely, and want to log in as root, it's a good idea to first use your garden-variety login, then use su - to shift to root once you're in. Doing this, instead of just jumping in as root from the get-go, can reduce the risk of being hacked.

You need root access for some services, like getting a web server to listen to port 80. It's only required to start things, however.
you need root access (not always but in most cases if you are not running MAC. remember that Fedora goes SELinux and here things are diffetent/better - based on roles not cheesy uid/gid matching) to perform bind() function on port lower than 1024 - in case of VNC this is port 6000+ so no need for root access (and if you don't need it - don't use it).