Permission question

I am working on learning ownership and permissions.

In this example, can anyone other that the owner read or write to the file ?

-rwxr-xr-x 1 andy 72 03-11-2017 Shutdown.sh

Maybe others would not agree with me, but I would go with google on that one.

https://www.google.com/search?client=ubuntu&channel=fs&q=rwxr-xr-x+meaning&ie=utf-8&oe=utf-8

-rwxr----x 1 harry users 2.7K Jan 4 07:32 /home/ryan/linuxtutorialwork/frog.png

In the above example the first 10 characters of the output are what we look at to identify permissions.

The first character identifies the file type. If it is a dash ( - ) then it is a normal file. If it is a d then it is a directory.
The following 3 characters represent the permissions for the owner. A letter represents the presence of a permission and a dash ( - ) represents the absence of a permission. In this example the owner has all permissions (read, write and execute).
The following 3 characters represent the permissions for the group. In this example the group has the ability to read but not write or execute. Note that the order of permissions is always read, then write then execute.
Finally the last 3 characters represent the permissions for others (or everyone else). In this example they have the execute permission and nothing else.

From the above, it shows that I am the owner and there are no groups.

It is confusing because the 5th thru the 10th character lists permissions for groups that do not exist ?

The last r-x means that everyone can read and execute, but not write to the file.

This page explains it pretty well: How UNIX File Permissions Work

How did you print this listing? If your ls command includes the -G flag, it will hide the group.

Thanks.

I used ls -lAxot for my listing as it shows pretty much all the info about a file.

I noticed that ls -l shows both owner and group.

I am looking for a way to prevent anyone except the owner to be able to read a file.

If I did this right, no one but the owner can read,write,or execute this file.

Yes, I know it is a text file. :slight_smile:

chmod 700 test.txt

-rwx------ 1 andy andy 5 Mar 11 19:27 test.txt

It works.

To verify it, I added another user.

Then I tried to open test.txt.

It said I did not have permission.

I put my password in 2 scripts to save time.

Someone told me not to do it.

Since I can make any file not viewable by anyone by owner, there should be no risk.