Category: CLI

How to configure the NFS server and mount NFS shares (Xubuntu 14.04)

NFS Server

Just one package to install:

apt-get update
apt-get install nfs-kernel-server

Create the folder which we want to share

mkdir /srv/nfs

Change the ownership of the folder in order to limit the rights of the client:

chown nobody:nogroup /srv/nfs

PS: do not share the /home directory because it will cause a massive permissions problem.

Now we have to inform the NFS server about what we what to share:

nano /etc/exports

and add the sharing point /srv/nfs:

[...]
/srv/nfs          *(rw,no_root_squash,async,no_subtree_check)

or in case we want to limit the share to a single client with IP=192.168.0.100:

[...]
/srv/nfs          192.168.0.100(rw,no_root_squash,async,no_subtree_check)

Next update the NFS table with the new sharing point

exportfs -rav

Finally start the NFS service:

service nfs-kernel-server start

 

NFS Client

Just one package to install:

sudo apt-get update
sudo apt-get install nfs-common

create the NFS mount point:

sudo mkdir -p /mnt/nfs

Next mount the NFS shared folder:

sudo mount -t nfs 192.168.0.80:/srv/nfs /mnt/nfs/

Now we are connected with the NFS share, we will crosscheck it as follows:

mount -t nfs
192.168.2.80:/srv/nfs on /mnt/nfs type nfs (rw,vers=4,addr=192.168.2.80,clientaddr=192.168.2.100)
Permanent NFS mounting

Add the NFS share in /etc/fstab file

 nano /etc/fstab

with:

 [...]
 192.168.0.80:/ /mnt/nfs nfs defaults 0 0

Recursively delete all files with a given extension

Example: I want to delete all .xmp files recursively:

find . -type f -name '*.xmp' -delete

Example: I want to delete any file or directory which contains .tmp in their names recursively:

find . -name '.tmp' -delete

Xubuntu: how to create a local repository

I had the necessity to create a local repository in order to handle the upgrade of local packages, as if they were from official repositories.
 
Create your own repository folder

sudo su
mkdir /usr/local/packages

 
Create and edit the script file which will upgrade the packages’ list every time we add a new one

touch packages_list_upgrade.sh
cat packages_list_upgrade.sh
 
#!/bin/sh
DIR="."
# open each .deb file and create a zipped list file
CMD="dpkg-scanpackages $DIR | gzip > $DIR/Packages.gz"

eval $CMD
chmod +x packages_list_upgrade.sh

 
Update /etc/apt/source.list with the new location

echo "deb file:/usr/local packages" >> /etc/apt/source.list

 
Copy your packages into the folder and run the script

./packages_list_upgrade.sh

 
Now you can install/remove/manage your local packages using command line or through Synaptic

How to copy SSH public key to remote host

Recently I found a fast method to move a ssh pub key to the remote host without using scp. Simply:

ssh-copy-id -i <my_sshkey.pub> <login>@<ip_host>

Example:

ssh-copy-id -i mykey_rsa.pub cesare@192.168.0.100

If you need to copy the default id_rsa key omit the -i option:

ssh-copy-id cesare@192.168.0.100

 

WordPress Themes