File system root directory files

quicktrick

Member

Reaction score: 1
Messages: 29

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

Code:
-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?
 

darcsis

Member

Reaction score: 10
Messages: 57

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

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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/.
 
OP
Q

quicktrick

Member

Reaction score: 1
Messages: 29

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

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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

Well-Known Member

Reaction score: 117
Messages: 398

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

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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

Well-Known Member

Reaction score: 117
Messages: 398

:) Long time ago sources were probably on the root filesystem.
 
OP
Q

quicktrick

Member

Reaction score: 1
Messages: 29

I made some further researches :) and found the following:
Code:
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:
Code:
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

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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))
Code:
  *** 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]
 
OP
Q

quicktrick

Member

Reaction score: 1
Messages: 29

Code:
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:
Code:
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
 
OP
Q

quicktrick

Member

Reaction score: 1
Messages: 29

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:
Code:
root@libra:/# find / -samefile .cshrc
/root/.cshrc
/.cshrc
root@libra:/# find / -samefile .profile
/root/.profile
/.profile
 
OP
Q

quicktrick

Member

Reaction score: 1
Messages: 29

BTW, I just added to .cshrc one alias to get my external IP in FreeBSD 11 (perhaps, it'll be helpful for someone):
Code:
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:
Code:
dig +short myip.opendns.com @resolver1.opendns.com
or just
Code:
curl -s ipinfo.io/ip
The same in Windows (from command line):
Code:
nslookup myip.opendns.com. resolver1.opendns.com
Just FWIW.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,680
Messages: 39,278

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.
 
Top