在Ubuntu系统中,有多种方法可以用来压缩和解压文件,具体如下:
zip 命令压缩单个文件或文件夹:zip compressed_file.zip file_name 例如:zip example.zip example.txt zip compressed_files.zip file1 file2 file3 例如:zip files.zip file1.txt file2.txt file3.txt zip -r compressed_folder.zip folder_name 例如:zip -r folder.zip folder zip -u existing_file.zip new_file 例如:zip -u existing.zip new.txt unzip -l compressed_file.zip 例如:unzip -l files.zip tar 命令压缩文件或文件夹:tar -czvf archive.tar.gz /path/to/file_or_folder tar -czvf archive.tar.gz /path/to/folder gzip、bzip2、lzma、xz 等工具进行压缩:gzip 压缩文件:gzip examplefile bzip2 压缩文件:bzip2 examplefile lzma 压缩文件:lzma -c --stdout examplefile > examplefile.lzma xz 压缩文件:xz examplefile zip 命令解压文件:unzip filename.zip unzip filename.zip -d /home/sunny unzip -d myfile.zip smart.txt unzip -o -d /home/sunny myfile.zip tar 命令解压文件:.tar.gz 或 .tgz 文件:tar -xzvf archive.tar.gz .tar.bz2 文件:tar -xjvf archive.tar.bz2 .tar 文件:tar -xvf archive.tar gunzip、gzip -d、bzip2 -d、bunzip2 等工具解压文件:.gz 文件:gunzip FileName.gz .bz2 文件:bzip2 -d FileName.bz2 .rar 文件(需要安装unrar):unrar x FileName.rar .7z 文件(需要安装p7zip):7z x filename.7z -o/home/xxx 请注意,如果系统没有预先安装某些压缩工具,如 zip,则需要先通过 sudo apt-get install zip 等命令进行安装。在使用上述命令时,请确保替换命令中的 archive.tar.gz、examplefile、folder 等为实际的文件名或路径。