CentOS

From GeilThings

Jump to: navigation, search
CentOS
General
Version 6.4
Stable 6.4
Function Operating System
Package Manager Yum
Log File /var/log/messages
Scripts
Version Script cat /etc/redhat-release
Centos logo h-5c-a-293.png

CentOS 5.6, 5.7, 5.8, 6.2, 6.3

Contents

General

Books:

iPad, Kindle: CentOS 6.2 Essentials: http://www.amazon.de/CentOS-6-Essentials-ebook/dp/B007MAIXO6/ref=sr_1_5?ie=UTF8&qid=1334342244&sr=8-5

Linux file directory structure:

http://www.pathname.com/fhs/
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

Runlevel

http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-sysv.html#_deploying_a_rack_based_ruby_application
Default runlevel can be found in /etc/inittab
id:3:initdefault:

Administration:

20 Linux System Monitoring Tools Every SysAdmin Should Know - [1]
How to Troubleshoot Your CentOS Linux Server - [2]
Server Monitoring With munin And monit On CentOS 5.2: http://www.howtoforge.com/server-monitoring-with-munin-and-monit-on-centos-5.2
Package Manager: Yum
Firewall: Iptables

Logos:

Centos Logos: http://wiki.centos.org/ArtWork/Logo

Community:

CentOS Mailing Lists: http://www.centos.org/modules/tinycontent/index.php?id=16
IRC: #centos and others; http://www.centos.org/modules/tinycontent/index.php?id=8

Installing CentOS

Install CentOS as a server

Install CentOS as a Virtual Machine under Windows

  • Using VMware Player or Oracle's VirtualBox. As of May 2012, Microsoft's Virtual PC DOES NOT accept 64-Bit Guest operating systems.
  • Minimal .iso:
Problem: "The CentOS disc was not found in any of your drives", after pressing "Test media" (or similar). The installation cannot proceed after the media is tested, so this "Test" step is better to be skipped. See http://www.redwireservices.com/centos-rhel-install-fails-to-find-dvd
Problems with network connection: Solved via https://forums.virtualbox.org/viewtopic.php?f=2&t=17754
ifconfig eth0 up
dhclient eth0
Problem installing the VMware tools: I could not mount the .iso images.
  • Live CD .iso:
Changes are NOT kept between boots. Next reboot will be at the same init level, no root password, installed applications will be gone.
Set default init level to 3 (Nonsense anyway):
In the menu, "Applications / System Tools / Terminal"
On the terminal, su - root
Initially, root has no password on the CentOS Live CD.
vi /etc/inittab
Type i to be able to insert characters in the file
Change level from "5" to "3" in the line id:3:initdefault
Write changes to disc: Esc :w
Leave vi: :q
Change root password:
As root, type
passwd
  • Netinstall .iso:
Downloaded from http://ftp.hosteurope.de/mirror/centos.org/5.8/isos/x86_64/
Skip the Media Test
Type of installation: CentOS 6 URL, CentOS 5 HTTP
CentOS 6.2 URL: Type http://mirror.centos.org/centos/6.2/os/x86_64/
CentOS 5.8: Linux text mode, no VNC mode, Server installation, SELinux (http://wiki.centos.org/HowTos/SELinux) disabled. It kept giving the error message "The CentOS installation tree in that directory does not seem to match your boot media." if using a 5.7 .iso and pointing to a 5.8 URL (e.g. using centos-5/5.8/os/x86_64/ or /centos/5/os/x86_64 or /centos-5/5/os/x86_64/ as CentOS directory). Solution: Download an use a current (5.8 as of 2012-05) .iso file for a CentOS 5 installation.
Web site name: mirror.centos.org
CentOS directory: /centos-5/5/os/x86_64/
CentOS 5.7 Installation: It stalled at "Starting install process..." for almost 3 hrs and then all of a sudden the "installation" started. ???. Others report similar experiences, http://serverfault.com/questions/242957/centos-5-5-remote-kickstart-installation-stalls-at-starting-install-process-h
CentOS 6.2 Installation: Software Development Workstation - It takes ages. Not good. Basic Server Installation: It also took about 2 hrs.
Check:
cat /etc/redhat-release
Update
yum update

Install CentOS as a dual boot option, Desktop

  • Followed the Book CentOS 6.2 Essentials
  • Install samba and samba-client to access Windows network shares (e.g. Windows Home Server) and the windows partition in case of a dual boot system.
  • Configure Nautilus (File browser): Edit / Preferences / Behavior / Check "Always open in browser windows"
  • Add fonts: As root, copy the new font directory (unpack / unzip first) to the /usr/share/fonts/ directory. See http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-x-fonts.html. Restart the graphical program in use so the new font is recognized.
  • Install beesu using yum. Using beesu, graphical applications can be run as root in Gnome. Type "beesu mycommand" in the field "Command" of the Properties of a launcher. Executing the command will start asking for the root password.

Uninstall

Installing CentOS, detailed instructions

+++WORK IN PROGRESS+++

Installing CentOS 6

The easiest way to test CentOS is to rent a machine on the hosting provider of your choice and select CentOS as your operating system. All major hosters have CentOS as part of their offerings. After getting access to a shell, CentOS is already installed and you probably would only need to run „yum update“ to bring CentOS to the current version.

If you want to install CentOS 6 by yourself:

I. Determining your CPU architecture

There are two versions of CentOS, a „i386“ and a „x86_64“ version. The i386 version is for 32-bit CPUs, the x86_64 for 64-bit machines. The x86_64 version cannot be installed for 32-bit processors, the i386 version can be installed for 64-bit processors. A 64-bit operating system can allocate much more RAM memory, is more future proof and has other advantages, however maybe the applications you plan to run on CentOS are better suited for, or only run on a 32-bit operating system; you should consult their administration manuals before deciding for 32-bit or 64-bit.

Essentially, new computers contain 64-bit CPUs; you can determine it:


II. Obtaining the Media

If you plan to install CentOS yourself, you first need a media containing the software. You can obtain a DVD/CD with CentOS from magazines, fairs, etc, or download CentOS from the website:


Now you can select one of the downloads. THEY ARE ALL THE SAME CENTOS, bigger or smaller in download size but nevertheless functional.

  • Live: The „Live“ Versions are restricted in a way so that they run in the memory of your computer and are for testing / rescuing purposes only, ANY CHANGES YOU MAKE ON A LIVE SYSTEM ARE LOST AFTER REBOOT, so if you are planning longer tests, installing software etc DO NOT go for a Live version. See Wikipedia's definition of Live CD/DVDs here: http://en.wikipedia.org/wiki/Live_CD. The LiveCD version contains a minimal set of packages for a functional CentOS, the LiveDVD contains many more packages.
  • Minimal: It has a minimum of packages needed to have a functional system, with no compromise regarding security and fully network and yum aware. Using yum you can add all the packages you need after the installation. Use the minimal installation if you only need a server with a very specific set of features, or if you have troubles with your internet connection or speed.
  • Netinstall: It contains a minimal set of features and will download the rest of the packages from a (later supplied) url. DO NOT use this method if your internet connection breaks from time to time.
  • Bin-DVD1 and 2: This is the whole thing. Go for it if you have a good internet connection or if you are using a BitTorrent client.


A corresponding (Live, bin-DVD, minimal, netinstall) Filename ending in .iso is the image you want to download. Alternatively, you can download the same file from the BitTorrent network (http://en.wikipedia.org/wiki/BitTorrent). For this, download instead the file ending in .torrent and open it with your BitTorrent client, which will then download the .iso file from the BitTorrent network. Use this method if you have a bad (slow or often breaking) internet connection. You should ensure that the files downloaded via BitTorrent are not corrupted via comparing their checksum with the ones supplied in the download directory (corresponding .md5sum.txt, .sha1sum.txt, .sha256sum.txt files). There are different tools for this, see http://en.wikipedia.org/wiki/Checksum#Checksum_tools. Corresponding Pretty Good Privacy (PGP) encrypted files ending in .asc are also supplied; they can be used to verify the authenticity of the checksums.

No matter which distribution you choose, you should run „yum update“ right after the installation finishes to bring your installed packages uptodate.

III. Installing CentOS

You can burn the .iso image to a DVD/CD, or you can use the .iso file directly to install CentOS as a virtual machine using Oracle's VirtualBox (http://www.oracle.com/technetwork/server-storage/virtualbox/overview/index.html) or VMware Player (http://www.vmware.com/products/player/). As of May 2012, Microsoft's Virtual PC DOES NOT accept 64-Bit Guest operating systems.

A description of the installation options (Minimal, Basic Server, ...) can be found in stackoverflow.com: http://bit.ly/JUYfcS

Commands

<command> > filename

Store output from <command> in filename.

<command> >> filename

Append output from <command> in filename.

<command> 2>&1

Redirect stderr (error output) to stdout (standard output).
More: http://www.cyberciti.biz/faq/redirecting-stderr-to-stdout/

<command> &> filename

Redirect stderr (error output) AND the output of <command> to filename.

alias

Show which alias are in place
From http://www.linuxforums.org/forum/red-hat-fedora-linux/27130-how-do-i-get-alias-stick-between-sessions.html
To make alias permanent for all users on the computer, edit the file:
/etc/bashrc
For a specific user, edit the file:
/home/<your current user name>/.bashrc

cat /etc/issue

cat comes from the word concatenate (http://beginnerlinuxtutorial.com/help-tutorial/basic-linux-commands/linux-cat-command/).
Linux distribution name (it does not work for all linuxes; for CentOS it works).

cat /etc/passwd

List users.

cat /etc/redhat-release

CentOS / RedHat distribution

cat /proc/version

Linux version

cd -

Back to the directory where you had been before.

chkconfig --list

List which services start at which runlevels.

chmod +x scriptname

make scriptname executable.

cp -pr /var/www/html/example/* /home/yeysus/example/

Copy; using cp command to copy all files and folders.
From http://www.labtestproject.com/linuxcmd/cp.html
cp command with option 'p' is to preserve the mode, ownership and timestamps of the file; option 'r' is to copy the directory recursively.
cp is a binary and is located in /bin/ (cp will be found via $PATH) value which always ask if I want to overwrite. To avoid answering yes, use /bin/cp -fr

crontab

To run scripts automatically.
crontab -l (list)
crontab -e (edit crontab)
The default crontab for root is in: /var/spool/cron/root
Examples: http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

echo $PATH

About the PATH variable:
http://www.troubleshooters.com/linux/prepostpath.htm

env

List all environment variables. Similar to printenv.

find / -name filename

/ - Start searching at the root directory

grep -r "string to search for" /path/to/search

Finds file in /path/to/search containing "string to search for"

groups <username>

List groups <username> belongs to.

history

Shows the last commands typed in the console.

ldd <file>

List dynamic dependencies; shared library dependencies

lspci -v

List devices, like network cards, wireless adapters, etc.

lsof

List open files. CentOS 6.2: Install it first using yum.

nohup script_name &

To run a script in the background after log out of the session.
Nohup: http://en.wikipedia.org/wiki/Nohup

passwd username

Change password of username.

printenv

Displays environment variables. Similar to env.

pwd

To know in which path I currently am.

rm

Remove file or symbolic link.
e.g. remove symbolic link to directory: rm cassandra (No / at the end!)

/sbin/ifconfig

IP Address.

scp -rp /source/* user@ip-destination-server:/destination

Copy files between two linux machines.
http://docstore.mik.ua/orelly/networking_2ndEd/ssh/ch07_05.htm
http://superuser.com/questions/345347/how-to-copy-a-file-between-two-linux-machines

script-name >>filename.log 2>&1

Redirect both standard output and errors to filename.log

su

Substitute user.
From http://www.linuxquestions.org/questions/red-hat-31/command-not-found-314827/
"su" just emulates a user login but does not set up all the profiles,
"su -" however is like logging in on a terminal, it sets up all the profiles and permissions.
su couchdb -c "command options" executes the script "command" with options "options" as the user "couchdb"
From "Running multiple commands for su in bash"
(http://unix.stackexchange.com/questions/10601/running-multiple-commands-for-su-in-bash)
su galaxy -c "command 1; command 2"

tail <file>

Show last 10 lines of a file.
-f: Waits for new lines and displays them.
-n: Displays the last n lines; default is 10.

uname -a

Linux platform I am running

uname -r

Linux kernel version, e.g. 2.6.18-274.12.1.el5 in CentOS 5.7, yam updated, January 2012.

unset variable

Remove an environment variable

useradd -m username

Create user including home directory.

userdel -r username

Delete a user including deleting her/his home directory.

usermod -d /path/to/new/homedir/ username

Change a user's home directory.

usermod -a -G groupname username

Add a user to a group and keep the older groups to which the user belongs (option "-a").

wc <option> <filename>.

Counts the number of bytes (-c), characters (-m), words (-w), or lines (-l) in filename.
It can be used with pipe like this: ps aux | grep google | wc -l

Utilities

Administration

  • For manipulating and viewing log files: uniq, cut, syslog-ng, rsyslog
  • Boot loader: Grub; configuration: /boot/grub/grub.conf
  • GParted: Resizing / Partitioning Tool

Bash

  • Ctrl-a: Go to the start of the line.
  • Ctrl-e: Go to end of the line.
  • Ctrl-k: Delete until the end of line starting at the current cursor position.

Bash Scripting

Logcheck

  • Used to scan automatically /var/log/messages and /var/log/secure looking for problems; it sends report mails.
  • Configure Logcheck: See ID's Blog: http://zeldor.biz/2010/08/configure-logcheck/
    • Config file: /etc/logcheck/logcheck.conf
    • Crontab config: /etc/cron.d/logcheck
yum install logcheck
 
# To avoid the error:
# /usr/sbin/logcheck: line 100: kill: (3917) - No such process
# see https://bugzilla.redhat.com/show_bug.cgi?id=678436
# add the logcheck user group (adm) to the access rights from both log files AND
# give them read access with chmod 640.
chgrp adm /var/log/messages
chmod 640 /var/log/messages
chgrp adm /var/log/secure
chmod 640 /var/log/secure
 
# To avoid the errors:
# su: PAM unable to dlopen(/lib64/security/pam_fprintd.so): 
# /lib64/security/pam_fprintd.so: cannot open shared object file: No such file or directory
# su: PAM adding faulty module: /lib64/security/pam_fprintd.so
# which happens because Anaconda configures fingerprint-auth for PAM but the fingerprint module is not installed.
# See https://bugzilla.redhat.com/show_bug.cgi?id=656434
# Disable it with:
authconfig --disablefingerprint --update
 
# Test manually.
# See http://zeldor.biz/2010/08/configure-logcheck/
su -s /bin/bash -c "/usr/sbin/logcheck" logcheck

Mail

# This will install the script "mail", just in case the error
# /bin/mail: No such file or directory
# happens somewhere.
yum install mailx

Sendmail

# If sendmail-cf is not installed, the error
# Package sendmail-cf is required to update configuration.
# will pop up when restarting the sendmail service.
# m4 is also needed as macro processor, see below and
# http://www.centos.org/docs/2/rhl-rg-en-7.2/s1-email-sendmail.html
yum install sendmail sendmail-cf m4
 
# Enable sending and receiving mails through port 25.
# In /etc/ma8l/sendmail.mc, change the line from:
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl
# to
dnl DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl
 
# Rebuild the file sendmail.cf after making changes in sendmail.mc
# using the macro processor m4
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
 
service sendmail start
 
# Test.
cat <some_file> | sendmail myusername@mymailprovider.com

SSH

  • Secure Shell. See SSH.

Vi

  • Text Editor.

Vi tasse.jpg

Websites

  • Tools for crawling or acquiring webpages: curl, links, lynx, wget.

Yum

  • CentOS Package Manager. See Yum.

Upgrade

yum clean all
 
# Check what will be updated.
yum list updates
 
# Update.
yum update
 
reboot
 
# Check.
cat /etc/redhat-release
# Answer whould be: 
# CentOS release 5.7 (Final) or
# CentOS release 5.8 (Final)
 
# Check error logs.
less /var/log/messages
 
# Check new files, e.g.
find / -name *.rpmnew
vi /etc/yum.conf.rpmnew
vi /etc/ssh/sshd_config.rpmnew
vi /etc/ssh/ssh_config.rpmnew
vi /etc/yum.repos.d/CentOS-Vault.repo.rpmnew

Software Versions

  • CentOS 5.7, 5.8: Python 2.4.3, Perl 5.8.8, Apache 2.2.3, PHP 5.1.6 (5.3.3), MySQL 5.0.95, Ruby 1.8.5, Java 1.4.2, PostgreSQL 8.1.9
  • CentOS 6.2: Python 2.6.6, Perl 5.10.1, Apache 2.2.15, PHP 5.3.3, MySQL 5.1.61, PostgreSQL 8.4.9, Ruby 1.8.7.352, Java 1.6.0_22, Tomcat 6.0.24, Git 1.7.1

Comments

blog comments powered by Disqus