Solved

centos see file permissions

Posted on 2011-09-30
9
469 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
 
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
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.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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.

911 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

21 Experts available now in Live!

Get 1:1 Help Now