How to configure auto-start service for Linux basic configuration

Source: Internet
Author: User
Basic linux configuration and self-starting service

10:58:09 | category: 22 linux | font size subscription

Basic configuration of Fedora Linux

Log on to linux and use pwd to print the current working directory.

Folder in the root directory

Use the su-command to convert to the root user (add-to sign in as a Super User), add a common user michael and set the password. Added michael's working directory under/home.

In the working directory of a common user, the system adds several hidden files ,. bash_profile and. bashrc is the initialization file when the user logs on to the system. You can add the variable that modifies the user's work environment to these two files. The. bash_logout script is automatically executed after the user exits the system.

/Sub-directories under the root directory:

Bin: A Tool for storing binary files. It is a basic tool set required by the system.

Boot: place the required file for system startup (required file for system startup, kernel required for system startup, Boot program configuration file, etc)

Dev: System Device Files (peripherals, disks, etc)

Etc: place all the configuration files of the system. The files in this directory are used to modify the system configuration.

Home: place files of common users.

Initrd: temporary directory, used during boot initialization. It is generally null and is not needed.

Lib: the shared dynamic link library of executable programs in linux, similar to the DLL Link Library in windows.

Lost + found: place the fragment files detected by self-check when the system starts. It is generally empty.

Misc: place additional files, which are generally empty and not needed. Mnt: Mount External Device Files (optical drive, floppy disk, etc ).

Opt: used to install third-party software office tools and databases.

Proc: Virtual File System, information in the kernel process. No disk space is occupied.

Root: Administrator's home directory.

Sbin: basic management tool for placing Super Users.

Tmp: place temporary files for each user. This directory is globally writable.

Usr: common configuration materials, tools, and documents for all users. This directory is large, and most programs are installed in this directory. The directory space size remains unchanged unless a new program is installed.

Var: Place dynamically changed data and logs.

In this directory, only the home and var directories are constantly changing. Their data needs to be maintained and updated frequently.

 

Next, let's take a look at the usage of Hard Disk Partitions:

The hard disk usage of the Df command is not very good by default. we can add a-h option.

 

Df can only view the usage of hard disk partitions, but cannot view the usage of each directory. To view the usage of each directory, we can use the du command.

Run the "Du-sh/*" command to view the usage of all directories under the/root directory. The parameter "s" serves to count the total number of directories. The parameter "h" makes the query results more user-friendly.

An error is prompted because a common user does not have permissions on the following directories. You can use ctrl + c to forcibly stop the operation.

Convert to the root user statistics directory information. Here we can see that the/usr directory occupies 1 GB of disk space.

The partition tool used to install the system can no longer be used after the system is installed. We can only use the fdisk command to view disk partitions.

 

If the hard disk supports DMA, we can use hdparm activation: hdparm-d1/dev/sda, the-d parameter indicates dma, and 1 indicates on. you can write this command into rc. local file, which is the script file initialized by the system. All commands and tasks automatically executed during system startup must be written into this script file. This file is provided to the Administrator.

 

View DNS configuration file: more/etc/resolv. conf

Check IP Address Configuration command: ifconfig

Ifconfig can also modify the IP address. We can change the IP address to 192.168.1.99 and use ifconfig to check whether the command has taken effect.

For more information about how to use ifconfig, run the man ifconfig command.

View route information: route-n

After the IP address is changed, the default gateway is deleted.

Use the route command to manually add the default gateway. Use route-n to check whether the command takes effect.

Note:

The modified information of Ifconfig eth0 is not saved immediately. This process is used for manual debugging. To save the data, we recommend that you use the netconfig command, this tool will write the configuration information into the configuration file.

By default, the fedora tool netconfig is not installed. We need to install it manually: yum install netconfig.

Restart the network service and use ifconfig eth0 to check whether it takes effect.

In the/etc/sysconfig/network-scripts directory, there are script files for starting, activating, and disabling network interfaces. Netconfig writes the configuration information into the ifcfg-eth0 configuration file.

Let's check if the ifcfg-eth0 configuration file is consistent with the above information. Enter cat/etc/sysconfig/network-scripts/ifcfg-eth0

Load ifcfg-eth0 configuration information. The IP address is 192.168.1.88 instead of 192.168.1.99. The configuration file takes effect.

We can directly use vi to manually edit the ifcfg-eth0 configuration file without using the netconfig command configuration. Use vi/etc/sysconfig/network-scripts/ifcfg-eth0, enter characters such as I, o, a in normal mode to enter the edit mode, manually modify IPADDR = 192.168.1.99, press ESC to return to normal mode. In normal mode, enter: wq to save and exit vi.

Reload the ifcfg-eth0 and you can see that the IP address 192.168.1.99 has taken effect.

When configuring the NIC, you must note that the sysconfig directory contains two network-related configuration directories: networking and network-scripts. The configuration file we modified earlier is the ifcfg-eth0 under the network-scripts directory, Netconfig will automatically write the NIC configuration information into this file. The Neat tool writes the network configuration information to the profiles directory under the networking Directory, which is preferred. If you fail to use the neat or graphical tool to configure the card, you need to clear all the files in the profiles directory.

View the user's language: locale, which can tell the current system's language.

You need to check the system's support for all languages: locale-

Make the system support Chinese characters: LANG = zh_CN.GB2312. Run the date command to check the date displayed in Chinese format. Because the data cannot be output in Chinese encoding in text mode, week, month, and day cannot be displayed, we then convert the system to English language environment: LANG = en_US.UTF-8, use the date command check, you can see that the normal display of the English format date.

The language configuration information is stored in/etc/sysconfig/i18n.

We have seen several configuration files under sysconfig. Most server programs start Initialization Configuration scripts in this directory. The sysconfig directory is the most basic configuration information, options, and parameters.

View the system hardware information: more/etc/sysconfig/hwconf. The information displayed is the hardware information detected by the system hardware checker.

There is a kudzu tool installed, which will automatically check the hardware configuration information. When the system adds new hardware, the system needs to detect the new hardware: service kudzu start.

It takes a long time for the system to start and detect the hardware. we can disable this function. You can use chkconfig to check the system service startup script. By default, runtime levels 3, 4, and 5 are enabled. If you need to adjust it, you can use the setup command, which is a comprehensive Configuration tool.

Select to run the system service tool.

Cancel the kudzu service.

Re-check the kudzu Information

Xinetd is not installed on fedora by default. We can install it manually: yum install xinetd.

View system self-starting services: chkconfig -- list | more. These services are started by the init system configuration script. The services listed in the following xinetd based services are not started by init, but by xinetd. You can see that most services are disabled by off. Xinetd itself is a system startup service. It is started at the 3-5 running level by default, and the Child Services started based ON xinetd will also start ON.

If you want to enable rsync, enter the chkconfig rsync on command. Then you can use chkconfig rsync-list to check that the service has enabled on. Check that this service is off. Restart the server. xinetd will find that the rsync service needs to be started and the service will be started.

To temporarily start this service, enter the service xinetd restart command.

The Service script started by the command is generally stored in a fixed directory:/etc/init. d, which has seven running levels from 0 to 6. Service xinetd restart is essentially to start/etc/init. the xinetd script under the d directory, and then the xinetd will check its own configuration Directory:/etc/xinetd. d. The various statuses of the services managed by the service are stored in the corresponding directory. The previous chkconfig rsync on is essentially modifying the rsync configuration file under/etc/xinetd. d to on. Then, when we restart the xinetd service, rsync is automatically loaded.

The seven operating levels of the system are essentially at/etc/rc ?. D ,? 0-7.

Each service has a symbolic link under the corresponding directory, so the system script is essentially placed under/etc/init. d. We only need to go to rc ?. D. a symbolic link in the corresponding running level directory should be able to automatically run this service.

Let's take a look at the kudzu service. In essence, kudzu is the script.

The script named kudzu on rc3.d can see that the first character is K, indicating that Kill is disabled. You can see that the script K95kudzu has a symbolic link pointing to/init. d/kudzu.

You can also run the runlevel check to indicate that all scripts are from/etc/rc3.d. Here, all the scripts starting with K are closed and those starting with S are enabled.

One of these services is often used in the future. It is sshd. We can use chkconfig sshd-list to check. The Sshd script starts an sshd server. By default, the sshd server is enabled on the 2-5 running level. This service is used for remote maintenance and management. Telnet is also a remote logon tool, but telnet is transmitted using a plaintext password. The data is public, the password is easy to leak, and it is very insecure. sshd is an encrypted and secure server, supports remote file transmission and maintenance.

How do we know the level at which the system runs and when each directory in the following needs them. When your system corresponds to the corresponding running level, it will enter the corresponding rc ?. D directory. You can refer to the/etc/inittab file, which is the main configuration file for system initialization. The number of system running levels and the configuration script to run are determined by it.

Let's take a look at the basic information of this file.

Id: 3: initdefault: the default system enters Level 3.

Si: sysinit:/etc/rc. d/rc. sysinit: system initialization. You can check the detailed configuration script of rc. sysinit:

I0: 0: wait:/etc/rc. d/rc 0

I1: 1: wait:/etc/rc. d/rc 1

I2: 2: wait:/etc/rc. d/rc 2

I3: 3: wait:/etc/rc. d/rc 3

I4: 4: wait:/etc/rc. d/rc 4

I5: 5: wait:/etc/rc. d/rc 5

I6: 6: wait:/etc/rc. d/rc 6

The seven running levels 0-6 come from the Seven-line configuration here, which are the Script Name and path. Let's take a look at these scripts to see why the system enters the runtime Level 3, runtime level 4, and runtime Level 5.

Another tool can quickly configure the system service ntsysv. Similar to the setup configuration interface.

After the system is configured, You can reboot and restart the system to make all the configurations take effect.

**************************************** ***********

Simple automatic start method:

Vi/etc/rc. local

Add the self-starting sh command.

FROM:

Http://blog.163.com/sjlksoft@126/blog/static/40018231200881810589856/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.