Currently I am trying to create some Solaris installations packages and
to do so I need the know the current file permissions for "/etc/env".
I thought "ls -l -d -? /etc/env'" with '-?' being an option I don't know
yet and which will change the display format from "drwxrwxrwt" to octal.
Now I read "ls --help", "man ls", "info ls", Wikipedia and
http://www.linux-command.com/ls.html on the search for right option.
I found "-n, --numeric-uid-gid List numeric UIDs and GIDs instead of
names" - but that's for the uid and gid but not for the file permissions.
But "-?, --numeric-* List numeric permissions instead of symbolic" is
nowhere to be see.
Could it really be that there is no such option?
Martin
PS I have both Solaris ls and an up-to-date self compiled GNU ls available.
--
mailto://kris...@users.sourceforge.net
Ada programming at: http://ada.krischik.com
I'm afraid there is no standard command to retrieve the file
permissions in octal.
You can convert the rw-r--r-- to octal with something like:
ls -ld FILENAME | sed 's/.\(.........\).*/\1/
h;y/rwsxtST-/IIIIIOOO/;x;s/..\(.\)..\(.\)..\(.\)/|\1\2\3/
y/sStTx-/IIIIOO/;G
s/\n\(.*\)/\1;OOO0OOI1OIO2OII3IOO4IOI5IIO6III7/;:k
s/|\(...\)\(.*;.*\1\(.\)\)/\3|\2/;tk
s/^0*\(..*\)|.*/\1/;q'
You could use GNU find:
find FILENAME -prune -printf '%m\n'
or GNU stat:
stat -c %a FILENAME
or zsh stat:
zstat -o +mode FILENAME
(also includes the file type)
--
Stephane
The original Unix designers where so keen on octal number so this
surprises me big time.
> You can convert the rw-r--r-- to octal with something like:
I tried the all - but they will only display 3 digit permissions. Well
for Solaris
pkgproto FILENAME
will do the trick.
Martin
$ perl -e'printf "%o\n", ( stat "/etc" )[ 2 ]'
40755
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
The "ls" from the ast-open toolkit allows you to get this information, use
ls --format='%(perm)o' filename
to get the value in octal, or
ls --format='%(perm)d' filename
to get the value in decimal. AST-open is available free under an
opensource license. Probably the most common reason for getting it is the
version of ksh93 by the original author.
>Could it really be that there is no such option?
SunOS and AT&T created a merged BSD/SysV Unix in 1987, when they
"standardized" all of the unix command line arguments.
Linux was started in 1991.
It's easy to convert the drwxrwxrwx string into octal. See Stephanee's
post. Perhaps that's why it wasn't added.
In those days, many people didn't like unnecessary "extras" in basic
commands. See Rob Pike's "UNIX Style, or cat -v Considered Harmful"
Quote:
"We are reminded that ls isn't the place for code to break a
single column into multiple ones"
> Martin Krischik <kris...@users.sourceforge.net> writes:
>
>
> >Could it really be that there is no such option?
>
> SunOS and AT&T created a merged BSD/SysV Unix in 1987, when they
> "standardized" all of the unix command line arguments.
>
> Linux was started in 1991.
>
> It's easy to convert the drwxrwxrwx string into octal. See Stephanee's
> post. Perhaps that's why it wasn't added.
>
> In those days, many people didn't like unnecessary "extras" in basic
> commands. See Rob Pike's "UNIX Style, or cat -v Considered Harmful"
But wouldn't the translation from octal into rwx notation be considered
more of an "extra"?
I've also been surprised for several decades that this doesn't exist.
--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
> > In those days, many people didn't like unnecessary "extras" in basic
> > commands. See Rob Pike's "UNIX Style, or cat -v Considered Harmful"
>
> But wouldn't the translation from octal into rwx notation be considered
> more of an "extra"?
Heh. heh. Perhaps.
But it does eliminate the question "which is write? 2 or 4?" :-)
Actually, there is one:
pax -w filename |
dd ibs=1 skip=103 count=4 2> /dev/null
Or better, to allow longer file names:
pax -x cpio -w filename |
dd ibs=1 skip=20 count=4 2> /dev/null
--
Stephane
stat --format=%a,%U,%G,%t,%n /etc/*
Denis
Have a nice day !
On 12 fév, 13:27, Martin Krischik <krisc...@users.sourceforge.net>
wrote:
> Hello
>
> Currently I am trying to create some Solaris installations packages and
> to do so I need the know the current file permissions for "/etc/env".
>
> I thought "ls -l -d -? /etc/env'" with '-?' being an option I don't know
> yet and which will change the display format from "drwxrwxrwt" to octal.
>
> Now I read "ls --help", "man ls", "info ls", Wikipedia andhttp://www.linux-command.com/ls.htmlon the search for right option.
>
> I found "-n, --numeric-uid-gid List numeric UIDs and GIDs instead of
> names" - but that's for the uid and gid but not for the file permissions.
>
> But "-?, --numeric-* List numeric permissions instead of symbolic" is
> nowhere to be see.
>
> Could it really be that there is no such option?
>
> Martin
>
> PS I have both Solaris ls and an up-to-date self compiled GNU ls available.
> --
> mailto://krisc...@users.sourceforge.net
> On Feb 13, 7:10 pm, Maxwell Lol <nos...@com.invalid> wrote:
> > Martin Krischik <krisc...@users.sourceforge.net> writes:
> > >Could it really be that there is no such option?
> >
> > SunOS and AT&T created a merged BSD/SysV Unix in 1987, when they
> > "standardized" all of the unix command line arguments.
> >
> > Linux was started in 1991.
> But 'ls' was written by GNU so that's sometime in the early to mid
> 80's...
According to coreutils-5.0/old/fileutils
The code to replace 'ls' was started 1997, not 1980's.
Are you trying to say that Linux systems before 1997 didn't have
ls?
From ftp.gnu.org/old-gnu, GNU textutils-1.0 in 1990 had ls already.
--
Stéphane
> 2008-03-11, 20:06(-04), Maxwell Lol:
> [...]
> >> > Linux was started in 1991.
> >> But 'ls' was written by GNU so that's sometime in the early to mid
> >> 80's...
> >
> > According to coreutils-5.0/old/fileutils
> > The code to replace 'ls' was started 1997, not 1980's.
>
> Are you trying to say that Linux systems before 1997 didn't have
> ls?
>
> From ftp.gnu.org/old-gnu, GNU textutils-1.0 in 1990 had ls already.
Thanks for the reference. Lowe Schmidt says that gnu ls was developed
in 'early to mid 80's...', and I am not able to verify this.
You all must realize that there was Unix long before GNU or Linux.
Unix ls(1) has been around for quite a while. It is documented in 6th
Edition Unix with date 3/20/74. That's 1974-03-20 in translation.
It too interprets mode bits as rwx not 421.
carl
--
carl lowenstein marine physical lab, u.c. san diego
clowe...@ucsd.edu
I don't think anyone knowing what GNU stands for doubts that.
Unix started in the late 60s, GNU in 1983.
> Unix ls(1) has been around for quite a while. It is documented in 6th
> Edition Unix with date 3/20/74. That's 1974-03-20 in translation.
[...]
If you're interested in Unix history, you can have a look at
www.tuhs.org where you can find for instance the man page for
Unix V3 ls.
I'd be interested on where to find old code archives for GNU.
IIRC, circa 1995, on Linux, there were several different
implementations of ls available. If my memory serves me right,
the default one on slackware didn't have colour support so it's
possible that it wasn't the GNU one.
--
Stéphane
> I'd be interested on where to find old code archives for GNU.
You probably already know
, don't you?
Well yes since I'm the one who brought it up in this thread, but
what about versions of fileutils prior to 3.13 for instance? Or
even prior to 1.0?
--
Stéphane
>> You probably already know
>>
>> ftp://ftp.gnu.org/old-gnu
>>
>> , don't you?
>
> Well yes since I'm the one who brought it up in this thread,
Ah erm...well...yes. I didn't read the thread very carefully :-)
> but what about versions of fileutils prior to 3.13 for instance? Or
> even prior to 1.0?
Actually, a bit of googling reveals no traces of those older versions. It
seems that they're actually really hard to find.
If you are content with binaries, then probably some old distro (perhaps to
be run in a virtual machine) for instance among those at
http://www.ibiblio.org/pub/historic-linux
/might/ provide older versions of GNU tools.