سجل الآن

تسجيل دخول

فقدت كلمة المرور

فقدت كلمة المرور الخاصة بك؟ الرجاء إدخال عنوان البريد الإلكتروني الخاص بك. ستتلقى رابطا وستنشئ كلمة مرور جديدة عبر البريد الإلكتروني.

أضف مقالة جديدة

‎يجب تسجيل الدخول لتستطيع أضافة مقالة .

أضف سؤال جديد

يجب عليك تسجيل الدخول لطرح سؤال.

تسجيل دخول

سجل الآن

مرحبا بكم في Scholarsark.com! سوف تسجيلك تمنح لك الوصول إلى استخدام المزيد من الميزات من هذا المنبر. يمكنك طرح الأسئلة, تقديم مساهمات أو تقديم إجابات, عرض لمحات من المستخدمين الآخرين، وغيرها الكثير. سجل الان!

إجابات وأسئلة تقييم المهارات على LinkedIn – باش

سحق هي لغة برمجة شائعة يمكنها مساعدتك في أتمتة المهام وتنفيذ العمليات المختلفة على أنظمة Linux. إذا كنت ترغب في عرض مهاراتك ومعرفتك في Bash, قد ترغب في اتخاذ تقييم مهارات LinkedIn لـ Bash. هذا اختبار يقيم كفاءتك في لغة Bash ويمنحك شارة يمكنك عرضها في ملفك الشخصي. ومع ذلك, اجتياز الاختبار ليس بالأمر السهل, وقد تحتاج إلى بعض المساعدة للتحضير لذلك.

لهذا السبب قمت بتجميع قائمة LinkedIn إجابات وأسئلة تقييم المهارات لـ Bash التي يمكنك استخدامها للدراسة والممارسة. في هذه المدونة وظيفة, سأشاركك بعض الأسئلة الأكثر شيوعًا وصعوبة التي قد تواجهها في الاختبار, مع الإجابات والتفسيرات الصحيحة. من خلال قراءة هذا المنصب, سوف تتعلم كيفية استخدام أوامر Bash, المتغيرات, حلقات, المهام, و اكثر. ستحصل أيضًا على بعض النصائح والحيل حول كيفية اجتياز الاختبار وإثارة إعجاب أصحاب العمل المحتملين بمهاراتك في Bash.

Q1. أي من الطرق الثلاث ستقوم بنسخ الدليل المسمى “تصوير لك” بشكل متكرر من الدليل الرئيسي للمستخدم إلى / النسخ الاحتياطية?

cp -R "~/photo dir" /backups #method1
cp -R ~"/photo dir" /backups #method2
cp -R ~/"photo dir" /backups #method3
  • لن يتم توسيع أي من الطرق الثلاث إلى الدليل الرئيسي للمستخدم. فقط باستخدام "$HOME/photo dir"سوف تكون ناجحة.
  • الطريقة الوحيدة 1 سوف تتوسع "~/" إلى الدليل الرئيسي للمستخدم ثم قم بإلحاق اسم الدليل المقتبس الذي يتضمن مسافة.
  • الطريقة الوحيدة 2 سوف تتوسع "~/" إلى الدليل الرئيسي للمستخدم ثم قم بإلحاق اسم الدليل المقتبس الذي يتضمن مسافة.
  • الطريقة الوحيدة 3 سوف تتوسع "~/" إلى الدليل الرئيسي للمستخدم ثم قم بإلحاق اسم الدليل المقتبس الذي يتضمن مسافة.

Q2. إذا تم تشغيل script.sh في الدليل الحالي, سوف تفشل. لماذا ا?

$ ls -1
Beach photo1.jpg
Photo1.jpg
Photo2.jpg
Script.sh

$ cat script.sh
for i in $(ls *.jpg); do
	mv $i ${i}.bak
done
  • ليرة سورية: لا يمكن الوصول إلى ملف غير موجود: لا يوجد ملف او مجلد
  • سيتم تقسيم حلقة for على حدود الكلمات وسيحتوي Beach photo1.jpg على مساحة بداخلها.
  • سيفشل الأمر mv لأن القوس المتعرج هو حرف خاص في Bash ولا يمكن استخدامه في أسماء الملفات.
  • سيكون تشغيل script.sh ناجحًا حيث يقوم الأمر ls بإنشاء قائمة بالملفات الموجودة في الدليل الحالي وحلقات for من خلال تلك القائمة لإعادة تسمية الملفات بامتداد .bak.

Q3. لتشغيل أمر نسخ في قذيفة فرعية, ما هو بناء الجملة الذي ستستخدمه?

  • ( command )
  • sh command
  • { command; }
  • (( command ))

مرجع. تعتبر الأغلفة الفرعية إحدى الطرق التي يمكن للمبرمج التقاطها (عادة بقصد المعالجة) الإخراج من برنامج أو برنامج نصي. الأوامر التي سيتم تشغيلها داخل غلاف فرعي تكون محاطة بأقواس مفردة وتسبقها علامة الدولار: المحتويات=$(ليرة سورية -ل) صدى صوت ${المحتويات}

Q4. عن طريق “محرج”, ماذا سيكون ناتج سلسلة الأوامر هذه?

echo "1 2 3" | awk '{for (i=1; i<=NF; i++) s=s+$i};END {print s}'
  • 6
  • 123
  • 3
  • 600

مرجع. AWK هي لغة برمجة مصممة لمعالجة البيانات النصية, سواء في الملفات أو تدفقات البيانات, أو باستخدام أنابيب قذيفة. بمعنى آخر، يمكنك دمج awk مع نصوص shell أو استخدامها مباشرة في موجه shell.

Q5. سيقوم الأمر أدناه بالبحث في نظام الملفات الجذر عن الملفات المسماة “Finance.db”. في هذا السياق, ما هي المعلومات التي يتم إرسالها إلى /dev/null?

find / -name "finance.db" 1>results.txt 2>/dev/null
  • أسماء الملفات التي لا تتطابق مع Finance.db
  • المعلومات المرسلة إلى الخطأ القياسي، على سبيل المثال, الأخطاء التي يعرضها أمر البحث أثناء تشغيله
  • أسماء الملفات التي تطابق Finance.db
  • المعلومات المرسلة إلى الإخراج القياسي، وهذا هو, المسار إلى الملفات التي حددها أمر البحث

مرجع. بناء الجملة لإعادة توجيه stderr (خطأ تقليدي) إلى ملف: command 2> errors.txt.

Q6. لإزالة الأسطر الفارغة بشكل دائم من ملف يسمى textfile, ما هو الأمر الذي يمكنك استخدامه؟?

  • sed -i '/^$/d' textfile
  • sed '/^$/d' textfile
  • cat textfile | sed '/^$/d
  • sed -i 's/^$//' textfile

مرجع
سيد : sed هو محرر دفق. يتم استخدام محرر الدفق لإجراء تحويلات النص الأساسية على دفق الإدخال.
-أنا[لاحقة] : يحدد هذا الخيار أن الملفات سيتم تحريرها في مكانها.
'/^$/د’ : regex يقع بين //. ^ هو بداية السطر, $ هي نهاية السطر. ^$ يعني أن البداية والنهاية لا يوجد بينهما شيء.
د : احذف مساحة النمط; ابدأ الدورة التالية على الفور.
تحذير, لن يعمل هذا المثال أعلاه على جهاز Mac نظرًا لاختلاف نكهات UNIX. هناك طريقة لجعلها تعمل على جهاز Mac بإضافة علامة إضافية -e, أو حتى فقط -- (وجدت على StackOverflow): sed -i -e '/^$/d' textfile.txt

Q7. على افتراض أن user1 موجود, ماذا ستكون نتيجة سلسلة الأوامر هذه?

awk -F: '/user1/{print $1 "-" $3 "-" $6}' /etc/passwd
  • سيظهر اسم المستخدم, معرف فريد, والدليل الرئيسي للمستخدم 1 مفصولاً بنقطتين.
  • فإنه سيتم طباعة UID, دائرة المخابرات العامة, والدليل الرئيسي للمستخدم 1 مفصول بواصلات.
  • فإنه سيتم طباعة UID, تعليق, والدليل الرئيسي للمستخدم 1 مفصول بواصلات.
  • سيظهر اسم المستخدم, معرف فريد, والدليل الرئيسي للمستخدم 1 مفصول بواصلات.

مرجع. تقليديا, يتم استخدام الملف /etc/passwd لتتبع كل مستخدم مسجل لديه حق الوصول إلى النظام. الملف /etc/passwd هو ملف مفصول بنقطتين ويحتوي على المعلومات التالية: 1-Username, 2-Password, 3-User ID (UID), 4-Group ID (GID), 5-User ID Info (GECOS), 6-Home directory, 7-Command/shell

Q8. ماذا يحدث إذا كنت تستخدم "set -e" في البرنامج النصي باش?

  • سيؤدي ذلك إلى خروج Bash إذا قامت دالة أو غلاف فرعي بإرجاع رمز حالة غير صفري.
  • سيؤدي ذلك إلى خروج Bash إذا أرجع الشرط رمز حالة غير صفري.
  • سوف يتسبب في خروج Bash إذا كان محليًا, يعلن, أو تقوم تعيينات التنضيد بإرجاع رمز حالة غير صفري.
  • سوف يتسبب في خروج Bash إذا صدر أمر, قائمة الأوامر, أمر مركب, أو من المحتمل أن يقوم خط الأنابيب بإرجاع رمز حالة غير صفري.

مرجع. يرشد الخيار set -e bash إلى الخروج فورًا في حالة وجود أي أمر [1] لديه حالة خروج غير صفرية. لن ترغب في تعيين هذا لـ Shell سطر الأوامر الخاص بك, ولكن في البرنامج النصي يكون مفيدًا بشكل كبير. في جميع لغات البرمجة ذات الأغراض العامة المستخدمة على نطاق واسع, خطأ وقت التشغيل غير المعالج – whether that’s a thrown exception in Java, or a segmentation fault in C, or a syntax error in Pythonimmediately halts execution of the program; subsequent lines are not executed.

Q9. ال _ keyword pauses the script to get input from standard input.

  • احصل على
  • دعوى
  • اقرأ
  • input

Q10. If file.sql holds SQL statements to be executed, what will be in file.txt?

mysql < file.sql > file.txt
  • a copy of the contents of file.sql
  • an error indicating that this is invalid syntax
  • the error output of the MySQL command
  • the non-error output of the MySQL command

ملحوظة: check the question below for a variant.

سوف تحتاج إلى تحقيق ما لا يقل عن. What will be the difference between the output on the screen and the contents of out.txt

mysql < file.sql > out.txt
  • The output on the screen will be identical to out.txt
  • There will be no output on the screen as it’s being redirected to out.txt.
  • The output on the screen will be identical to out.txt plus line numbers.
  • سيحتوي ملف out.txt على STDERR وسينتقل STDOUT إلى الشاشة.

ملحوظة: check the question above for a variant.

س 12. كيف يؤثر SUID أو setuid على الأوامر القابلة للتنفيذ?

  • عندما يقوم الأمر بإنشاء ملفات, ستكون مملوكة لمالك المجموعة للأمر.
  • يسمح بت SUID لأي شخص بتنفيذ الأمر بغض النظر عن الأذونات الأخرى التي تم تعيينها.
  • عندما يتم تنفيذ الأمر, يتم رفع امتيازات التشغيل الخاصة به إلى مالك المستخدم للأمر.
  • عندما يتم تنفيذ الأمر, يتم رفع امتيازات التشغيل الخاصة به إلى مالك المجموعة للأمر.

مرجع. تشير حقوق الوصول إلى Linux وUnix إلى setuid وsetgid (اختصار لتعيين هوية المستخدم وتعيين هوية المجموعة)[1] السماح للمستخدمين بتشغيل ملف قابل للتنفيذ باستخدام أذونات نظام الملفات لمالك الملف القابل للتنفيذ أو المجموعة على التوالي وتغيير السلوك في الدلائل.

Q13. من أجل استخراج النص من العمود الأول من الملف المسمى textfile, الأمر الذي ستستخدمه?

  • cat {$1,textfile}
  • cat textfile | awk [print $1]
  • cat textfile | awk '{print $1}'
  • awk textfile {print $1}

س 14. ما هو اختصار لوحة المفاتيح لاستدعاء بحث سجل Bash كما هو موضح أدناه?

(reverse-i-search)`':
  • خروج + R
  • كنترول + H
  • كنترول + R
  • بديل + R

ملحوظة: على ماك سوف تظهر bck-i-search: بدلا من (reverse-i-search).

س 15. ما التعبير الحسابي الذي سيعطي الإجابة الأكثر دقة؟?

  • var=$( expr 10 / 8 )
  • (( var= 10 /8 ))
  • var=$(( 10 / 8 ))
  • var=$(echo 'scale=2; 10 / 8' | bc)

مرجع. يتم استخدام الأمر bc لآلة حاسبة سطر الأوامر. إنها تشبه الآلة الحاسبة الأساسية التي يمكننا من خلالها إجراء العمليات الحسابية الأساسية. القسمة مع 2 سيتم تمرير دقة الأرقام إلى bc, تقييمها, وتخصيصه للمتغير.

س 16. ما هي نتيجة هذا السيناريو?

txt=Penguins
[[ $txt =~ [a-z]{8} ]]; echo $?
  • 0, يمثل "صحيح", لأن المتغير “رسالة قصيرة” يحتوي على ثمانية أحرف
  • 0, يمثل "صحيح", لأن الجميع يحب طيور البطريق!
  • 1, يمثل "كاذبة", لأن المتغير “رسالة قصيرة” أطول من ثمانية أحرف
  • 1, يمثل "كاذبة", لأن المتغير “رسالة قصيرة” لا يحتوي على ثمانية أحرف صغيرة بين a و z

Q17. كيف يمكنك تغيير موجه Bash Shell الخاص بك إلى ما يلي?

HAL>
  • SHELL="HAL\>"
  • SHELL="HAL>"
  • export PS1="HAL>"
  • PS1="HAL\>"

س 18. ما هو الناتج من هذا الكود?

VAR="/var/www/html/website.com/html/"
echo "${VAR#*/html}"
  • /website.com/html/
  • /html/website.com/html/
  • /var/www/html/website.com/
  • لن يتم تكرار أي شيء على الشاشة.

مرجع ما يحدث هنا نقلاً عن مواصفات POSIX Shell: ${parameter#[word]}. إزالة أصغر نمط البادئة. يجب توسيع الكلمة لإنتاج نمط. يجب أن يؤدي توسيع المعلمة بعد ذلك إلى المعلمة, مع حذف أصغر جزء من البادئة المطابق للنمط.
على سبيل المثال ${VAR#?} يتوسع إلى قيمة $VAR مع حذف الحرف الأول. و ${VAR#\*/html}يتوسع ليشمل كافة الأحرف بما في ذلك/htmlالنص الذي سيتم حذفه من المتغير الذي ينتج عنه مخرجات/website.com/html/

Q19. إذا طُلب منك النص عند الإدخال القياسي, يمكنك معرفة الأمر الذي انتهيت منه من إدخال النص باستخدام مجموعة المفاتيح?

  • كنترول + ا (شبابيك) أو الأمر + ا (ماك)
  • كنترول + E (شبابيك) أو الأمر + E (ماك)
  • كنترول + د (شبابيك) أو الأمر + د (ماك)
  • كنترول + مع (شبابيك) أو الأمر + مع (ماك)

س 20. من أجل تنفيذ البرنامج النصي Bash مثل أمر نظام التشغيل, it should start with a shebang line. What does this look like?

  • #!/usr/bin/env bash
  • ~/usr/bin/env bash
  • '$!/usr/bin/env bash
  • #/usr/bin/env bash

س 21. What line of Bash script probably produced the output shown below?

The date is: Sun Mar 24 12:30:06 CST 2019!
  • echo "The date is: !"
  • echo "The date is: date!"
  • echo "The date is: (date)!"
  • echo "The date is: $(date)!"

Q22. Suppose your current working directory is your home directory. How could you run the script demo.sh that is located in your home directory? Find three correct answers.

A. /home/demo.sh
B. ./demo.sh
C. ~/demo.sh
D. bash /home/demo.sh
E. bash demo.sh
  • ب, C, E
  • ا, ب, C
  • C, د, E
  • ب, د, E

Q23. How could you get a list of all .html files in your tree?

  • find . -type html
  • find . -name *.html
  • find *.html
  • find . -name \*.html -print

The second seems well, but will expand the \* if there is any .html file on your working directory.

س 24. ماذا سيكون في out.txt?

cat < in.txt > out.txt
  • The output from the command line. By default STDIN comes from the keyboard.
  • Nothing because you can’t redirect from file (in.txt) إلى ملف آخر (out.txt). You can only redirect from a command to a file.
  • It would be the contents of in.txt.
  • لا شئ. The redirect will create a new empty file but there will not be any output from the cat command to redirect.

Q25. What does this bash statement do?

(( $a == $b ))
echo $?
  • It loops between the values of $a و $b.
  • It tests whether the values of variables $a و $b are equal.
  • It returns $b if it is larger than $a.
  • It returns $a if it is larger than $b.

س 26. What do you use in a case statement to tell Bash that you’re done with a specific test?

  • ; ;
  • : :
  • done
  • $$

Q27. What does the asterisk represent in this statement?

#!/usr/bin/env bash
case $num in
	1)
	echo "one"
	;;
	2)
	echo "two"
	;;
	*)
	echo "a mystery"
	;;
esac
  • a case that matches any value, providing a default option if nothing else catches that value
  • a case only for what happens when the asterisk character is passed into the script
  • the action of all of the other cases combined together
  • an action that is taken for any input, even if it matches a specified condition

س 28. What Bash script will correctly create these files?

  • touch file{1+10}.txt
  • touch file{1-10}.txt
  • touch file{1..10}.txt
  • touch file(1..10).txt

س 29. Which variable would you check to verify that the last command executed successfully?

  • $$
  • $?
  • $!
  • $@

Q30. What is the output of this script?

#!/bin/bash
fname=john
john=thomas
echo ${!fname}
  • john
  • thomas
  • Syntax error
  • blank

مرجع

س 31. What will be the output of this script?

سؤال

  • A ا
  • B ب
  • C C
  • D د

Here’s a text based version of Q.30:

ll
-rw-r--r-- 1 frankmolev staff 374   Jun 3 19:30 .
-rw-r--r-- 1 frankmolev staff 1666  Jun 3 19:30 ..
-rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file1.txt
-rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file2.txt
..

ll | sed -e 's,file,text,g'
  • ا
  -rw-r--r-- 1 frankmolev staff 374   Jun 3 19:30 .
  -rw-r--r-- 1 frankmolev staff 1666  Jun 3 19:30 ..
  -rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file1.file
  -rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file2.file
  ..
  • ب
  -rw-r--r-- 1 frankmolev staff 374   Jun 3 19:30 .
  -rw-r--r-- 1 frankmolev staff 1666  Jun 3 19:30 ..
  -rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file1.txt
  -rw-r--r-- 1 frankmolev staff 0     Jun 3 19:30 file2.txt
  ..
  • C
  -rw-r--r-- 1 frankmolev staff 68    Jun 3 19:30 .
  -rw-r--r-- 1 frankmolev staff 1666  Jun 3 19:30 ..
  • د
-rw-r--r-- 1 frankmolev staff 374     Jun 3 19:30 .
-rw-r--r-- 1 frankmolev staff 1666    Jun 3 19:30 ..
-rw-r--r-- 1 frankmolev staff 0       Jun 3 19:30 text1.txt
-rw-r--r-- 1 frankmolev staff 0       Jun 3 19:30 text.txt
..

Q32. What is wrong with this script?

#!/bin/bash
read -p "Enter your pet type." PET
if [ $PET = dog ] ;then
    echo "You have a dog"
fi
  • If the value of PET doesn’t match dog, the script will return a nonzero status code.
  • There is nothing wrong with it. The condition checks the value of PET perfectly.
  • It will fail if the user hits the Enter (Return) key without entering a pet name when prompted.
  • The then statement needs to be on a separate line.

على ___. How can you gather history together for multiple terminals?

  • It just works by default.
  • history --shared
  • history --combined
  • shopt -s histappend

س 34. What is the difference between the @���* variables?

  • $@ treats each quoted argument as a separate entity. $* treats the entire argument string as one entity.
  • $* treats each quoted argument as a separate entity. $@ treats the entire argument string as one entity.
  • $* is used to count the arguments passed to a script, $@ provides all arguments in one string.
  • $* is the wildcard that includes all arguments with word splitting, $@ يحمل نفس البيانات ولكن في صفيف.

تتم محاذاة كل طبقة وهذه كلها في نفس الوقت. ما هو الأمر الذي يتم تشغيله في هذا البرنامج النصي للتحقق من وجود file.txt؟?

if [ -f file.txt ]; then
    echo "file.txt exists"
fi
  • /usr/bin/test
  • /usr/bin/[
  • the built-in [ command
  • /usr/bin/[[

Q36. What will be the output of this script?

#!/bin/bash
Linux=('Debian' 'Redhat' 'Ubuntu' 'Android' 'Fedora' 'Suse')
x=3

Linux=(${Linux[@]:0:$x} ${Linux[@]:$(($x + 1))})
echo "${Linux[@]}"
  • ديبيان ريدهات أوبونتو أندرويد فيدورا سوس
  • ذكري المظهر
  • فيدورا سوسة
  • ديبيان ريدهات أوبونتو فيدورا سوس

Q37. ما هو الملف الذي يسمح لك بحفظ التعديلات على بيئة الصدفة عبر الجلسات؟?

  • /etc/bash.conf
  • ~/.profile
  • /etc/bashprofile
  • ~/profile

Q38. بالنظر إلى الأذونات المدرجة في data.txt، هل من الممكن أن يكون المستخدم 2 قد قرأ, كتابة, وتنفيذ الأذونات على data.txt?

$ ls -l
total 0
-rwx------+ 1 user1 user1 0 Oct 27 10:54 data.txt
  • لا, فمن الواضح أن المستخدم 2 لم يقرأ, كتابة, وتنفيذ الأذونات.
  • نعم فعلا, ال + في نهاية سلسلة الأذونات المكونة من 10 أرقام، يشير ذلك إلى وجود قائمة للتحكم في الوصول. قد يؤدي هذا إلى منح المستخدم 2 أذونات غير مرئية ls -l.
  • من الممكن أن يوفر SELinux إمكانية القراءة, كتابة, وتنفيذ أذونات المستخدم 2 غير المرئية ls -l.
  • نعم فعلا, ال + at the end of the 10-digit permission string signifies there’s an extended attribute set. This could give user2 permissions to read, كتابة, and execute data.txt.

Q39. What does this script accomplish?

#!/bin/bash
declare -A ARRAY=([user1]=bob [user2]=ted [user3]=sally)
KEYS=(${!ARRAY[@]})

for (( i=0; $i < ${#ARRAY[@]}; i+=1 ));do
        echo ${KEYS[$i]} - ${ARRAY[${KEYS[$i]}]}
done
  • It sorts the associative array named ARRAY and stores the results in an indexed array named KEYS. It then uses this sorted array to loop through the associative array ARRAY.
  • Using a C-style for loop, it loops through the associative array named ARRAY using the associative array’s keys and outputs both the key and values for each item.
  • It creates an indexed array of the associative array named ARRAY. It then uses a C-style for loop and the indexed array to loop through all items in the associative array, outputting the key and value of each array item using the index number.
  • يقوم بإنشاء مصفوفة ترابطية تسمى ARRAY, والتي يتم تكرارها من خلال استخدام نمط C للحلقة وأرقام الفهرس لكل عنصر في مفاتيح المصفوفة النقابية, إخراج قيمة كل عنصر.

س 40. ما الملف الذي سيطابق الكود أدناه?

ls Hello[[.vertical-line.]]World
  • لا شئ, هذا ملف غير صالح.
  • Hello.vertical-line.World
  • Hello[[.vertical-line.]]World
  • Hello|World

س 41. ماذا سيكون في out.txt?

ls nonexistentfile | grep "No such file" > out.txt
  • لايوجد ملف مشابه
  • ليرة سورية: لا يمكن الوصول إلى ملف غير موجود: لا يوجد ملف او مجلد
  • لا شئ, سيكون out.txt فارغًا.
  • سيكون محتويات ملف غير موجود.

س 42. لطباعة البرنامج النصي “هو رقمي” على الشاشة, ما الذي يجب على المستخدم إدخاله عند مطالبته بذلك?

#!/bin/bash
read -p "Enter text " var
if [[ "$var" =~ "^[0-9]+$" ]];then
    echo "Is numeric"
else
    echo "Is not numeric"
fi
  • أي تسلسل من الأحرف يتضمن عددًا صحيحًا
  • سيتعين على المستخدم إدخال تسلسل الأحرف الخاص بـ ^[0-9]]+$ فقط هذا سيثبت أنه صحيح و “هو رقمي” ستتم طباعتها على الشاشة بسبب بناء جملة غير صحيح. من خلال تغليف التعبير العادي بين علامتي اقتباس مزدوجتين، ستفشل كل مطابقة باستثناء السلسلة النصية ^[0-9]+$
  • One or more characters that only includes integers
  • Due to a syntax error it is impossible to get the script to print “هو رقمي”

The regex must not be quoted to work properly.

س 43. How would you find the last copy command run in your history?

  • history | find cp
  • history | grep cp
  • grep cp history
  • cp history

س 44. In order to write a script that iterates through the files in a directory, which of the following could you use?

  • for i in $(ls); do ... done
  • for $(ls); do ... done
  • for i in $ls; do ... done
  • for $ls; do ... done

س 45. When executing a command and passing the output of that command to another command, which character allows you to chain these commands together?

  • |
  • ->
  • \#
  • @

س 46. In the script shown below, ما هو greeting?

#!/usr/bin/env bash
greeting="Hello"
echo $greeting, everybody!
  • a command
  • a loop
  • a parameter
  • متغير

Q47. Which statement checks whether the variable num is greater than five?

  • (( num -gt 5 ))
  • [[$num -lt 5]]
  • (( num > 5 ))
  • num > 5

مرجع

س 48. Using Bash extended globbing, what will be the output of this command?

$ ls -l
apple
banana
bananapple
banapple
pineapple
strawberry
$ shopt -s extglob
$ ls -l @(ba*(na)|a+(p)le)
  • ا
apple
banana
  • ب
apple
banana
bananapple
banapple
pineapple
strawberry
  • ج
apple
banana
bananappple
banapple
pineapple
  • د
apple
banana
bananapple
banapple
pineapple

مرجع

Q49. When used from within a script, which variable contains the name of the script?

  • $0
  • $# // عدد المعلمات الموضعية
  • $$ // معرف الصدفة الحالية
  • $@ // بناء يشبه المصفوفة لجميع المعلمات الموضعية

س 50. ماذا يكون ال + للدلالة في نهاية أذونات الملف المكونة من 10 أرقام على data.txt?

ls -l
-rwx------+ 1 user1 u1 0 Oct 1 10:00 data.txt
  • يوجد سياق أمان SELinux
  • يتم تعيين البت اللاصق وسيبقى الملف في ذاكرة الوصول العشوائي (RAM) من أجل السرعة
  • هناك قائمة التحكم في الوصول
  • هناك سمة موسعة مثل مجموعة غير قابلة للتغيير

س 51. في باش, ماذا يفعل الأمر أدناه?

cd -
  • ينقلك إلى الدليل الذي كنت فيه سابقًا.
  • ينقلك إلى المجلد الرئيسي الخاص بك (مهما كان دليل العمل الحالي الخاص بك).
  • يقوم بحذف الدليل الحالي.
  • ينقلك دليل واحد فوق دليل العمل الحالي الخاص بك.

Q52. ماذا يفعل هذا الأمر?

cat > notes -
  • يقبل النص من الإدخال القياسي ويضعه فيه “ملاحظات”
  • يخلق “ملاحظات” والمخارج
  • إخراج محتوى الملاحظات وحذفها
  • إلحاق النص بالنص الموجود “ملاحظات”

Q53. What is the output of:

VAR="This old man came rolling"
echo "\${VAR//man/rolling}"
  • This old rolling came rolling
  • This old man came man
  • This old man came rolling
  • This old came

س 54. The shell looks at the contents of a particular variable to identify which programs it can run. What is the name of this variable?

  • $INCLUDE
  • $PATH
  • $PROGRAM
  • $PATHS

Q55. What statement would you use to print this in the console?

Shall we play a game? yes\no

  • echo "Shall we play a game? yes/\no"
  • echo "Shall we play a game\? yes\\no"
  • echo "Shall we play a game? yes\\no"
  • echo "Shall we play a game? yes\no"

س 56. Given a directory with these seven files, what would remain after executing these commands?

archive.tar
image1.gif
image1.jpg
image2.gif
image2.jpg
textfile1.txt
textfile2.txt

----------

`shopt -s extglob
rm !(*gif|*jpg)`
  • ا
archive.tar
image1.gif
image1.jpg
image2.gif
image2.jpg
textfile1.txt
textfile2.txt
  • ب
archive.tar
textfile1.txt
textfile2.txt
  • c : All of this files will be deleted

  • د:

image1.gif
image1.jpg
image2.gif
image2.jpg

Q57. The code below seems to work and outputs “8 is greater than 5”. ومع ذلك, what unexpected result will tell you it is not functioning properly?

#!/bin/bash
var="8"
if [ $var > 5 ]; then
    echo "$var is greater than 5"
fi
  • There will be no unexpected results. This script works as is and the output will be “8 is greater than 5”.
  • The comparison will not be able to handle floating-point numbers, as Bash only handles integers. So this example will output an error message if the value of $var is changed to “8.8”.
  • There will be a file in the current directory named 5.
  • The variable $var is not quoted, which will lead to word splitting. This script will fail with aunary operator expectedmessage if you change the value of

س 58. ما هي نتيجة هذا السيناريو?

سؤال

  • It removes the directory ‘fooand the files contained within it.
  • It removes all files except those in the current directory.
  • It removes all files in the current directory.
  • It removes all files except those in the ‘foodirectory.

س 59. Which one is true?

  • SELinux policy rules are checked after DAC rules.
  • SELinux policy rules are checked before DAC rules
  • SELinux policy rules are never checked after DAC rules.
  • None of these

مرجع

س 60. Which does the below command do?

w
  • It doesn’t display information about the users currently on the machine.
  • It displays information about the users currently on the machine.
  • It displays information about the users currently on the another machine.
  • None of these

س 61. Which sed options should you use to change the second-to-last instance of variable to rock so it would read:

A constant is a variable that is a rock that isn’t variable

var="A constant is a variable that is a variable that isn't variable"
echo "$var" | sed _____
  • s/\(.*\)variable\(.*variable\)/\1rock\2/'
  • s/variable/rock/'
  • s/variable/rock/g'
  • s/(.*\)variable\(.*variable\)/\1rock\2/'

س 62. To make a Bash script named script.sh executable, what should you run?

  • exec script.sh
  • chmod +x script.sh
  • bash script.sh
  • source script.sh

س 63. How can you create a shared terminal in a Bash shell?

  • شاشة
  • screen -X
  • شاشة –مشترك
  • terminal -shared

س 64. Wich operator sends the output of ls to a file for later use?

  • ليرة سورية < filelist.txt
  • ls ¦ filelist.txt
  • ليرة سورية > filelist.txt
  • ليرة سورية – filelist.txt

س 65. When comparing items with case, what statement indicates an end to the evaluation block?

  • توقف
  • esac
  • منتهي
  • exit

س 66. To run a group of commands without spawning a subshell, ما هو بناء الجملة الذي ستستخدمه?

  • (command1; command2)
  • { command1; command2; }
  • (( command1; command2 ))
  • command1; command2

Q67. What are the results of the command with a user named jon?

echo 'Hello, $(whoami)!'
  • أهلا, $(jon)!
  • أهلا, jon!
  • أهلا, $(whoami)!
  • أهلا, whoami!

Q68. How can you copy a directory to another system with compression?

  • tar -ssh usertest19284621.158.1.1 /bin/newfile
  • tar cvzf - /wwwdata | ssh roottest19284621.168.1.201 "dd of=/backup/wwwdata.tar.gz"
  • You can’t compress the stream
  • scp -r directory usertest19284621.168.1.1:/tmp

Q69. To assign the command ls -lah to the shortcut command lh, what command should you use?

  • alias lh='ls -lah'
  • link lh='ls -lah'
  • alias 'ls -lah'=lh
  • lh | ls -lah

س 70. Which statement will print all of the fully qualified .csv files in the home directory or subdirectories while not displaying any errors?

  • find $USER_DIR -name “*.csv” 2>/ديف/خالية
  • find $HOME -name “*.csv” 1>/ديف/خالية
  • find $HOME -name “*.csv” 2>/ديف/خالية
  • find HOME -name “*.csv” 1>/ديف/خالية

س 71. في باش, what does a # at the end of the default prompt string indicate?

  • that the user is acting as root
  • that the current working directory is the root of the file system
  • that there are updates for the system available
  • that the user is unprivileged

التحكم في مخاطر سلامة العمليات. What will be the output of this command?

$ ls -l
file10.txt
file1.txt
fileabc.txt
filea.txt
fileb.txt
filec.txt
$ ls -l file[^abc]*.txt
  • ا
file1.txt
file10.txt
  • ب
file10.txt
file1.txt
fileabc.txt
filea.txt
fileb.txt
filec.txt
  • C
fileabc.txt filea.txt fileb.txt filec.txt
  • د
filea.txt
fileb.txt
filec.txt

مرجع The caret (^) symbol here negates matches inside the bracket.

Q73. What is the output of this command sequence?

cat <<EOF
------------------------
   This is line 1.
   This is line 2.
   This is line 3.
------------------------
EOF
  • ا
This is line 1.
This is line 2.
This is line 3.
  • ب
------------------------This is line 1.This is line 2.This is line 3.------------------------
  • C
------------------------
   This is line 1.
   This is line 2.
   This is line 3.
------------------------
  • د
------------------------
This is line 1.
This is line 2.
This is line 3.
------------------------

التحكم في مخاطر سلامة العمليات. ماذا سيكون في out.txt?

#!/bin/bash

echo 123446789 > out.txt
exec 3<> out.txt
read -n 4 <&3
echo -n 5 >&3
exec 3>&-
  • 123446789
  • the hyphen symbol (-)
  • 123456789
  • the number 5, which is written to the file using echo
  1. I/O Redirection
  2. ماهو الفرق بين “صدى صوت” و “echo -n”?

Q75. Which variable contains the process ID (PID) of the script while it’s running?

  • $هوية شخصية
  • $#
  • $@
  • $$

س 76. By combining extended globbing and parameter expansion, what would be the value of VAR?

#!/bin/bash
shopt -s extglob
VAR='     This is...     a string of characters     '
VAR=${VAR##+([[:space:]])}; VAR=${VAR%%+([[:space:]])};
echo "$VAR"
  • <pre> This is... a string of characters</pre>
  • <pre> This is...a string of characters</pre>
  • <pre>This is... a string of characters</pre>
  • <pre>This is...a string of characters</pre>

المراجع:

  1. What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
  2. What does expanding a variable as “${var%%r*}” mean in bash?

Q77. Which operator tells the shell to run a given command in the background?

  • !
  • &&
  • &
  • $

Q78. The range of nice number in LINUX system is?

  • -20 إلى 0
  • -20 إلى 19
  • 0 إلى 19
  • 10 إلى 10

مرجع

Q79. في باش, what does this expression evaluate to?

echo $((4/3))
  • 1.3
  • 1.3333333333
  • 1
  • 2

مرجع

س 80. To keep a loop going until a certain condition becomes true, what would you likely use?

  • إذا
  • قضية
  • في حين
  • إلى عن على

مرجع

س 81. What does this command sequence do?

cat > notes -
  • It creates an empty file called “ملاحظات” and then exits.
  • It outputs the contents of the “ملاحظات” الملف إلى الشاشة, ثم يقوم بحذفه.
  • يقبل النص من الإدخال القياسي ويضعه في ملف “ملاحظات” ملف.
  • يقوم بإلحاق نص بملف موجود يسمى “ملحوظات.”

س 82. تريد مطابقة المتناظرات المكونة من خمسة أحرف مثل الرادار, الدوار, وعقيدة. ما هو خيار sed الذي يجب أن تستخدمه؟?

  • sed -E -n '/^(.)(.)\3\2\1$/p'
  • sed -E -n '/^(.)(.)(.).\2\1$/p'
  • sed -E -n '/^(.)(.)(.)\2\1$/p'
  • sed -E -n '/^(.)(.)(.)(.)\3\2\1$/p'

س 83. لإضافة قيمة إلى البيئة الحالية, what command should you use ?

  • shell_add
  • حفظ
  • صدى صوت
  • يصدّر

س 84. ما هو الفرق بين هذين التعبيرين الشرطيين?

[[$A==$B]]
[[$A -eq $B]]
  • [[$أ == $ب]] يستخدم للمقارنات الرقمية في حين [[$مكافئ $B]] يستخدم لمقارنات النص.
  • [[$أ==$ب]]هي الطريقة الجديدة لإجراء المقارنة حيث [[$مكافئ $B]]هو بناء الجملة القديم.
  • إنهم متشابهون.
  • [[$أ==$ب]]يستخدم لمقارنات النص بينما [[$مكافئ $B]]يستخدم للمقارنات الرقمية.

Q85. ما هو الناتج من هذا الكود?

VAR="united states"
echo "${VAR^}"
  • الولايات المتحدة
  • الولايات المتحدة الامريكانية
  • الولايات المتحدة
  • الولايات المتحدة

س 86. ماذا سيحدث إذا قمت بتشغيل البرنامج النصي أدناه كما هو مكتوب?

#!/bin/bash
#condition 1
if [ $foo = "bar" ]; then echo "foo is bar"
fi
#condition 2
if [[ $foo = "bar" ]]; then echo "foo is bar"
fi
  • كلا الشرطين سوف تفشل.
  • كلا الشرطين سينجحان.
  • والتطبيق العملي لـ PWM 1 سوف تنجح والحالة 2 ستفشل.
  • والتطبيق العملي لـ PWM 1 سوف تفشل والحالة 2 سوف تنجح.

تتم محاذاة كل طبقة وهذه كلها في نفس الوقت: البرنامج النصي كمخرجات مكتوبة line 3: [: =: unary operator expected. تحديد المتغير وتعيين القيمة foo="bar", وسينجح كلا الشرطين.

Q87. المتغير الذي يحتوي على عدد الوسائط التي تم تمريرها إلى البرنامج النصي من سطر الأوامر?

  • $#
  • $@
  • 0
  • $!

Q88. في البرمجة النصية باش, ماذا يكون ال “كوخ” (#!) في بداية البرنامج النصي تشير, ولماذا هو مهم?

  • يشير إلى موقع مترجم Bash الذي يجب استخدامه لتنفيذ البرنامج النصي.
  • وهو يحدد إصدار Bash المطلوب لتشغيل البرنامج النصي.
  • إنه يمثل البرنامج النصي على أنه قابل للتنفيذ.
  • يساعد النظام على تحديد مترجم البرنامج النصي, التأكد من استخدام المترجم الصحيح.

Q89. Which variable contains the process ID (PID) of the script while it’s running?

  • $ID
  • $@
  • $#
  • $$

س 90. إذا أراد المستخدم تنفيذ البرنامج النصي sh بدون غرامة shebang أو أذونات التنفيذ, ماذا يجب على المستخدم أن يكتب?

  • مطلوب سطر shebang لتنفيذ برنامج نصي shell.

  • "باش النصي.sh".

  • "نص تنفيذي.sh".

  • أذونات ExecuteExecute مطلوبة لتنفيذ برنامج نصي Shell.

س 91. أي خيار هو الناتج الأكثر احتمالاً للأمر المركب الموضح أدناه?

cat -n animals | sort -r | head -n 5
  • ا.
	1	Ant
	2	Bear
	3	Cat
	4	Dog
	5	Elephant
  • ب.
	9	Ibex
	B	Hippo
	7	Giraffe
	6	Fox
	5	Elephant
	4	Dog
	3	Cat
	2	Bear
	1	Ant10	Jaguar
  • ج.
	Jaguar
	Ibex
	Hippo
	Giraffe
	Fox
  • د.
	9	Ibex
	8	Hippo
	7	Giraffe
	6	Fox
	5	Elephant

Q92. أي مما يلي ليس اسمًا صالحًا لمتغير Bash?

  • $HOME
  • my_var
  • 1var
  • !

س93.في باش, قم بإنشاء أمر أحادي الخط يبحث بشكل متكرر عن جميع الملفات ذات الامتداد “.رسالة قصيرة” التمديد في الدليل والأدلة الفرعية الخاصة به, ويحسب إجمالي عدد الأسطر في تلك الملفات. يجب أن يعرض الإخراج إجمالي عدد الأسطر فقط.

أي من أوامر Bash التالية تنجز هذه المهمة؟?

  • find . -name "*.txt" -exec wc -l {} \; | awk '{total += $1} END {print total}'
  • grep -r ".*\.txt$" | wc -l
  • find . -type f -name "*.txt" | xargs wc -l | tail -n 1
  • find . -name "*.txt" -exec cat {} \; | wc -l

Q94. ما هو الفرق بين > و >> مشغلي إعادة التوجيه?

  • > overwrites the contents of the target file, while >> appends to the end of the target file.
  • > redirects input, while >> redirects output.
  • > is used for standard output, while >> is used for standard error.
  • > is a unary operator, while >> is a binary operator.

مرجع

عن هيلين باسي

مرحبا, I'm Helena, كاتب مدونة شغوف بنشر محتويات ثاقبة في مجال التعليم. أعتقد أن التعليم هو مفتاح التنمية الشخصية والاجتماعية, وأريد أن أشارك معرفتي وخبرتي مع المتعلمين من جميع الأعمار والخلفيات. على مدونتي, ستجد مقالات حول موضوعات مثل استراتيجيات التعلم, التعليم عبر الإنترنت, إرشاد مهني, و اكثر. وأرحب أيضًا بتعليقات واقتراحات القراء, لذلك لا تتردد في ترك تعليق أو الاتصال بي في أي وقت. أتمنى أن تستمتع بقراءة مدونتي وتجدها مفيدة وملهمة.

‎إضافة تعليق