Understanding created file permissions

When Bash creates a new file on the system for you into which output has been directed, it needs to decide what permissions to set for the new file. It decides what those permissions should be with reference to a value called umask for the current process, which can be set by the process' owner.

The logic for how this decision is made is a little involved, and may require a quick review of how permissions on Unix-like systems work. To start, let's create a new file using an output redirection, and examine it with ls -l:

$ printf 'Hello, world\n' > myfile $ ls -l myfile -rw-r--r-- 1 bashuser bashuser 1 2018-07-29 20:53:23 myfile

 

The permissions for the file are described in the the -rw-r--r-- string ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.