Solved

CentOS File/Directory Permissions Problem

Posted on 2013-01-08
14
554 Views
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
0
Comment
Question by:ws11
  • 5
  • 3
  • 2
  • +2
14 Comments
 
LVL 19

Expert Comment

by:jools
Comment Utility
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.

examples;
sudo chown myuserid:myuserid filename
sudo chmod 755 filename
0
 
LVL 6

Expert Comment

by:g3nu1n3
Comment Utility
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.
0
 

Author Comment

by:ws11
Comment Utility
It appears no matter what level I update I get permission denied or operation not permitted.
0
 

Author Comment

by:ws11
Comment Utility
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 {} \;
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Check the logs and see if you are encountering SELinux access denials.
0
 

Author Comment

by:ws11
Comment Utility
If I am how can I change it?  I don't think I will have permissions to update the conf file.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 31

Expert Comment

by:farzanj
Comment Utility
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
getenforce
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
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.
0
 

Author Comment

by:ws11
Comment Utility
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.
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Did you reboot after changing the SELinux setting?
0
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
Comment Utility
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?
0
 

Author Comment

by:ws11
Comment Utility
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.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now