1

example of files with there permissions

-rwxr-xr-x. 1 root root  659 Jan  4  2018 zookeeper-server-initialize
-rwxr-xr-x. 1 root root  649 Jan  4  2018 zookeeper-server-cleanup
-rwxr-xr-x. 1 root root  648 Jan  4  2018 zookeeper-server
-rwxr-xr-x. 1 root root  303 Jan  4  2018 zookeeper-client
-rwxr-xr-x. 1 root root 6822 Jan  4  2018 zkServer.sh
-rwxr-xr-x. 1 root root   12 Jan  4  2018 zkServer-initialize.sh
-rwxr-xr-x. 1 root root 2840 Jan  4  2018 zkEnv.sh
-rwxr-xr-x. 1 root root 1709 Jan  4  2018 zkCli.sh
-rwxr-xr-x. 1 root root 2155 Jan  4  2018 zkCleanup.sh

in case we have just this file for example : ( without the dot )

-rwxr-xr-x 1 root root 2155 Jan  4  2018 zkCleanup.sh

Then what is the command to add this dot to the file permissions ?

second how to add a dot recursive

for example on all sub folders under

/usr/hdp/current/zookeeper-server

example before

 pwd
/usr/hdp/current/zookeeper-server


 ls -Z
drwxr-xr-x root root ?                                bin
lrwxrwxrwx root root ?                                conf -> /etc/zookeeper/2.6.4.0-91/0
drwxr-xr-x root root ?                                doc
drwxr-xr-x root root ?                                etc
drwxr-xr-x root root ?                                lib
drwxr-xr-x root root ?                                man
drwxr-xr-x root root ?                                usr
-rw-r--r-- root root ?                                zookeeper-3.4.6.2.6.4.0-91.jar
lrwxrwxrwx root root ?                                zookeeper.jar -> zookeeper-3.4.6.2.6.4.0-91.jar

expected output:

 pwd
/usr/hdp/current/zookeeper-server

ls -Z
drwxr-xr-x. root root system_u:object_r:bin_t:s0       bin
lrwxrwxrwx. root root unconfined_u:object_r:usr_t:s0   conf -> /etc/zookeeper/2.6.4.0-91/0
drwxr-xr-x. root root system_u:object_r:usr_t:s0       doc
drwxr-xr-x. root root system_u:object_r:usr_t:s0       etc
drwxr-xr-x. root root system_u:object_r:lib_t:s0       lib
drwxr-xr-x. root root system_u:object_r:usr_t:s0       man
drwxr-xr-x. root root system_u:object_r:usr_t:s0       usr
-rw-r--r--. root root system_u:object_r:usr_t:s0       zookeeper-3.4.6.2.6.4.0-91.jar
lrwxrwxrwx. root root system_u:object_r:usr_t:s0       zookeeper.jar -> zookeeper-3.4.6.2.6.4.0-91.jar

we try

restorecon -r /usr/hdp
ls -ltr
total 12
drwxr-xr-x. 27 root root 4096 Oct 29 10:05 2.6.0.3-8
drwxr-xr-x  29 root root 4096 Nov  6 11:29 2.6.4.0-91
drwxr-xr-x.  2 root root 4096 Dec 31 13:01 current

but 2.6.4.0-91 folder with the same permissions ( include the sub folders under 2.6.4.0-91 )

ls -Z
drwxr-xr-x. root root system_u:object_r:usr_t:s0       2.6.0.3-8
drwxr-xr-x  root root ?                                2.6.4.0-91
drwxr-xr-x. root root unconfined_u:object_r:usr_t:s0   current

1 Answer 1

3

The trailing . indicates that a file has an SElinux security context. To set the default security contexts you should be able to run

restorecon -r /usr/hdp 

The above requires that you have SELinux enabled on your system. If you do not then you will have to enable it and label the filesystem

Edit /etc/selinux/config and ensure that

SELINUX=enforcing # or permissive
SELINUXTYPW=targeted

Then run the commands

touch /.autorelabel
reboot
7
  • in case we want to remove it , so what should be the opposite way ?
    – shalom
    Jan 1, 2019 at 13:54
  • we try restorecon -r /usr/hdp/current/zookeeper-server ( but files or folders with exactly the same permissions ) we also try restorecon -r /usr/hdp , see my update in the question
    – shalom
    Jan 1, 2019 at 13:57
  • we are using OS - redhat 7.2
    – shalom
    Jan 1, 2019 at 14:02
  • we also try restorecon -rF /usr/hdp ( but folder/sub folders/files with the same permissions)
    – shalom
    Jan 1, 2019 at 14:03
  • 3
    Go and read the documentation on SELinux.
    – user9517
    Jan 1, 2019 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .