Linuxopsys Profile picture
May 8 25 tweets 4 min read Twitter logo Read on Twitter
The operating system controls file access in Linux by utilizing file permissions, attributes, and ownership. In Linux, file permissions, attributes, and ownership determine the level of access that system programs and users have to files.

Learn more about Linux file permissions Image
This ensures that only particular directories and files are accessible to authorized users and processes only.
Having knowledge of the Linux file system permissions structure enables you to restrict access to files and directories to only authorized users and processes, hence increasing the level of security of your system.
In Linux, each file is owned by a specific user and a group, and authorization access rights are assigned to three different types of users:

• The owner of the file.
• The group members.
• Others users (everybody else).
There are three types of file permissions that apply to each user class and let you determine which users can read, write to, or execute the file.
Here are three types of file permissions that apply to each user class:

• The read permission.
• The write permission.
• The execute permission.

Both files and directories have identical permission properties. However, they have different meanings.
[+] Read Permission (r)

• When the read permission is set, the file can be read; for example, the user can open the file in a text editor (nano, vim, and so on).

• The contents of the directory can be viewed. The ls command allows the user to list files within a directory.
[+] Write Permission (w)

• A file that has write permissions can be changed or modified.

• If a directory has write permissions, its contents can be modified. The user can create new files, delete existing files, move files, rename files, etc.
[+] Execute permission (x)

• The file can be run, such as a bash script.
• The directory can be entered using the cd command.
As I have mentioned, file permissions or attributes can be viewed using the ls command. Here is an example: Image
A breakdown of the ls command output: Image
The file type is indicated by the first character. It could be a normal file (-), a directory (d), a symbolic link (l), or any other form of file. The file permissions are represented by nine characters, three groups of three characters each.
The first group indicates the owner's permissions, the second group indicates group permissions, and the third is everyone else's permissions.
In the example above, (`-rwxr-xr-x`) means that the file owner has read, write and execute permissions (`rwx`), and the group and others have only read and execute permissions (`r-x`).
[+] File permissions numerical representations:

File permissions can be represented numerically or symbolically. In this thread I will only concentrate on the numerical format.
The permission number might be three or four digits in length, ranging from 0 to 7.

When a three-digit number is used, the first digit denotes the file's owner's permissions, the second the file's group, and the last all other users.
The following numbers represent the write, read, and execute permissions:

• r (read) = 4
• w (write) = 2
• x (execute) = 1
• no permissions = 0
The permissions digit of a particular user class is the sum of the permissions values for that class.

Each digit of the permissions number can be an addition of 4, 2, 1, or 0:
• 0 (0+0+0) - There is no permission.
• 1 (0+0+1) - Execute permission only.
• 2 (0+2+0) - Only write access permissions.
• 3 (0+2+1) - Permission to write and execute.
• 4 (4+0+0) - Read-only permission.
• 5 (4+0+1) - Permission to read and execute.
• 6 (4+2+0) - Read and write access permissions.
• 7 (4+2+1) - Permission to read, write, and execute.
For example, if the permission number is set to 755 it means that the file’s owner has read, write and execute permission, file’s group has read and execute permissions, and other users have also read and execute permissions:
Owner: rwx=4+2+1=7
Group: r-x=4+0+1=5
Others: r-x=4+0+1=5
When using a four-digit number, the first digit has the following meaning:

• setuid=4
• setgid=2
• sticky=1
• no changes = 0
If you are having trouble calculating the permissions of your files, here is an online website that can assist you.

Chmod Calculator:
An awesome Chmod Calculator to convert Linux file permissions between different formats.

chmod-calculator.com
That's all! Thank you for getting this far. I hope you find this thread useful.

If you found this thread helpful

1. Toss us a follow for more daily threads on Linux, sysadmin, and DevOps→@linuxopsys

2. Like and RT the first tweet so that other Linux users can find it as well.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Linuxopsys

Linuxopsys Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @linuxopsys

May 5
paste command in Linux explained

(simple yet powerful way to merge and organize data from multiple text files):

Learn more about the paste command in this master guide: Image
The paste command merges lines of files horizontally by combining corresponding lines from each file specified as an argument and separating them with tabs.

In this thread, we will guide you on how to utilize the paste command effectively.
How to use the paste Command

The paste command is not as commonly used as other Linux and Unix command-line utilities, but it can be incredibly useful.

The paste command has the following syntax:

$ paste [OPTION]... [FILE]...
Read 22 tweets
May 3
The basename command in Linux prints the last element of a file path. This is particularly helpful in bash scripts where you only want the file name from a given file path.

In this thread, we will look at various examples to help us understand the basename command in Linux: Image
The "basename" function takes a filename and prints the last portion of it. If necessary, it can also remove any subsequent suffixes.
[+] Basename command syntax:

The basename command supports two syntaxes:

$ basename NAME [SUFFIX]
$ basename OPTION... NAME...
Read 14 tweets
May 3
The basename command in Linux prints the last element of a file path. This is particularly helpful in bash scripts where you only want the file name from a given file path.

In this thread, we will look at various examples to help us understand the basename command in Linux: Image
The "basename" function takes a filename and prints the last portion of it. If necessary, it can also remove any subsequent suffixes.
[+] Basename command syntax:

The basename command supports two syntaxes:

$ basename NAME [SUFFIX]
$ basename OPTION... NAME...
Read 14 tweets
Apr 30
pushd and popd are very underutilized commands, yet incredibly powerful.

These cmds give you the ability to manage your directory stack and easily switch between directories, making them a must-have tool for any Linux user looking to maximize their efficiency and productivity Image
In this thread, I'll show you how to use the pushd and popd commands to unlock the power of easy system directory navigation and streamline your workflow.
First let's understand what a Directory Stack is?

The Directory Stack is an ordered list of directories that have been accessed during navigation.

The contents of the Directory Stack can be viewed through the execution of the dirs command.
Read 29 tweets
Apr 28
Logs are a critical component of system and application management, providing valuable info for troubleshooting, performance analysis, security analysis, and compliance.

This thread will go over a few tools that can help you parse & analyze logs effectively from the cmdline. Image
Linux logs are a valuable resource for system administrators, network administrators, developers, and security professionals.
They record a timeline of events on a Linux system, such as operating system events, application activity, and user activities and actions (for example log-in attempts). This information can be valuable for troubleshooting, performance analysis, security analysis, and compliance.
Read 23 tweets
Apr 26
DevOps Tools 🧰

Operating system → Linux (recommended), Windows

Programming → Go, Python, Groovy

Container orchestration → Kubernetes

Containers → Docker

Source Code Management → Git, Subversion

Cloud → AWS, GCP, Azure, CivoCloud
CI/CD → Jenkins, CircleCI, Bamboo

Source control and collaborative coding → GitHub, BitBucket, GitLab

IaC (Infrastructure as Code) and IP (Infrastructure Provisioning) → Ansible, Puppet, Chef, Terraform, Pulumi, Stack, Crossplane
Continuous Feedback → GetFeedback, Jira, Slack, Pendo

Observability (monitoring, logging, and analyzing system behavior) → Nagios, Grafana , Prometheus, New Relic, ELK Stack Datadog

Plan → Jira Software, Confluence, Slack
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(