Hello, everyone In this Article we are going to change the policy for the passwords in Linux in a very simple and easy step-by-step approach.
chage command
If we want to set the account policy on the user account then we can use the chage command
Before jumping the chage command we should know the syntax of the chage command
chage [ options ] username
1 How to get Password related information for the user
To get password related information then we can execute chage command with ( -l ) option and username this will give all the information related to the user1 account.
# change -l user1
2. How to change default password policy
To change the default password-related policy for the user then we can use chage command with a username.
# chage user1
Again when we execute the #chage -l user1 command the entry for the user1 now changed
If we want to change only warring then execute # chage –help command this command give us all the options to change .
Now if we add any user by default their home directory will go to /home folder. We want that whenever we add any user it’s home directory will go to /customdir.
# vi /etc/default/useradd – This is the file that has all the entries when we adding the user.
When we change the content of this file and when we add the user will be created in our customized location.
Here we want that the user that is creating now must have the default home directory in /customlocation directory.
Here we just changed HOME variable to /customlocation.
Now when ever we create any user their home directory will go to /customdir directory
When we create any user by default there are hiding files are there in the user home directory to view that files we can use ll -a command in the user where we are logged in..
If any file from the user home account got corrupted or deleted then the user will not able to login to their account.
Soo there is a centralized location where these hidden files are coming from when anything got corrupted then we can copy the files from that location and paste again into the user home directory then everything works again.
The centralized location where these hidden files are coming from is the
# cd/etc/skel– First go to this directory then when we do ls -l here we can see the same hidden files that are available when we create the user .
As we can see we have all the data same when we create the user soo if we lost any files just copy from here and paste to the user home directory we can easily recover the login shell of the user
Let us create one folder and inside that folder let us create some files. as follow
# mkdir /data
# cd /data
# touch abc{1.5}.txt
Now we want that whenever we create the user by default this /data folder will come in their home directory by default.
Soo goes to the folder that we want to copy to the user account. and copy all the files from the /data folder to /etc/skell/ file.
Soo now when we create any new user the files will also there in the user /home directory.
Conclusion
This is the complete article on How to change the policy for the passwords
If you want to learn Linux in the most simple language then please click on this link.
This is the complete knowledge of How to change the policy for the passwords in Linux if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on the DevOps Articles.