RHCSA EX200 - Managing Files LAB
creating a tar from /usr/share/doc directory
[csr@rhel-lab1 ~]$ du -sh /usr/share/doc
63M /usr/share/doc
[csr@rhel-lab1 ~]$ tar -cf documentation.tar /usr/share/doc
tar: Removing leading `/' from member names
[csr@rhel-lab1 ~]$ ls
2 archives documentation.tar Desktop Documents Downloads Music output Pictures Public Templates Videos
[csr@rhel-lab1 ~]$ ls -l
total 59748
-rw-r--r--. 1 csr csr 1328 Apr 11 18:55 2
drwxr-xr-x. 2 csr csr 26 Apr 9 18:32 archives
-rw-r--r--. 1 csr csr 61173760 Apr 15 18:33 documentation.tar
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Desktop
drwxr-xr-x. 2 csr csr 72 Apr 11 18:04 Documents
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Downloads
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Music
-rw-r--r--. 1 csr csr 6 Apr 11 17:56 output
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Pictures
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Public
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Templates
drwxr-xr-x. 2 csr csr 6 Apr 10 12:03 Videos
[csr@rhel-lab1 ~]$ du -sh *.tar
59M ddocumentation.tar
listing content of a tar file - tar-tvf filename (t list the content, -v verbose, -f use file archive)
[csr@rhel-lab1 ~]$ tar -tvf documentation.tar | more
drwxr-xr-x root/root 0 2024-04-09 17:31 usr/share/doc/
drwxr-xr-x root/root 0 2024-04-08 14:55 usr/share/doc/hwdata/
-rw-r--r-- root/root 175 2023-08-21 01:22 usr/share/doc/hwdata/LICENSE
drwxr-xr-x root/root 0 2024-04-08 14:55 usr/share/doc/xkeyboard-config/
-rw-r--r-- root/root 510 2021-06-08 15:20 usr/share/doc/xkeyboard-config/AUTHORS
-rw-r--r-- root/root 9244 2021-06-08 15:20 usr/share/doc/xkeyboard-config/COPYING
-rw-r--r-- root/root 861 2021-06-08 15:20 usr/share/doc/xkeyboard-config/HOWTO.testing
-rw-r--r-- root/root 2303 2021-06-08 15:20 usr/share/doc/xkeyboard-config/HOWTO.transition
-rw-r--r-- root/root 5108 2021-06-08 15:20 usr/share/doc/xkeyboard-config/NEWS
-rw-r--r-- root/root 1627 2021-06-08 15:20 usr/share/doc/xkeyboard-config/README
-rw-r--r-- root/root 7515 2021-06-08 15:20 usr/share/doc/xkeyboard-config/README.config
-rw-r--r-- root/root 23948 2021-06-08 15:20 usr/share/doc/xkeyboard-config/README.enhancing
-rw-r--r-- root/root 1882 2021-06-08 15:20 usr/share/doc/xkeyboard-config/README.symbols
create the same but compressed using gz
[csr@rhel-lab1 ~]$ tar -czvf documentation.tar.gz /usr/share/doc | more
tar: Removing leading `/' from member names
/usr/share/doc/
/usr/share/doc/hwdata/
/usr/share/doc/hwdata/LICENSE
/usr/share/doc/xkeyboard-config/
/usr/share/doc/xkeyboard-config/AUTHORS
/usr/share/doc/xkeyboard-config/COPYING
/usr/share/doc/xkeyboard-config/HOWTO.testing
/usr/share/doc/xkeyboard-config/HOWTO.transition
/usr/share/doc/xkeyboard-config/NEWS
/usr/share/doc/xkeyboard-config/README
/usr/share/doc/xkeyboard-config/README.config
/usr/share/doc/xkeyboard-config/README.enhancing
/usr/share/doc/xkeyboard-config/README.symbols
/usr/share/doc/tzdata/
/usr/share/doc/tzdata/README
/usr/share/doc/tzdata/theory.html
/usr/share/doc/tzdata/tz-art.html
/usr/share/doc/tzdata/tz-link.html
[csr@rhel-lab1 ~]$ du -sh docu*.*
59M documentation.tar
19M documentation.tar.gz
using J for compression
[csr@rhel-lab1 ~]$ tar -cjvf documentation.tar.bz2 /usr/share/doc | more
tar: Removing leading `/' from member names
/usr/share/doc/
/usr/share/doc/hwdata/
/usr/share/doc/hwdata/LICENSE
/usr/share/doc/xkeyboard-config/
/usr/share/doc/xkeyboard-config/AUTHORS
/usr/share/doc/xkeyboard-config/COPYING
/usr/share/doc/xkeyboard-config/HOWTO.testing
/usr/share/doc/xkeyboard-config/HOWTO.transition
/usr/share/doc/xkeyboard-config/NEWS
/usr/share/doc/xkeyboard-config/README
/usr/share/doc/xkeyboard-config/README.config
/usr/share/doc/xkeyboard-config/README.enhancing
/usr/share/doc/xkeyboard-config/README.symbols
/usr/share/doc/tzdata/
[csr@rhel-lab1 ~]$ du -sh docu*.*
59M documentation.tar
16M documentation.tar.bz2
19M documentation.tar.gz
Listing the gz file content
[csr@rhel-lab1 ~]$ tar -ttzvf documentation.tar.gz | more
drwxr-xr-x root/root 0 2024-04-09 17:31 usr/share/doc/
drwxr-xr-x root/root 0 2024-04-08 14:55 usr/share/doc/hwdata/
-rw-r--r-- root/root 175 2023-08-21 01:22 usr/share/doc/hwdata/LICENSE
drwxr-xr-x root/root 0 2024-04-08 14:55 usr/share/doc/xkeyboard-config/
-rw-r--r-- root/root 510 2021-06-08 15:20 usr/share/doc/xkeyboard-config/AUTHORS
-rw-r--r-- root/root 9244 2021-06-08 15:20 usr/share/doc/xkeyboard-config/COPYING
-rw-r--r-- root/root 861 2021-06-08 15:20 usr/share/doc/xkeyboard-config/HOWTO.testing
-rw-r--r-- root/root 2303 2021-06-08 15:20 usr/share/doc/xkeyboard-config/HOWTO.transition
-rw-r--r-- root/root 5108 2021-06-08 15:20 usr/share/doc/xkeyboard-config/NEWS
-rw-r--r-- root/root 1627 2021-06-08 15:20 usr/share/doc/xkeyboard-config/READ
untar file and view the content using tree
[csr@rhel-lab1 ~]$ mkdir doctests
[csr@rhel-lab1 ~]$ mv documentation.tar* /doctests/
mv: target '/doctests/' is not a directory
[csr@rhel-lab1 ~]$ mv documentation.tar* ~/doctests/
[csr@rhel-lab1 ~]$ cd doctests/
[csr@rhel-lab1 doctests]$ ls
documentation.tar documentation.tar.bz2 documentation.tar.gz
[csr@rhel-lab1 doctests]$ tar -xzvf documentation.tar.gz
[csr@rhel-lab1 doctests]$ ls -la
total 93816
drwxr-xr-x. 3 csr csr 99 Apr 15 18:51 .
drwx------. 17 csr csr 4096 Apr 15 18:49 ..
-rw-r--r--. 1 csr csr 61173760 Apr 15 18:33 documentation.tar
-rw-r--r--. 1 csr csr 15930018 Apr 15 18:44 documentation.tar.bz2
-rw-r--r--. 1 csr csr 18954095 Apr 15 18:42 documentation.tar.gz
drwxr-xr-x. 3 csr csr 19 Apr 15 18:51 usr
[csr@rhel-lab1 doctests]$ tree usr | more
usr
└── share
└── doc
├── abattis-cantarell-fonts
│ ├── NEWS
│ └── README.md
├── accountsservice
│ ├── AUTHORS
│ └── README.md
├── adcli
│ ├── AUTHORS
│ ├── ChangeLog
│ ├── COPYING
│ ├── NEWS
│ └── README
├── adobe-mappings-cmap
│ ├── README.md
│ └── VERSIONS.txt
├── adobe-mappings-pdf
│ └── README.md
├── adobe-source-code-pro-fonts
│ └── README.md
├── alsa-lib
│ ├── asoundrc.txt