web dictionary for beginners
The following is a list of UNIX commands that you might find helpful when modifying your web sites on the server. Most UNIX commands have many options and parameters which are not listed here. For more complete information on using UNIX commands, you can refer to the online manual by typing man [command] at the UNIX prompt, where "[command]" represents the command you would like more information about. Other UNIX help commands you can type are [command] -? and [command] --help. Note : When something is specified in brackets, such as [command] or [filename], it is used to indicate that you must input your desired information here. Do NOT include brackets in your command.
|
|
||||||||||||||||||||||||||||||||||||||||
Navigating in UNIX
Moving, Copying and Deleting Files
Creating, Moving, Copying and Deleting Directories
Searching Files and Directories
|
File and Directory Permissions
There are three levels of file permissions: read, write and execute. In addition, there are three groups to which you can assign permissions: file owner, user group and everyone. The command chmod followed by three numbers is used to change permissions. The first number is the permission for the owner, the second for the group and the third for everyone. Here are how the levels of permission translate:
| 0 = --- | No permission |
| 1 = --X | Execute only |
| 2 = -W- | Write only |
| 3 = -WX | Write and execute |
| 4 = R-- | Read only |
| 5 = R-X | Read and execute |
| 6 = RW- | Read and write |
| 7 = RWX | Read, write and execute |
It is preferred that the group always have permission of 0. This prevents other users on the server from browsing files via Telnet and FTP. Here are the most common file permissions used:
| chmod 604 [filename] | Minimum permissions for HTML file |
| chmod 705 [directory name] | Minimum permissions for directories |
| chmod 755 [filename] | Minimum permissions for scripts & programs |
| chmod 606 [filename] | Permissions for data files used by scripts |
| chmod 703 [directory name] | Write-only permissions for public FTP uploading |
Scheduling Tasks ("Cron")
You can schedule tasks to run automatically by using the UNIX cron command. To use this, you create a text file with cron instructions, then process this file. cron instructions are basically UNIX commands with extra info about the time that they will run.
One important thing to note is that it is best to use full paths when creating your cron file. As an example, create a file called mycronfile and in it place one line:
0 1 * * * cp /usr/www/file.txt /usr/www/backup.txt
now at the command line, type the following:
crontab mycronfile
You have just scheduled an automated task! This task will run at the time specified until you decide you want to cancel it. There are six fields in this file. The first five represent the time that the job will run. The sixth field is a UNIX command that will run at the specified time. The above example will run every night at 1AM, at which time it will copy a file.
Here is how the fields break down:
Field 1 | Field 2 | Field 3 | Field 4 | Field 5 Minutes | Hours | Day of Month | Month | Day of Week (0-59) | (0-23) | (1-31) | (1-12) | (0-6)
You can enter a number in the field, a range of numbers, or an * to indicate all. Here are a few more examples. These examples use the ls command, which would be pretty useless. Note the time that it runs, though.
0 1 * * 1-5 ls (this would run every Monday-Friday at 1am) 0 1 * * 1,3,5 ls (this would run every Monday, Wednesday and Friday at 1am) 10 2 1 * * ls (this would run at 2:10am on the first of every month) 0 1 1 1 * ls (this would run at 1am on January 1 every year)
If you have a more complicated command that you want to run, it is sometimes helpful to create a shell script and have that script run. You specify the shell script as you would any UNIX command. For example:
0 1 * * * /usr/www/myscript
There are some other crontab switches that are useful:
crontab -l (lists your currently scheduled tasks) crontab -r (delete all currently scheduled tasks) crontab -e (directly edit your scheduled tasks)
Please note that excessive cron use - for instance a processor-intensive script that is run every hour - may consitute a violation of the Acceptable Use Policy. As a general rule we ask that you have cron tasks run no more than twice per 24 hour period.
source: http://www.duffyinfodesign.com/support/support_unix.html
Leave a reply