# File system root directory files



## quicktrick (Sep 28, 2017)

Hello!  Sorry for a newbie question.  Is it normal that I have these files in my file system root directory '/':


```
-rw-r--r--   1 root  wheel          957 Jul 21 05:11 .cshrc
-rw-r--r--   1 root  wheel          249 Jul 21 05:11 .profile
-rw-------   1 root  wheel         1024 Sep 27 14:31 .rnd
-r--------   1 root  wheel     33554432 Sep 27 17:24 .sujournal
-r--r--r--   1 root  wheel         6199 Jul 21 05:11 COPYRIGHT
```
In fact, I'm especially confused with the files /.cshrc and /.profile  

Are they proper for that location? Or, perhaps, I accidentally forced them to be copied there?  To be honest, I edited /root/.cshrc and /root/.profile to add some aliases, and I couldn't get them to work at first. Now my aliases work fine. But is it possible that something went wrong with that?


----------



## getopt (Sep 28, 2017)

quicktrick said:


> But is it possible that something went wrong with that?


No. They are all ok.


----------



## darcsis (Sep 28, 2017)

As far as I know, these files are normal in the root directory. .cshrc and .profile are actually hard symbolics to /root/.cshrc and /root/.profile respectively (or the other way around? You can use 'ls -i'  to check the i-node number of them. If two files have the same i-node number, they are hard symbolic links). .sujournal is 'soft update journal' I guess. It exists in every UFS partitions (no such files if you use ZFS). COPYRIGHT always lies in the root directory. As for .rnd, I have no idea. I think it is no harm at all.


----------



## SirDice (Sep 29, 2017)

In ancient times root's home directory was /. That's why those files are there. But as darcsis already noted most of them are hardlinks to their respective files in root's current home directory; /root/.


----------



## quicktrick (Sep 29, 2017)

Thanks to everyone!

BTW, I have one more file in the root directory:

/sys

Midnight Commander colors it in red and shows an exclamation mark (!) next to it. It means that this is a stalled symlink (link that points nowhere). That's true, because it points to /usr/src/sys , but there is no such a file or directory in my file system.


----------



## SirDice (Sep 29, 2017)

It shouldn't be there. Perhaps at one time created in an effort to mimic Linux's /sys/ filesystem? It has no purpose on FreeBSD. Have a look at hier(7) for an explanation of the directory structure on FreeBSD.

Edit: Thinking about it, I do believe on old FreeBSD versions /sys was a symlink to /usr/src/sys. Or something like that, memory is a bit fuzzy.


----------



## MarcoB (Sep 29, 2017)

Still have the /sys symlink (to /usr/src/sys) on my system. Afaik it has always been there. If you install the sources the symlink will be ok again.


----------



## SirDice (Sep 29, 2017)

Yeah, you're right. I just checked a few more machines, it's still there. It's not really used though, it has no real purpose anymore.


----------



## MarcoB (Sep 29, 2017)

Long time ago sources were probably on the root filesystem.


----------



## quicktrick (Sep 29, 2017)

I made some further researches  and found the following:

```
root@libra:/# find / -samefile .cshrc
/dev/urandom
/.cshrc

root@libra:/# find / -samefile .profile
/dev/console
/.profile

root@libra:/# cd /root

root@libra:~# find / -samefile .cshrc
/root/.cshrc

root@libra:~# find / -samefile .profile
/root/.profile
```
Then I tried to check it another way:

```
root@libra:/# ls -li .cshrc
8 -rw-r--r--  1 root  wheel  957 Jul 21 05:11 .cshrc

root@libra:/# find / -inum 8
/dev/urandom
/.cshrc

root@libra:/# find / -xdev -inum 8
/.cshrc
```
That means the files /.cshrc and /root/.cshrc  (and /.profile and /root/.profile) are different (won't it make any troubles in the future?).  That is because I edited my /root/.cshrc and now its content differs from /.cshrc

I edited /root/.profile too and saved it a few times but later removed my edits.


----------



## SirDice (Sep 29, 2017)

quicktrick said:


> That means the files /.cshrc and /root/.cshrc (and /.profile and /root/.profile) are different (won't it make any troubles in the future?). That is because I edited my /root/.cshrc and now its content differs from /.cshrc
> 
> I edited /root/.profile too and saved it a few times but later removed my edits.


With source updates and running mergemaster(8) this gets fixed automatically.

(I deleted /.cshrc and ran mergemaster(8))

```
*** There is no installed version of ./.cshrc

  Use 'd' to delete the temporary ./.cshrc
  Use 'i' to install the temporary ./.cshrc

  Default is to leave the temporary file to deal with by hand

How should I deal with this? [Leave it for later] i

   *** Historically BSD derived systems have had a
       hard link from /.cshrc and /.profile to
       their namesakes in /root.  Please indicate
       your preference below for bringing your
       installed files up to date.

   Use 'd' to delete the temporary ./.cshrc
   Use 'l' to delete the existing /root/.cshrc and create the link

   Default is to leave the temporary file to deal with by hand

  How should I handle ./.cshrc? [Leave it to install later]
```


----------



## quicktrick (Sep 29, 2017)

```
root@libra:/# mergemaster

*** Creating the temporary root environment in /var/tmp/temproot
 *** /var/tmp/temproot ready for use
 *** Creating and populating directory structure in /var/tmp/temproot

make: don't know how to make distrib-dirs. Stop

  *** FATAL ERROR: Cannot 'cd' to /usr/src and install files to
      the temproot environment
```
Though /usr/src exists.  I tried it one more time and got almost the same:

```
root@libra:/# mergemaster

*** The directory specified for the temporary root environment,
    /var/tmp/temproot, exists.  This can be a security risk if untrusted
    users have access to the system.

  Use 'd' to delete the old /var/tmp/temproot and continue
  Use 't' to select a new temporary root directory
  Use 'e' to exit mergemaster

  Default is to use /var/tmp/temproot as is

How should I deal with this? [Use the existing /var/tmp/temproot]

   *** Leaving /var/tmp/temproot intact

*** Creating the temporary root environment in /var/tmp/temproot
 *** /var/tmp/temproot ready for use
 *** Creating and populating directory structure in /var/tmp/temproot

make: don't know how to make distrib-dirs. Stop

  *** FATAL ERROR: Cannot 'cd' to /usr/src and install files to
      the temproot environment
```


----------



## quicktrick (Sep 29, 2017)

No, it didn't help.



> The script    uses the owner and group ids that the files are    created    with
> by    /usr/src/etc/Makefile, and file    permissions as specified by the    umask.
> Unified diffs are used by default to display any differences unless you
> choose context diffs.


There is no /usr/src/etc/Makefile on my system.  Only the empty dir  /usr/src

I think it's easier to delete /.cshrc and /.profile manually and make hard links to /root/.cshrc and /root/.profile   If it makes any sense.

*Edit:
*
I made it manually:

```
root@libra:/# find / -samefile .cshrc
/root/.cshrc
/.cshrc
root@libra:/# find / -samefile .profile
/root/.profile
/.profile
```


----------



## SirDice (Sep 29, 2017)

getopt said:


> Mergemaster needs to be run from /usr/src/.


You can run mergemaster(8) from anywhere, I ran it from root's home directory. But you do need to have the full source tree in /usr/src/.


----------



## SirDice (Sep 29, 2017)

quicktrick said:


> I think it's easier to delete /.cshrc and /.profile manually and make hard links to /root/.cshrc and /root/.profile If it makes any sense.


That's basically what mergemaster(8) does, so it should be good. Nothing wrong with creating them by hand.


----------



## quicktrick (Sep 29, 2017)

BTW, I just added to .cshrc one alias to get my external IP in FreeBSD 11 (perhaps, it'll be helpful for someone):

```
alias myip 'drill myip.opendns.com @resolver1.opendns.com | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | head -1'
```
In Linux it's a little simpler to do the same thing:

```
dig +short myip.opendns.com @resolver1.opendns.com
```
or just

```
curl -s ipinfo.io/ip
```
The same in Windows (from command line):

```
nslookup myip.opendns.com. resolver1.opendns.com
```
Just FWIW.


----------



## SirDice (Sep 29, 2017)

The dns/bind-tools port/package has a few of the BIND tools like dig(1) and nslookup(1).


----------



## quicktrick (Sep 29, 2017)

Sure, but I wanted to use built in tools.


----------



## SirDice (Sep 29, 2017)

Yeah, I'm addicted to dig(1). drill(1) is not bad but it's seriously lacking the +short (or similar) option to make it useful for scripts.


----------

