99

What is the command line that displays file informations (or properties), such as in GUI method Display properties in GNOME?

Display properties GNOME

I know that ls -l shows properties; but how to display the same informations?

For example, instead of

rw-rw-r--

we have such GUI rendering:

abdennour@estifeda: $wishedCmd myFile
 ..... 
  Permissions : 
    Owner Access: Read & write 
    Group Access :Read & Write 
    Others Access: Read only
   .....

Screenshot of permissions dialogue

kos
  • 41,268

10 Answers10

170

Use the stat command to know the details of the file. If file name is file_name, use

stat file_name
muru
  • 207,228
Arun. K. P
  • 1,801
43

There is no dedicated command for this. For meta information like time, size and access rights, use

ls -l path-to-file

You might also be interested in what kind of file it is, file path-to-file will help you with that.

Jens Erat
  • 5,131
  • 7
  • 33
  • 37
33

Have you tried file?

For example:

file picture.jpg
SirCharlo
  • 40,096
19

Something like

#!/bin/bash
print_perm() {
  case "$1" in
    0) printf "NO PERMISSIONS";;
    1) printf "Execute only";;
    2) printf "Write only";;
    3) printf "Write & execute";;
    4) printf "Read only";;
    5) printf "Read & execute";;
    6) printf "Read & write";;
    7) printf "Read & write & execute";;
  esac
}

[[ ! -e $1 ]] &&  echo "$0 <file or dir>" 2>&1 && exit 1

perm=$(stat -c%a "$1")
user=${perm:0:1}
group=${perm:1:1}
global=${perm:2:1}

echo "Permissions :"
printf "\tOwner Access: $(print_perm $user)\n"
printf "\tGroup Access: $(print_perm $group)\n"
printf "\tOthers Access: $(print_perm $global)\n"

Output

# rwxr-x--- foo*
> ./abovescript foo
Permissions :
    Owner Access: Read & write & execute
    Group Access: Read & execute
    Others Access: NO PERMISSIONS
Danatela
  • 13,384
13
ls -lh filename

for human readable version

A.B.
  • 92,125
Ross Jones
  • 231
  • 2
  • 3
3

Display the attributes of the files in the current directory:

lsattr

List the attributes of files in a particular path:

lsattr path

List file attributes recursively in the current and subsequent directories:

lsattr -R

Show attributes of all the files in the current directory, including hidden ones:

lsattr -a

Display attributes of directories in the current directory:

lsattr -d

Bou Said
  • 121
1

You can use ls command to list files and their properties by adding the -l option. Example:

$ls -l filename
0

As described in the Linux Pocket Guide by Daniel J. Barrett you can list extended attributes of files and directories with:

lsattr file_name
0

You can try the following script:

set filepath "$HOME/.bashrc"
set fileuri $(echo $filepath | python -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())")
dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItemProperties array:string:"$fileuri" string:""

P.S. If you do not convert file path to file uri then path like $HOME/Desktop/directory with spaces and ümläuts.txt will not work.

0

Use

ls -l filename

(use small L)

Eric Carvalho
  • 55,453