search
HomeSystem TutorialLINUXShadow files in Linux: The key to system security

Linux 中的影子文件:保障系统安全的关键

Complete manual of /etc/shadow file in Linux

Shadow files and passwd files are generally used to perform the authentication process on Linux. Shadow files are text-based files used to store user data on a system. The most important thing is the linux vi command, where the password is saved in encrypted or hashed format.

Storing passwords in the /etc/passwd file can easily make the system insecure. Shadow files have file permissions set to 640 or 400.

What will we cover?

In this article, we will explain Shadow files in Linux.

Why do we need shadow files?

The passwd file in Linux is readable by everyone and for this purpose the encrypted passwords are transferred to different files called shadow files. It can only be read by root. Shadow files are also located in /etc/shadow in the /etc folder.

Very similar to the passwd file, the first array in the shadow file contains account names and uses commas to separate different primary keys. Having a separate file containing encrypted passwords also helps in adding new parameters to the account. It is reported that this helps control accounts and control password aging.

Shadow files remain read-protected to protect encrypted passwords. This is an important security measure, as anyone with read access to the file can attempt to crack the encryption password.

Security Aspects of Shadow Files

Shadow file is a good tool to reset the root password of Linux system. We can find the root user's account entry and manipulate some settings to recover the root password. However, the process of recovering passwords from shadow files is currently off topic.

As mentioned before, shadow files can only be read by the root directory. If a malicious account holder attempts to hack into other system accounts linux etc directory permissions, he will just bang his head against a tree. Assuming someone obtains the password in some form, the time it takes to crack it depends on the encryption algorithm used. Still, it's not easy, as cracking encryption passwords can take anywhere from minutes to years.

Sentence patterns for shadow files

The sentence pattern of shadow file is as follows:

login:encyrptedpassword:lastchangedate:min_age:max_age:warning:inactivity:expiration_date:reserved

The array in the upper row is expressed in days. lastchange and expiration are date arrays. The time in such an array is taken from the start date of Unix time linux etc directory permissions, which is January 1, 1970.

Description of primary keys in shadow files

There are nine arrays in this file, separated by quotes ':'

Let me explain bit array here:

Login: Every line in the Shadow file starts with the username. The username links the entry in the Shadow file to the entry in /etc/passwd.

linux目录给用户权限_linuxt权限_linux etc目录 权限

cryptopassword: It is a placeholder for the encrypted password. So even though it doesn't have any resemblance to a real password. If there is * or ! placed here, it means that the account has no password.

Lastchange Date – It is basically a date expressed as a number of days from the beginning of Unix time. This is the time giving the date of the previous password change. If the value is 0, it means that the user must change the password the last time he logged in.

minage–This array indicates that the password will only be modified when the date value is minage+lastage. If the array is empty, it means that the password can be modified at any time.

maxage – This array indicates that the password must be changed when the date value is maxage+lastage. It is actually the date the password expires. For empty passwords, the expiration date is meaningless, so the maxage, warning, and inactivity arrays are not needed.

warning – When the date changes to lastchange+maxage-warning or the password warning period has started, the user will be warned to change the password. If the value is 0 or blank (empty), it means there is no warning period.

Inactivity – When a password expires, users can still change their password until the number of days of inactivity. If this array is not filled in, there is no inactivity period.

Expiration Date – This is the date on which the user’s account will expire. From now on, it will be difficult to log in to this account. If this array is empty, the account will never expire. Also, never use a "0" value here.

Special sign: This place is not normally used and has been reserved for future use.

Now we use a counterexample to illustrate our understanding of the above array. Take the following sample entry in the shadow file:

linux-console:$6$kKRCC8ip8nKtFjjdZJIj:12825:14:45:10:30:13096

Let’s break down each bit of the array gradually:

1.linux-console is the username.

linux目录给用户权限_linux etc目录 权限_linuxt权限

2. The next array is the user’s encrypted password. This is a very long password. However, we truncated it slightly for simplicity.

3. The user has changed the password 12825 days or January 11, 35, which is February 11, 2005 since Unix epoch time (i.e. January 1, 1970).

4. The minimum period for users to change their password is 14 days. To make the password changeable at any time, set this array to 0.

5. Password needs to be reset every 45 days.

6. A warning to reset your password will appear 10 days before the modification date.

7. If the password expires and no login operation is performed within 30 days, the user account will be disabled.

8. The account will expire 13096 days from the Unix epoch time or November 9, 2005.

Inference

Shadow files are a particularly secure place to store your account information. There is a security issue with strong user passwords in passwd files. Making Shadow files readable by root only eliminates opportunities for malicious users and attackers to exploit passwords.

The above is the detailed content of Shadow files in Linux: The key to system security. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are the main tasks of a Linux system administrator?What are the main tasks of a Linux system administrator?Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Is it hard to learn Linux?Is it hard to learn Linux?Apr 18, 2025 am 12:23 AM

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

What is the salary of Linux administrator?What is the salary of Linux administrator?Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

What is the main purpose of Linux?What is the main purpose of Linux?Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is Linux actually good for?What is Linux actually good for?Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software