Linux and its distributions are much secure and reliable operating systems than any commercial OS. Security is the key element of Linux that has attract so many users over all these years despite of its complex and often command based interface. In this article, I’m going to explain how you can protect your user password or files in Linux.
To password protect your files in Ubuntu or Linux, you don’t need any third software. Just right click on the file/folder you want to protect.
Select compress > Compression format > Other options > Enter any password
Check on ‘Encrypt’ > Create. That’s it. You have now compressed and password protected file or folder. If you want to ensure that no one can delete or move your file, open the terminal, cd to file location and use the following command :
- sudo chatter +i filename.ext
To undo this
- use sudo chattr –i filename.ext
Chattr is a command line utility that set/unset characteristics of file to save from accidental deletion or modification. + will add the attribute, – will remove and =: will append the attribute to existing attributes of the file.
To protect root or any user, you must have a strong password attached to it. In Linux world, passwords are managed directly from the command line. The passwd utility gives an easy access to all password related commands on your system. To change your password, type passwd command with nothing else. Shell will ask you to enter current password followed by your new one. With root or sudo privileges, you can also change anyone’s password on the system, if you know the password.
If you want to stop a user from access to system, you can lock its password using -1 flag. Simply use sudo passwd -1 username. To unlock use -u flag.
- sudo passwd –u username
You can also lock root by leaving only the sudo. Use
- sudo passwd -1 root
and it will lock all access to the root account.