For system administrators, you should know the basic commands and the mechanisms to manage users’ files and directories. There are distinct ways of managing files and directories for both Linux and Windows operating systems. In this blog, we will be discussing the differences between these two platforms for managing files and directories.
Linux: User and Group Administration
There are a few commands for managing users and groups which are not difficult to remember.
User Management
- useradd: Creates a new user.
- usermod: Modifies an existing user.
- userdel: Deletes a user.
- passwd: Sets or changes a user password.
User information is stored in /etc/passwd and password information in /etc/shadow.
Group Management:
- groupadd: Creates a new group.
- groupmod: Modifies an existing group.
- groupdel: Deletes a group.
Group information is stored in /etc/group.
Example Commands:
useradd tarek
passwd tarek
groupadd trainer
usermod -aG trainer tarek
In Linux, you will be able to assign a user to multiple groups and set permissions accordingly using the chmod, chown, and chgrp commands.
Windows: User and Group Administration
Windows user and group management is primarily conducted through the graphical user interface, but it also supports command-line tools:
User Management
- net user: Used to manage user accounts from the command line.
- Add-LocalUser: Used to add a new user (using PowerShell).
- User information is typically managed via the Control Panel or the Local Users and Groups management console.
Group Management
- net localgroup: Used to manage local groups from the command line.
- Add-LocalGroupMember: Used to add a user to a group (using PowerShell).
- Example Commands:
net user tarek /add
net localgroup trainer /add
net localgroup trainer tarek /add
In Windows, you will be able to allow users to belong to multiple groups and use Group Policies for advanced management.
File and Directory Permissions: Linux
In Linux, you will be able to provide file permissions with a high level of control over who can read, write, and execute files. The permission system is built around:
Permission Types
- r: Read (4)
- w: Write (2)
- x: Execute (1)
Permission Levels
- User (u): The owner of the file.
- Group (g): The group assigned to the file.
- Others (o): Everyone else.
Example Commands:
chmod 740 testfile
chown rana testfile
chgrp support testfile
In Linux, you will also be able to use special permissions like SUID, SGID, and the sticky bit, enhancing security and functionality.
File and Directory Permissions: Windows
In Windows, file permissions are managed through NTFS (New Technology File System) and offer a different permission types and levels:
Permission Types
- Full Control
- Modify
- Read & Execute
- List Folder Contents
- Read
- Write
Permission Levels
- You will be able to manage through the Security tab in the file properties dialog.
- You will also be able to configure inheritance and explicit permissions to propagate permissions through a directory hierarchy.
Example Commands:
icacls testfile /grant rana:F
icacls testfile /grant support:R
In Windows, the permissions can be complex due to the use of Access Control Lists (ACLs) but provide fine-grained control.
Special Features:Linux
SUID, SGID, and Sticky Bit
- SUID: Allows users to run an executable with the permissions of the executable’s owner.
- SGID: Allows users to run an executable with the permissions of the executable’s group.
- Sticky Bit: Ensures that only the file owner can delete or rename files within a directory.
Umask
- Used to defines default permissions for new files and directories.
- Example: umask 0022 sets new files to 644 and directories to 755.
Special Features: Windows
Group Policies
- Administrators will be able to set policies at a domain level to manage user and computer settings centrally.
NTFS Quotas
- Administrators will be able to limit the amount of disk space users can use.
Conclusion
As a system administrator, you might need to configure any of these two platforms, Windows or Linux. Both platforms have powerful features for managing users, groups, and directory/file permissions. As we already know, Windows will provide a user-friendly interface whereas in Linux you will have to be familiar with the command line interface. Understanding these commands will help you to enhance your technical skills and ensure efficient and secure system management.: