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

Secure PHP Development- P170 pot

5 119 0
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Secure PHP Development
Trường học University of Example
Chuyên ngành Computer Science
Thể loại Thesis
Năm xuất bản 2025
Thành phố Example City
Định dạng
Số trang 5
Dung lượng 102 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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 allow

Trang 1

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 /tmpon UNIX systems; on Windows systems, this is typically set to /tempor 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/~usernameURLs under Apache Server The -R option tells chmod

to recursively change permissions for all files and directories under the named directory

Trang 2

Syntax:

chown [ -fhR ] Owner [ :Group ] { File | Directory }

The chowncommand 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 Groupparameter can be

a group ID or a group name in the /etc/groupfile

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 chownoptions

T ABLE 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 cpcommand to make an exact copy of a file The cpcommand 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 secsec-ond argument is

Trang 3

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.bakin the same directory These two files are identical, bit for bit

grep

Syntax:

grep [-viw] pattern file(s)

The grepcommand 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 grepcommand is useful when you have numerous files and you want to find out which ones contain certain words or phrases

Using the -voption, you can display the inverse of a pattern Perhaps you want

to select the lines in data.txtthat do not contain the word the:

grep -vw ‘the’ data.txt

If you do not specify the -woption, any word containing thematches, such as

toge[the]r The -woption specifies that the pattern must be a whole word Finally, the -ioption 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 findcommand finds files and directories, as shown in the following example:

find -type d

The findcommand returns all subdirectory names under the current directory

The -typeoption is typically set to d(for directory), f(for file), or l(for links):

find -type f -name “*.txt”

Trang 4

The preceding command finds all text files (ending with a .txtextension) 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 .txtextension)

in the current directory, including all its subdirectories for the keyword magic, and returns their names (because -lis 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 -lcommand

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

lncreates 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

Trang 5

You cannot remove a file that has hard links from the hard disk until you remove all links You create hard links without the -soption:

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_htmlon file system 1

locate

Syntax:

locate keyword

The locatecommand finds the path of a particular file or command if updated script was run at an earlier time using cron job or manually locatefinds 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 fooin the absolute path

or does not have any output

ls

Syntax:

ls [-1aRl] file or directory

The lscommand allows you to list files (and subdirectories) in a directory It is one of the most popular programs When you use it with the -1option, it displays only the file and directory names in the current directory When you use the -l

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