Similar to Unix, Linux is a free and open source operating system. Generally, Linux will be distributed as released version for personal computer and service, which includes kernel and database as well as many other software. Since Linux is a freeware, any user can create their own Linux according to their needs.
Part 2: Reasons of Locking Files in Linux
Two main reasons of locking files in Linux could be:
1. To avoid two or more progress accessing the same file. If not, data lose could happen.2. To prevent unauthorized access.
Here we will go a little further on the first reason. In a multitasking operating system environment, if a program want to access a file which is used by another program, the running program could get some damaged or incomplete data. If two programs access and modify a same file, the file could be damaged. In order to solve this problem, a mechanism, file lock, is designed to solve this problem.
Part 3: How to Lock Files in Linux
(Lock) Command Line – Linux Chattr
Being one of the commands in Linux, Chattr can change the attributes of Linux files. It can also be used to change the attributes of files and folders saved in ext2 system.
The following 8 modes are available:
a: Provide append-only permission to a file or folder
b: Do not update the accessed date of files or folders
c: Save files/folders after compressed
chattr [ -RVf ] [ -v version ] [+/-/=
][file or folder…] • -R recursively lists attributes of directories and their contents
• -v <version no.> set the version of file or folder.
• -V displays the program version.
• +<attributes> Enable target attribute for directory or file
• -<attributes> Disable target attribute for directly or file
• =<attributes> Specify target attribute for directly or file
• [root@w zdw]# chattr +a test.sh
• [root@w zdw]# rm -f test.sh
• rm: cannot remove `test.sh’: Operation not permitted
• [root@w zdw]# echo 11 >>test.sh
• [root@w zdw]# echo 11 >>test.sh
• [root@w zdw]# echo 11 >test.sh
• -bash: test.sh: Operation not permitted
• [root@w zdw]# lsattr test.sh
Locking key system files can upgrade system security. Here are some files locked with chattr:
• chattr +i /etc/passwd file
• chattr +i /etc/shadow password protected file
• chattr +i /etc/group group file
• chattr +i /etc/gshadow main password file
• chattr +i /etc/inittab important system boot files
Being a command in Linux, Nautilus will open a window with terminal location with root authority. Users can manage, delete or add files inside the current folder.
Following is detailed steps of locking files with Nautilus:
1. Right-click the target file, and select [Compress] in the menu. Then set the password.
2. Then you will receive the notification of compressing successfully.
1. Click the Lock icon around the target file and then enter the password in the pop up window.
2. File will be unlocked after entering the correct password.
Using Rijndael cipher, Ccrypt, a tool to encrypt and decrypt files , is using AES encryption standard and provide great safety. The encryption and decryption both relies on the keywords that users offer. In default, system will ask users to type the keywords n terminal which ensure the safety.
Openssl, a command line tool, is for encrypting message and files on Internet. It is also used for secure communication and has been widely spread on webpage server.
Password Management in Linux
The algorithm of the key is public. The security of data relies on the confidentiality of the key instead of the algorithm.
Symmetric encryption: key can be used to decrypt at the same time. Generally, the key will be included in the encryption code, which enlarge the possibility of cracking. Besides, the administrator can get access to the key and then find out the password. So, the key should be kept in confidential way. As a result, the key should be set privately and transmit in a safe way.
Asymmetric encryption: The security of password is equal to that of the key. The plaintext of the password is encrypted with the public key. If users want to restore the original password, corresponding private key is necessary. In other words, users need to ensure the security of the private key to protect the password.
Methods of locking Linux files has been listed above. Windows is still one of the most popular computer system. If you want to lock files in Windows, data security software (Renee SecureSilo and Renee File Protector) are recommended.