how to backup and restore file permissions using acl

$mkdir data
$cd data/
$ls
$pwd
/home/jeffrin/data
$echo hello > file1.txt
$echo world > file2.txt
$ls -l
total 8
-rw-r--r-- 1 jeffrin jeffrin 6 Jan 22 22:44 file1.txt
-rw-r--r-- 1 jeffrin jeffrin 6 Jan 22 22:44 file2.txt
$getfacl -R . > permissions.txt
$cat permissions.txt 
# file: .
# owner: jeffrin
# group: jeffrin
user::rwx
group::r-x
other::r-x

# file: permissions.txt
# owner: jeffrin
# group: jeffrin
user::rw-
group::r--
other::r--

# file: file1.txt
# owner: jeffrin
# group: jeffrin
user::rw-
group::r--
other::r--

# file: file2.txt
# owner: jeffrin
# group: jeffrin
user::rw-
group::r--
other::r--

$chmod 777 file2.txt 
$ls -l file2.txt 
-rwxrwxrwx 1 jeffrin jeffrin 6 Jan 22 22:44 file2.txt
$setfacl --restore=permissions.txt 
$ls -l file2.txt 
-rw-r--r-- 1 jeffrin jeffrin 6 Jan 22 22:44 file2.txt
$

chattr practice session . I

The following shows a command line session with chattr 
command which helps in changing attributes of files.

$lsattr functions.txt
-------------e-- functions.txt
$chattr -e functions.txt
chattr: Clearing extent flag not supported on functions.txt
$lsattr functions.txt
-------------e-- functions.txt
$chattr +c functions.txt
$lsattr functions.txt
--------c----e-- functions.txt
$lsattr functions.txt
--------c----e-- functions.txt
$chattr +a functions.txt
chattr: Operation not permitted while setting flags on functions.txt
$chattr +C functions.txt
$lsattr functions.txt
--------c----e-- functions.txt
$

The 'e' attribute indicates that the file is using
extents for mapping the blocks on  disk.

A file with the `c' attribute set is automatically 
compressed on the disk by the kernel.

A file with the `a' attribute set can only be open 
in append mode for writing.

A  file  with  the 'C' attribute set will not be subject
to copy-on-write updates.

lsattr practice session . II

The following shows a command line session with lsattr 
command which helps in listing file attributes.
$lsattr 
-------------e-- ./A.txt
-------------e-- ./beautyastudyin00rothuoft.pdf
-------------e-- ./trueprint-5.4.tar.gz.sig
-------------e-- ./sample
-------------e-- ./scsh-common-0.6_0.6.7-8_all.deb
-------------e-- ./photos
-------------e-- ./beautifulwork-sorting
-------------e-- ./Templates
-------------e-- ./apache2_2.4.7-1_amd64.deb
-------------e-- ./Pictures
-------------e-- ./a.out
-------------e-- ./sent
-------------e-- ./Videos
-------------e-- ./functions.txt~
-------------e-- ./Desktop
-------------e-- ./books
-------------e-- ./myapp.rb
-------------e-- ./tmp
-------------e-- ./ethstatus_0.4.3.dsc
-------------e-- ./test.png
-------------e-- ./1
-------------e-- ./lsattr1.txt
-------------e-- ./physical.computing
-------------e-- ./rubyhw.rb
-------------e-- ./mysqlbackup
-------------e-- ./gsl
-------------e-- ./new.sass
-------------e-- ./trueangle.org
-------------e-- ./iso
-------------e-- ./#tmps#
-------------e-- ./wp-config.php
-------------e-- ./resume-micro
-------------e-- ./mathematics
-------------e-- ./source
-------------e-- ./resume-related.txt~
-------------e-- ./beautifulwork
-------------e-- ./#temp#
-------------e-- ./dap-3.8.tar.gz.sig
-------------e-- ./DMD
-------------e-- ./oo~
-------------e-- ./trueangle
-------------e-- ./dap-3.9
-------------e-- ./functions.txt
----------I--e-- ./Downloads
-------------e-- ./test.html
----------I--e-- ./National Geogrpahic compiled photos
-------------e-- ./playground
-------------e-- ./dap-3.7.tar.gz.sig
-------------e-- ./Mail
-------------e-- ./new.css
-------------e-- ./join.png
-------------e-- ./#workrecord.txt#
-------------e-- ./debian-binary
-------------e-- ./study.png
-------------e-- ./test.synctex.gz
-------------e-- ./processing
-------------e-- ./wallphotos-old
-------------e-- ./perl-new.txt
-------------e-- ./r8169
-------------e-- ./wallphotos
-------------e-- ./xf86-video-radeonhd
-------------e-- ./scsh-0.6_0.6.7-8_i386.deb
-------------e-- ./bw-wordpress
-------------e-- ./beautifulwork-ethstatus
-------------e-- ./work.png
-------------e-- ./bw-theme
-------------e-- ./beautifulwork.org-git
-------------e-- ./apache
-------------e-- ./Public
-------------e-- ./colors
-------------e-- ./ruby-related-bubblesort-related
-------------e-- ./test.aux
-------------e-- ./linux
-------------e-- ./resume-related.txt
-------------e-- ./ethstatus_0.4.3.tar.gz
-------------e-- ./testanother.html
-------------e-- ./data.tar.xz
-------------e-- ./sdata
-------------e-- ./dap-3.9.tar.gz
-------------e-- ./beautifulwork-temp
-------------e-- ./scsh_0.6.6.3_all.deb
-------------e-- ./physics
-------------e-- ./sshot.png
-------------e-- ./control.tar.gz
-------------e-- ./test.pdf
-------------e-- ./viva_jaago_zara.mp3
-------------e-- ./test.tex
-------------e-- ./Music
-------------e-- ./Documents
-------------e-- ./tem
-------------e-- ./temp
-------------e-- ./languagelearning
-------------e-- ./test.log
-------------e-- ./a.txt
-------------e-- ./filename
-------------e-- ./ahiliation.github.io
-------------e-- ./solutions
-------------e-- ./search.txt
-------------e-- ./dap-3.0.tar.gz.sig
-------------e-- ./dap
-------------e-- ./publish.png
-------------e-- ./dot-emacs
-------------e-- ./#mission#
-------------e-- ./test.html~
$

The 'e' attribute indicates that the file is using extents for mapping the blocks on  disk.  It  may not be removed using chattr.

lsattr – list file attributes on a ext2fs

The following shows a command line session with lsattr
and stat commands which helps in listing file attributes.

$lsattr -v colors 
1936034688 -------------e-- colors
$lsattr  colors 
-------------e-- colors
$ls -l colors 
-rw-r--r-- 1 jeffrin jeffrin 173 Feb 17 21:46 colors
$stat colors 
  File: ‘colors’
  Size: 173       	Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d	Inode: 3672604     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/ jeffrin)   Gid: ( 1000/ jeffrin)
Access: 2014-03-30 21:42:28.074551288 +0530
Modify: 2014-02-17 21:46:33.476488095 +0530
Change: 2014-02-17 21:46:33.476488095 +0530
 Birth: -
$ls -R colors 
colors
$lsattr -R colors 
-------------e-- colors
$lsattr  resume-micro 
-------------e-- resume-micro
$lsattr  beautifulwork-sorting/
-------------e-- beautifulwork-sorting/gnu-c
-------------e-- beautifulwork-sorting/TODO
-------------e-- beautifulwork-sorting/README
-------------e-- beautifulwork-sorting/bubblesort.php
-------------e-- beautifulwork-sorting/php-hypertext-processor
-------------e-- beautifulwork-sorting/ruby
$lsattr  /bin/ls
-------------e-- /bin/ls
$lsattr  /bin/date 
-------------e-- /bin/date
$lsattr -v  /bin/date 
18446744072723245045 -------------e-- /bin/date
$stat /bin/date
  File: ‘/bin/date’
  Size: 64168     	Blocks: 128        IO Block: 4096   regular file
Device: 801h/2049d	Inode: 14418067    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-04-06 20:48:40.575978902 +0530
Modify: 2013-07-21 03:22:44.000000000 +0530
Change: 2014-02-17 22:49:42.956708864 +0530
 Birth: -
$

http://unix.stackexchange.com/questions/32256/whats-the-meaning-of-output-of-lsattr

The ‘e’ attribute indicates that the file is using extents for mapping the blocks on disk.

Showing about hidden directories

$lsattr -a
--------------e---- ./.config
--------------e---- ./Public
--------------e---- ./.atom
--------------e---- ./.profile
--------------e---- ./.gitconfig
--------------e---- ./.
--------------e---- ./Templates
--------------e---- ./Firefox_wallpaper.png
--------------e---- ./.ICEauthority
--------------e---- ./..
--------------e---- ./.pki
--------------e---- ./beautifulwork
--------------e---- ./.gconf
--------------e---- ./.local
--------------e---- ./.bash_logout
--------------e---- ./.mozilla
--------------e---- ./.cache
--------------e---- ./.gimp-2.8
--------------e---- ./.gnupg
--------------e---- ./.emacs.d
--------------e---- ./Downloads
--------------e---- ./.bash_history
--------------e---- ./Documents
--------------e---- ./.bashrc
--------------e---- ./Music
--------------e---- ./Videos
--------------e---- ./avocado
--------------e---- ./.bashrc~
--------------e---- ./Pictures
--------------e---- ./.ssh
--------------e---- ./Desktop
--------------e---- ./communications201703-dl.pdf
$

Testing Mail Servers with OpenSSL

commandline session

$ openssl s_client -connect pop.mail.yahoo.co.in:995
CONNECTED(00000003)
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert High Assurance CA-3
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=CA/L=Sunnyvale/O=Yahoo! Inc./CN=legacy.pop.mail.yahoo.com
   i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3
 1 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3
   i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIISjCCBzKgAwIBAgIQClDT0u/4pW4O2yOSzos4yzANBgkqhkiG9w0BAQUFADBm
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSUwIwYDVQQDExxEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
ZSBDQS0zMB4XDTEzMDkyNjAwMDAwMFoXDTE1MTEyNDEyMDAwMFowaDELMAkGA1UE
BhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTdW5ueXZhbGUxFDASBgNVBAoM
C1lhaG9vISBJbmMuMSIwIAYDVQQDExlsZWdhY3kucG9wLm1haWwueWFob28uY29t
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoqy61Hr/vHKuiQXK+X9T
ExkaqtnlatpB0/MihN1wagUVK/oVKzfXUvEWA/EP/NudWRf7ARv8tJ7i8Zts7pHo
prEiGQnmSZq2d/bIPTbfgaczzIJJomoRAuesI8ggR4RbAG461b4W58ETyYbHNR32
sqLueUiU3hIeXP8Hd3QVc/LtTPjZHTpP/KxwXrsTLIELGfcK5t64tfLRZSNiV/3p
n3IxElpijAIugena7svG3IyyXlQ+6U0VgGftIP6lHy9PQOOwv3B+QksOpBHBPudp
ByUOXk0fjm06OqZmjhSkhMTNn0TI/kC/JXLtb+uOeemizJHkRtB45P//VTrZHxpL
mwIDAQABo4IE8DCCBOwwHwYDVR0jBBgwFoAUUOpzidsp+xCPnuUBINTeeZlIg/cw
HQYDVR0OBBYEFPN1hfVOIPSbnmQ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GMAYwBlAHAAdABhAG4AYwBlACAAbwBmACAAdABoAGUA
IABEAGkAZwBpAEMAZQByAHQAIABDAFAALwBDAFAAUwAgAGEAbgBkACAAdABoAGUA
IABSAGUAbAB5AGkAbgBnACAAUABhAHIAdAB5ACAAQQBnAHIAZQBlAG0AZQBuAHQA
IAB3AGgAaQBjAGgAIABsAGkAbQBpAHQAIABsAGkAYQBiAGkAbABpAHQAeQAgAGEA
bgBkACAAYQByAGUAIABpAG4AYwBvAHIAcABvAHIAYQB0AGUAZAAgAGgAZQByAGUA
aQBuACAAYgB5ACAAcgBlAGYAZQByAGUAbgBjAGUALjB7BggrBgEFBQcBAQRvMG0w
JAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBFBggrBgEFBQcw
AoY5aHR0cDovL2NhY2VydHMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0SGlnaEFzc3Vy
YW5jZUNBLTMuY3J0MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQEFBQADggEBAJ0u
09cnxR4/5VXcMjDkjnfmGYsbjjAK0RDwkMGzItrMqQDsPnUnaci5ynCqAAWuU7UI
07YE1pOM6z+3f0koKsmqtsrTouCG7JhNLrOfQOlRlEmo1m1TvH2z/U8rjfehS3rV
f7gHb9/bc2MCeZZo5kjesoB6d3qEKN2HiDuOQbAYOZd48E7ykt7nRsZJJwqbNdFd
X6g7OB5Hn5ajOqu/kLLksYYKkqhEgYPAiDyEZdWEvP8EvGM/KlIGtTPnLBB4X2iA
dkabRf7jLTklarx0J5/erdB3Cm90gOv8DVS/+m7KUJCEfD9vdYVSPyrAALlxpnEh
HP1MZt3X4XXJGRYKe+0=
-----END CERTIFICATE-----
subject=/C=US/ST=CA/L=Sunnyvale/O=Yahoo! Inc./CN=legacy.pop.mail.yahoo.com
issuer=/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3
---
No client certificate CA names sent
---
SSL handshake has read 4061 bytes and written 631 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : RC4-SHA
    Session-ID: 62C41F5F804C91D86B8E99A93DE6EA88A74C802F4EE7D1E2EA31B90B7DF82DB6
    Session-ID-ctx: 
    Master-Key: 93D29DEE014AE52BEC86DA6344439F1BB254D89C017E8E758CB34E3137C2D1F4432D70704E3EA7DFDF59B2662D7D1CE7
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket:
    0000 - e0 71 94 74 df a0 d9 bb-1c 7d 55 55 ea ad 72 d6   .q.t.....}UU..r.
    0010 - 45 1f 47 de aa f2 26 9e-3f c3 fc c3 be 59 61 a7   E.G...&.?....Ya.
    0020 - fb 65 b3 9a 60 fe 8f e3-cf dc 5f ea 9c c5 59 c4   .e..`....._...Y.
    0030 - be a8 54 0d ab 1a ff 0a-4f be d4 6d 57 d1 5e 4c   ..T.....O..mW.^L
    0040 - 8b c0 48 5a 64 4f 98 2d-c3 d6 05 4f fb 2e 5d c1   ..HZdO.-...O..].
    0050 - 57 ca 7d 85 de fb 15 ec-b5 c7 24 38 fd 09 01 24   W.}.......$8...$
    0060 - 33 e6 33 67 b5 66 22 04-4a 24 ad 83 61 fc b6 d5   3.3g.f".J$..a...
    0070 - 98 ea 46 d5 a2 2b c4 d3-3d d9 6d 97 37 f4 43 9b   ..F..+..=.m.7.C.
    0080 - 3e b0 22 33 e9 3c b4 71-bb c6 7f 96 3b 43 a2 b9   >."3.<.q....;C..
    0090 - 54 c3 06 45 c4 5d 2b b2-4b 4a 64 41 51 ce 41 53   T..E.]+.KJdAQ.AS

    Start Time: 1395243263
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---
+OK hello from popgate-0.8.0.504347 pop114.plus.mail.gq1.yahoo.com 


chmod – change file mode bits

ABOUT chmod

In Unix and Unix-like operating systems, chmod is the command and system call which is used to change the access permissions of file system objects (files and directories). It is also used to change special mode flags. The request is filtered by the umask. The name is an abbreviation of change mode.[1]

TYPICAL COMMANDLINE EXPOSURE
[bash]
$ chmod +t source/
$ ls -l
total 12
drwxr-xr-x 2 ahiliation ahiliation 4096 2010-03-13 04:40 Desktop
drwxr-xr-x 2 ahiliation ahiliation 4096 2010-03-13 19:20 Downloads
drwxr-xr-t 2 ahiliation ahiliation 4096 2010-03-13 20:41 source
[/bash]

t - Save text attribute (sticky bit) - The user may delete or modify only those files in the directory that they own or have write permission for.

[bash]
$chmod -c
$ls -l rwsem.c
-rw-rw-r– 1 root root 21007 Aug 30 2011 rwsem.c
$chmod -c rwsem.c
chmod: missing operand after ‘rwsem.c’
Try ‘chmod –help’ for more information.
$chmod -c
chmod: missing operand
Try ‘chmod –help’ for more information.
$chmod -c 700 rwsem.c
chmod: changing permissions of ‘rwsem.c’: Operation not permitted
$sudo chmod -c 700 rwsem.c
mode of ‘rwsem.c’ changed from 0664 (rw-rw-r–) to 0700 (rwx——)
$
[/bash]

LINKS
https://en.wikipedia.org/wiki/Chmod
http://www.gnu.org/software/coreutils/manual/html_node/chmod-invocation.html