There are two roots: the Linux root user and the root directory. There’s also the root home, but let’s not talk about that for now to avoid confusion. For now, I want to discuss what is a Linux root user.
Table of Contents
EC2 / Root Directory
A Linux instance is launched with a default Linux system user for each instance. Users can be added and deleted. The AMI (Amazon Machine Image) determines the default user name for the instance’s default user.
Default user names
The AMI determined the default user name for your EC2 instance.
By default, sudo is enabled and password authentication and root login are disabled.
I’m logged in as the root user in Linux. You can also tell that you are the root user because we discussed earlier that this indicator shows you are the root user. This means you are the super user and can do anything to your system.
This is super important to recognize because, as a super user, issuing wrong commands could cause significant damage, and you might have to rebuild your system from scratch. Be careful only to issue commands as root. Usually, in production environments at work or home when connected to the Internet, you don’t want to run as root. Anything executed on your system will have access to anything it wants because it will be executed as root. For example, if you accidentally download a virus or malware and execute it as root, it will have root privileges, meaning it will have unrestricted access to your system. Conversely, if you log in as a regular user without super admin powers and run the virus, it might not access the needed files.
Because this is a crucial user, the first thing you want to do is change the default password by issuing the passwd
command. It will ask you to enter and retype a new password. After updating, it will confirm the successful update of the password.
Now, let’s talk about directory structures. Now that you understand the concept of the root user, let’s explore the root directory.
Contents:
- Contains all essential system directories such as
/bin
,/etc
,/home
,/var
,/usr
, etc.
Usage:
- This is the starting point of the entire filesystem hierarchy. All other directories and files branch out from here.
/root (Root User’s Home Directory)
The root directory, where everything is visible, is the main directory or trunk of the tree that branches out.
Home Directory for Root:
- The
/root
directory is the personal home directory for the root user. It contains files, scripts, and configuration settings that are specific to the root user.
Access
- Only the root user has access to this directory by default. This means that other users cannot view or modify the contents of this directory unless proper permissions have been set.
Configuration Files:
.bashrc
or.bash_profile
: Configuration files for the Bash shell, which customize the shell environment for the root user..ssh/
: Directory containing SSH keys and configuration files, such asauthorized_keys
for SSH access.
Scripts and Executables:
- Custom scripts or programs that the root user needs to run for system administration tasks.
- Backup scripts, maintenance scripts, or other administrative tools.
Log Files:
- Temporary log files that the root user may create for debugging or monitoring purposes.
Backups and Temporary Files:
- Backup files or temporary files that require root access for creation and management.
Personal Files:
- Any other files the root user needs to store, such as documents, notes, or configuration files for specific applications.
Conclusion
In an Amazon EC2 instance, the /root
directory is designated as the home directory for the root user, who is granted superuser privileges.It is reserved for files, configurations, and scripts that are considered essential for system administration. Common contents include shell configuration files (like .bashrc
), SSH keys stored in the .ssh
directory, custom scripts, log files, and temporary or backup files.
Access to /root
is restricted to the root user, ensuring that only users with appropriate permissions can view or modify its contents. This security measure helps maintain the integrity and security of administrative tasks and sensitive data.