# I deleted all files from /etc accidentally



## sk8harddiefast (Sep 11, 2010)

As the title sais i made a big mistake!
Also commands like sudo now are not recognized.
How to solve that?
I am afraid is a little serious


----------



## adamk (Sep 11, 2010)

Restore everything from your backups.  You do have backups, right?

Adam


----------



## OH (Sep 11, 2010)

If you have full source available, you could try manually installing /etc from there and then redo your users and other configuration.

Note: I've never had to try it thankfully, but I would think it's possible...


----------



## Dereckson (Sep 11, 2010)

Binary executables are not located in /etc, so if message you got trying software like sudo isn't complaint about missing config files but something like 
	
	



```
command not found
```
, you've also deleted stuff in /usr/local/bin for ports, /bin /usr/bin or /usr/sbin for core utilities.


----------



## sk8harddiefast (Sep 11, 2010)

In /usr/src/etc i have the files but sudo is not working to let me copy them back to /etc
On sudo i take: *sudo: unknown uid: 1001*


----------



## graudeejs (Sep 11, 2010)

use *su*, if you're member of wheel group


----------



## sk8harddiefast (Sep 11, 2010)

Also is not responding.* I take a question: Who are you?*
I rebooted and i tried to use fixit from cd but cannot work because fixit cannot find /etc/fstab


----------



## lme@ (Sep 11, 2010)

Mhh, can you still boot?
If you reach single user mode, you can try this:
`# mount -uw /`
Then mount the partition where /usr/src resides on.
Go to /usr/src
`# make distribution`
Create a new /etc/fstab
Copy /var/backups/groups.bak and /var/backups/master.passwd.bak to /etc.
Run tzsetup(8).
Try to re-create /etc/rc.conf.
And the whole rest of /etc
Sorry to tell you that there's no other way to do that manually.


If you don't reach single user mode, you can do the same with the DVD or big USB image.


----------



## sk8harddiefast (Sep 11, 2010)

> Mhh, can you still boot?


No  I take a mountroot>


> # mount -uw /


returns fstab: /etc/fstab:0: No such file or directory


----------



## aragon (Sep 11, 2010)

lme@ said:
			
		

> Copy /var/backups/groups.bak and /var/backups/master.passwd.bak to /etc.


I think he'll also need to run pwd_mkdb(8) after copying (and renaming) those files into /etc.


----------



## aragon (Sep 11, 2010)

sk8harddiefast said:
			
		

> returns fstab: /etc/fstab:0: No such file or directory


Create a new /etc/fstab.

Oh, I just realised your / will be read only.  Try run the same mount command, but specify the device node too, eg. mount -uw /dev/ad0s1a /


----------



## sk8harddiefast (Sep 11, 2010)

Ok. I copy back /etc but now on boot i take a mountroot> and is not responding. I cannot write nothing


----------



## da1 (Sep 11, 2010)

boot the install CD/DVD and copy the "base" distribution.


----------



## OH (Sep 11, 2010)

sk8harddiefast said:
			
		

> Ok. I copy back /etc but now on boot i take a mountroot> and is not responding. I cannot write nothing



You get that prompt because your /etc/fstab is empty or non-existant.

I hope you filled /etc the right way and not just copied the stuff. I have no idea why (else) that prompt is unresponsive. You should be able to type a question mark to get a list of your drives, then pick the right drive like so:
[cmd=]ufs:ad1s1a[/cmd]
and you're halfway into single user mode.

If the prompt does remain unresponsive, you indeed have to boot from DVD or USB-stick and edit /etc/fstab by hand or you could mount the harddrive in another system and edit /etc/fstab from there. You could probably even install etc this way (provided they are of the same FreeBSD-version) by setting DESTDIR in your make commands.


----------



## Beastie (Sep 11, 2010)

da1 said:
			
		

> boot the install CD/DVD and copy the "base" distribution.


The *base* distribution contains the entire system minus the GENERIC kernel. It would be better to extract it to a third-party location and copy /etc alone using a livefs system.


----------



## psycho (Sep 11, 2010)

wow, how did you managed to delete /etc files? :S


----------



## sk8harddiefast (Sep 11, 2010)

Well i put an * accidently 
I started a new fresh install


----------



## Beastie (Sep 11, 2010)

sk8harddiefast said:
			
		

> I started a new fresh install


*Raises eyebrow*


----------



## aragon (Sep 12, 2010)

The hard knocks are the best lessons.


----------



## gkontos (Sep 12, 2010)

aragon said:
			
		

> The hard knocks are the best lessons.



I remember doing:
[CMD=]#rm -rf[/CMD]
in the root directory once


----------



## UNIXgod (Sep 12, 2010)

can't you just boot into single user mode and run mergemaster.


----------

