ARCHIVING FILES
1. tar
Command
You may archiving recordsdata or listing use the tar
command. The tar
command can create an archive file from a number of recordsdata. Archiving and compressing recordsdata or listing are helpful when creating beckups and transferring knowledge throughout a community.
2. Syntax and Choices of the tar
Command
Syntax :
$ tar [options] [archive-file] [file or directory to be archived]
Choices :
-
-c
or--create
: Create a brand new archive. -
-x
or--extract
: Extract from an present archive. -
-t
or--list
: Listing the desk of contents of an archive. -
-v
or--verbose
: Present which recordsdata get archived or extracted. -
-f
or--file=
: File identify. -
-p
or--preserve-permissions
: Protect the permissions of recordsdata and directories when extracting an archive, with out subtracting the umask. -
-z
or--gzip
: Use gzip compression (.tar.gz). -
-j
or--bzip2
: Use bzip2 compression (.tar.bz2). bzip2 usually achieves a greater compression ratio than gzip. -
-J
or--xz
: Use xz compression (.tar.xz). The xz compression usually achieves a greater compression ratio than bzip2.
3. The tar
Command Utilization :
Instance :
-
Consumer A
will create an archive file namedgood friend.tar
with the content material recordsdata ofagung, iyan, and adit
within theperson A
dwelling listing. -
The
tar
command also can create an archive file from a listing. Instance :Consumer A
will create an archive file namedtjkt2.tar
with the contents file from/and many others
listing, earlier than archiving/and many others
listing,Consumer A
should swap toroot
person, as a result of solely the basis person is allowed to learn all the recordsdata current within the /and many others listing. -
To checklist the contents of the
tar
file, you should use the-t
possibility. Instance : -
To extract archive file, you need to create an empty listing in order to not overwrite different recordsdata. You should use
-x
choice to extract archive file. Instance :
– NOTE :
Use-p
choice to protect the permissions of an archived file. Use command :
# tar -xpf [name archive-file]
4. gzip
, bzip2
, and xz
There are three completely different compression strategies supported by the tar command:
1. gzip
You may create a gzip
compressed archive use -z
possibility. Instance :
You may extract it utilizing the command :
2. bzip2
You may create a bzip2
compressed archive use -j
possibility. Instance :
You may extract it utilizing the command :
3. xz
You may create a xz
compressed archive use -J
possibility. Instance :
You may extract it utilizing the command :
SCP
Which means of SCP
SCP (Safe Copy Protocol) is a community protocol used to securely copy recordsdata/folders between Linux (Unix) methods on a community. SCP protects your knowledge whereas copying throughout an SSH (Safe Shell) connection by encrypting the recordsdata and the passwords.
Use of SCP
SCP can be utilized to :
- Copying recordsdata from a neighborhood host to a distant host.
For Instance :
$ scp dwelling/adit/schedule.txt [email protected]:/dwelling/agung
NOTE :
– dwelling/adit/schedule.txt : the identify of the file being copied and its location.
– [email protected] : the username and IP handle of the distant host.
– /dwelling/agung : the situation the place to retailer the copied file.
- Copying recordsdata from a distant host to a neighborhood host.
For Instance :
scp [email protected]:/dwelling/iyan/bicycle.txt dwelling/adit
NOTE :
– [email protected] : the username and IP handle of the distant host from the place the file is at present positioned.
– /dwelling/iyan/bicycle.txt : the identify of the file being copied and its location.
– dwelling/adit : the situation the place to retailer the copied file.