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

  • 6
    What about stat? That will give you a huge amount of information on a selected file or folder; see man stat. – user76204 Oct 8 '13 at 15:33
up vote 13 down vote accepted

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

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

stat file_name
  • Needed just this - thank you. – a coder Sep 15 '14 at 18:34

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.

Have you tried file?

For example:

file picture.jpg
  • I'm sure he meant permissions. – Braiam Oct 8 '13 at 15:07
ls -lh filename

for human readable version

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

$ls -l filename

Use

ls -l filename

(use small L)

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.