linux daily notes (1)

1, SELlinux
SELinux is the United States National Security Agency (NSA) to implement mandatory access control = "can root privileges restricted
  to close SELinux =" modify the configuration file, permanent;
    sed -i 'S / SELINUX enforcing = / = SELINUX disabled '/ etc / selinux / config
  viewing options selinux configuration file
    grep SELINUX = / etc / selinux / config
  closed SELinux = "temporarily closed
    setenforce 0
    0: permissive but warned not to block the execution of
    1: enforcing open selinux
  View selinux state
    getenforce
2, provided running Linux level
command Description:
  the runlevel: run-level view of the current system
  the init: switching the operating level, followed by a number (1-6)
  seven kinds of running Linux level Description:
    0: system down, the system defaults run level can not be set to 0, otherwise it does not start, turn off the machine.
    1: single-user work status, root permission for system maintenance, prohibits remote login, login as safe mode under Windows.
    2: multi-user state, no NFS support.
    3: Complete multi-user mode with NFS, after landing into the console command line mode.
    4: The system is not used, reserved generally do not, in some special cases you can use it to do something. For example, when the laptop battery exhaustion, this mode can be switched to do some settings.
    5: X11 console After you log in GUI mode graphics, XWindow system.
    6: a normal system shutdown and restart, the default operating level can not be set to 6, or can not start properly. Run init6 machine will restart.
    Standard Linux run level 3 or 5
3, chkconfig

chkconfig command is mainly used to update operational level information (start or stop) and query system services.

Using the syntax:
the chkconfig [--add] [- del] [- List] [System Services] or chkconfig [--level <class code>] [Service System] [on / off / reset]

chkconfig run when no parameters, display usage. If you add the service name, then check whether the service starts running in the current level. If so, it returns true, otherwise false. If you specify a service name after the on, off or reset, it will change the start chkconfi information specified service. on and off, respectively, refer to the service is started and stopped, reset means that resets the startup information services, regardless of the initial question of what the script specified. on and off switch, only the default class 3,4,5 effective operation, but the reset may be active in all stages.

Parameters Usage:
--add increase the specified system services to chkconfig command to manage it, and at the same time increasing the data in the system startup file description.
--del delete the specified system service is no longer managed by chkconfig command, and delete data in the system startup file description.
--level <level code> Specifies the reading system to be turned on or off services in which Bi execution levels.
Level 0 represents: represents off
Level 1 represents: single-user mode
Level 2 represents: no network connection multi-user command line
Level 3 means: a multi-user command line network connection
Level 4 represents: N
represents Level 5: belt multi-user mode GUI
grade 6, said: restart
should be noted that, level option to specify the level you want to view the run and not necessarily the current operating level. For each run level, only one startup script or a stop script. When switching run level, init does not restart the service has been launched, it will not have to stop to stop the service again.

chkconfig --list [name]: displaying the operation state information of all system services run level (on or off). If the name is specified, then displays only the status of the specified services at different run levels.
chkconfig --add name: to add a new service. chkconfig to ensure that each class has a running start (S) or killed (K) entrance. If anything is missing, it will automatically establish the default init scripts.
chkconfig --del name: delete services, and the related symbolic link from /etc/rc[0-6].d.
chkconfig [--level levels] name: Set a service to run at a specified level is to be started, stopped or reset.

Run-level file:
each is required under the corresponding init.d script plus two lines or more lines of comments chkconfig management services. The first line tells chkconfig default startup run levels and start and stop priority. If a service is not in default of any level to start running, use - instead of run level. The second line of the service description, you can use \ interbank comment.
For example, random.init comprising three lines:
# the chkconfig: 2345 80 20 is
# Description: Saves and restores the pool for Entropy System \
# IN AREAS OF COMMUNICAITIONS Quality Random Number Generation.

Examples of use:
chkconfig --list # list all system services
chkconfig --add httpd # service httpd increase
chkconfig --del httpd # delete httpd service
chkconfig --level httpd 2345 on # Set httpd running level 2, 3, 4 and 5 is the case where the on (open) state
chkconfig --list # listing system where all services start
chkconfig --list mysqld # lists services provided mysqld case
chkconfig --level 35 mysqld on # set mysqld in level 3 and 5 for the power to run the service, - level 35 indicates the operation performed only in level 3 and 5, on start showing, off means closed
chkconfig mysqld on # mysqld in each level is set on, "each level" includes 2 , 3,4,5 grade

How to add a service:
1. Service script must be stored in /etc/ini.d/ directory;
2.chkconfig --add SERVICENAME
increase this service chkconfig tool in the list of services, in which case the service will be in the / etc / rc. d / rcN.d imparting K / S of the inlet;
3.chkconfig --level mysqld ON 35
changes to the default level of service is started.


4, Linux service starts to close (permanent and temporary)
systemctl
how to start in Linux, re-start, stop, reload and Inspection Service (httpd.service) state
  systemctl Start httpd.service
  systemctl restart httpd.service
  systemctl STOP httpd.service
  reload httpd.service systemctl
  systemctl Status httpd.service
how to activate the service and enable or disable the service at boot time (to start the service automatically when the system boots)
  systemctl IS-the Active httpd.service
  systemctl enable httpd.service
  systemctl disable httpd.service
how to use the command systemctl termination of service
  systemctl the kill httpd
  systemctl Status httpd
how to shield (it can not start) or unmask socket (cups.socket)
  systemctl mask cups.socket
  LN -s' / dev / null '' /etc/systemd/system/cups.socket '
  systemctl unmask cups.socket
  rm '/etc/systemd/system/cups.socket'


5, view the command under linux absolute path (which whereis)

which is used to view the path of the current command to be executed is located.
principle which commands: PATH variable in the specified path, the location of a search system commands, and returns the first search results. In other words, the use of which command, you can see whether there is a system command, and in the end which is a position of command execution.

whereis used to view the path of a command or file is located,
whereis command principle: You can only search for the program name, and only search binary files (parameter -b), man documentation (parameter -m) and source code files (parameter -s). If the parameter is omitted, all the information is returned.
eg:
Here's an example will be described. If your linux system upload multiple versions of java. If you type commands directly from the command line "java -version", you will get a result. But, you know java in a path in which to perform it? If you want to know, which you can use the command:

which java

The return path is the location of the first JAVA PATH, which is the default location JAVA command execution

If you use the command: whereis java

Then you will get a lot of the result, because all paths that contain this command java (either file or folder) are listed.

 

Guess you like

Origin www.cnblogs.com/tslite/p/11305997.html
Recommended