• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Day 23/ 30 Days of Linux Mastery: 'tar' Command

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Table of Contents

  • Introduction
  • What is the tar Command?
  • Core tar Commands
  • Real-World Scenario: tar Command
  • Conclusion
  • Let's Connect


Introduction


Welcome back to Day 23 of this practical Linux challenge! Today, we are diving into one of the most useful Linux commands: tar.

When you think of archiving and backing up files, think of tar


What is the tar Command?


tar stands for Tape Archive. It is a powerful utility used to create, extract, compress, and archive files or directories into a single file, usually with .tar, .tar.gz, or .tgz extensions.


Core tar Commands


More commonly used tar command options are listed in the table below.

tar CommandWhat It DoesExplanation
tar -cvf myarchive.tar myfolder/Creates an archive -c = create, -v = show progress (verbose), -f = name the archive file
tar -xvf myarchive.tarExtracts an archive -x = extract files from the archive
tar -czvf myarchive.tar.gz myfolder/Creates a compressed archive using gzip -z = compress with gzip
tar -xzvf myarchive.tar.gzExtracts a .tar.gz archive -x = extract, -z = unzip gzip file
tar -tvf myarchive.tarLists archive contents -t = list files inside the archive
tar -xvf myarchive.tar file.txtExtracts a specific fileOnly pulls out file.txt from the archive
tar -C /target/folder -xvf myarchive.tarExtracts to a specific directory -C = change to target directory before extracting
tar --delete -f myarchive.tar file.txtDeletes a file from the archive (non-compressed only)Removes file.txt from the .tar file (Does not work on .tar.gz)


Real-World Scenario: tar Command

  • Select a file you wish to archive. Add .tar to the filename.

tar -cvf demologs.txt.tar
ls -lh # to confirm it compressed


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  • Verify the file is created

tar -tvf demologs.txt.tar


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  • Restore the tar file.

mkdir demoarchives - # we create a separate folder to move our archives

tar -xvf demologs.txt.tar.gz -C demoarchives - # restores the .tar to original file format
ls -lh # to confirm both the original and compressed file are there


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Conclusion


By now, you have seen how to create, extract, compress, and manage archives with tar. You also understand the most useful options (-c, -x, -v, -f, -z, -t, --delete) and how to combine them based on what you are trying to achieve.

Keep experimenting in your terminal. Start by archiving test directories and extracting them to specific locations. The more hands-on you get, the more confident you will become. Stay curious. Stay hands-on.

If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 24!


Let's Connect!


If you want to connect or share your journey, feel free to reach out on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.
I am always happy to learn and build with others in the tech space.

#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу