Learn to record 007-network configuration and Scheduled tasks

Source: Internet
Author: User

First, simple knowledge
1. Command accumulation:
Ifup eth0//start NIC
Ifdown Etho//Turn off the network card
Route-n//View Gateway
Route del default GW 10.0.0.244//delete gateway, GW on behalf of Gateway add on behalf of adding gateway

Why does the configuration file need to be restarted in 2.linux?
Prevent configuration errors
Put all the configuration in memory, if put on the disk, it will be very slow

3. Basic issues with some network configurations
/etc/sysconfig/network//Gateway configuration and User name configuration
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf//Modify DNS host www.baidu.com returns an IP address stating that DNS is not a problem

If the ping gateway is out of the way, DNS is not available, then look at the local DNS is not a problem
If Ping gateway is pass, Ping Baidu does not pass, ping8.8.8.8.8, this time to consider whether the bandwidth provider is not a problem, with the route ping, the way to ping the intranet and the external network, ping the intranet and the external network ip-t
Related Reference Blog:
http://blog.csdn.net/it1988888/article/details/8249942
Http://www.djjwz.com/news/news2375.html

4.suid and Sgid, why/ETC/PASSWD's permission is 644, can change the password?
[Email protected] ~]# LL/ETC/PASSWD
-rw-r--r--. 1 root root 1463 June 02:34/etc/passwd
Setuid is a privilege that allows a normal user to run as the root user
[Email protected] ~]# LL/USR/BIN/PASSWD
-rwsr-xr-x. 1 root root 30768 Feb 2012/usr/bin/passwd
As in the above example of s,suid==4, that is, 4755, is to have it, ordinary users can change the password, because this command you can not control how others use, so less use as good
The G in Setgid is 2000, which means
Sticky bit chmod 0+t 1.txt//t end, a directory even if it is 777 permissions, plus sticky bit, in addition to the owner and the root user can delete it, other people could not delete it, mainly for sharing

Second, Scheduled Tasks

1.crond is a service or software that the system periodically executes commands or designates in, program tasks, like the alarm clock that we use in our lives, boot-up service: SSH network syslog systat Crond, mainly used for the company's 0-point backup

2. Daemon or daemon: The program that the computer is executing, the daemon is a running program
Program Files: program code composed, but not executed within the computer, currently not executing

3.linux system itself regularly perform tasks, back up system logs, clean up system cache

[Email protected] logrotate.d]# Pwd/etc/logrotate.d[[email protected] LOGROTATE.D] #Display all 1969 possibilities? (Y or N) [email protected] logrotate.d]# cat syslog/var/log/cron/var/log/maillog/var/log/messages/var/log/secure/var/log/ Spooler{sharedscriptspostrotate/bin/kill-hup ' cat/var/run/syslogd.pid 2>/dev/null ' 2>/dev/null | | Trueendscript}

  


4. Tasks performed by the user (System administrator's job): There are three kinds of at,crontab,anacron
At: Just once, these crontab can meet
Anacron: It's not a mission for the hour, the room is 7* 24 hours, so no need
CRONTAB-E-L Common,-time-sharing week
/etc/cron.deny//Reject
/etc/cron.allow//Allow
/var/spool/cron//Edit crontab task profile, under $user (current user)
User's timed tasks: * * * * * cmd//cmd is command
Scheduled tasks for the system: Cat/etc/crontab
Special Symbolic Meanings:
* ANY
-Partition number 17-19
, dividing the meaning of the time period 17,19,22
/n represents a number, every n units of time
Remember that weeks and days do not have to be used at the same time, because sometimes not on the same day
Chkconfig--list Crond//Direct view process
Ps-ef|grep Cron
Experiment: Print your name to the/server/log service every minute
First Mkdir/server/log-p//create a directory of your own

[[email protected] ~]# cd/etc/logrotate.d[[email protected] logrotate.d]# Crontab-eno crontab for root-using an empty Onecrontab:installing new Crontab//File Add * * * * * echo Xiongchao >>/server/log/carlton[[email protected] Logrotat e.d]# tail-f/server/log/carltonxiongchao//Results executed successfully

  


5. Add the day's date to the scheduled task to print it out and perform it regularly
The most important problem is the problem-solving ideas, first of all to know how to set up a scheduled task, configuration files under ETC/LOGROTATE.D to perform CRONTAB-E modifications

Verify that the date +%f can not show the 2016-06-28

Next Mkdir/server/log/1.log-p
Date +%f >>/server/log/1.log//After the cat file, confirm that 1.log was added successfully 2016-06-28
The most important step is to write the above command to log.sh
VI log.sh//Add date +%f >>/server/log/1.log// Here log.sh the most critical is the. Sh end of the script, the name is not important, as long as the. Sh end can be executed inside the command added, the date command results are written to 1.log
/bin/sh/server/log/log.sh//execute the command after cat to see if update 2016-06-28
Enter/ETC/LOGROTATE.D crontab-e input Scheduled Tasks, complete scheduled Tasks
Difficulty: To understand the role of the. sh file and/bin/sh is used to start the. Sh script or Vi/var/spool/cron/root for editing
Related blog: http://www.cnblogs.com/mingforyou/p/3930636.html
The standard essentials of timed tasks:
A. Writing tasks with annotations
B. Add/bin/sh before executing the shell Script task
C. Perform related scheduled tasks under the specified user
D. The end of the scheduled task plus (usually add after the script, echo error) >/dev/null2>&1 equivalent to 1>/dev/null
2>/dev/null 2>&1 that both right and wrong redirect the past
> and 1> are equivalent to representing the appended information directly to the target file
1>> and >> are the equivalent to represent additional information directly appended to the target file
Standard error Output: Code 2 using 2> or 2>>
E. Production task procedures do not print output information at will
F. Timed task scripts to standardize

Learn to record 007-network configuration and Scheduled tasks

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.