Tuesday, April 26, 2011

Ubuntu - simple setup after install

0. change root password
su -
passwd root

1. static network
Check the network interface:
ifconfig

Change to static network:

auto eth0
iface eth0 inet static
address 10.1.10.99
netmask 255.255.255.0
network 10.1.10.0
broadcast 10.1.10.255
gateway 10.1.10.1

sudo /etc/init.d/networking restart


2. Install SSH server:
sudo apt-get install openssh-server


3. Disable root logins:
nano /etc/ssh/sshd_config

Change to say "no":
PermitRootLogin no

Save file, exit.
Start up ssh:
/etc/init.d/ssh restart

4. test by logging in from another server:
ssh user@newserver

5. Set up secondary drives using UUID:

sudo mkdir /mnt/d1
sudo mkdir /mnt/d2
sudo mkdir /mnt/d3
sudo mkdir /mnt/d4

Next, we need to list all the drives and mark down the UUID of each drive, and make sure you know which drive is sda1, sdb1, sdc1, and so on.

# list all drives
sudo fdisk -l

# next, list them by uuid
ls -l /dev/disk/by-uuid/

Edit fstab and start adding entries. For each drive, copy and paste its UUID and associate it with a mount point, ex: /mnt/d1, etc.

sudo nano /etc/fstab

# sda1
UUID=ba20caf8-6ef0-42e7-9e45-4187bfa8e543 /mnt/d1 auto defaults 0 2
# sdb1
UUID=315310c3-b3f2-4092-a7fa-eb944084e335 /mnt/d2 auto defaults 0 2
# sdc1
UUID=e041f16e-a009-4390-97f9-2daf29c0c505 /mnt/d3 auto defaults 0 2
# sdd1
UUID=2a236394-5010-4742-9ef8-1a5b2d1b74fa /mnt/d4 auto defaults 0 2

Save fstab file, close it.

Mount all file systems in /etc/fstab, run:
sudo mount -a
(fix any errors, try again, until it works)

List all drive contents,
ls /mnt/d1
ls /mnt/d2
ls /mnt/d3
ls /mnt/d4

I personally create directories on each drive so that I can identify the drives later. For example, on the root of each drive, I create a directory such as: "this_is_drive_1"

6. set up Samba

#Install samba - for network file sharing
sudo apt-get install samba

#create group
sudo groupadd samba

#create a system user who should have samba access
sudo adduser sambauser

#add this user to the samba group
sudo usermod -a -G samba sambauser

# add the user who can access samba shares
sudo smbpasswd -a sambauser
(enter their password)

#edit conf file
sudo nano /etc/samba/smb.conf

# my drives
[d1]
comment = This is the /d1 shared drive
path = /mnt/d1
browseable = yes
read only = no
guest ok = no
writable = yes
admin users = sambauser
write list = sambauser
create mask = 0775
directory mask = 0775
public = yes

[d3]
comment = This is the /d3 shared drive
path = /mnt/d3
browseable = yes
read only = no
guest ok = no
writable = yes
admin users = sambauser
write list = sambauser
create mask = 0775
directory mask = 0775
public = yes


Save the file.

#restart samba
sudo service smbd restart

# list the shares from another PC (from Windows, start, run \\IP_of_server)
smbclient --username=sambauser -L 10.1.10.99
(you should see the drives being listed)