Difference between revisions of "Ubuntu Quick Guides"

From Teknologisk videncenter
Jump to: navigation, search
(Created page with "<references /> <h1> Formating/mounting a new harddisk </h1> <ol> <li>Find your harddisk<br /><code>ls /dev/</code><br /><br />Note: <strong>sd<letter></strong> is hard...")
 
Line 13: Line 13:
 
<li>Add uuid and insert the path where to mount in <kbd>/etc/fstab</kbd><br /><code>sudo nano /etc/fstab</code><br /><br />Examble:<br /><samp>UUID=2687047d-f506-40f0-8823-d753c1ef34cd /data ext4</samp><br /><br />
 
<li>Add uuid and insert the path where to mount in <kbd>/etc/fstab</kbd><br /><code>sudo nano /etc/fstab</code><br /><br />Examble:<br /><samp>UUID=2687047d-f506-40f0-8823-d753c1ef34cd /data ext4</samp><br /><br />
 
<li>Mount the partitions<br /><code>mount -a</code>
 
<li>Mount the partitions<br /><code>mount -a</code>
 +
</ol>
 +
  
 
<h1>LVM</h1>
 
<h1>LVM</h1>
Line 23: Line 25:
 
<li>Format the volume with a filesystem<br /><code>mkfs -t <strong>&#60;filesystem, eg. ext4&#62;</strong> /dev/<strong>&#60;volume group name&#62;</strong>/<strong>&#60;logical volume name&#62;</strong></code><br /><br />
 
<li>Format the volume with a filesystem<br /><code>mkfs -t <strong>&#60;filesystem, eg. ext4&#62;</strong> /dev/<strong>&#60;volume group name&#62;</strong>/<strong>&#60;logical volume name&#62;</strong></code><br /><br />
 
<li>You can now mount it to a path<br /><br />
 
<li>You can now mount it to a path<br /><br />
 
+
</ol>
 
<a href="http://www.howtoforge.com/linux_lvm">Read more</a>
 
<a href="http://www.howtoforge.com/linux_lvm">Read more</a>
  
Line 37: Line 39:
 
<li>Insert the new configuration<br /><code>sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php</code><br /><br />
 
<li>Insert the new configuration<br /><code>sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php</code><br /><br />
 
<li>You can now access your new mediawiki webpage by going to http://<strong>&#60;server address&#62;</strong>/mediawiki
 
<li>You can now access your new mediawiki webpage by going to http://<strong>&#60;server address&#62;</strong>/mediawiki
 +
</ol>
 +
 +
  
 
<h1>Install php</h1>
 
<h1>Install php</h1>
Line 42: Line 47:
 
<li>Install php<br /><code>sudo apt-get install php5</code><br /><br />
 
<li>Install php<br /><code>sudo apt-get install php5</code><br /><br />
 
<li>PHP should now be installed.
 
<li>PHP should now be installed.
 +
</ol>
  
  
Line 48: Line 54:
 
<li>Install phpmyadmin<br /><code>sudo apt-get install phpmyadmin</code><br /><br />
 
<li>Install phpmyadmin<br /><code>sudo apt-get install phpmyadmin</code><br /><br />
 
<li>You can now access phpmyadmin via http &#60;server address&#62;/phpmyadmin
 
<li>You can now access phpmyadmin via http &#60;server address&#62;/phpmyadmin
 
+
</ol>
  
  
Line 57: Line 63:
 
<li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br />
 
<li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br />
 
<li>Http requests should now be redirected to https
 
<li>Http requests should now be redirected to https
 
+
</ol>
  
  
Line 75: Line 81:
 
<li>Save and exit<br /><br />
 
<li>Save and exit<br /><br />
 
<li>Reload samba<br /><code>sudo /etc/init.d/samba reload</code>
 
<li>Reload samba<br /><code>sudo /etc/init.d/samba reload</code>
 
+
</ol>
  
  
Line 82: Line 88:
 
<li>Install openssh server<br /><code>sudo apt-get install openssh-server</code><br /><br />
 
<li>Install openssh server<br /><code>sudo apt-get install openssh-server</code><br /><br />
 
<li>You can now access your server via ssh (with eg. putty)
 
<li>You can now access your server via ssh (with eg. putty)
 
+
</ol>
  
  
Line 95: Line 101:
 
gateway 192.168.1.1</samp><br /><br /><br />
 
gateway 192.168.1.1</samp><br /><br /><br />
 
<li>Restart networkworking and that's it<br /><code>sudo /etc/init.d/networking restart</code>
 
<li>Restart networkworking and that's it<br /><code>sudo /etc/init.d/networking restart</code>
 +
</ol>
  
  
  
  
 
<a href="index.html">Index</a>
 
 
<h1>Update ubuntu</h1>
 
<h1>Update ubuntu</h1>
 
<ol>
 
<ol>
 
<li>To update your server, run this command<br /><code>sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade</code><br /><br />
 
<li>To update your server, run this command<br /><code>sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade</code><br /><br />
 
+
</ol>
  
  
Line 118: Line 123:
 
<li>Run the wordpress configuration, open a webbrowser and go to http://<strong>&#60;server address&#62;</strong>/wordpress/wp-admin/install.php<br />Note: mysql user should be root<br /><br />
 
<li>Run the wordpress configuration, open a webbrowser and go to http://<strong>&#60;server address&#62;</strong>/wordpress/wp-admin/install.php<br />Note: mysql user should be root<br /><br />
 
<li>You can now access your new wordpress webpage by going to http://<strong>&#60;server address&#62;</strong>/wordpress
 
<li>You can now access your new wordpress webpage by going to http://<strong>&#60;server address&#62;</strong>/wordpress
 
+
</ol>
  
  
Line 126: Line 131:
 
<li>To install apache2 run this command<br /><code>sudo apt-get install apache2</code><br /><br />
 
<li>To install apache2 run this command<br /><code>sudo apt-get install apache2</code><br /><br />
 
<li>That's it! You can now create your webpage in the /var/www folder
 
<li>That's it! You can now create your webpage in the /var/www folder
 
+
</ol>
  
  
Line 143: Line 148:
 
<li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br />
 
<li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br />
 
<li>Your server should now use the certificate you have created.
 
<li>Your server should now use the certificate you have created.
 
+
</ol>
  
  

Revision as of 12:43, 3 May 2012



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