- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 758 Views
Red Hat Linux Interview Series 20
Q.) While writing a bash script - how can you make a user enter a number at the prompt and your script should be able to read the input ?
Q.) How to force/trigger a file system check on next reboot?
Q.) Here is my output of free -h :
total used free shared buff/cache available
Mem: 32 24 8 1 2 15
Swap: 15 2 13
Why is swap memory being used even though I can see I have enough free RAM space ? Can we tune it ?
Bonus Q.) In the above question, is the given situation troublesome or good for your system performance ?
Level - L2 and above.
I'll be posting a series of Linux-related questions covering various skill levels. Feel free to share your insights and expertise. Your contributions will benefit learners at all stages, from those in current roles to those preparing for Linux interviews.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 733 Views
Question: How to force/trigger a file system check on next reboot?
My research points me to do something in the file /etc/sysconfig/grub.
In this file, I have a choice of adding an item to the end of either of the
following lines:
- GRUB_CMDLINE_LINUX
or
- GRUB_CMDLINE_LINUX_DEFAULT
What's the difference? Glad you asked.
Options in GRUB_CMDLINE_LINUX are always effective.
Options in GRUB_CMDLINE_LINUX_DEFAULT are effective ONLY during normal boot (NOT during recovery mode).
Which ever line you choose to use, you'll want to add/append the following to that
line: fsck.mode=force
After making that modification to the /etc/sysconfig/grub file, you'll then need to
run the following command: # grub2-mkconfig -o /boot/grub2/grub.cfg
After that, reboot your Linux system, and go enjoy a cup of tea, while fsck is
running to perform the filesytem check.
Note: If you don't wish to have this filesystem check performed each time you
boot your system, you'll want to remove the fsck.mode=force item that you added
previously. And of course, anytime you make a modification to the
/etc/sysconfig/grub file, you'll want to update grub!!!!
Okay, that's all I have for this episode of "Red Hat Linux Interview"!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 728 Views
Why does swap memory get used, even when RAM is not exhausted?
A little background on the operating system - the OS actively manages memory
by temporarily storing less actively used data from RAM, onto the swap space,
to free up RAM - for more immediate operations. By doing this, swap space is
essentially being used as a cache for data that might be needed later, even if there's
currently enough free RAM - thus preventing potential performance sluggishness
when RAM becomes full.
By moving less active data to swap space, this allows for faster access to frequently
used data that is currently in RAM.
The kernel (the king decision maker in all of this) actively decides when to swap data
out to free up RAM for new operations.
Can we tune this operation? Absolutely!!! How? By using one of the kernel's
parameters: swappiness
Swappiness is a Linux kernel parameter commonly linked to enhancing system
performance. However, the parameter does not directly improve performance, and
a high swappiness value can have unfavorable outcomes.
Swappiness controls how often data is swapped between RAM and swap space.
Swappiness determines how quickly a Linux system moves processes from RAM
to swap space, to free up RAM
The swappiness value is a number between 0 and 200 - with higher values indicating
more aggressive swapping.
Swapping helps balance data in RAM, and frees up space in RAM for more active
processes. However, this can sometimes come at the cost of long I/O pauses.
Nevertheless, the definite benefit outweighs the potential drawback! Still, you need
to be aware that incorrectly tuning the swappiness parameter could hurt performance.
The kernel doesn't move (or swap) data, from RAM to swap space, ONLY when the
use of RAM is high! Data is also moved from RAM to swap space when that data is
not in use for a long time!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 728 Views
Bonus Question: Is the given situation of swap space being used, even when RAM
is not being fully utilized, a trouble situation or good for system performance?
Answer:
If the swappiness value is set to an optimum value, this is definitely/absolutely
a benefit for the performance of the system!!! Even knowing this, the swappiness
value should be chosen with caution:
*** Tuning vm.swappiness may hurt performance, or may have a different impact
between light and heavy workloads. Changes to this parameter should be made
small increments, and should be tested under the same conditions that the system
normally operates!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 651 Views
@Trevor wonderful insights!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 644 Views
Thanks Chetan. I'm tryin' real hard!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 596 Views
While writing a bash script - how can you make a user enter a number at the prompt and your script should be able to read the input?
For this we can use the builtin read with the -p option
#!/bin/bash
read -p "Please enter a number: "
echo "Your number is $REPLY"
The builtin read has the default variable REPLY which is very useful, because there is no need to declare a variable for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 595 Views
@Emanuel_Haine great work explaining the answer!