Linux development and management commands
1. sync: writes the disk buffer to the disk to prevent sudden power loss. This command is called when Linux is shut down.
2. view and configure Kernel Parameters in sysctl. The Kernel Parameter configuration file/etc/sysctl. conf, sysctl-p is run by default/etc/sysctl. conf, which can be followed by the specified configuration file name.
3. ntsysv Red Hat and other systems are supported. Run the command as ROOT. You can configure services that are automatically started upon startup. * Indicates that the instance is started. The space key is used to set the selection or cancellation. The tab key is used to switch to the confirmation, cancellation, or selection list. Not effective immediately
4. chkconfig
Example:
Chkconfig -- list # list all system services
Chkconfig -- add httpd # add httpd service
Chkconfig -- del httpd # Delete the httpd service
Chkconfig -- level httpd 2345 on # Sets httpd to on when the running level is 2, 3, 4, or 5.
Chkconfig -- list # list all system startup statuses
Chkconfig -- list mysqld # list mysqld service settings
Chkconfig -- level 35 mysqld on # Set mysqld to run at level 3 and 5. -- level 35 indicates that the operation is only executed at level 3 and 5, on indicates that the operation is started, and off indicates that the operation is disabled.
Chkconfig mysqld on # Set mysqld to on at each level. "Each level" includes 2, 3, 4, and 5 levels.
How to add a service:
1. The service script must be stored in the/etc/init. d/directory with the same name as the service name.
2. chkconfig -- add servicename
Add this service to the chkconfig tool service list. In this case, the service will be assigned a K/S entry in/etc/rc. d/rcN. d;
3. chkconfig -- level 35 servicename on
Modify the default service start level.
5. crontab periodically executes certain tasks. System Task/etc/crontab: add your own task, create the task description file, and add the task to the user's task list by "crontab file name, in/var/spool/cron, the file named after the user name indicates the user's scheduled task.
Meaning of the crontab file:
In the crontab file created by the user, each row represents a task, and each field in each row represents a setting. Its format is divided into six fields. The first five fields are time sets, the sixth part is the command segment to be executed. The format is as follows:
Minute hour day month week command
You can also use the following special characters in the preceding fields:
Asterisk (*): represents all possible values. For example, if the month field is an asterisk, this command is executed every month after the conditions of other fields are met.
Comma (,): values separated by commas (,) can be used to specify a list range, for example"
Middle bars (-): You can use the middle bars between Integers to represent an integer range. For example, "2-6" indicates "2, 3, 4, 5, 6"
Forward slash (/): You can use a forward slash to specify the interval of time. For example, "0-23/2" indicates that execution is performed every two hours. At the same time, the forward slash can be used with the star number, for example, */10. If it is used in the minute field, it indicates that the execution is performed every ten minutes.
For example, 30 12 */2 1-8 */bin/ps-aux>/tmp/log.txt, every two days from 1 to August, the Process status at is recorded.
6. route
-N: view route table information
Route add-net 192.168.1.0/24 gw 192.168.2.1 added to a CIDR Block
Route add-host 192.168.1.1 gw 192.168.2.1 added to a host
Add default route add default gw 192.168.2.1
To delete a route, replace add with del.
7. Run the "setup Red Hat" command to configure ip dns.
8. openssl RSA encryption and decryption
① Generate an RSA key. openssl genrsa-out test. key 1024 Description: 1024 key length of the test. key Private key File
② Extract Public key: openssl rsa-in-test. key-pubout-out test_public.key extract the public key file test_public.key from the private key file
③ Encryption File (public key encryption): openssl rsautl-encrypt-in hello.txt-inkey test_pub.key-pubin-out hello. en hello. en after Encryption By hello.txt
④ Decryption file (Private key decryption): openssl rsautl-decrypt-in hello. en-inkey test. key-out hello.de
8. User Account and Group Management
Add User
Useradd
-D specifies the home directory-u uid
-M: If the main directory does not exist, create-M: do not create the main directory
User Deletion
Userdel-r user name delete user and Home Directory
Usermod
Add the user to the group: usermod-a-G group name username use the-a option, the user will not be removed from the previous group, a = append
9. Modify Kernel Parameters
/Etc/sysctl. conf
Net. ipv4.icmp _ echo_ignore_all = 1 # ping prohibited from this host
Net. ipv4.tcp _ fin_timeout = 30 # configure the TIMEOUT time
Net. ipv4.tcp _ tw_reuse = 1 # Allow the port in the TIME-WAIT status to be used for the new socket
Sysctl-p takes effect immediately
This article permanently updates the link address: