Day 11 Learnings: File Operations and Process Management in Linux
Today’s focus was on understanding how to manage file group ownership and how to list running processes in Linux. These topics are foundational for managing system resources and controlling access permissions.
What I Learned This Week
Managing File Group Ownership with the
chgrp
Command:
Thechgrp
command is used to change the group ownership of files or directories in Linux.Listing Running Processes with the
ps
Command:
Theps
command helps monitor processes, providing details such as process IDs, statuses, and resource usage.
Steps I Followed
Managing Group Ownership | chgrp
Command
Check Current Group Ownership:
Used thels -l
command to view file group ownership:ls -l file.txt
Example output:
-rw-r--r-- 1 user oldgroup 1024 Jan 11 12:00 file.txt
Change Group Ownership:
Changed the group of a file:sudo chgrp newgroup file.txt
Change Group Ownership Recursively:
Applied the command to a directory and its contents:sudo chgrp -R newgroup directory_name
Verify Changes:
Confirmed the new group ownership:ls -l file.txt
Monitoring Processes | ps
Command
List All Processes:
Displayed all running processes:ps -e
Detailed Process Information:
Used the-f
option for a full-format listing:ps -ef
Filter by Username:
Listed processes for a specific user:ps -u username
Filter by Process Name:
Displayed processes matching a specific name:ps -C process_name
Monitor CPU and Memory Usage:
Usedps
to check resource usage of processes:ps -eo pid,comm,%cpu,%mem --sort=-%cpu
Problems I Encountered
"Operation Not Permitted" Error with
chgrp
:
Encountered this error when attempting to change group ownership without sufficient permissions.Finding Specific Processes:
Initially, I struggled to filter specific processes effectively usingps
options.
How I Solved These Problems
Using
sudo
for Elevated Permissions:
Resolved thechgrp
an error by running the command withsudo
.Referencing the
ps
Manual:
Usedman ps
to explore options for filtering processes, which helped me craft efficient commands.
Resources I Used
Linuxize Guide to chgrp Command
Linuxize Guide to ps Command
Community forums for practical examples and troubleshooting tips.
Conclusion
Today’s learnings enhanced my understanding of managing group ownership and monitoring system processes. The chgrp
command is essential for fine-tuning file permissions, while the ps
command is a powerful tool for process management and troubleshooting.
I’m excited to continue exploring Linux tomorrow. Stay tuned for Day 12 updates!