How to fix permission problem on Linux and Solaris


This  KB describe how to fix the permission problem on Linux and  Oracle  Solaris. If you made a mistake and changed all permissions of the file under  "/"  you can use this method to fix this problem. Sometimes by mistakes all file permissions get changed and you need to restore file permission. But don't forget only the files will be fixed which installed with  "rpm" and "pkginstall" commands. Other extracted files won't be fixed.

Linux; 

Step 1: How to check rpm file permissions on Linux?

#rpm -qlv openssh-clients-5.3p1-111.el6.x86_64
# rpm -qlv openssh-clients-5.3p1-111.el6.x86_64
-rw-r--r-- 1 root root 2047 May 4 2015 /etc/ssh/ssh_config
-rw-r--r-- 1 root root 65 May 4 2015 /usr/bin/.ssh.hmac
-rwxr-xr-x 1 root root 63552 May 4 2015 /usr/bin/scp
-rwxr-xr-x 1 root root 96328 May 4 2015 /usr/bin/sftp
lrwxr-xr-x 1 root root 5 May 4 2015 /usr/bin/slogin -> ./ssh
-rwxr-xr-x 1 root root 446728 May 4 2015 /usr/bin/ssh
-rwxr-xr-x 1 root root 158920 May 4 2015 /usr/bin/ssh-add
-rwxr-sr-x 1 root nobody 141384 May 4 2015 /usr/bin/ssh-agent
-rwxr-xr-x 1 root root 1402 May 4 2015 /usr/bin/ssh-copy-id
-rwxr-xr-x 1 root root 249752 May 4 2015 /usr/bin/ssh-keyscan
-rwxr-xr-x 1 root root 116784 May 4 2015 /usr/libexec/openssh/ssh-pkcs11-helper
-rw-r--r-- 1 root root 2312 May 4 2015 /usr/share/man/man1/scp.1.gz
-rw-r--r-- 1 root root 4324 May 4 2015 /usr/share/man/man1/sftp.1.gz
-rw-r--r-- 1 root root 14083 May 4 2015 /usr/share/man/man1/slogin.1.gz
-rw-r--r-- 1 root root 2937 May 4 2015 /usr/share/man/man1/ssh-add.1.gz
-rw-r--r-- 1 root root 3242 May 4 2015 /usr/share/man/man1/ssh-agent.1.gz
-rw-r--r-- 1 root root 1056 May 4 2015 /usr/share/man/man1/ssh-copy-id.1.gz
-rw-r--r-- 1 root root 2002 May 4 2015 /usr/share/man/man1/ssh-keyscan.1.gz
-rw-r--r-- 1 root root 14083 May 4 2015 /usr/share/man/man1/ssh.1.gz
-rw-r--r-- 1 root root 11013 May 4 2015 /usr/share/man/man5/ssh_config.5.gz

Step 2: How to set the permission of files extracted with rpm?

# rpm --setperms <RPM_NAME>
# rpm --setperms openssh-clients-5.3p1-111.el6.x86_64

Step 3: How to set the owner and group of files which extracted with rpm?

#rpm --setugids <RPM_NAME>
#rpm --setugids openssh-clients-5.3p1-111.el6.x86_64

**You can check this script to fix permission and owner: group properties on Linux platform for RPM files.

#!/bin/ksh
for i in $(rpm -qa)
do
rpm --setperms $i
rpm --setugids $i
done

Step 4: How to fix wrong permissions on Oracle Solaris?

-Boot  Oracle Solaris on single-user mode with type "boot  -F  failsafe" on ok {}  prompt.

-Mount necessary filesystem. Also root filesystem under  a temporary link like "/a"

mount / /a
mount /usr /a/usr
mount /var/ /a/var
mount /opt /a/opt

#pkgchk -R /a -f

 

 

 

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me