Difference between revisions of "Ubuntu Quick Guides"

From Teknologisk videncenter
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 26: Line 26:
 
<li>You can now mount it to a path<br /><br />
 
<li>You can now mount it to a path<br /><br />
 
</ol>
 
</ol>
<a href="http://www.howtoforge.com/linux_lvm">Read more</a>
+
[http://www.howtoforge.com/linux_lvm Read more}
  
  
Line 62: Line 62:
 
</ol>
 
</ol>
  
<h1>Setting up static ip</h1>
+
<h1>Use static ip</h1>
 
<ol>
 
<ol>
 
<li>Enter the /etc/network/interfaces file<br /><code>sudo nano /etc/network/interfaces</code><br /><br />
 
<li>Enter the /etc/network/interfaces file<br /><code>sudo nano /etc/network/interfaces</code><br /><br />
Line 74: Line 74:
 
</ol>
 
</ol>
  
 
+
<h1>Use static DNS</h1>
 +
<ol>
 +
<li>Enter the /etc/resolv.conf file<br /><code>sudo nano /etc/resolv.conf</code><br /><br />
 +
<li>Edit the domain, search and nameserver to suit your needs<br /><br />Examble:<br /><samp>domain tekkom.local<br />search tekkom.local<br />nameserver 172.16.4.66<br />nameserver 172.16.4.77</samp><br /><br /><br />
 +
<li>Restart networkworking and that's it<br /><code>sudo /etc/init.d/networking restart</code>
 +
</ol>
  
  
Line 82: Line 87:
 
</ol>
 
</ol>
  
 
+
<h1>Install dns server</h1>
 +
<ol>
 +
<li>Install bind9<br /><code>sudo apt-get install bind9</code><br /><br />
 +
<li>That was all, you can see how to configure it on help.ubuntu.com
 +
</ol>
  
 
<h1>Install mediawiki</h1>
 
<h1>Install mediawiki</h1>
Line 95: Line 104:
 
<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>
 
<ol>
 
<li>Install php<br /><code>sudo apt-get install php5</code><br /><br />
 
<li>PHP should now be installed.
 
</ol>
 
 
 
<h2>Install phpmyadmin</h2>
 
<ol>
 
<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
 
 
</ol>
 
</ol>
  
Line 138: Line 132:
  
  
 +
<h2>Enable https</h2>
 +
<ol>
 +
<li>Enable https<br /><code>sudo a2enmod ssl</code><br /><br />
 +
<li>Use default certificate<br /><code>sudo a2ensite default-ssl</code><br /><br />
 +
<li>Restart apache<br /><code>sudo service apache2 restart</code><br /><br />
 +
<li>Https should now be enabled on your server.
 +
</ol>
  
  
 
+
<h3>Using your own certificate</h3>
<h2>Using your own certificate</h2>
 
 
<ol>
 
<ol>
 
<li>Now we have to edit the https site to use your certificate, enter the https site.<br /><code>sudo nano /etc/apache2/sites-available/default-ssl</code><br /><br />
 
<li>Now we have to edit the https site to use your certificate, enter the https site.<br /><code>sudo nano /etc/apache2/sites-available/default-ssl</code><br /><br />
Line 153: Line 153:
 
<ol>
 
<ol>
 
<li>Enter your site file<br /><code>sudo nano /etc/apache2/sites-available/default</code><br /><br />
 
<li>Enter your site file<br /><code>sudo nano /etc/apache2/sites-available/default</code><br /><br />
<li>Under the line<br />&#60;VirtualHost *:80&#62;<br />insert the line<br />Redirect permanent / https://&#60;server address&#62;/<br /><br />
+
<li>Under the line<br />&#60;VirtualHost *:80&#62;<br />insert the line<br />Redirect permanent / https&#58;//&#60;server address&#62;/<br /><br />
 
<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>
 
</ol>
 +
 +
 +
 +
 +
<h2>Install php</h2>
 +
<ol>
 +
<li>Install php<br /><code>sudo apt-get install php5</code><br /><br />
 +
<li>PHP should now be installed.
 +
</ol>
 +
 +
 +
<h3>Install phpmyadmin</h3>
 +
<ol>
 +
<li>Install phpmyadmin<br /><code>sudo apt-get install phpmyadmin</code><br /><br />
 +
<li>You can now access phpmyadmin via http&#58;//&#60;server address&#62;/phpmyadmin
 +
</ol>
 +
 +
 +
 +
 +
<h1>Enable forwarding</h1>
 +
<ol>
 +
<li>Enter the /etc/sysctl.conf file<br /><code>sudo nano /etc/sysctl.conf</code><br /><br />
 +
<li>Remove the <kbd>#</kbd> from the line <kbd>#net.ipv4.ip_forward = 1</kbd><br /><br />
 +
<li>Save and exit<br /><br />
 +
<li>Activate<br /><code>sudo sysctl -p /etc/sysctl.conf</code>
 +
</ol>
 +
  
  

Latest revision as of 12:04, 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

[http://www.howtoforge.com/linux_lvm Read more}


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 openssh-server (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)

Create your own certificate

  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


Use 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

Use static DNS

  1. Enter the /etc/resolv.conf file
    sudo nano /etc/resolv.conf

  2. Edit the domain, search and nameserver to suit your needs

    Examble:
    domain tekkom.local
    search tekkom.local
    nameserver 172.16.4.66
    nameserver 172.16.4.77



  3. 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 dns server

  1. Install bind9
    sudo apt-get install bind9

  2. That was all, you can see how to configure it on help.ubuntu.com

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 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


Enable https

  1. Enable https
    sudo a2enmod ssl

  2. Use default certificate
    sudo a2ensite default-ssl

  3. Restart apache
    sudo service apache2 restart

  4. Https should now be enabled on your server.


Using your own certificate

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

  2. 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

  3. Save the changes

  4. Restart apache
    sudo service apache2 restart

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

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 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



Enable forwarding

  1. Enter the /etc/sysctl.conf file
    sudo nano /etc/sysctl.conf

  2. Remove the # from the line #net.ipv4.ip_forward = 1

  3. Save and exit

  4. Activate
    sudo sysctl -p /etc/sysctl.conf


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