[Last Call] Learn how to a build a cloud-first strategyRegister Now


CentOS File/Directory Permissions Problem

Posted on 2013-01-08
Medium Priority
Last Modified: 2013-11-08
Playing around with CentOS to learn how Linux works and the chmod command I now can no longer edit files that I could previously edit.  Is there a way to reset a folder to the initial default settings?  Can you reinstall without having to loose the current setup of applications and files?  Thanks
Question by:ws11
  • 5
  • 3
  • 2
  • +2
LVL 19

Expert Comment

ID: 38755868
I dont have a system in front of me but I believe there was an option in rpm that would reset the permissions, I can have a look later but check out the man page. You will need to run as root so as long as you didnt play with the full system then you should be ok.

It also may depend on what files you edited, you can change single files running chown/chmod from root but you need to be careful. perhaps if you can give an example of what doesnt work we can offer a simple fix.

sudo chown myuserid:myuserid filename
sudo chmod 755 filename

Expert Comment

ID: 38755918
Depending on if you are logged in as root or not, you will want to go to the directory where the files are you're trying to edit and run:
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;

This will fix the permissions on both your files and directories. You may also want to move into the directory above and make sure the permissions are set right.

If you can run the command history and paste the output. That may help us determine what exactly you did.

Author Comment

ID: 38756064
It appears no matter what level I update I get permission denied or operation not permitted.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 38756700
303  cd Public                                                              
  304  dir                                                                    
  305  cd Applications                                                        
  306  cd ..                                                                  
  307  dir                                                                    
  308  cd Applications                                                        
  309  su                                                                    
  310  cd ..                                                                  
  311  su                                                                    
  312  dir                                                                    
  313  su                                                                    
  314  chmod -R 777 *                                                        
  315  cd ..                                                                  
  316  cd..                                                                  
  317  cd ..                                                                  
  318  dir                                                                    
  319  cd var                                                                
  320  dir                                                                    
  321  cd www                                                                
  322  chmod -R 777 *                                                        
  323  cd ..                                                                  
  324  cd var                                                                
  325  cd www                                                                
  326  cd html                                                                
  327  chmod -R 777                                                          
  328  chmod -R 777 *                                                        
  329  cd .                                                                  
  330  cd ..                                                                  
  331  cd var                                                                
  332  cd www                                                                
  333  chmod -                                                                
  334  chmod -R 755 *                                                        
  335  cd html                                                                
  336  chmod -R 755 *                                                        
  337  cd ..                                                                  
  338  dir                                                                    
  339  cd var                                                                
  340  dir                                                                    
  341  cd ..                                                                  
  342  cd etc                                                                
  343  cd vsftpd                                                              
  344  vi vsftpd.conf                                                        
  345  dir                                                                    
  346  vi vsftpd.conf                                                        
  347  chmod -R 777 *                                                        
  348  vi vsftpd.conf                                                        
  349  chmod -rwx 777 *                                                      
  350  chmod -A 777 *                                                        
  351  chmod o=rwx *                                                          
  352  chmod -rwx 777 *                                                      
  353  cd ..                                                                  
  354  chmod -rwx *                                                          
  355  cd var                                                                
  356  chmod -rwx *                                                          
  357  chmod -w *                                                            
  358  chmod 777 var                                                          
  359  cd ..                                                                  
  360  chmod 777 var                                                          
  361  chmod 755  var                                                        
  362  cd opt                                                                
  363  dir                                                                    
  364  cd ..                                                                  
  365  cd etc                                                                
  366  chmod 755 *                                                            
  367  dir                                                                    
  368  cd ..                                                                  
  369  cd var                                                                
  370  cd ..                                                                  
  371  cd etc                                                                
  372  dir                                                                    
  373  cd vsftpd                                                              
  374  dir                                                                    
  375  vi vsftpd.conf
  376  chmod 755 csftpd.conf
  377  chmod 755 vsftpd.conf
  378  chmod -R 777 vsftpd.conf
  379  chmod -R a+w *
  380  cd ..
  381  chmod -R a+w *
  382  cd ..
  383  dir
  384  cd etc
  385  chmod -R a+w *
  386  cd vsftpd
  387  dir
  388  vi vsftpd.conf
  389  chmod -R r+w *
  390  chmod -R r+w .????*
  391  chmod -R 777 *
  392  chmod r+w+x *
  393  chmod -O r+w *
  394  chmod -R a+w *
  395  dir
  396  cd Desktop
  397  cd Music
  398  cd Templates
  399  cd Documents
  400  find . -type f -exec chmod 0644 {} \;
  401  cd ..
  402  find . -type f -exec chmod 0644 {} \;
  403  cd ..
  404  dir
  405  cd var
  406  find . -type f -exec chmod 0644 {} \;
LVL 40

Expert Comment

ID: 38764989
Check the logs and see if you are encountering SELinux access denials.

Author Comment

ID: 38765041
If I am how can I change it?  I don't think I will have permissions to update the conf file.
LVL 31

Expert Comment

ID: 38765206
I think you have played with chmod and chown as the experts above suggested.

Where are you experiencing this issue?  Lets take one directory at a time.  This is the directory under which you cannot edit files any longer.

Issue these command

df -hT /path/of/directory
ls -ld /path/of/directory
getfacl /path/of/directory
LVL 40

Expert Comment

ID: 38765536
Well the first problem is to figure out why you can't modify files. My suspicion, since it appears that you are doing so as root, is that SELinux  is the cause.

Author Comment

ID: 38767712
Prior to this happening I went into the /etc/selinux root and modified the config to SELINUX=disabled.  Is that the problem?

I was troubleshooting why vsftpd would not let me upload files and thought this would be a way to test if the selinux settings were causing this.
LVL 40

Expert Comment

ID: 38767833
Did you reboot after changing the SELinux setting?
LVL 31

Accepted Solution

farzanj earned 1500 total points
ID: 38767849
You have not replied to my post.  I had asked questions to figure out all the possible reasons for this problem.  Are you interested in solving the problem?

Author Comment

ID: 38767926
ok farzanj ran your commands and I went to the selinux config file to edit it and it still will not let me edit the file I used :q!CR and :w!CR and they both returned errors

I have rebooted but not after trying farzanj's recommendation.  I did not see that he mentioned that.

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 9 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question