Forrest logo
back to the stat tool

stat:tldr:253cf

stat: Show only octal file permissions.
$ stat --format="%a %n" ${filename}
try on your machine

This command uses the "stat" command to display the file access mode (permissions) and the filename of the specified file.

Here's a breakdown of the different parts of the command:

  • "stat" is a command-line utility in Unix-like operating systems used to display detailed information about files or file systems.
  • "--format" is an option used to specify the output format of the command. In this case, it is set to "%a %n", where "%a" is a format specifier for the file access mode/permissions and "%n" is a format specifier for the filename.
  • "${filename}" is a placeholder for the actual filename. It should be replaced with the name of the file you want to retrieve information about.

When you run this command, the "stat" command will output the file access mode/permissions (represented as a numerical value) followed by a space and then the filename. For example, the output might look like "644 myfile.txt", where "644" represents the file's access mode and "myfile.txt" is the filename.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the stat tool