Day 1: Linux Basics - Commands, File System, Users & Permissions - challenges

Table of contents
- Challenge 1: List all files (including hidden ones) in your home directory and sort them by modification time.
- Challenge 2: Create a directory named devops_challenge_Day1, navigate into it, and create an empty file named day1.txt.
- Challenge 3: Find total disk usage of /var/log in human-readable format.
- Challenge 4: Create a new user called devops_user and add them to the sudo group.
- Challenge 5: Create a group called devops_team and add devops_user to that group.
- Challenge 6: Change the permissions of day1.txt to allow only the owner to read and write, but no permissions for others.
- Challenge 7: Find all files in /etc modified in the last 7 days.
- Challenge 8: Write a one-liner command to find the most frequently used command in your shell history.
- Topics Covered Today

Challenge 1: List all files (including hidden ones) in your home directory and sort them by modification time.
๐ฏ Goal: Understand how to list files and sort them based on their last modification time.
Command:
ls -alt
Explanation:
ls
โ List files and directories-a
โ Show hidden files (files starting with.
)-l
โ Display detailed file information (permissions, owner, size, date modified, etc.)-t
โ Sort by modification time (newest first)
Challenge 2: Create a directory named devops_challenge_Day1
, navigate into it, and create an empty file named day1.txt
.
๐ฏ Goal: Learn directory and file manipulation.
Commands:
mkdir devops_challenge_Day1 cd devops_challenge_Day1 touch day1.txt
Explanation:
mkdir
โ Creates a new directorycd
โ Navigates into that directorytouch
โ Creates an empty file
Challenge 3: Find total disk usage of /var/log
in human-readable format.
๐ฏ Goal: Learn how to check the disk usage of a specific directory.
Command:
du -sh /var/log
Explanation:
du
โ Disk usage command-s
โ Summarizes total size instead of showing individual files-h
โ Displays output in a human-readable format (KB, MB, GB)
Challenge 4: Create a new user called devops_user
and add them to the sudo
group.
๐ฏ Goal: Learn how to manage users and grant administrative privileges.
Commands:
sudo useradd -m devops_user sudo usermod -aG sudo devops_user
Explanation:
useradd -m
โ Creates a new user and assigns a home directoryusermod -aG
โ Adds the user to a specific group (sudo
in this case)
Challenge 5: Create a group called devops_team
and add devops_user
to that group.
๐ฏ Goal: Learn how to create user groups and manage group memberships.
Commands:
sudo groupadd devops_team sudo usermod -aG devops_team devops_user
Explanation:
groupadd
โ Creates a new groupusermod -aG
โ Adds an existing user (devops_user
) to the new group (devops_team
)
Challenge 6: Change the permissions of day1.txt
to allow only the owner to read and write, but no permissions for others.
๐ฏ Goal: Understand file permissions and how to modify them using
chmod
.
Command:
chmod 600 day1.txt
Explanation:
600
โ Sets file permissions so that:Owner โ Read (
r
) and write (w
)Group & Others โ No permissions (
---
)
Challenge 7: Find all files in /etc
modified in the last 7 days.
๐ฏ Goal: Learn how to search for files based on modification time.
Command:
find /etc -type f -mtime -7
Explanation:
find
โ Searches for files-type f
โ Looks for regular files (not directories)-mtime -7
โ Finds files modified in the last 7 days
Challenge 8: Write a one-liner command to find the most frequently used command in your shell history.
๐ฏ Goal: Analyze and optimize your command-line usage.
Command:
history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5
Explanation:
history
โ Displays a list of previously executed commandsawk '{print $2}'
โ Extracts only the command name (ignores line numbers)sort | uniq -c
โ Counts occurrences of each commandsort -nr
โ Sorts the list in descending order (most used first)head -5
โ Shows the top 5 most frequently used commands
Topics Covered Today
โ
Basic Shell Commands โ Navigating directories (cd
), listing files (ls
), viewing file contents (cat
, touch
).
โ
Filesystem Hierarchy โ Understanding Linux directory structures (/etc
, /var
, /home
).
โ
File Permissions โ Using chmod
, ls -l
, and learning read, write, execute (rwx
).
โ
User & Group Management โ Creating users (useradd
), modifying groups (usermod
, groupadd
).
โ
File & Directory Operations โ Creating, modifying, and searching files (find
, du
, ls
, awk
, sort
).
โ
History & Command Usage โ Analyzing shell history to improve workflow.
Subscribe to my newsletter
Read articles from Hari Kiran B directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
