In part 1 of the CentOS 5.4 setup, we completed the ssh configuration along with a basic iptables setup.
Now let’s run some checks and install some personal configuration files to make life easier. Once done, we can update the install and create a solid base for the ‘meat’ of the server.
OS check
First thing is to confirm what OS we’re using. We know we should be using CentOS but let’s see:
cat /etc/redhat-releaseYou should get an output similar to this:
CentOS release 5.4 (Final)Good.
Using free
Memory usage should be very low at this point but let’s check using ‘free -m’ (the -m suffix displays the result in MB’s which I find easier to read):
free -mIt’s nice to know what is going on so let’s look at that output:
. total used free shared buffers cachedThe line to take notice of is the second one as the first line includes cached memory – in this demo slice I have 254MB memory in total with 30MB actually used, 223MB free and no swap used. Nice.
Mem: 254 55 199 0 2 21
-/+ buffers/cache: 30 223
Swap: 511 0 511
.bash_profile
Let’s make the terminal a bit more attractive and a bit more informative by adding a few lines to our .bash_profile file.
nano ~/.bash_profileAdd the next few lines at the end of the existing text. The following line will make the terminal display the server name in colour and display the working directory (the directory we are in) in a different colour:
export PS1=’\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: ‘Now we can add aliases to the file. Aliases are shortcuts to commands or sequences of commands. I’ve included a few below but you can have as many or as few as you want.
alias free=”free -m”The examples above are pretty simple. Instead of typing ‘free -m’ every time I want to look at the memory usage, I just type ‘free’. Typing ’sudo yum install’ can get tedious, so I just type ‘install’.
alias update=”sudo yum update”
alias install=”sudo yum install”
alias upgrade=”sudo yum upgrade”
alias remove=”sudo yum remove”
I still need to provide my password for the sudo command to work, but it is more productive/quicker/easier to have shortcuts.
To activate the changes enter this command:
source ~/.bash_profileYou should now see the slice name in purple and the working directory in brown.
To change the colours to ones of your choosing, adjust the 0;35m and the 0;33m values in the ‘export PS1′ line of your .bash_profile.
For example:
export PS1=’\[\033[0;32m\]\h\[\033[0;36m\] \w\[\033[00m\]: ‘…would give you a green and blue output.
Set locale
You can check the current locale setting for your slice by running:
localeIf the code doesn’t match what it should be for the localization you would like to use for your slice (or if it uses a generic locale like ‘POSIX’), run something like the following commands:
sudo locale-gen en_US.UTF-8‘Something like’ because you may want to use a locale other than US English. If so, substitute the language code for ‘en’ and the region code for ‘US’ above. The locale ‘cy_GB.UTF-8′ would designate Welsh for the language and Great Britain for the region, for example. A complete list of language and region codes can be found here.
sudo /usr/sbin/update-locale LANG=en_US.UTF-8
If you change the default locale for your slice you will need to log out and log back in to see the change when running ‘locale’ by itself again.
Package repositories
A CentOS Slice comes with a basic set of repositories.
Have a look at the enabled repositories by running:
sudo yum repolist enabledEach repository listed should include a brief description and the number of packages available from that source.
If you’d like to have a look at the configuration files that point to each repository, they’re stored in this directory:
/etc/yum.repos.dIf you look through one of the files there, you will see each repository has a set of definitions including which mirror to use and what gpg key to use (and actually whether to check the package signature at all).
You can, of course, add more repositories whenever you want to but I would just give a word of caution: Some of the available repositories are not officially supported and may not receive any security updates should a flaw be discovered.
Keep in mind it is a server we are building and security and stability are paramount.
Update
Now we can update the package list that yum uses.
The following command will also offer to install any updated packages. As with all installs have a careful look at the list and, once happy, press ‘y’ to continue:
sudo yum updateNOTE: If you have used the .bash_profile aliases shown above you just need to enter ‘update’ as the alias will use the entire command. I’ve put the whole thing here so you know what is happening.
That’s really the basics done for the Slice.
Once any updates have been installed, we can move on to installing some essential packages.
Development Tools
CentOS has some handy meta-packages that include sets of pre-defined programs required for a single purpose.
So instead of installing a dozen different package names, you can install just one meta-package. One such package is called ‘Development Tools’. Issue the command:
sudo yum groupinstall ‘Development Tools’Notice the programs that are to be installed include gcc, make, patch and so on. All these are needed for many other programs to install properly. A neat system indeed.
Enter ‘y’ and install them.
Now we have the necessary packages should we want to build an application from source.
Done
The console is now informative and less drab, locales have been configured and basic compile tools have been installed. Quite a lot happening here but now we have a more secured Slice with updated packages ready for the meat of the server to be put in place.
Tidak ada komentar:
Posting Komentar