|
Home > Archive > Linux/Unix > October 2002 > linux command
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| bass2k1 2002-10-23, 5:32 am |
| Stupid question, but what is the command to stop/start a service in Linux from the Command Line Interface, and also to bring up or shut down an interface, such as eth0, etc?
Regards
sebastiaan.rothman@bhpbilliton.com | |
| Mr. Linux Guy 2002-10-23, 7:14 am |
| Each service in Linux has "server" progra which need to be running for the machine to be able to respond to requests. there are scripts installed on your system which will start or stop the servers for you, usually located in the /etc/init.d directory. The files in this directory will look something like this:
xinetd sendmail sshd httpd ntpd crond
And so on. There are two usual ways to start and stop services. To use the example of the Secure Shell server, sshd, we could use the following command to start the service manually:
# /etc/init.d/sshd start
To stop the service manually, you use a similar command:
# /etc/init.d/sshd stop
Some servers support the "restart" parameter, and some may use additonal ones, but 'start' and 'stop' are the only one that I have ever used. Each service running on your machine will have a server that allows it to accept incoming requests. usually this will be the name of the service with a 'd' attached to the end (the 'd' stands for 'daemon', a type of program which repsonds to incoming reqeusts while running in the background). The daemons or servers for Apache is 'httpd', for FTP is 'ftpd', for MySQL is 'mysqld', and so on. Once you start or stop a server manually like this, you should see a status message letting you know whether it has been successful or not.
To have the services started or stopped automatically upon bootup or shutdown, you will add a link to the appropriate run command directory. Usually you will see some directories under /etc/rc?.d where the '?' is a number in (0, 1, 2, 3, 4, 5, 6). Each of these directories has links to the scripts in /etc/init.d that tell which services will be started or stopped upon startup or shutdown. For example, usually the critical directories will be runlevels 3-5, as level 3 represents a multi-user environment with networking functionality enabled (1 is single user mode, 2 is multi-user with no networking, both of these are typically used for maintenance). RL 4 is usually the same as three, with your own added customisations which most people do not use, so in essence it is the same as 3. 5 is with the X Window system available. 6 is reboot, 0 is shutdown. If you look in /etc/rc3.d you will find a number of files that look like this:
K25squid K87portmap S55sshd S85httpd
These files are all links to the scripts in /etc/init.d. The links are named with starting with either a 'K' or an 'S'. The 'K' means 'kill' (i.e., it sends the 'stop' parameter to the service in question) and the 'S' means 'start' (i.e., it sends the 'start' parameter to the server in question). The number following it determines the order in which the service is stopped are started. The order is not always important, but sometimes it can be. For example, if you are running a database driven website, you will want your database server to be started before you start your web server. You will see the messages stating that the start or stop of the service was Ok or not OK upon startup and shutdown and these messages should be stored in /var/log/boot.log for review later on.
Sometimes there are internet-related servers that do not usually stand alone, but are run from a "super-server" or "meta-daemon". Services like ftp, telnet, finger, and so on are run from this daemon. Instead of each service taking up its own memory space all the time, when the service may be only sporadically needed, the "superserver" runs as a single process and listens to requests on a number of ports. if it hears an incoming request on port 79, for example, it will spawn a finger server process in order to respond to the request, and then after it has performed its job, it will kill the finger server since it is no longer needed. This causes a delay but also saves system resources by eliminating the memory usage of non-productive processes. The dameon name is usually /etc/init.d (usually in older distros( or /etc/xinet.d (for newer distros).
To configure a network card, you use the "ifconfig" command (interface configuation). The man pages should take you from there.
If you need any more help, let me know. | |
| bass2k1 2002-10-23, 8:02 am |
| Thanks a million! you really helped a lot. I am pretty new to Linux, so IO will probably bother you guys a lot more in the future.
Thanks
sebastiaan.rothman@bhpbilliton.com | |
| Mr. Linux Guy 2002-10-23, 8:06 am |
| Bother us all you like.  |
|
|
|
|