Today we are going to learn how to remove an AD User which is not Active since a long time lets say 1 year. As a part of Server hardening best practices, you should always run checks to remove the disabled or orphan accounts from Active directory. We will be using the Active Directory module in Powershell to perform the activity : CODE : $Date =(Get-Date).AddDays(-365) Get-ADUser -Filter 'LastLogondate -le $Date' -Properties LastLogonDate | Select Name, LastLogonDate To remove the ADUser use : Remove-ADUser -Identity "<SamAccountName>"
Today we will see how one can become a root user if he / she has sudoers access. In some organizations if you try to switch user to root ( sudo su - root ), you may see error like below : Sorry, user <username> is not allowed to execute '/bin/su - root' as root on <hostname> But you can try other method to switch as root user. Lets look into those steps. Method 1 : Type sudo vi -v '!bash' in the command line console and that's it. Method 2 : Type sudo vi a.txt in the command line console , it will open vi editor just press ESC (Escape) and then :sh and Enter Hope you all enjoyed this little hack, do share your queries in the comment box below.