In this brief article, I present 10 essential Linux questions along with their answers.
This foundational knowledge is crucial for anyone seeking to master Linux.

Q1: How do you use cut to extract a username from /etc/passwd where UID is greater than 1000?
You would use awk first to filter based on UID, then cut to extract the username.


Q2: How do you display only the first 5 characters of each line from a file?

cut -c 1-5 filename



Q3: Can cut handle negative indexing like extracting the last column?
No, cut does not support negative indexing.


Q4: How do you use cut in a script to extract specific fields dynamically?
You can use variables in the script to specify fields dynamically.


Q5: What is the difference between cut -f and cut -c?
-f extracts fields, while -c extracts specific characters.


Sed Command
Q6: How do you sort a file in ascending and descending order using the sort command?
• Ascending:
sort filename
• Descending:
sort -r filename


Q7: How do you sort a file numerically instead of lexicographically?

sort -n filename



Q8: How do you sort a file based on a specific column?

sort -k column_number filename



Q9: How do you sort a file while ignoring case sensitivity?

sort -f filename



Q10: How do you remove duplicate lines while sorting?

sort -u filename



Stay tuned for part 11 coming tomorrow!

Connect with me on LinkedIn


#30DaysLinuxChallenge #RedHatEnterpriseLinux
#CloudWhistler #CloudEngineer #Linux
#DevOps #RedHat #OpenSource
#CloudComputing #Automation
#CloudEngineer