Ubuntu Quick Guides

From Teknologisk videncenter
Jump to: navigation, search



Formating/mounting a new harddisk

  1. Find your harddisk
    ls /dev/

    Note: sd<letter> is harddisks, and sd<letter><number> is partitions.

  2. Enter your disk with fdisk
    sudo fdisk /dev/sd<letter>

  3. Create your partitions
    use m for help
    n to create a partitions
    t to change partition type

  4. When you have created your partition, exit with w to save and exit

  5. Format the new partition
    mkfs -t <filesystem, eg. ext4> <device, eg. /dev/sdb1>

  6. Get the uuid of your partition
    ls -l /dev/disk/by-uuid

  7. Add uuid and insert the path where to mount in /etc/fstab
    sudo nano /etc/fstab

    Examble:
    UUID=2687047d-f506-40f0-8823-d753c1ef34cd /data ext4

  8. Mount the partitions
    mount -a


LVM

  1. Install LVM2
    sudo apt-get install lvm2

  2. Create at least 2 Linux LVM (8e) partitions with fdisk

  3. Create the LVM partitions
    pvcreate <partition 1> <partition 2>

    Note: more partitions can be added - pvcreate <partition 1> <partition 2> <partition 3>

  4. Create a volume group for the partitions
    vgcreate <name> <partition 1> <partition 2>

  5. Create a logical volume for the volume group
    lvcreate --name <name> --size <size, eg. 10G or 20M> <volume group name>

  6. Format the volume with a filesystem
    mkfs -t <filesystem, eg. ext4> /dev/<volume group name>/<logical volume name>

  7. You can now mount it to a path

<a href="http://www.howtoforge.com/linux_lvm">Read more</a>

Install mediawiki

  1. Install apache2, mysql-server, php5, php5-mysql and mediawiki. Run this command and follow the instructions
    sudo apt-get install apache2 mysql-server php5 php5-mysql mediawiki

  2. Enter the /etc/mediawiki/apache.conf file
    sudo nano /etc/mediawiki/apache.conf

  3. remove # from the line #Alias /mediawiki /var/lib/mediawiki

  4. Save and exit

  5. Restart apache2
    sudo /etc/init.d/apache2 restart

  6. go to http://<server address>/mediawiki and run the configuration

  7. Rename the old configuration
    sudo mv /var/lib/mediawiki/LocalSettings.php /var/lib/mediawiki/LocalSettings.php.backup

  8. Insert the new configuration
    sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php

  9. You can now access your new mediawiki webpage by going to http://<server address>/mediawiki


Install php

  1. Install php
    sudo apt-get install php5

  2. PHP should now be installed.


Install phpmyadmin

  1. Install phpmyadmin
    sudo apt-get install phpmyadmin

  2. You can now access phpmyadmin via http <server address>/phpmyadmin


Make you http site redirect to your https site

  1. Enter your site file
    sudo nano /etc/apache2/sites-available/default

  2. Under the line
    <VirtualHost *:80>
    insert the line
    Redirect permanent / https://<server address>/

  3. Restart apache
    sudo service apache2 restart

  4. Http requests should now be redirected to https


Install samba file server (create network shares)

  1. Install samba
    sudo apt-get install samba

  2. Enter the sudo nano /etc/samba/smb.conf file
    sudo nano /etc/samba/smb.conf

  3. Browse to the bottom and create a share

    Example:
    [Share]
    comment = Guest access share
    path = /path/to/dir/to/share
    browseable = yes
    read only = yes
    guest ok = yes



  4. Save and exit

  5. Reload samba
    sudo /etc/init.d/samba reload


Making shares open

  1. Enter the sudo nano /etc/samba/smb.conf file
    sudo nano /etc/samba/smb.conf

  2. Find the line security = guest and replace it with security = share

  3. Save and exit

  4. Reload samba
    sudo /etc/init.d/samba reload


Install ssh (cli remote control)

  1. Install openssh server
    sudo apt-get install openssh-server

  2. You can now access your server via ssh (with eg. putty)


Setting up static ip

  1. Enter the /etc/network/interfaces file
    sudo nano /etc/network/interfaces

  2. Change iface eth0 inet dhcp to iface eth0 inet static

  3. Write your address, netmask and gateway

    Example:
    iface eth0 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1



  4. Restart networkworking and that's it
    sudo /etc/init.d/networking restart



Update ubuntu

  1. To update your server, run this command
    sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade


Install wordpress

  1. To install wordpress. Run this command and follow the instructions
    sudo apt-get install apache2 mysql-server php5 php5-gd php5-mysql wordpress

  2. Make a symbolic link so that Apache2 knows where to find the installation folder
    sudo ln -s /usr/share/wordpress /var/www/wordpress

  3. Then install WordPress using the supplied script
    sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

  4. Add the line the line ServerName localhost to the file /etc/apache2/httpd.conf
    sudo nano /etc/apache2/httpd.conf

  5. Restart apache
    sudo /etc/init.d/apache2 restart

  6. Change the permissions of the wordpress folder
    sudo chmod -R 777 /var/www/wordpress

  7. Delete the wordpress configuration file
    sudo rm /var/www/wordpress/wp-config.php

  8. Run the wordpress configuration, open a webbrowser and go to http://<server address>/wordpress/wp-admin/install.php
    Note: mysql user should be root

  9. You can now access your new wordpress webpage by going to http://<server address>/wordpress


Install apache (web server)

  1. To install apache2 run this command
    sudo apt-get install apache2

  2. That's it! You can now create your webpage in the /var/www folder


Using your own certificate

Openssh-server should be installed before you begin.

  1. Generate keys for the Certificate Signing Request (CSR)
    openssl genrsa -des3 -out server.key 2048

  2. Now create the insecure key, the one without a passphrase, and shuffle the key names
    openssl rsa -in server.key -out server.key.insecure
    mv server.key server.key.secure
    mv server.key.insecure server.key


  3. Create the CSR
    openssl req -new -key server.key -out server.csr

  4. Create the self-signed certificate
    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

  5. Install the certificate
    sudo cp server.crt /etc/ssl/certs
    sudo cp server.key /etc/ssl/private


  6. Now we have to edit the https site to use your certificate, enter the https site.
    sudo nano /etc/apache2/sites-available/default-ssl

  7. Change the following
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    to
    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key

  8. Save the changes

  9. Restart apache
    sudo service apache2 restart

  10. Your server should now use the certificate you have created.


Common commands

  • sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade
    Used to update ubuntu

  • sudo
    Used to run commands as root

  • ls
    Used to show files and folders in a directory

  • mkdir
    Used to make a directory

  • cd
    Used to change the directory you're working in

  • cp
    Used to copy files/directories

  • rm
    Used to delete files/directories

  • mv
    Used to move/rename files/directories

  • locate
    Used to find files/directories

  • adduser
    Used to create a user

  • userdel
    Used to delete a user

  • usermod
    Used to modify a user

  • groupadd
    Used to create a group

  • addgroup
    Used to create a group

  • groupdel
    Used to delete a group

  • delgroup
    Used to delete a group

  • groupmod
    Used to modify a group

  • chmod
    Used to change permissions of a file/directory

  • chgrp
    Used to change the group of a file/directory

  • chown
    Used to change the owner of a file/directory

  • fdisk
    Used to create partitions on a disk

  • mount
    Used to mount partitions

  • blkid
    Used to show where partitions are mounted

  • mkfs
    Used to format a partition

  • vi
    Text editor

  • nano
    Text editor

  • ifconfig
    Used to show interface configuration

  • man
    Used to show the manual of a command