|Version Script||cat /etc/redhat-release|
CentOS 5.6, 5.7, 5.8, 6.2, 6.3
- 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:
- Default runlevel can be found in /etc/inittab
- 20 Linux System Monitoring Tools Every SysAdmin Should Know - 
- How to Troubleshoot Your CentOS Linux Server - 
- 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
- Centos Logos: http://wiki.centos.org/ArtWork/Logo
- 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
Install CentOS as a server
- A virtual server or a dedicated machine can be rented @ Host Europe (http://www.hosteurope.de/).
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
- 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.
- cat /etc/redhat-release
- yum update
- Installation of the VMware Tools: See VMware Player.
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.
- To remove CentOS 6 and restore Windows 7 boot manager, see http://www.sevenforums.com/backup-restore/62209-remove-grub-restore-windows-7-a.html
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:
- In Linux, run „grep flags /proc/cpuinfo“. If the word „lm“ (long mode) is one of the flags, it is a 64-bit CPU.
- In Windows (7, Vista, or XP), follow the instructions on the Microsoft page: http://windows.microsoft.com/en-us/windows7/32-bit-and-64-bit-windows-frequently-asked-questions
- In a Macintosh, follow the instructions on Apple's page: http://support.apple.com/kb/HT3696
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:
- 32-bit CPU: http://isoredirect.centos.org/centos/6/isos/i386/
- 64-bit CPU: http://isoredirect.centos.org/centos/6/isos/x86_64/.
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
<command> > filename
- Store output from <command> in filename.
<command> >> filename
- Append output from <command> in filename.
- 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.
- 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:
- For a specific user, edit the file:
- /home/<your current user name>/.bashrc
- 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).
- List users.
- CentOS / RedHat distribution
- Linux version
- Back to the directory where you had been before.
- 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
- 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/
- About the PATH variable:
- 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"
- List groups <username> belongs to.
- Shows the last commands typed in the console.
- List dynamic dependencies; shared library dependencies
- List devices, like network cards, wireless adapters, etc.
- 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
- Change password of username.
- Displays environment variables. Similar to env.
- To know in which path I currently am.
- Remove file or symbolic link.
- e.g. remove symbolic link to directory: rm cassandra (No / at the end!)
- IP Address.
scp -rp /source/* user@ip-destination-server:/destination
- Copy files between two linux machines.
script-name >>filename.log 2>&1
- Redirect both standard output and errors to filename.log
- 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"
- su galaxy -c "command 1; command 2"
- Show last 10 lines of a file.
- -f: Waits for new lines and displays them.
- -n: Displays the last n lines; default is 10.
- Linux platform I am running
- Linux kernel version, e.g. 2.6.18-274.12.1.el5 in CentOS 5.7, yam updated, January 2012.
- 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
- For manipulating and viewing log files: uniq, cut, syslog-ng, rsyslog
- Boot loader: Grub; configuration: /boot/grub/grub.conf
- GParted: Resizing / Partitioning Tool
- 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.
- Advanced Bash-Scripting Guide: Complex Functions and Function Complexities: http://tldp.org/LDP/abs/html/complexfunct.html
- Bash Guide for Beginners: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
- Executing a command: http://stackoverflow.com/questions/3927062/problem-with-backticks-in-shellscript
- About chkconfig in init scripts: http://tldp.org/HOWTO/HighQuality-Apps-HOWTO/boot.html
- 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
# This will install the script "mail", just in case the error # /bin/mail: No such file or directory # happens somewhere. yum install mailx
- Using mail:
- How to send email from the Linux command line: Simple Help: http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/
- Mail: About.com: http://linux.about.com/od/commands/l/blcmdl1_Mail.htm
- Usage: echo "Body Text" | mail -s "Hello world from mail" firstname.lastname@example.org -c email@example.com -b firstname.lastname@example.org
- -s Subject, -c Copy, -b Blind Copy, email@example.com is the main recipient of the mail
- Configuring Sendmail: http://www.unixmen.com/configuring-sendmail-smtp-server-on-centos-a-scientific-linux/
# 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 firstname.lastname@example.org
- Secure Shell. See SSH.
- Text Editor.
- Tools for crawling or acquiring webpages: curl, links, lynx, wget.
- CentOS Package Manager. See Yum.
- From CentOS 5.6 to 5.7: http://www.how2centos.com/upgrading-centos-5-6-to-centos-5-7/
- From CentOS 5.7 to 5.8: http://www.gtkdb.de/index_7_1528.html
- From CentOS 5.7 to 6: Not supported. From http://wiki.centos.org/Manuals/ReleaseNotes/CentOS6.0: ..."Similar to the practice of the upstream vendor, there is no supported path to 'upgrade' an installation of a prior major CentOS release (presently CentOS 5 or CentOS 4) to a new major release. This is not a CentOS imposed limitation, but rather reflects the upstream's approach on this matter."...
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
- 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 220.127.116.112, Java 1.6.0_22, Tomcat 6.0.24, Git 1.7.1