Find the answer to your Linux question:
Results 1 to 10 of 10
Is it possible for listing directory and files' permission into numbers? Generally ls command shows directory and files' permission as follows; [root:maestro:/home/ddisk_net]# ls -al Total 44 drwx------ 4 ddisk_net users ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    12

    [SOLVED] ls permission to numbers?


    Is it possible for listing directory and files' permission into numbers?

    Generally ls command shows directory and files' permission as follows;

    [root:maestro:/home/ddisk_net]# ls -al
    Total 44
    drwx------ 4 ddisk_net users 4096 7월 20 10:40 .
    drwxr-xr-x 21 root root 4096 7월 20 10:28 ..
    -rw------- 1 ddisk_net webteam 5 7월 20 10:40 .bash_history
    -rw-r--r-- 1 ddisk_net users 33 1월 22 2009 .bash_logout
    -rw-r--r-- 1 ddisk_net users 176 1월 22 2009 .bash_profile
    -rw-r--r-- 1 ddisk_net users 124 1월 22 2009 .bashrc
    -rw-r--r-- 1 ddisk_net users 515 5월 25 2008 .emacs
    drwxr-xr-x 3 ddisk_net users 4096 8월 12 2002 .kde
    drwx------ 2 ddisk_net webteam 4096 7월 20 11:09 .ssh
    -rw-r--r-- 1 ddisk_net users 658 9월 22 2009 .zshrc
    What i want to see is like this;

    [root:maestro:/home/ddisk_net]# ls -al
    합계 44
    700 4 ddisk_net users 4096 7월 20 10:40 .
    750 21 root root 4096 7월 20 10:28 ..
    600 1 ddisk_net webteam 5 7월 20 10:40 .bash_history
    644 1 ddisk_net users 33 1월 22 2009 .bash_logout
    644 1 ddisk_net users 176 1월 22 2009 .bash_profile
    644 1 ddisk_net users 124 1월 22 2009 .bashrc
    644 1 ddisk_net users 515 5월 25 2008 .emacs
    750 3 ddisk_net users 4096 8월 12 2002 .kde
    700 2 ddisk_net webteam 4096 7월 20 11:09 .ssh
    644 1 ddisk_net users 658 9월 22 2009 .zshrc
    Thanks in advance.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,380
    So, you want the permission bits to be displayed in octal format? Sorry, but the 'ls' command won't do that normally (no option for that). However, there is no reason why you can't adapt/modify it to do so by adding a --octal option to the command. If you have a bit of C coding experience, it should not be difficult to modify the 'ls' source code to do that.
    Last edited by Rubberman; 07-20-2010 at 02:26 PM.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Newbie
    Join Date
    Jul 2007
    Location
    Here. There. Anywhere.
    Posts
    157
    BRILLIANT!!!

    ...
    sorry. The idea excites me, though. Let me know if you're going to try/do this, since I am a slow coder and all, but I think I'll look into making this happen myself.

  4. #4
    Linux Newbie
    Join Date
    Jul 2007
    Location
    Here. There. Anywhere.
    Posts
    157
    Oh, and just FYI if you don't want to do the C coding/ls modifying, it would probably be even less difficult to write a script to run ls and just modify the permissions column real quick.

  5. #5
    Just Joined!
    Join Date
    Sep 2009
    Posts
    12
    Quote Originally Posted by Rubberman View Post
    So, you want the permission bits to be displayed in octal format? Sorry, but the 'ls' command won't do that normally (no option for that). However, there is no reason why you can't adapt/modify it to do so by adding a --octal option to the command. If you have a bit if C coding experience, it should not be difficult to modify the 'ls' source code to do that.
    Rubberman/ I'm very sorry that I'm not a programmer and am a bigginer of linux for many uears...... I ned linux for studying home page, but there are so many things to access terminal and linux console and check permission and ownerships. And I am familiar with numeric permission.

    Would you please exlain me how to do this:

    why you can't adapt/modify it to do so by adding a --octal option to the command

  6. #6
    Just Joined!
    Join Date
    Sep 2009
    Posts
    12
    Quote Originally Posted by ryokimball View Post
    Oh, and just FYI if you don't want to do the C coding/ls modifying, it would probably be even less difficult to write a script to run ls and just modify the permissions column real quick.
    ryokimball/

    It is impossible for me "to write a script to run ls and just modify the permissions column".....

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,380
    Quote Originally Posted by neowindstory View Post
    ryokimball/

    It is impossible for me "to write a script to run ls and just modify the permissions column".....
    Using scripting tools like sed and awk, or perl/python, this should not be difficult. Is the problem that you just don't know where to start? Or that you just don't know what to do? Scripting is programming, but with a lot of the "plumbing" made easier for you.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #8
    Just Joined!
    Join Date
    Sep 2009
    Posts
    12
    Quote Originally Posted by Rubberman View Post
    Using scripting tools like sed and awk, or perl/python, this should not be difficult. Is the problem that you just don't know where to start? Or that you just don't know what to do? Scripting is programming, but with a lot of the "plumbing" made easier for you.
    yes, actually I don't know where to start and what to do.
    At present I am studying php.

  9. #9
    Linux Newbie
    Join Date
    Jul 2007
    Location
    Here. There. Anywhere.
    Posts
    157
    PHP _may_ work, but definitely isn't my drug of choice here. Sed/awk seem to be a good choice if you don't have the desire to learn another language like Perl, but I have honestly never used either.

    Here (wikipedia) is a direct listing of octal-to-text permissions, which is certainly useful.

    And if you do want to pick up Perl, here's where I learned it from: O'Reilly - Safari Books Online: Learning Perl, 3rd Edition

  10. #10
    Just Joined!
    Join Date
    Sep 2009
    Posts
    12
    ryokimball/

    Thanks for your kind reply, and advice.

    About learning perl, I'll study later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •