This blog post will also give you understanding of the vi editor. It's not a bad idea to read up on some of the basic commands before starting out, although the commands you need to know will be described..
Create a User and Add it to Sudoers
[root@centos66 ~]# useradd johan
[root@centos66 ~]# passwd johan
to create and then set password for the user. But maybe change the username "johan" for something else. Make sure that the new user can get root privileges when requested, by executing
[root@centos66 ~]# visudo
This will open the sudoers file in the vi text editor. If you are not familiar with the vi/vim editor, it can appear somewhat strange. But just use the down-arrow button and scroll down the file, until you find a line which says
root ALL=(ALL) ALL
Put the cursor on the "r" in "root", that is, the first character of that line, and press the letter o on your keyboard. This will open a new line under the existing row, and on the bottom of the screen it says "--INSERT-", to indicate that you're in insert/edit mode. Type
johan ALL=(ALL) ALL
But exchange "johan" for the username that you selected earlier. Please note: Using Tab is preferred for separating the three fields. Once done, press the Esc-button to leave the edit mode, and "--INSERT--" will disappear from the screen. To save the changes and leave the editor, type ":wq" ( that is, colon-w-q) and press enter. It will take you back to the command line. This may feel like a lot of awkward command just to edit a text file, but vi/vim is a very useful text editor when you get to know it better!
You now have a user which can elevate to root privileges with the somewhat magical "sudo" command.
First disable it for the current session
[root@centos66 ~]# setenforce 0
Then disable it permanently (will take affect after next reboot). by editing th file /etc/sysconfig/selinux, and change "SELINUX=enforcing" to "SELINUX=disabled"
You can use the "vi" editor to update the file:
[root@centos66 ~]# vi /etc/sysconfig/selinux
Use the down-arrow until you get to the line which you should change, and press the a button (append information to the line). The editor will show that you are in edit mode again, by prompting "--INSERT--" at the bottom of the screen. Now you can use the arrow-keys to navigate, use delete/backspace to remove text from the line, and type in the new data. When done, press ESC-w-q-Enter to leave Edit-mode, Write and Quit the editor.
To edit the file, use the vi editor again, and use what you learned in the previous step, about changing the value of a line.
[root@centos66 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
To enable the network card for this session, execute
[root@centos66 ~]# ifup eth0
By default, you will get a NATed IP-address, meaning that your server can access the internet, but cannot accept connections _from_ the internet. This is usually sufficient for testing web applications
To verify that you have got internet access, you can ping something on the internet
[root@centos66 ~]# ping ping.sunet.se
Press Ctrl-C to break the ping program. The output should be something similar to the image below
Add EPEL Repository
You install a RPM which contains the repository information, by:
[root@centos66 ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
This assumes that you installed the 64-bit version of CentOS 6.6 in Step 2, for 32-bit versions, use
Update the Server
[root@centos66 ~]# yum update
This can take a little while. On my demo-server, i had 48 applications to update, with a total of 81 MB to download. A suitable time to fetch another cup of coffee or tea. There was probably a new kernel downloaded and installed by the operation, so once finished it's a good idea to restart the server
[root@centos66 ~]# reboot
After the reboot, it's a good idea to check that the network now is enabled automatically at start, execute:
[root@centos66 ~]# ifconfig
You should see a "eth0" section, similar to the picture below. You can also try the ping command again, to verify.
To set your server to UTC-time, you just need to change the timezone link "/etc/localtime". See image below for instructions.
Set System Clock to UTC
Reduce Swap Profile
So you should tell the operating system to take it easy with the swapping (that is, memory/disk-operations). CentOS comes with a swappiness value set to 60 by default. This can be demonstrated by
[root@centos66 ~]# cat /proc/sys/vm/swappiness
You should not change this to 0, as this could have some bad consequences, but instead set it to 1, by executing:
[root@centos66 ~]# echo 1 > /proc/sys/vm/swappiness
You can verify the change by:
[root@centos66 ~]# cat /proc/sys/vm/swappiness
[root@centos66 ~]# yum install man mlocate telnet wget curl nc
If you want to know what these applications actually do, you can use the "info" mode of the yum program, e.g.,
[root@centos66 ~]# yum info mlocate
In Part 4, we will install the VirtualBox Guest Additions, which are needed to communicate between your computer and the virtual instance.