PDA

View Full Version : services tutorial



earobinson111
5th January 2005, 06:00 AM
anyone have a good fc3 services tutorial?

earobinson111
6th January 2005, 06:43 PM
can anyone give me some help with this?

ewdi
6th January 2005, 06:44 PM
services you mean like managing services right using chkconfig?

earobinson111
6th January 2005, 06:47 PM
hum, im not sure im makeing this post from school and we use debian. im talking about the ones that let you pick what programs run for example cups. my problem is that the info they give you on what it does is very limited and so im not sure what i should run and what i should not. i only use the gui editor and its under the name or services in the gui i think its system preferences or the other one close buy then its in another folder inside there.

ewdi
6th January 2005, 06:49 PM
i got this one from a text file in college



Using chkconfig & /sbin/service to manage run start up scripts in RedHat - Printable View


Red Hat includes the checkconfig & service utilities to help you manage your start up scripts and save you a lot of typing. This is handy when you're adding your own services and also in managing the already existing services. chkconfig is available if you want to use it on other distributions that may not come with it - just go to freshmeat.net and look it up. /sbin/service is just a shell script that comes as part of Red Hat's initscripts package.

Without a tool like chkconfig, symbolic links to the scripts in /etc/rc.d/init.d are typically created by hand at the appropriate run levels. This can be messy & difficult to standardize. Also, it is necessary to view the contents of each run level directory to see which services are configured to run. Here's some ways to use chkconfig: What's enabled at run level 3?

[root@tapir init.d]# chkconfig --list | grep 3:on
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
random 0:off 1:off 2:on 3:on 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
nfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

Enable a service for runlevel 3

[root@tapir init.d]# chkconfig wine on
[root@tapir init.d]# chkconfig --list wine
wine 0:off 1:off 2:on 3:on 4:off 5:off 6:off

Disable it

[root@tapir init.d]# chkconfig wine off
[root@tapir init.d]# chkconfig --list wine
wine 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Checkconfig reads some lines at the beginning of an rc script to determine what run levels the script should be run at. We'll use the openssh rc script as our example.

[root@tapir init.d]# head -8 sshd
#!/bin/bash
#
# Init file for OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: OpenSSH server daemon
#

The chkconfig line & description line must go into every script that is to go under the control of chkconfig. The description line seems pretty self-explanatory. the chkconfig line:

# chkconfig: 2345 55 25
| | |
| | priority for kill scripts
| |
| priority for start scripts
|
run levels at which to start service

If you've created an rc script for a service, put your chkconfig line & description line in as listed above. Then you need to add your service to those under the management of chkconfig.

[root@tapir init.d]# chkconfig sshd --add

Now you can enable it.

[root@tapir init.d]# chkconfig sshd on

You can see by looking at listings of the directories that the appropriate links have been created in each of the run levels.

[root@tapir rc.d]# for i in 1 2 3 4 5 6
> do
> ls rc$i.d/*ssh*
> done
rc1.d/K25sshd
rc2.d/S55sshd
rc3.d/S55sshd
rc4.d/S55sshd
rc5.d/S55sshd
rc6.d/K25sshd

If you didn't know, the K links pass a stop parameter to the script and the S links send a start parameter. The numbers determine in what order they'll run relative to the other scripts at a given runlevel. The rc scripts are executed in the order you see when you list them in the directory, first the K's in numerical order, then the S's in numerical order. So at run levels 1 and 6 the script is run with a stop parameter, and in run levels 2,3,4,5 it receives a start parameter. We also see this by running a simple command:

[root@tapir rc2.d]# chkconfig sshd --list
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Now that you can manage your scripts using chkconfig, here's a tip that will save you a little bit of typing. When running an rc script to restart a daemon or what have you, the path is pretty long:

[root@tapir rc2.d]# /etc/rc.d/init.d/sshd restart

or you could type this instead:

[root@tapir rc2.d]# service sshd restart

Hey, it's 9 keystrokes less! It has some other cool features - get the status on all your services:

[root@tapir rc2.d]# service --status-all
apmd (pid 682) is running...
arpwatch is stopped
atd (pid 1151) is running...
cannaserver (pid 985) is running...
crond (pid 1003) is running...
cserver (pid 966) is running...
jserver (pid 946) is running...
gpm is stopped
identd is stopped
ipchains: Incompatible with this kernel
No status available for this package
kserver (pid 1023) is running...
lpd is stopped

You get the idea. Have Fun!

by Urbana Der Ga'had

ewdi
6th January 2005, 06:50 PM
the post above should help, it's a tutorial how to manage services like cups and etc

Note : chkconfig is in /sbin/

earobinson111
6th January 2005, 06:50 PM
i think that is it is there a gui for that program? and what i want to know is what they all do so i know what ones i need to run found a screen shot of the program in talking about http://docs.biostat.wustl.edu/rhl-cg-en-9/figs/services/serviceconf.png

and i know the basics like cups but i want to know what they all do but the info the program gives is very limited so i want to know if there is a good tutorial telling me about each one or do i just have to google each one. or is there a bunch of presets for diferent kinds of people so i can download one of them to use.

ewdi
6th January 2005, 06:52 PM
ah yes, Redhat Service Manager, but i think it's better to get used to the command line, it will be a lot easier to learn from it as you will need it one day for remote administration work and etc. most services are daemon, below is some of the common services



anacron

Related to the 'cron'-daemon. 'cron' runs tasks like system maintenance at certain times, but skips them if the system isn't running at that time. That's where 'anacron' comes in: it checks delayed 'cron'-tasks at boot-time and executes them. If your machine doesn't run all the time, you should leave it enabled. Optional. Doc: man anacron

apmd

The Advanced Power Management BIOS Daemon. Only needed if your computer runs on battery. Optional. Doc: man apmd

arpwatch

Keeps track of ethernet/ip address pairings. Usually not enabled. Optional. Doc: man arpsnmp

atd

The "At Daemon". Manages scheduled jobs. Related to crond. Essential. Doc: man atd, man at

autofs

Controls the automount daemon (note: this has nothing to do with 'supermount'). Usually not enabled. You might need it if you want to mount network-shares automatically. Optional. Doc: man autofs, man automount

bootparamd

Used to provide boot-information to diskless clients. You probably don't need this vulnerable service. Usually not enabled. Optional. Doc: man bootparamd

crond

The Cron Daemon. Manages repeated tasks. Related to atd. Essential. Doc: man crond, man cron

gpm

General Purpose Mouse Daemon. Necessary only if you want to use your mouse on the console (not xterms). If you only work within X it's better to turn it off, incompatibilities with X are a known issue. Optional. Doc: man gpm

httpd

The daemon necessary to run the Apache web-server. If you do not intend to run a web-server, turn it off: it uses a considerable amount of system resources and makes your box vulnerable to outside attacks if not configured properly. Optional. Doc: man httpd.

inet(d)

This handles dial-in services like ftp, pop3 and telnet (these three are enabled by default). If you only dial-out turn it off!. In its default setting it essentially invites anyone who knows your IP to launch an attack at your box. If you want to use it however, have a look at '/etc/inetd.conf', '/etc/hosts.allow', '/etc/hosts.deny' and install the tcp-wrappers.rpm. Optional. Doc: man inetd, man hosts_access and man tcpd.

keytable

Loads the selected keyboard map as set in '/etc/sysconfig/keyboard'. Usually enabled. Essential for users with non-US keyboards. Doc: man loadkeys

kudzu

Detects and configures new or changed hardware during boot. If you turn it off your box will boot faster. You can then run it from within the system. Usually enabled. Optional. Doc: man kudzu

linuxconf

This is not needed to run LinuxConf. This service is used to configure a linux box remotely with a browser. Most linux users will probably never use this. If not needed, it's safe to turn this off. Usually enabled. Optional. Doc: '/usr/lib/linuxconf/help.

lpd

The "Line Printer Spooler Daemon". Needed for printing. Usually enabled. Optional. Doc: man lpd

netfs

Network Filesystem Mounter. Generic service. Needed for mounting NFS, SMB and NCP shares on boot. Usually enabled. Optional. Doc: man mount

network

Activates all network interfaces at boot time by calling the scripts in '/etc/sysconfig/network-scripts'. Usually enabled. Essential. Doc: man ifconfig and the appropriate documentation for the initiated interfaces.

nfslock

Starts and stops the NFS file locking service. If you have no idea what this means, you can turn it off. Usually enabled. Optional. Doc: man nfs.

numlock

Locks NumLock key at init runlevel change. Usually enabled. Optional. No docs.

pcmcia

For laptop users only. Optional. Read the script.

portmap

Needed for Remote Procedure Calls. Portmap can be a huge security risk if not properly configured. It should only be needed for NFS or NIS services, if you don't use these then turn it off. Usually enabled. Optional. Doc: man portmap

postfix

This is the "Mail Transport Agent", something like sendmail. If you use Netscape Mail, KMail you can turn it off. Usually enabled. Optional. Doc: man postfix, '/usr/doc/postfix-[version]/html/index.html'

random

Random Number Generating Daemon. Needed for security. Essential. Doc: man 4 random

routed

Network Routing Daemon. Don't use this unless you really need it and don't use this if you have a dial-up connection. Optional. Doc: man routed

rstatd

The kernel statistics server (advanced networking stuff). Usually not enabled. Optional. Doc: man rpc.rstatd

rusersd, rwalld, rwhod

Provide several services useful when running a server. Usually not enabled. Optional. Doc: man-pages

smb

Needed for running SAMBA, the "Server Message Block Protocol Server". It allows you to provide network services to Windows clients and access shares on those machines from your GNU/Linux box. Usually not enabled. Optional. Doc: man samba, MUO pages on configuring SAMBA.

syslog

System Message Logger. Essential. Doc: man sysklogd

usb

Daemon for devices on the Universal Serial Bus. If you don't use such devices, you can turn it off. Usually enabled. Optional. For more check the files in /usr/src/linux/drivers/usb (you'll need the kernel-sources.rpm for this)

xfs

X Font Server. If you don't load this then you'll have to manually set the font paths in '/etc/X11/XF86Config' and use and external TrueType font server like xfstt. Usually enabled. Essential for X users. Doc: man xfs

earobinson111
6th January 2005, 06:54 PM
ok fair but will that give me better info on what each one is doing?

thanks that seems helpfull. when i get home i will take a look at it.

ewdi
6th January 2005, 06:56 PM
it should, most of them have descriptions to it

earobinson111
6th January 2005, 06:57 PM
thanks a lot

uglybluecat
10th January 2005, 02:09 PM
Thanks ewdi, that list is extremely helpful to us semi-noobs wanting to streamline our systems.

noodlehead
9th April 2005, 04:02 PM
I'm a newbie to Linux and Apache. I'm trying to run some example code from O'Reilly's Apache, the definitive guide. The examples call for me to execute "./go" that contains the following code:
test -d logs || mkdir logs
httpd -f `pwd`/conf/httpd.cong -d `pwd`
Executing the GO script takes me right back to the command prompt. I used "ps" to verift that httpd was NOT running. I then tried executing httpd and after a short delay I use "ps" to verify that httpd was running. I'm guessing that the service in the background overrides any foreground commands.
How can I run Apache from the command line?

AndyGreen
9th April 2005, 04:09 PM
service httpd start

Zigzagcom
9th April 2005, 04:12 PM
:) Hi, were you in the directory that contains the script you want to execute?

fc_jeff
9th April 2005, 04:28 PM
ewdi -
THat was simply an outstanding tutorial / list / explanation for managing services from the command line. You did a fantastic job and you have my gratitute. I had mostly used the RH GUI services utility before, plus some starting and stopping of the Apache and MySQL services from the command line. But your little tutorial gave me the big picture for observing and managing all the services from the command line - something I wanted to know how to do and become proficient at. Excellent job!! :)

noodlehead
9th April 2005, 04:51 PM
I think I want to use http from the command line and not as a service. I'm not sure typing in service will do that.

noodlehead
9th April 2005, 04:52 PM
Yes I was in "/usr/www/APACHE3/site.toddle" where the "go" script is. I typed in "./go" and nothing happened. What do you think I'm doing wrong?

AndyGreen
9th April 2005, 05:00 PM
Dude, httpd is a service. The d stands for daemon. You are completely confused.

Why don't you forget your "go" script a minute and describe what you are trying to achieve.

noodlehead
9th April 2005, 06:04 PM
I'm'm trying the example code from the Apache book. The book suggest that instead of using the standard "httpd.conf" file that contains alot of settings, it suggests starting with a much smaller conf file - one that has only the items that you need to learn about. I have tried typing in "httpd -f `pwd`/conf/httpd.con -d`pwd` from my sites' base directory, but nothing starts up. When I type in "httpd" without any arguments from the same base directory, Apache starts up with the standard (WRONG) conf settings. Any idea what I might be doing wrong?

noodlehead
9th April 2005, 06:14 PM
Andy, when I try tp get help on http by typing "httpd --help". nothing happens. But when I run "ps -aux" I see alot of httpd --help's. It looks like it took whatever I type in after the httpd as some kind of service name. I've used apache on a Window's XP system and not had these knid of problems so I assume I'm doing something really stupid.

AndyGreen
9th April 2005, 07:31 PM
I'm afraid the something stupid thing sounds right. I think your first mistake is trying to follow that book. Second is to misunderstand httpd and treat it like it is a program you can run from the commandline. Http*d* is a daemon, aka a service, which sits running the background waiting for network traffic on port 80. You do NOT run it from the commandline like you have been doing. Instead you start it ONCE using

service httpd start


To recover from your situation:

service httpd stop (just in case)
killall -9 httpd

That should kill all the bogus httpd processes. Do

service httpd start

to set it going again.


Why did I say that the book was a mistake? The cool guys at Redhat have set Apache up already with sane defaults. From your newbie position, what you need is to get Apache up and start getting experience and confidence with it. Redhat have done the work for you to do that without fiddling with anything. The bogus advice in your book is just making you screw up what Redhat has already done properly for you. Put the book on one side.

Have you been editing /etc/httpd/conf/httpd.conf? I hope not, and from the sound of it the book you were using did not know where it was on a Redhat system. In this case when you start the httpd service, you are already good to go. Point your browser to http://localhost and you should see the default server page.

Put your own index.html in /var/www/html and you'll see that instead.

noodlehead
10th April 2005, 05:00 PM
Actually, I do know the the "d" in httpd implies daeman and I do have some experience with it on other operating systems. Unfortunately you just assume I was a newbie. Actually, daemans like httpd can be started from the command line. What I was hoping to find was someone in the forum that could tell me what if anything was intercepting my invocation of httpd and preventing me from assigning my own arguments to it. I talked to many of my follow programmers at work who think Linux is the best OS ever. You should know that no of them are currently using any RedHat versions of Linux. Not a single programmer so far was able to figure out what the problem was until this morning.

I knew something had to be intercepting my command invocation and after looking around a bit I found that I needed to turn off the SELinux protection of the HTTPD Daemon. Everything works fine now!

The book "Apache: The Definitive Guide, Third Edition by Ben Laurie and Peter Laurie" is actually very good. My fellow Linux programmers at work were able to use it on their systems and I was able to use it on a Windows system. The only negative to the book is that it did not anything about SELinux until half way through the book and even then it did not say much about it. You might want to read it.

I would like to thank you for trying to help me.

AndyGreen
10th April 2005, 06:38 PM
Good luck in your efforts, noodlehead.

Fedora really wants you to run it as a service using the service wrapper. When you do so, you don't need to turn off SELinux and the whole thing just works, saving you the heartache of this problem and the time researching it, and giving the security benefits of SELinux to what is usually an internet-facing app.

As for Linux guys and what distro they run, if you have faith in these guys stop using Fedora and use whatever they use. For me Alan Cox and the other kernel hackers at Redhat using Fedora is endorsement enough :-)