Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was resetting permissions on /var/www and screwed it up!

Now I get frequent problems connecting to mysql, using the package manager because /var has fairly open permissions.

Anyone know if /var is a fairly blanket

sudo chmod -R 700 *

Help!

share|improve this question
    
You will ruin your system if you do that. –  chris Aug 5 '09 at 13:43
add comment

2 Answers

up vote 3 down vote accepted

Most directories should be 755 and owned by root. Sadly not everything should be that. If you do a recursive permission change, you will do significantly more damage. On my machine, I have:

mojo-jojo david% sudo find /var -type d ! -perm 755 -ls
278532    4 drwxrwsr-x   2 root     staff        4096 Oct 20  2008 /var/local
286930    4 drwx-wx--T   2 root     crontab      4096 Sep  9  2008 /var/spool/cron/crontabs
286848    4 drwxrwx--T   2 daemon   daemon       4096 Jul 10  2008 /var/spool/cron/atspool
286849    4 drwxrwx--T   2 daemon   daemon       4096 Oct 21  2008 /var/spool/cron/atjobs
319499    4 drwx--x---   3 root     lp           4096 Oct 21  2008 /var/spool/cups
319500    4 drwxrwx--T   2 root     lp           4096 Oct 20  2008 /var/spool/cups/tmp
352575    4 drwxr-x---   5 Debian-exim Debian-exim     4096 Mar 28 09:03 /var/spool/exim4
352624    4 drwxr-x---   2 Debian-exim Debian-exim     4096 Aug  5 07:02 /var/spool/exim4/msglog
352622    4 drwxr-x---   2 Debian-exim Debian-exim     4096 Dec 14  2008 /var/spool/exim4/db
352623    4 drwxr-x---   2 Debian-exim Debian-exim     4096 Aug  5 07:02 /var/spool/exim4/input
279126    4 drwxrwsr-x   2 libuuid  libuuid      4096 Oct 21  2008 /var/lib/libuuid
352603    4 drwxrwx---   2 logcheck logcheck     4096 Oct 22  2008 /var/lib/logcheck
320214    4 drwxrwx---   2 root     polkituser     4096 Oct 21  2008 /var/lib/PolicyKit
352614    4 drwxrwxr-x   2 munin    munin        4096 May  3 09:05 /var/lib/munin/plugin-state
270524    4 drwx------  10 postgres postgres     4096 Jul 29 04:07 /var/lib/postgresql/8.3/main
270533    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_twophase
270540    4 drwx------   7 postgres postgres     4096 Dec 13  2008 /var/lib/postgresql/8.3/main/base
1106278    4 drwx------   2 postgres postgres     4096 Dec 18  2008 /var/lib/postgresql/8.3/main/base/pgsql_tmp
311894    4 drwx------   2 postgres postgres     4096 Jul 29 04:07 /var/lib/postgresql/8.3/main/base/11511
270542    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/base/1
270937    4 drwx------   2 postgres postgres     4096 Mar 28 09:29 /var/lib/postgresql/8.3/main/base/16385
311320    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/base/11510
270543    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_tblspc
270527    4 drwx------   2 postgres postgres     4096 Aug  5 08:32 /var/lib/postgresql/8.3/main/global
270528    4 drwx------   3 postgres postgres     4096 Dec 17  2008 /var/lib/postgresql/8.3/main/pg_xlog
270529    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_xlog/archive_status
270535    4 drwx------   4 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_multixact
270538    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_multixact/offsets
270536    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_multixact/members
270532    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_subtrans
270530    4 drwx------   2 postgres postgres     4096 Dec 12  2008 /var/lib/postgresql/8.3/main/pg_clog
321312    4 drwxrwx--T   3 root     gdm          4096 Jul 29 08:17 /var/lib/gdm
1729012    4 drwx------   2 mysql    mysql        4096 Feb  3  2009 /var/lib/mysql/newforms_sess
1728971    4 drwx------   2 mysql    mysql        4096 Feb 16 21:38 /var/lib/mysql/newforms
369895    4 drwxrwxr-x   3 root     tomcat6      4096 Dec 17  2008 /var/lib/tomcat6/webapps
270506    4 drwxr-x---  15 root     root         4096 Apr 25 11:50 /var/lib/puppet/clientbucket
271123    4 drwxrwx---   3 root     root         4096 Apr 18 13:51 /var/lib/puppet/clientbucket/*
270483    4 drwxrwx--x   6 root     root         4096 Mar 28 19:21 /var/lib/puppet/ssl
270490    4 drwxr-x---   2 root     root         4096 Mar 28 19:21 /var/lib/puppet/ssl/private_keys
270488    4 drwxr-x---   2 root     root         4096 Mar 28 19:21 /var/lib/puppet/ssl/private
270481    4 drwxr-xr-t   2 root     root         4096 Aug  5 08:18 /var/lib/puppet/state
534313    0 drwx------   3 root     Domain Users       60 Jul 29 21:30 /var/run/sudo
534314    0 drwx------   2 root     Domain Users      100 Aug  5 08:32 /var/run/sudo/david
  9242    0 dr-x--x--x   2 lp       lpadmin        40 Aug  5 07:43 /var/run/cups/certs
  8006    0 drwxrwxrwt   2 puppet   puppet         60 Aug  2 07:43 /var/run/puppet
  7877    0 drwxr-x---   2 root     winbindd_priv       60 Aug  2 08:26 /var/run/samba/winbindd_privileged
  7463    0 drwxr-x---   2 Debian-exim Debian-exim       60 Jul 29 04:07 /var/run/exim4
  6880    0 drwxrwsr-x   2 postgres postgres      100 Jul 29 04:07 /var/run/postgresql
  6172    0 drwxrwx---   2 root     polkituser       40 Jul 29 04:07 /var/run/PolicyKit
  6016    0 drwxrwxr-x   2 root     utmp           40 Jul 29 04:07 /var/run/screen
278583    4 drwxrwsr-x   2 root     mail         4096 Oct 21  2008 /var/mail
327995    4 drwxrwxrwt   2 root     root         4096 Apr  9 07:35 /var/crash
278535    4 drwxrwxrwt   2 root     root         4096 Aug  2 10:34 /var/tmp
  2878    0 drwxrwxrwt   4 root     root          100 Aug  5 07:43 /var/lock
320430    4 drwxrwxr-x   4 root     lp           4096 Mar 28 09:12 /var/cache/cups
320432    4 drwxrwxr-x   2 root     lp           4096 Oct 20  2008 /var/cache/cups/rss
278548    4 drwx------   2 root     root         4096 Aug  5 08:30 /var/cache/ldconfig
271257    4 drwx------   2 tomcat55 adm          4096 Nov 18  2008 /var/cache/tomcat5.5
287018    4 drwxr-sr-x  44 man      root         4096 Aug  5 07:43 /var/cache/man
287178    4 drwxr-sr-x   2 man      root         4096 Aug  5 07:43 /var/cache/man/*
541847    4 drwxr-x---   3 tomcat6  adm          4096 Jun 20 18:43 /var/cache/tomcat6
327693    4 drwxrwsr-t   2 root     admin        4096 Oct 21  2008 /var/cache/jockey
352620    4 drwxr-s---   2 Debian-exim adm          4096 Aug  5 07:43 /var/log/exim4
328117    4 drwxr-x---   3 root     adm          4096 Aug  2 07:43 /var/log/samba
353025    4 drwx------   3 root     root         4096 Oct 22  2008 /var/log/samba/cores
353026    4 drwx------   2 root     root         4096 Oct 22  2008 /var/log/samba/cores/winbindd
279487    4 drwxr-sr-x   2 news     news         4096 Oct 21  2008 /var/log/news
352612    4 drwxr-x---   2 munin    adm          4096 Aug  5 07:43 /var/log/munin
311823    4 drwxrwxr-t   2 root     postgres     4096 Aug  2 07:43 /var/log/postgresql
288323    4 drwxr-x---   2 tomcat55 adm          4096 Aug  4 07:52 /var/log/tomcat5.5
328912    4 drwxr-x---   2 root     adm          4096 Aug  2 07:43 /var/log/apache2
328064    4 drwxr-s---   2 mysql    adm          4096 Jan 29  2009 /var/log/mysql
369892    4 drwxr-x---   2 tomcat6  adm          4096 Aug  4 07:52 /var/log/tomcat6
294961    4 drwxr-x---   2 puppet   puppet       4096 Aug  2 07:43 /var/log/puppet

There will be many more files with different permissions. Hopefully this gives you some idea of what to fix.

share|improve this answer
add comment

You say package manager, I'm guessing you're running Ubuntu? Unfortunately, if you're running an apt-based distro, then you'll have to do it manually like David states.

If you're running an RPM-based distro, you can do this:

for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done

That's one of the few advantages RPM has over deb/apt.

share|improve this answer
    
I did it manually. It took ages. –  Stewart Robinson Aug 6 '09 at 10:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.