Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
816 views
in Technique[技术] by (71.8m points)

permissions - Basic shell exercise

I have an exercise on shell where I need to work with permissions. I need to reproduce a repository where files should look like this when using ls -l :

dr-x---r-- 2 XX XX XX Jun 1 22:45 test0
-rwx--xr-- 1 XX XX 4  Jun 1 22:56 test1
-r-----r-- 2 XX XX 1  Jun 1 22:45 test2

so I can reproduce it in some ways (with basic commands like mkdir test0 chmod 504 test0/chmod ugo-rwx) but it will always look like this

dr-x---r--@ 2 XX XX 64 Jun 1 22:45 test0
-rwx--xr--  1 XX XX 0  Jun 1 22:54 test1
-r-----r--  1 XX XX 5  Jun 1 22:45 test2

As you can see, in test0 I have an "@" and I can't find what it stands for, nor how to delete it. And then, once i create another file or directory, test0 will automatically change and look like this :

drwxr-xr-@ 2 XX XX 64 Jun 1 22:45 test0

For test1 i don't know how to make so that my file size is "4" and not "0"

For test2 i don't know how it is not a directory and still has 2 linked hard-links and it's size is 1.

Thanks in advance !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The @ is a Mac OS convention and means that the directory has been set up with extended permissions. Further information can be found here:

http://scottlab.ucsc.edu/xtal/wiki/index.php/Extended_Attributes

With regards to the size of the files, you can create files and specify their sizes with dd and so:

dd if=/dev/zero of=test1 bs=4c count=1

dd if=/dev/zero of=test2 bs=5c count=1

dd details from man pages:

  dd - convert and copy a file

  bs=BYTES
          read and write up to BYTES bytes at a time


   count=N
          copy only N input blocks


  N and BYTES may be followed by the following multiplicative suffixes: c
   =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M
   GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...