Linux permissions issue (2) Permissions issues raised by-unzip

Source: Internet
Author: User
Tags bz2

background: still a friend, when invoking the unzip command with PHP, there is a problem with permission being rejected again.

Notice: The problem described here is to execute PHP files using the PHP command line, so the process is the owner of the user who is logged in, not the Nginx user.

Log in as root to set read and Execute permissions for MyUser's home directory

Notice:CD to a directory, you need to have Execute permissions on the directory, otherwise the permission is denied prompt.

chmod a+-d myuserdrwxr24096: MyUser

Go to MyUser user's home directory using Redheat users

$ Ll-d 'pwd' drwxr24096:/home/   WhoAmI  redheat

As you can see, Redheat has only read and execute permissions on the directory.

Execute unzip command to decompress

Unzip /home/redheat/zip_test/sysinfo. Zip Archive:   /home/redheat/zip_test/sysinfo. Zip Error:  cannot create sysinfo.go        Permission denied

Obviously, there was a prompt for permission denied.

Unzip by default will extract the files to your current directory (the directory displayed by PWD), when you do not have write permission to the directory, there will be a permissions issue.

Unzip the specified directory to extract the parameter is-D.

$Unzip/home/redheat/zip_test/sysinfo.Zip-d/home/redheat/zip_test/Archive:/home/redheat/zip_test/sysinfo.Zipinflating:/home/redheat/zip_test/Sysinfo.go $ ll/home/redheat/zip_test/ Total --rw-r--r--.1Redheat Redheat11140June the  the: ASysinfo.go-rw-r--r--.1Root root2167June in  -:GenevaSysInfo.Zip

tip: For example, use above, the first time you run out of/home/redheat/zip_test/, the second time you use this parameter, enter ESC. (Esc press and release, and then press.), the parameter is filled in automatically. There are more shortcut keys in Marco Linux base learning notes.

The differences between-F and-u are described below unzip

excerpted from man document-F     freshen  existing files, i.e., extract only those files, already exist on disk and that    is newer than the disk copies. Updates the existing file. (only those files already exist on disk and are newer than the copy on disk) -U     if needed.  function as the- in does not already exist on disk. Updates the existing files, if needed, creates a new one. This option is similar to -F, which extracts files with the same name and updates, and it also extracts files that do not exist on disk.

Well, my English is not good, the translation is rather rotten.

It is obvious, however, that when the file in the package is not changed, the-f option does nothing, and the files that were not previously in the package are compressed and then added and decompressed, and it does not extract the new files.

The-u option also does nothing if the files in the package are not changed, but if there are new files in the package, the-u option extracts the new files.

$Unzip-F SysInfo.ZipArchive:sysinfo.Zip$ lltotal2024-rw-r--r--.1Redheat Redheat11140June the  the: ASysinfo.go-rw-r--r--.1Redheat Redheat2056718June in  -: inSysInfo.Zip$ Unzip-U sysinfo.ZipArchive:sysinfo.Zipinflating:monitor_agent.Tar. bz2 $ lltotal4032-rw-r--r--.1Redheat Redheat2055327June - Ten: -Monitor_agent.Tar. bz2-rw-r--r--.1Redheat Redheat11140June the  the: ASysinfo.go-rw-r--r--.1Redheat Redheat2056718June in  -: inSysInfo.Zip

When using-F, no new files are extracted, and when you use-u, a new file is extracted.

And Sysinfo.go has not changed.

Summarize:

1.unzip,-D can specify the directory to extract to

2.-f and-U still have some differences, depending on the situation to add the corresponding parameters.

Linux permissions issue (2) Permissions issues raised by-unzip

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.