English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux ar command

Linux Command大全

The Linux ar command is used to create or modify backup files or extract files from backup files.

The ar command on Linux allows you to combine many files into a single backup file. In the backup file, all member files retain their original attributes and permissions.

Syntax

ar[-dmpqrtx][cfosSuvV][a<member file>][b<member file>][i<member file>][backup file][member file]

Parameters:

Required parameters:

  • -d Delete member files from the backup file.
  • -m Change the order of the member files in the backup file.
  • -p Display the content of the member files in the backup file.
  • -q Append the file to the end of the backup file.
  • -r Insert the file into the backup file.
  • -t Display the files contained in the backup file.
  • -x Extract member files from the backup file.

Option parameters:

  • a<member file> Insert the file after the specified member file in the backup file.
  • b<member file> Insert the file before the specified member file in the backup file.
  • Create a backup file.
  • To avoid compatibility issues with other systems' ar commands due to excessively long filenames, this parameter can be used to truncate the names of member files that are to be placed in the backup file.
  • i<member file> Insert the file before the specified member file in the backup file.
  • o Preserve the file dates in the backup file.
  • s If the backup file contains object patterns, use this parameter to create a symbol table for the backup file.
  • S Do not generate symbol tables.
  • u Only insert newer files into the backup file.
  • v Display detailed information during program execution.
  • V Display version information.

Online Examples

Packed file

[[email protected] ~]# ls   //Display the files in the current directory   
a.c  b.c d.c  install.log  qte
anaconda-ks.cfg c.c Desktop 
[[email protected] ~]# ar rv one.bak a.c b.c //Pack a.c b.c files 
ar: Creating one.bak
a - a.c
a - b.c
[[email protected] ~]# 

Pack multiple files

[[email protected] ~]# ar rv two.bak *.c  //Pack files ending with .c  
ar: Creating two.bak
a - a.c
a - b.c
a - c.c
a - d.c
[[email protected] ~]# 

Display the content of the packed file

[[email protected] ~]# ar t two.bak    
a.c
b.c
c.c
d.c
[[email protected] ~]# 

Delete the member files of the packed file

[[email protected] ~]# ar d two.bak a.c b.c c.c  
[[email protected] ~]# ar t two.bak       
d.c

Linux Command大全