Apache automatically starts and adds services as Linux
Note:
Apache installation path:/usr/local/Apache
The Linux Startup level is 5, and the version is Linux as4
After Apache is installed, it is found that Apache cannot be started automatically. Check/etc/rc. d/rc5.d/. There should be no link file starting with S and ending with httpd.
1. Copy the apachectl file to/etc/rc. d/init. d and add a link under/etc/rc. d/rc5.d.
The D0 command is as follows:
CP/usr/local/Apache/bin/apachectl/etc/rc. d/init. d/httpd // if another version of Apache exists, it can be overwritten directly.
6 P "^ n! X5v # p r] 0ln-S/etc/rc. d/init. d/httpd/etc/rc. d/rc5.d/s85httpd // create a link (the meaning of 85 will be introduced later)
Apache can be started automatically.
2. Run chkconfig -- list and find that httpd is not in the Linux service list. Use chkconfig -- add httpd to add httpd, but the prompt is: the HTTPd service does not support chkconfig. Edit/etc/rc. d/init. d/httpd and add the following comments:
# Chkconfig: 345 85 15
# Descr restart ption: Apache
The value of the three numeric parameters in the first line is as follows: Which Linux levels need to start httpd (3, 4, 5), the startup sequence number (85), and the shutdown sequence number (15 ).
Save and run chkconfig -- add httpd.
The link file of s85httpd will appear in the rc3.d, rc4.d, and rc5.d paths, and the link file of k61httpd will appear in other running-level paths.
3. Run chkconfig -- list and httpd.
==========================================
How to Set auto-start options in Ubuntu
You can use some gadgets to manage the startup options of Ubuntu:
Small Tool rcconf:
# Sudo apt-Get rcconf
# Sudo apt-Get install rcconf
Run the following command under root: # sudo rcconf
More comprehensive tools: sysv-RC-Conf
# Sudo apt-Get update
# Sudo apt-Get install sysv-RC-Conf
Run: # sudo sysv-RC-Conf
You can also directly add the startup program, for example, add/etc/init. d/red5 to the Automatic startup list of the system:
# Sudo sysv-RC-conf red5 on
For other usage methods, see Google: Ubuntu: sysv-RC-Conf.
You can also directly modify
Directly change/etc/rc0.d ~ Something in/etc/rc6.d and/etc/RCs. D. Start with S and not start with K,
For example, if you want to disable auto start of red5, you only need to # sudo mV/etc/rc2.d/s20red5/etc/rc2.d/k20red5.
Ubuntu automatically starts the program
First, all the services started randomly in Linux are in/etc/init. d. All the files in this folder are script files (in simple words, the script program writes the program to be run to a file so that the system can execute it in order, similar to Windows Autorun. in addition, there are folders such as rc1.d, rc2.d to rc6.d In the/etc folder, which are different runlevels in Linux, generally, the running level of multiple users in X Windows is 5th, that is, rc5.d. The script file in this folder is the service program to be started randomly when the script file is 5th. Note that in each RC (1-6 ). the files in the D folder are all/etc/init. A soft connection to the files in the D folder (similar to the shortcut in Windows), that is, in/etc/init. the D folder contains all the service programs, and each RC (1-6 ). d. Only link it to start the desired service program!
To start scim (a program), we first need to know where the scim program is. We can use the locate command to find it. scim is in/usr/bin/scim, the USR table indicates that the user belongs to the user, and bin indicates that the program can be executed in Linux. In this way, I can write a script program, put it in/etc/init. d, and then make a corresponding soft link in rc5.d.
This script is actually very simple, just two lines:
#! /Bin/bash
/Usr/bin/scim
The first line is to declare the terminal used to run the script, and the second line is the command to run.
Note that in rc5.d, the name of each link starts with S or K, k starts with a random start. In this case, you can know which service I want to start at random, and change the first letter K to S. Of course, after changing S to K, this service cannot be started randomly. Therefore, we need to name this link sxxx so that the system can start it at random.
In RH, RC. local is the last script file started by default. Therefore, if you want to start it at random, another method is in RC. add/usr/bin/scim to the end of the local file. Linux Automatic startup program
1. automatically run the program at startup
After Linux is loaded, it initializes the hardware and device drivers, and then runs the first process init. Init starts other processes based on the configuration file. Normally, the modification is placed in/etc/rc or/etc/rc. d or/etc/rc ?. The script file in the d directory can enable init to automatically start other programs. For example, edit/etc/rc. d/RC. local file (this file is usually the last script started by the system). Add "xinit" or "startx" at the end of the file to directly enter the X-window after the file is started.
2. automatically run the program upon Logon
When a user logs on, bash automatically runs the global logon Script:/ECT/Profile created by the system administrator. Bash then searches for one of the three special files in sequence in the user's starting Directory:/. bash_profile,/. bash_login, And/. profile, but only executes the first one found.
Therefore, you only need to add commands to the above files as needed to automatically run certain programs (similar to autoexec. BAT in DOS) during user logon ).
3. automatically run the program upon logon.
When you log out, bash automatically runs the personal logout script/. bash_logout. For example /. in bash_logout, add the command tar-cvzf C. source. tgz *. c, the "tar" command is automatically executed every time you log out to back up *. c file.
4. Periodically run the program automatically
Linux has a daemon called crond. Its main function is to periodically check the content of a group of command files in the/var/spool/cron directory, and execute the commands in these files at the specified time. You can use the crontab command to create, modify, and delete these command files.
For example, create a crondfile with the content "00 9 23 Jan * happybirthday". After running the "crontab cronfile" command, every time the system automatically executes the "happybirthday" program at AM on March 23, lunar January ("*" indicates that no matter the day of the day is the day of the week ).
5. automatically run the program once at a scheduled time
Scheduled command execution at is similar to crond (but it is only executed once): The command is executed at a given time, but is not automatically repeated. The at command is generally in the format of at [-F file] time. All commands in the file are executed at the specified time. You can also enter the command directly from the keyboard:
$ At 12: 00
At> mailto Roger-s "have a lunch" <plan.txt
At> CTR-d
Job 1
At, an email entitled "have a lunchtasks, containing the plan.txt file content was automatically sent to Roger .?
At, February 9, an email entitled "have a lunch.pdf containing the plan.txt file was automatically sent to Roger. Er. Ger. Er.
Automatically mount Windows partitions when Ubuntu is started
To mount NTFS format partitions, You Need To NTFS-3g this software. It is short and powerful.
NTFS-3g is an open source software that supports reading and writing NTFS format partitions under windows. It is fast and secure. It supports Windows 2000, XP, and 2003, and supports all POSIX-compliant disk operations.
First, edit sources. List.
# Sudo gedit/etc/APT/sources. List
Add Ubuntu drapper:
Deb http://givre.cabspace.com/ubuntu/ dapper main-all
Deb http://ntfs-3g.sitesweetsite.info/ubuntu/ dapper main-all
Deb http://flomertens.keo.in/ubuntu/ dapper main-all
Add Ubuntu edgy:
Deb http://givre.cabspace.com/ubuntu/ edgy main
Deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main
Deb http://flomertens.keo.in/ubuntu/ edgy main
At the same time, you must import the GPG-key, which can be as follows:
# Wget http://flomertens.keo.in/ubuntu/givre_key.asc-o-| sudo apt-key add-
# Wget http://givre.cabspace.com/ubuntu/givre_key.asc-o-| sudo apt-key add-
Update the source:
# Sudo aptitude update
Formal Installation
Run the following command under "terminal:
# Sudo apt-Get install ntfs-3g
Configure NTFS-3g
First, let's look at the partition types of some hard disk partitions.
# Sudo fdisk-l
Now you can modify/etc/fstab to enable the NTFS partition to be automatically mounted when Ubuntu is started. But first back up this file:
# Sudo CP/etc/fstab. Bak
Create a mount point. For example, mount it to/Media/windows.
# Sudo mkdir/Media/Windows
Now you can add
/Dev/hda1/Media/ntfs-3g ults, locale = zh_cn.utf8 0 0
Modify according to your own situation.
Examples
Mount/dev/hda3
Add/dev/hda3/Media/Windows ntfs-3g Ro, locale = zh_cn.utf8, uid = 1000 0 0
About your locale
You can use the following command to view all locale
# Locale-
If you do not want to restart, you can
# Sudo umount-
# Sudo Mount-
The last command to mount the FAT partition
# Sudo Mount/dev/hda3/Media/Windows/-T vfat-O iocharset = utf8, umask = 000
Of course, you can add it in/etc/fstab.
/Dev/hda3/Media/Windows vfat iocharset = utf8, umask = 000 0 0
Openfire is automatically started with Ubuntu
Openfire is not started randomly by default. To solve the problem of manual startup every time, I wrote a script, which is placed in the/etc/init. d directory.
# Sudo Vim/etc/init. d/openfire
The content is as follows:
#! /Bin/sh
Openfire_start (){
/Etc/openfire/bin/openfire start
}
Openfire_stop (){
/Etc/openfire/bin/openfire stop
}
Case $1 in
Start)
Openfire_start
;;
Stop)
Openfrie_stop
;;
*)
Echo 'usage: openfire START | stop'
;;
Esac
This article comes from the podcast http://xinsync.xju.edu.cn on the iceberg, the original address: http://xinsync.xju.edu.cn/index.php/archives/1328