Random Linux User Space Assignments (Difficulty Level: Advanced)
If you have completed earlier assignments, and want to move to Advance assignments, here are 10 new assignments designed to challenge you and enhance your understanding of Linux user-space development. These are more generic and curated to test your knowledge from previous assignments.I have added the hints as well, but you can completely ignore them.
1️⃣ Implement a Custom ls Command
Objective: Write a program that lists files in a directory without using the ls command.
Hint:
-
Use system calls like
opendir(),readdir(), andclosedir(). -
Display file names in a column format, similar to
ls. -
Optionally, implement
-lmode to show file sizes and permissions.
2️⃣ Create a Simplified cat Utility
Objective: Build a basic version of cat to display file contents.
Hint:
-
Use
open(),read(), andwrite()system calls. -
Handle errors like file not found or insufficient permissions.
-
Optionally, support multiple files as arguments (
./mycat file1 file2).
3️⃣ Build a Basic Shell
Objective: Create a simple shell that reads and executes user commands.
Hint:
-
Use
fork()andexecvp()to execute commands. -
Implement a loop to continuously read and process user input.
-
Optionally, add support for command chaining (
&&,||).
4️⃣ Develop a File Change Monitor Using inotify
Objective: Monitor a directory and print a message when a file is added, modified, or deleted.
Hint:
-
Use the
inotifyAPI (inotify_init(),inotify_add_watch()). -
Detect and log events like file creation, deletion, and modification.
-
Optionally, allow monitoring multiple directories.
5️⃣ Parse /proc Filesystem for System Information
Objective: Extract and display system details like CPU and memory usage.
Hint:
-
Read from
/proc/cpuinfoand/proc/meminfo. -
Format and display information clearly.
-
Optionally, monitor memory usage in real-time with a loop + sleep().
6️⃣ Implement a Simple HTTP Server in C
Objective: Create a basic web server that serves static HTML files.
Hint:
-
Use sockets (
socket(),bind(),listen(),accept()). -
Respond with HTTP headers + file content when a request is received.
-
Optionally, log incoming requests with timestamps.
7️⃣ Design a Custom Memory Allocator
Objective: Implement your own malloc() and free().
Hint:
-
Use
sbrk()ormmap()to allocate memory. -
Implement a simple linked list to track free and allocated blocks.
-
Optionally, add best-fit or first-fit memory allocation strategies.
8️⃣ Implement a Simple File Copy Utility
Objective: Create a program that copies a file from source to destination.
Hint:
-
Use
open(),read(),write(), andclose(). -
Read and write in chunks (e.g., 4KB at a time) for efficiency.
-
Optionally, display a progress percentage during copying.
9️⃣ Implement a Process Tree Viewer
Objective: Simulate a process tree using fork() and visualize parent-child relationships.
Hint:
-
Use
fork()to create multiple child processes. -
Use
getpid()andgetppid()to display process hierarchy. -
Optionally, create a multi-level tree (parent → child → grandchild).
Example output:
Parent [PID 1000]
├── Child [PID 1001]
├── Child [PID 1002]
├── Grandchild [PID 1003]
🔟 Simulate the head and tail Commands
Objective: Create programs that display the first or last N lines of a file.
Hint:
-
Read the file line by line using
fgets()orgetline(). -
Count total lines before displaying the last N lines for
tail. -
Optionally, support
-noption (./head -n 5 file.txt).
Final Thoughts
With this, you're completely ready to move to the Linux kernel space development. To get started on those start reading Linux kernel development by Robert love, till I create assignments on those.