Tuesday, June 13, 2023
HomeNetworkingSharing, compressing and password-protecting information on Linux

Sharing, compressing and password-protecting information on Linux


Protecting your information personal from anybody however these with superuser (root) entry is straightforward on Linux. File permissions present the whole lot you want. By default, you may have a username and first group assigned to your account, and you should use the chmod (change mode) command to regulate what anybody else can view or change.

(If permissions like “750” and “rwxr-x—” do not ring any bells for you, try these posts for insights into how file permissions work on Linux: A deeper dive into Linux permissions and Unix: past group and everybody else)

Any time you request an extended file itemizing with the ls -l command, you may see strains like this:

-rw-r-----. 1 myacct   admins 2088 Jun 26 recipe

The permissions needs to be pretty apparent, however this little diagram identifies how the permissions relate to numerous customers:

-rw-r-----
^^  ^  ^
||  |  |
||  |  +-- everybody else has no entry
||  +----- different members of the admins group can learn
|+-------- you might have learn and write entry
+--------- file sort ("-" identifies an everyday file)

Word that should you have been to set permissions on a file to 044 (—r–r–), you wouldn’t be capable of view the file though you are clearly a member of the group.

$ ls -l dumfile
----r--r--. 1 myacct amins 9 Jun 13 10:41 dumfile
$ cat dumfile
cat: dumfile: Permission denied

You can, after all, change the permissions again to one thing extra affordable.

In case you see a + signal on the finish of the permissions string (e.g., -rw-r—–+), that signifies that different customers past these included within the proprietor, group and different teams even have entry to the file. The getfacl command can be utilized to supply the main points. Within the instance beneath, John Doe has learn and write entry despite the truth that he’s not a member of the admins group.

$ getfacl recipe
# file: recipe
# proprietor: myacct
# group: admins
consumer::rw-
consumer:johndoe:rw-
group::r--
masks::rw-
different::---

Information will be simply shared with members of your major group and even with anybody with an account on the system, although it will require that they’ve entry to the file location in addition to the information themselves. A file just like the one listed beneath can be readable by anybody within the tech workforce (since they may have learn entry), however they won’t be able to make any modifications.

$ ls -l meeting_notes
-rwxr-----. 1 myacct techteam 2534 Jun 11 meeting_notes

Word that it is in all probability finest to retailer information to be shared with others in a listing aside from your house listing.

Compressing information

Linux supplies quite a few instructions for compressing information — a superb factor to do when information are pretty massive and do not must be considered or modified fairly often. The shrinkage will depend upon file content material. This is an instance:

$ ls -l dict.mp4
-rw-r--r--. 1 shs shs 11215553 Mar 14 15:07 dict.mp4
$ gzip dict.mp4
$ ls -l dict*
-rw-r--r--. 1 shs shs 8507802 Mar 14 15:07 dict.mp4.gz

The hyperlink beneath will take you to a submit on compressing information.

Easy methods to compress information on Linux 5 methods

Password-protecting information

One quite simple solution to encrypt a file on Linux by including a -x choice to your vi or vim instructions. This can be a very simple solution to maintain the contents personal with out relying on file permissions – even from root. To create a passcode-protected file, use a command like this:

$ vim -x newfile

You’ll be requested twice to enter the encryption key. While you go to edit the file once more utilizing a command like “vim newfile”, you’ll requested to enter the identical key once more. This command supplies an easy solution to cover the contents of a textual content file with out having to depend on file permissions.

Extra on encrypting information with vim (together with how one can reverse the method) is accessible at this hyperlink:

Utilizing vim to shortly encrypt and decrypt information

Wrap-up

Linux instructions make it potential to share information with everybody on the system, so be very selective about who can view them or cover their contents from everybody however your self.

Copyright © 2023 IDG Communications, Inc.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments