Unzip files in particular directory or folder under Linux or UNIX
Q. I’m new to Linux command line. I’ve a command called unzip and a file called package.zip. I can extract file using command:
unzip package.zip
All files are extracted into current directory (it is making a directory called package). I want all files and subdirectory extracted into /opt directory. How do I extract files in /opt?
A. unzip command will list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems. The default behavior (with no options) is to extract into the current
directory (and subdirectories below it) all files from the specified ZIP archive.
By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed.
Syntax:
unzip {.zip-file-name}-d {/path/to/extract}
For example extract package.zip into /opt, enter:
# unzip package.zip -d /opt
# cd /opt
# ls
If you want to rename package directory use mv command:
# mv package newname
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- How do I unzip multiple / many files under Linux?
- How to: Linux or UNIX List just directories or directory names
- Find Out Linux Kernel Modules ( Drivers ) Location / Directory
- Backup CentOS Linux RPM database
- Examining the Linux / FreeBSD / UNIX filesystem with ls command
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



Recent Comments
Today ~ 1 Comment
Today ~ 1 Comment
Yesterday ~ 2 Comments
Yesterday ~ 1 Comment
Yesterday ~ 7 Comments