الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

معمل 3.1RHCSA 10, الفصل 3

Organize files, make links and back up a folder

المستوى
سهل
30 دقيقة
الأجهزة
server1
الحالة
لم يبدأ

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

الهدف

Make a folder structure, copy and move files, create both kinds of links, find files by owner and size, and make a compressed backup that you can restore.

قبل أن تبدأ

  • Work on server1. Some tasks need root (sudo -i).

المهام

  1. Create the folders /data/projects/web, /data/projects/db and /data/archive with one command.
  2. Copy all files from /etc that start with host to /data/projects/web. Keep their permissions and times.
  3. Rename /data/projects/web/hosts to /data/projects/web/hosts.old.
  4. Make a symbolic link /data/current that points to /data/projects/web. Make a hard link /data/projects/db/hosts.hard to /data/projects/web/hosts.old.
  5. Find all files in /usr/share bigger than 5 MiB and write their names to /data/archive/big-files.txt.
  6. Create the archive /data/archive/etc.tar.bz2 of the folder /etc compressed with bzip2.
  7. Extract only the file etc/hosts from that archive into /tmp/restore.

تحقّق من عملك

ls -lR /data
ls -l /data/current
ls -li /data/projects/web/hosts.old /data/projects/db/hosts.hard
wc -l /data/archive/big-files.txt
tar -tjf /data/archive/etc.tar.bz2 | head
cat /tmp/restore/etc/hosts
  • /data/current shows -> /data/projects/web.
  • The two hard-linked files have the same inode number and a link count of 2.
  • The archive lists files that start with etc/.

تلميحات

اعرض التلميحات

الحل

اعرض الحل
  1. Make the folders.
    mkdir -p /data/projects/{web,db} /data/archive
  2. Copy with the attributes.
    cp -a /etc/host* /data/projects/web/
  3. Rename.
    mv /data/projects/web/hosts /data/projects/web/hosts.old
  4. Make the links.
    ln -s /data/projects/web /data/current
    ln /data/projects/web/hosts.old /data/projects/db/hosts.hard
  5. Find big files.
    find /usr/share -type f -size +5M > /data/archive/big-files.txt
  6. Create the bzip2 archive.
    tar -cjf /data/archive/etc.tar.bz2 /etc
  7. Extract one file.
    mkdir -p /tmp/restore
    tar -xjf /data/archive/etc.tar.bz2 -C /tmp/restore etc/hosts

ملاحظاتي

لا توجد ملاحظات بعد.

دروس هذا المعمل

الأوامر في هذا المعمل