Hướng dẫn chi tiết cách giải nén file RAR trên Linux cho bạn tham khảo.
Table of Contents
Cài Đặt Lệnh Unrar
Nếu đang sử dụng Debian hoặc Ubuntu Linux, bạn có thể sử dụng lệnh apt-get hoặc lệnh apt như dưới đây để cài đặt chương trình unrar:
$ sudo apt-get install unrar
Hoặc:
$ sudo apt install unrar
Nếu đang sử dụng CentOS / RHEL, bạn có thể sử dụng lênh yum để cài đặt unrar:
# yum install unrar
Nếu đang sử dụng Fedora Linux, bạn sử dụng lệnh dnf:
$ sudp dnf install unrar
Nếu đang sử dụng FreeBSD Unix, bạn sử dụng lệnh pkg_add:
# pkg_add -v unrar
Nếu đang sử dụng macOS Linux và Homebrew, bạn sử dụng lệnh brew:
$ brew install unrar
Nếu các lệnh trên không hoạt động trên phiên bản Linux / Unix mà bạn đang sử dụng, tải binary package từ trang chủ rarlab về:
$ cd /tmp ## 32 bit linux ## $ wget https://www.rarlab.com/rar/rarlinux-5.5.0.tar.gz
Hoặc phiên bản Linux 64 bit:
$ wget http://www.rarlab.com/rar/rarlinux-x64-5.3.b4.tar.gz
Tiếp theo giải nén file tar mà bạn vừa tải về bằng lệnh Tar:
$ tar -zxvf rarlinux-*.tar.gz
Cả lệnh unrar và lệnh rar nằm trong thư mục con rar. Chỉ cần sử dụng cd để điều hướng đến thư mục rar:
$ cd rar $ ./unrar
Tiếp theo sao chép các file rar và unrar vào thư mục /usr/local/bin, nhập lệnh dưới đây vào:
$ sudo cp rar unrar /usr/local/bin
Cách Sử Dụng Lệnh Unrar
Lệnh unrar hỗ trợ các tùy chọn khác nhau, dưới đây là các tùy chọn phổ biến mà bạn cần để giải nén các file.
Giải Nén File RAR
Để giải nén rar trên Linux hoặc Unix trong thư mục hiện tại, bạn sử dụng lệnh:
$ unrar e file.rar
Kết quả đầu ra:
cach giai nen file rar tren linux hoac unix
Liệt Kê Danh Sách Tất Cả Các File Trong File RAR
Sử dụng lệnh dưới đây để liệt kê tất cả các file trong file RAR:
$ unrar l file.rar
cach giai nen file rar tren linux hoac unix 2
Giải Nén Các File Với Đường Dẫn Đầy Đủ
Để giải nén các file với đường dẫn đầy đủ, bạn sử dụng lệnh dưới đây:
$ unrar x file.rar
Kết quả đầu ra:
cach giai nen file rar tren linux hoac unix 3
Kiểm Tra Tính Toàn Vẹn File RAR
Để kiểm tra tính toàn vẹn của file RAR bạn sử dụng lệnh dưới đây:
$ unrar t file.rar
Kết quả đầu ra:
cach giai nen file rar tren linux hoac unix 4
Nhận Hỗ Trợ Lệnh Unrar
Sử dụng lệnh dưới đây:
$ man unar
Hoặc:
$ unrar | more
Kết quả đầu ra:
unrar UNRAR 5.50 freeware Copyright (c) 1993-2017 Alexander Roshal Usage: unrar - - <@listfiles...> e Extract files without archived paths l[t[a],b] List archive contents [technical[all], bare] p Print file to stdout t Test archive files v[t[a],b] Verbosely list archive contents [technical[all],bare] x Extract files with full path - Stop switches scanning @[+] Disable [enable] file lists ad Append archive name to destination path ag[format] Generate archive name using the current date ai Ignore file attributes ap Set path inside archive c- Disable comments show cfg- Disable read configuration cl Convert names to lower case cu Convert names to upper case dh Open shared files ep Exclude paths from names ep3 Expand paths to full including the drive letter f Freshen files id[c,d,p,q] Disable messages ierr Send all messages to stderr inul Disable all messages kb Keep broken extracted files n Additionally filter included files n@ Read additional filter masks from stdin n@ Read additional filter masks from list file o[+|-] Set the overwrite mode ol[a] Process symbolic links as the link [absolute paths] or Rename files automatically ow Save or restore file owner and group p[password] Set password p- Do not query password r Recurse subdirectories sc[obj] Specify the character set sl Process files with size less than specified sm Process files with size more than specified ta Process files modified after in YYYYMMDDHHMMSS format tb Process files modified before in YYYYMMDDHHMMSS format tn Process files newer than to Process files older than ts[m|c|a] Save or restore file time (modification, creation, access) u Update files v List all volumes ver[n] File version control vp Pause before each volume x Exclude specified file x@ Read file names to exclude from stdin x@ Exclude files listed in specified list file y Assume Yes on all queries
Chúc bạn thành công!