Skip to main content

Command Palette

Search for a command to run...

🧠💻Understanding Linux Users, Groups, and File Management📂👥

Published
4 min read
🧠💻Understanding Linux Users, Groups, and File Management📂👥
V

Experienced QA professional with a passion for manual and automation testing. Proficient in DevOps practices, ensuring seamless integration and continuous delivery. Dedicated to ensuring top-notch software quality and efficiency. Eager to contribute my skills to Hashnode's vibrant tech community. Let's collaborate and create exceptional experiences!

👋Introduction

Within the realm of Linux, the management of users, groups, and files holds significant importance as it ensures robust security, facilitates access control, and promotes efficient data organization. The purpose of this blog post is to present a comprehensive guide on these subjects while incorporating a practical DevOps case study that involves the transfer of log files to a QA lead with specific requisites.

👥What are Users & Groups?

In Linux, users refer to individuals who interact with the system, while groups are collections of users. Each user is associated with one primary group and may belong to multiple secondary groups. Users and groups are identified by unique numerical IDs (UIDs and GIDs) and are essential for resource access control.

🤔Why do we need Users & Groups?

Users and groups are essential for security and access control. By assigning permissions to files and directories based on users and groups, administrators can restrict or allow access to specific resources, protecting sensitive data and maintaining system integrity.

⚙️How to Create a Group?

To create a group, you can use the groupadd command followed by the group name. For example:

🔎How to Locate Groups?

The list of groups can be found in the /etc/group file. To view the file's content, you can use the cat command:

How to Add Single & Multiple Users?

To add a single user, you can use the useradd command followed by the username:

To add multiple users at once, use the command with space-separated usernames:

🗑️How to Delete a User from a Group?

To remove a user from a specific group, you can use the gpasswd command with the -d option:

How to Delete a Whole Group?

To delete a group, use the groupdel command followed by the group name:

Will the User be Deleted?

Note: Deleting a group does not delete the users associated with it, but it removes them from the group🚫👥❌

📄How to View File Details (Creator, Timestamp, etc.)?

In the world of Linux, you can easily retrieve comprehensive information about files and directories using the 'ls' command. To access detailed information about a particular file, you simply need to use the -l option with the ls command:

🔍How to Find Files & Directories?

In Linux, to search for files and directories, you can use various commands like find, locate, and grep. The find command is commonly used for this purpose.

Now let's see each Command with an Example:

a) find: To find all text files in the current directory and its subdirectories:

b) locate: To locate a file named "document.pdf":

c) grep: To search for the word "error" in all text files:

🔧DevOps scenario from day-to-day life

Scenario: As a DevOps engineer, you receive a request from the QA lead to provide a log file from a specific location on the server. The QA lead requires the log file with only certain columns, and the data must be transferred securely via SSH and SCP.

Steps to achieve the task:

Step 1: SSH into the server and navigate to the log file's location🌐🔒

Step 2: Use the awk command to extract the desired columns. For example, to extract columns 2, 4, and 7:

Step 3: Archive the log file using the tar command:

Step 4: Transfer the archived file to the QA lead's server via SCP:

🎯Conclusion

Understanding Linux users, groups, and file management is crucial for effective system administration and resource access control. In our DevOps case study, we demonstrated how to extract specific columns from a log file and securely transfer it to a QA lead using SSH and SCP. By mastering these concepts and commands, you can efficiently manage Linux systems and streamline data sharing within your DevOps workflow🧠💡🚀

Thank you for taking the time to read this blog. I hope you found the information helpful and insightful. So please keep yourself updated with my latest insights and articles on DevOps 🚀 by following me on :

Hashnode: vishaltoyou.hashcode.dev

LinkedIn: linkedin.com/in/vishalphadnis

So, Stay in the loop and stay ahead in the world of DevOps!

Happy learning and Linux-ing 🚀😊🐧📦🔧🛠️💻💼🔍📈🚀🌟📊📚