Difference between revisions of "Ubuntu Quick Guides"
From Teknologisk videncenter
Computerkim (talk | contribs) |
Computerkim (talk | contribs) |
||
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> | ||
− | + | [http://www.howtoforge.com/linux_lvm Read more} | |
Revision as of 11:54, 3 May 2012
Contents
Formating/mounting a new harddisk
- Find your harddisk
ls /dev/
Note: sd<letter> is harddisks, and sd<letter><number> is partitions.
- Enter your disk with fdisk
sudo fdisk /dev/sd<letter>
- Create your partitions
usem
for helpn
to create a partitionst
to change partition type
- When you have created your partition, exit with
w
to save and exit
- Format the new partition
mkfs -t <filesystem, eg. ext4> <device, eg. /dev/sdb1>
- Get the uuid of your partition
ls -l /dev/disk/by-uuid
- 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
- Mount the partitions
mount -a
LVM
- Install LVM2
sudo apt-get install lvm2
- Create at least 2 Linux LVM (8e) partitions with fdisk
- Create the LVM partitions
pvcreate <partition 1> <partition 2>
Note: more partitions can be added -pvcreate <partition 1> <partition 2> <partition 3>
- Create a volume group for the partitions
vgcreate <name> <partition 1> <partition 2>
- Create a logical volume for the volume group
lvcreate --name <name> --size <size, eg. 10G or 20M> <volume group name>
- Format the volume with a filesystem
mkfs -t <filesystem, eg. ext4> /dev/<volume group name>/<logical volume name>
- You can now mount it to a path
[http://www.howtoforge.com/linux_lvm Read more}
Install samba file server (create network shares)
- Install samba
sudo apt-get install samba
- Enter the sudo nano /etc/samba/smb.conf file
sudo nano /etc/samba/smb.conf
- 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
- Save and exit
- Reload samba
sudo /etc/init.d/samba reload
Making shares open
- Enter the sudo nano /etc/samba/smb.conf file
sudo nano /etc/samba/smb.conf
- Find the line security = guest and replace it with security = share
- Save and exit
- Reload samba
sudo /etc/init.d/samba reload
Install openssh-server (cli remote control)
- Install openssh server
sudo apt-get install openssh-server
- You can now access your server via ssh (with eg. putty)
Create your own certificate
- Generate keys for the Certificate Signing Request (CSR)
openssl genrsa -des3 -out server.key 2048
- 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
- Create the CSR
openssl req -new -key server.key -out server.csr
- Create the self-signed certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
- Install the certificate
sudo cp server.crt /etc/ssl/certs
sudo cp server.key /etc/ssl/private
Setting up static ip
- Enter the /etc/network/interfaces file
sudo nano /etc/network/interfaces
- Change iface eth0 inet dhcp to iface eth0 inet static
- 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
- Restart networkworking and that's it
sudo /etc/init.d/networking restart
Update ubuntu
- To update your server, run this command
sudo aptitude update && sudo aptitude safe-upgrade && sudo do-release-upgrade
Install mediawiki
- 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
- Enter the /etc/mediawiki/apache.conf file
sudo nano /etc/mediawiki/apache.conf
- remove # from the line #Alias /mediawiki /var/lib/mediawiki
- Save and exit
- Restart apache2
sudo /etc/init.d/apache2 restart
- go to http://<server address>/mediawiki and run the configuration
- Rename the old configuration
sudo mv /var/lib/mediawiki/LocalSettings.php /var/lib/mediawiki/LocalSettings.php.backup
- Insert the new configuration
sudo cp /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki/LocalSettings.php
- You can now access your new mediawiki webpage by going to http://<server address>/mediawiki
Install php
- Install php
sudo apt-get install php5
- PHP should now be installed.
Install phpmyadmin
- Install phpmyadmin
sudo apt-get install phpmyadmin
- You can now access phpmyadmin via http <server address>/phpmyadmin
Install wordpress
- To install wordpress. Run this command and follow the instructions
sudo apt-get install apache2 mysql-server php5 php5-gd php5-mysql wordpress
- Make a symbolic link so that Apache2 knows where to find the installation folder
sudo ln -s /usr/share/wordpress /var/www/wordpress
- Then install WordPress using the supplied script
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost
- Add the line the line ServerName localhost to the file /etc/apache2/httpd.conf
sudo nano /etc/apache2/httpd.conf
- Restart apache
sudo /etc/init.d/apache2 restart
- Change the permissions of the wordpress folder
sudo chmod -R 777 /var/www/wordpress
- Delete the wordpress configuration file
sudo rm /var/www/wordpress/wp-config.php
- Run the wordpress configuration, open a webbrowser and go to http://<server address>/wordpress/wp-admin/install.php
Note: mysql user should be root
- You can now access your new wordpress webpage by going to http://<server address>/wordpress
Install apache (web server)
- To install apache2 run this command
sudo apt-get install apache2
- That's it! You can now create your webpage in the /var/www folder
Using your own certificate
- Now we have to edit the https site to use your certificate, enter the https site.
sudo nano /etc/apache2/sites-available/default-ssl
- 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
- Save the changes
- Restart apache
sudo service apache2 restart
- Your server should now use the certificate you have created.
Make you http site redirect to your https site
- Enter your site file
sudo nano /etc/apache2/sites-available/default
- Under the line
<VirtualHost *:80>
insert the line
Redirect permanent / https://<server address>/
- Restart apache
sudo service apache2 restart
- Http requests should now be redirected to https
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