Solved

centos see file permissions

Posted on 2011-09-30
9
471 Views
Last Modified: 2013-12-15
hello there,
im using centos v5.7 and normally when I try to see the file permission I see
drwxr-xr-x how can I see the number instead? like 0777 or 0600

[(12:26 PM)][(root@alpha)] [(~)] $ ls -alh
total 208K
drwxr-x--- 14 root  root  4.0K Sep 30 03:39 .
drwxr-xr-x 26 root  root  4.0K Sep 14 20:36 ..
-rw-r--r--  1 root  root   315 Sep 30 03:39 a.php
-rw-------  1 root  root  8.4K Sep 30 04:41 .bash_history
-rw-r--r--  1 root  root    24 Jan  6  2007 .bash_logout
-rw-r--r--  1 root  root   276 Feb  1  2009 .bash_profile
-rw-r--r--  1 root  root  5.4K Mar 19  2009 .bashrc        
0
Comment
Question by:XK8ER
9 Comments
 
LVL 88

Expert Comment

by:rindi
ID: 36893029
In my point of view, although it might be a "cheat" or "workaround", would be to start mc (midnight commander), set one panel to "info", and in the other highlight the file or folder you need the info on, and it will be displayed in the panel you have set to "info". This is one of the best tools available in the 'nix world, and I can't understand why it isn't included by default in every Linux distro. If you don't have it, just install it with yum install mc.
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 36893092
stat -c "%a %n" /folder/*
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36894589
jgiordano is correct, stat will do just that.

To mimic your 'ls' output, you can add a few more colums:

stat -c "%a %h %G %U %s %n" *

Open in new window

0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 1

Author Comment

by:XK8ER
ID: 36894930
gerwinjansen, that works nicely..
what is the number 1 right next to the permissions and how can I display the size in human readable
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36895689
The number 1 you mean is the amount of hard links to that file.

I'm not sure what you mean by 'human readable', the file size is displayed in bytes, do you require some other format? You can have a look in the stat man pages (man stat), only field available for size is 'bytes'. You can do some formatting afterwards but what do you want exactly?
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36895704
when you do
du -h /root
you can see KB or MB or GB in bytes its hard to know the size
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 36896180
I understand, do you want to see the size of the files in KB? du -h is showing file size in KB.
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36897106
yes KB is fine
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 500 total points
ID: 36897482
awk will do the trick, please test this on your system:

stat -c "%a %h %G %U %s %n" * | awk '{ $5=sprintf ( "%.0fK", $5/1024);print $0 }'

Open in new window

If it works, you can create a shell script like ~/bin/lstat containing the above command line.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question