Solved

centos see file permissions

Posted on 2011-09-30
9
467 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 87

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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now