1. Trang chủ
  2. » Công Nghệ Thông Tin

Secure PHP Development- P170 pot

5 119 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 102 KB

Nội dung

For example, the following are equivalent: upload_max_filesize = 2M upload_max_filesize = 2097152 upload_tmp_dir The load_tmp_dir directive defines the temporary directory location for files uploaded via PHP. It is customary to set this to /tmp on UNIX systems; on Windows systems, this is typically set to /temp or left alone, in which case, PHP uses the sys- tem default. Syntax: load_tmp_dir directory Common File/Directory Commands This section describes a few commonly used Linux file and directory commands. chmod Syntax: chmod [-R] permission-mode file or directory Use this command to change the permission mode of a file or directory. The per- mission mode is specified as a three- or four-digit octal number. For example: chmod 755 myscript.pl The preceding command changes the permission of myscript.pl script to 755 (rwxr-xr-x), which allows the file owner to read, write, and execute, and allows only read and execute privileges for everyone else. Here is another example: chmod -R 744 public_html The preceding command changes the permissions of the public_html directory and all its contents (files and subdirectories) to 744 (rwxr-r-), which is a typical permission setting for the personal Web directories you access using http://server/~username URLs under Apache Server. The -R option tells chmod to recursively change permissions for all files and directories under the named directory. Appendix D: Linux Primer 821 34 549669 AppD.qxd 4/4/03 9:28 AM Page 821 chown Syntax: chown [ -fhR ] Owner [ :Group ] { File . . . | Directory. . . } The chown command changes the owner of a file or directory. The value of the Owner parameter can be a user ID or a login name in the /etc/passwd file. Optionally, you also can specify a group. The value of the Group parameter can be a group ID or a group name in the /etc/group file. Only the root user can change the owner of a file. You can change the group of a file only if you are a root user or you own the file. If you own the file but are not a root user, you can change the group only to a group of which you are a member. Table D-3 describes the chown options. TABLE D-3 CHOWN OPTIONS Option Description -f Suppresses all error messages except usage messages. -h Changes the ownership of an encountered symbolic link but not that of the file or directory to which the symbolic link points. -R Descends directories recursively, changing the ownership for each file. When a symbolic link is encountered and the link points to a directory, the ownership of that directory is changed, but the directory is not further traversed. The following example changes the owner of the file to another user: chown bert hisfile.txt cp Syntax: cp [-r] source destination Use the cp command to make an exact copy of a file. The cp command requires at least two arguments. The first argument is the file you want to copy, and the sec- ond argument is the location or file name of the new file. If the second argument is 822 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 822 an existing directory, cp copies the source file into the directory. The -r parameter recursively copies a directory. cp main.c main.c.bak The preceding example copies the existing file main.c and creates a new file called main.c.bak in the same directory. These two files are identical, bit for bit. grep Syntax: grep [-viw] pattern file(s) The grep command enables you to search for one or more files for particular character patterns. Every line of each file that contains the pattern is displayed at the terminal. The grep command is useful when you have numerous files and you want to find out which ones contain certain words or phrases. Using the -v option, you can display the inverse of a pattern. Perhaps you want to select the lines in data.txt that do not contain the word the: grep -vw ‘the’ data.txt If you do not specify the -w option, any word containing the matches, such as toge[the]r. The -w option specifies that the pattern must be a whole word. Finally, the -i option ignores the difference between uppercase and lowercase letters when searching for the pattern. Much of the flexibility of grep comes from the fact that you can specify not only exact characters but also a more general search pattern. To do this, you use what are described as regular expressions. find Syntax: find [path] [-type fdl] [-name pattern] [-atime [+-]number of days] [-exec command {} \;] [-empty] The find command finds files and directories, as shown in the following example: find . -type d The find command returns all subdirectory names under the current directory. The -type option is typically set to d (for directory), f (for file), or l (for links): find . -type f -name “*.txt” Appendix D: Linux Primer 823 34 549669 AppD.qxd 4/4/03 9:28 AM Page 823 The preceding command finds all text files (ending with a .txt extension) in the current directory, including all its subdirectories. find . -type f -name “*.txt” -exec grep -l “magic” {} \; The preceding command searches all text files (ending with the .txt extension) in the current directory, including all its subdirectories for the keyword magic, and returns their names (because -l is used with grep): find . -name ?*.gif? -atime -1 -exec ls -l {} \; The preceding command finds all GIF files that have been accessed in the past 24 hours (one day) and displays their details using the ls -l command. find . -type f -empty The preceding command displays all empty files in the current directory hierarchy. head Syntax: head [-count | -n number] filename This command displays the first few lines of a file. By default, it displays the first 10 lines of a file. However, you can use the preceding options to specify a different number of lines, as follows: head -2 doc.txt # Outline of future projects # Last modified: 02/02/99 The preceding example illustrates how to view the first two lines of the text file doc.txt. ln Syntax: ln [-s] sourcefile target ln creates two types of links: hard and soft. Think of a link as two names for the same file. Once you create a link, you cannot distinguish it from the original file. 824 Part VII: Appendixes 34 549669 AppD.qxd 4/4/03 9:28 AM Page 824 You cannot remove a file that has hard links from the hard disk until you remove all links. You create hard links without the -s option: ln ./www ./public_html A hard link does have limitations, however. A hard link cannot link to another directory, and a hard link cannot link to a file on another file system. Using the -s option, you can create a soft link, which eliminates these restrictions: ln -s /dev/fs02/jack/www /dev/fs01/foo/public_html Here you create a soft link between the directory www on file system 2 and a newly created file public_html on file system 1. locate Syntax: locate keyword The locate command finds the path of a particular file or command if updated script was run at an earlier time using cron job or manually. locate finds an exact or substring match. For example: locate foo /usr/lib/texmf/tex/latex/misc/footnpag.sty /usr/share/automake/footer.am /usr/share/games/fortunes/food /usr/share/games/fortunes/food.dat /usr/share/gimp/patterns/moonfoot.pat The output that locate produces contains the keyword foo in the absolute path or does not have any output. ls Syntax: ls [-1aRl] file or directory The ls command allows you to list files (and subdirectories) in a directory. It is one of the most popular programs. When you use it with the -1 option, it displays only the file and directory names in the current directory. When you use the -l Appendix D: Linux Primer 825 34 549669 AppD.qxd 4/4/03 9:28 AM Page 825 . location for files uploaded via PHP. It is customary to set this to /tmp on UNIX systems; on Windows systems, this is typically set to /temp or left alone, in which case, PHP uses the sys- tem default. Syntax:

Ngày đăng: 07/07/2014, 07:20