20061026

From Wsms

Jump to: navigation, search

previous next
GO TO:
Linux Class Notes
Basic log files and security tools


Thursday Oct 26 2006

Contents

Never forget that...

  1. Linux is Case SensItIVe!!!!
  2. Lynux translates everything to lowercase, and then it finds nothing if some directories' names are in uppercase.
  3. You can do certanly almost everything in apache, but it is guaranteed that you will not like to do it in a regular basis.
  4. There are different coding information for characters. There is an environmetal variable set for every user, called LANG. We have to make sure that the variable has to be exported to our language, that is en_us-utf.8 (or C). We have to say export LANG=C, or export LANG=en_us, and you get the problem fixed.

about cron

It is based in cron , that is the scheduled activities.
You better find that crond is running in your system.
Using the file /etc/crontab , you can schedule activities. Crond is checking that file every minute.
The non-administrator users also have permission to schedule activities, but not to change the crontab file.
To schedule as non administrator user, it is necesary to use a special tool, that will file a special crontab file in a special folder.
This folder is /var/spool/cron . In order to build that files, the user must use a special program, because those files are protected and only the root users can get to them.

Crontab

The program used is crontab
The interesting thing is that we have a file called crontab, and an application called crontab.
This is the look of the file crontab:
[root@localhost etc]# more crontab          
SHELL=/bin/bash                             
PATH=/sbin:/bin:/usr/sbin:/usr/bin          
MAILTO=root                                 
HOME=/                                      
                                            
# run-parts                                 
01 * * * * root run-parts /etc/cron.hourly  
02 4 * * * root run-parts /etc/cron.daily   
22 4 * * 0 root run-parts /etc/cron.weekly  
42 4 1 * * root run-parts /etc/cron.monthly 

The fields:

  1. Minutes
  2. Hours of the day
  3. Day of the month
  4. Months of the year
  5. Days of the week

For example, the first line says that the commands located in /etc/cron.hourly, will be executed at 01 minute, after an hour every hour of the day, every day of the month, every month of the year, every day of the week.
The last line is about the commands to run every first day of the month at 04:42 am.
Every time the cron does something, it is logged in /etc/run/cron/log
An interesting thing of this is that throught crontab command, user can write to a file that is in /var/spool/cron, and the user doesn't have permission to see or write to that file. That's very interesting, and has to have further discussion:

Why crontab is different with permissions???

It is usual that programs work with the same permissions as the user that are running them.
Somehow or other, the crontab program has a way to modify the permission of that folders.
This is asociated with the "s" permission, that we have not considered before, and that is related to the capability that some PROGRAMS have to access to this programs as a super user.

About files in /etc.cron.daily

  1. There is a file called 00webalizer, that on a daily basis, it has to process the data that's in the log files that it mantains in the webserver, and it builds graphic files that you can lookup with a web browser.
  2. 0anacron: If you turn off your computer, this looks for tasks that were scheduled, and make them run without the script. Servers are generally on 7x24, but if a machine doesn't, anacron takes care of it.
  3. Cups: Printing.
  4. logrotate: Task that actually creates new log files, so they are not so big to crash the system down.
  5. makewhatis.cron: Generates a database to find out wether or not information is available (for example apropos or whatis)
  6. mlocate: Locate is a program that identifies where a string is included as either part of a file name, or part of a folder name. That locate command runs very fast, because it runs from a database, that is built by the mlocate program.
Personal tools