Join the community today
Register Now

Sysadmin Urgent : Messed up permissions - any solution ?

Discussion in 'System Administration' started by harryneopotter, Aug 12, 2017.

  1. harryneopotter

    harryneopotter Member

    70
    3
    8
    Aug 16, 2015
    Ratings:
    +8
    Local Time:
    2:30 PM
    Nginx 1.9.3
    MariaDB 10.0
    Hi,

    So a friend created a mess, by running :

    chown -R nginx .*

    in /root directory

    then to fix it, he ran

    chown -R root .*

    in the same directory.

    Now nothing works. Any solution apart from reinstalling it all again ?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,626
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,307
    Local Time:
    7:00 PM
    Nginx 1.13.x
    MariaDB 5.5
    Ouch you're screwed. Only 100% sure way of fixing is reinstalling again unfortunately :(

    a little trick in future to minimise the mess is if you are manually typing commands is to also change into the directory you're targetting first before running chmod, chown, rm, etc commands and using full path to file or directory you want to delete/chown/chmod etc

    i.e. need to delete contents in /home/nginx/domains/domain.com/public/dir1

    instead of
    Code (Text):
    rm -rf /home/nginx/domains/domain.com/public/dir1/*
    

    or
    Code (Text):
    cd /home/nginx/domains/domain.com/public/dir1/
    rm -rf *
    

    do instead
    Code (Text):
    cd /home/nginx/domains/domain.com/public/dir1
    rm -rf /home/nginx/domains/domain.com/public/dir1/*
    

    also use command to list your present working directory always before running commands
    Code (Text):
    pwd
    

    this tells you were you are directory wise right now so to double check you are running commands in right place

    when you first log into server, pwd command will give you = /root location
    Code (Text):
    pwd
    /root
    

    change into /usr/local/src/centminmod and run pwd will give you = /usr/local/src/centminmod present working directory
    Code (Text):
    cd /usr/local/src/centminmod
    pwd
    /usr/local/src/centminmod
    
     
    Last edited: Aug 12, 2017
    • Like Like x 1
    • Agree Agree x 1
  3. Jimmy

    Jimmy Premium Member Premium Member

    1,146
    253
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +615
    Local Time:
    4:00 AM
    1.13.x
    MariaDB 10.1.x
    Ouch. The power of the command line.
     
    • Like Like x 1
  4. eva2000

    eva2000 Administrator Staff Member

    30,626
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,307
    Local Time:
    7:00 PM
    Nginx 1.13.x
    MariaDB 5.5
    indeed it is, getting into habit of using pwd command first as second nature will save your bacon most of the times :)
     
    • Like Like x 1
  5. harryneopotter

    harryneopotter Member

    70
    3
    8
    Aug 16, 2015
    Ratings:
    +8
    Local Time:
    2:30 PM
    Nginx 1.9.3
    MariaDB 10.0
    Thanks a lot. but it was more like "press up key for the previous command entered and press enter" scenario. Wanted to do "nprestart" instead did this mess.

    Anyway, we did reinstall and restored from the backup, no harm done, except wasted a few hours.

    :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,626
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,307
    Local Time:
    7:00 PM
    Nginx 1.13.x
    MariaDB 5.5
    ah yes - train yourself to wait a few seconds between up/down arrow keys to let the command that you scroll to to settle. Sometimes there could be lag between the next entry showing up especially you you git up/down arrow keys many times successively.