Home System Tutorial LINUX Shadow files in Linux: The key to system security

Shadow files in Linux: The key to system security

Jul 31, 2024 am 07:36 AM

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 of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The Ultimate Guide to High-Performance Gaming on Linux The Ultimate Guide to High-Performance Gaming on Linux Aug 03, 2025 am 05:51 AM

ChoosePop!_OS,Ubuntu,NobaraLinux,orArchLinuxforoptimalgamingperformancewithminimaloverhead.2.InstallofficialNVIDIAproprietarydriversforNVIDIAGPUs,ensureup-to-dateMesaandkernelversionsforAMDandIntelGPUs.3.EnabletheperformanceCPUgovernor,usealow-latenc

What are the main pros and cons of Linux vs. Windows? What are the main pros and cons of Linux vs. Windows? Aug 03, 2025 am 02:56 AM

Linux is suitable for old hardware, has high security and is customizable, but has weak software compatibility; Windows software is rich and easy to use, but has high resource utilization. 1. In terms of performance, Linux is lightweight and efficient, suitable for old devices; Windows has high hardware requirements. 2. In terms of software, Windows has wider compatibility, especially professional tools and games; Linux needs to use tools to run some software. 3. In terms of security, Linux permission management is stricter and updates are convenient; although Windows is protected, it is still vulnerable to attacks. 4. In terms of difficulty of use, the Linux learning curve is steep; Windows operation is intuitive. Choose according to requirements: choose Linux with performance and security, and choose Windows with compatibility and ease of use.

Understanding RAID Configurations on a Linux Server Understanding RAID Configurations on a Linux Server Aug 05, 2025 am 11:50 AM

RAIDimprovesstorageperformanceandreliabilityonLinuxserversthroughvariousconfigurations;RAID0offersspeedbutnoredundancy;RAID1providesmirroringforcriticaldatawith50�pacityloss;RAID5supportssingle-drivefailuretoleranceusingparityandrequiresatleastthre

Linux how to enable and disable services at boot Linux how to enable and disable services at boot Aug 08, 2025 am 10:23 AM

To manage the startup of Linux services, use the systemctl command. 1. Check the service status: systemctlstatus can check whether the service is running, enabled or disabled. 2. Enable the service startup: sudosystemctlenable, such as sudosystemctlenablenginx. If it is started at the same time, use sudosystemctlenable--nownginx. 3. Disable the service startup: sudosystemctldisable, such as sudosystemctldisablecups. If it is stopped at the same time, use sudosystemctldisabl

Setting up a Development Environment on Linux for Python Setting up a Development Environment on Linux for Python Aug 03, 2025 am 12:26 AM

InstallPythonandessentialtoolsusingyourdistribution’spackagemanager,ensuringpython3-venvandpython3-devareincludedforenvironmentisolationandCextensions.2.Alwaysusevirtualenvironmentsbyrunningpython3-mvenvmyproject_envandactivatewithsourcemyproject_env

How to set up a firewall in Linux How to set up a firewall in Linux Aug 22, 2025 pm 04:41 PM

UsefirewalldoriptablestosecureLinux;firewalldisuser-friendlywithzonesandservices,idealforCentOS/RHEL/Fedora,whileiptablesoffersgranularcontrolforDebian/Ubuntu.Enablefirewalld:sudosystemctlstartfirewalld,allowserviceslikeSSHwith--add-service=ssh,orope

Linux how to list all running processes Linux how to list all running processes Aug 08, 2025 am 06:42 AM

Usepsauxforacompletesnapshotofallrunningprocesses,showingdetailedinformationlikeUSER,PID,CPU,andmemoryusage.2.Usetoporhtopforreal-timemonitoringofprocesseswithdynamicupdates,wherehtopoffersamoreintuitiveinterface.3.UsepgreporpidoftoquicklyfindthePIDs

How to clean up your Linux system How to clean up your Linux system Aug 22, 2025 am 07:42 AM

Removeunusedpackagesanddependencieswithsudoaptautoremove,cleanpackagecacheusingsudoaptcleanorautoclean,andremoveoldkernelsviasudoaptautoremove--purge.2.Clearsystemlogswithsudojournalctl--vacuum-time=7d,deletearchivedlogsin/var/log,andempty/tmpand/var

See all articles