Friday, August 22, 2014

create a samba share and user

I found a lot of posts intended to explain how to create a samba share and user that would work even connecting from a Windows box. Unfortunately lot of these tuto's simply do not work.

I was able to do the job this way:

#this creates the user in linux
sudo useradd -s /bin/true (username)

#this will prompt you for a password
sudo smbpasswd -L -a (username)

#this enables the user
sudo smbpasswd -L -e (username)

#creates new samba user
sudo smbpasswd -a (username)

#add username to smbusers file
sudo nano /etc/samba/smbusers
(linuxusername) = '(username)'

#restart samba
sudo restart smbd
sudo restart nmbd
#Then create a samba share:

path = /path/to/share
read only = no
writable = yes
guest ok = no
create mask = 0755
directory mask = 0755
valid users = username

#Where the username is the username just above created

Friday, May 2, 2014

Scheduled updates with cron job

If you want to install updates on a server you may want it done at night when users are sleeping (hopefully).

That is not that difficult with a shell script and a cron job. The shell script takes care of calling all the update commands and the cron job schedules the executing and log the output to a custom log file.

First the shell script:

echo "\nUpdate on: $(date)\n"
echo 'Update the packages list\n'
sudo /usr/bin/apt-get update >> /dev/null 2>&1
echo '\nUpgrade to latest package version\n'
sudo /usr/bin/apt-get upgrade --yes
echo '\nUpgrade the distribution\n'
sudo apt-get dist-upgrade --yes
echo '\nCleanup\n'
sudo /usr/bin/apt-get autoremove --yes
sudo /usr/bin/apt-get autoclean --yes
sudo /usr/bin/apt-get clean --yes
# The End

The script executes after all a bit of cleanup.

Put the "" script in a folder and make it executable:

$ chmod +x

Now the cron job rule:

open crontab as root:

$ sudo crontab -e

Add a line to call the "" script:

30 4 3 5 *  /home/administrator/ > /home/administrator/myupdates.log

In the line above I call the "" in my administrator folder at 04:30 on May the 3rd. The output of the script will be sent to "myupdates.log" file.

After the job is executed you can check the log file and comment out the line in crontab with a #

I hope it is useful to you.