All notes
Centos

Basics

SeLinux

Just disable

Changing the SELINUX setting to disabled in /etc/selinux/config.

SELINUX=disabled
# Or
SELINUX=permissive

Gentle way


# Enable access to the relevant ports (e.g. 27017) for SELinux if in enforcing mode.
semanage port -a -t mongod_port_t -p tcp 27017

Fonts

Stackexchange.

Packages

Newest firefox

TecAdmin.

mongodb

mongoDB.

SQL server client

CoderWall.

Microsoft's client

Download the source code: Microsoft. InstallationGuide.


# uninstall unixODBC if version < 2.3.0 present
sudo yum remove unixODBC 

# The script installs unixODBC 2.3.0, ODBC driver, sqlcmd and bcp utilities.
./build_dm.sh
./install.sh verify
./install.sh install 

# Print the version
sqlcmd -S serverName -d dbname -U user_id -P password -Q "select @@version" # test

# bcp can be used for bulk import / export.

Centos FAQ

fsck

BlogSpot.


# Take system down to runlevel one:
init 1
# Unmount file system, for example if it is /home (/dev/sda2) file system then type command:
umount /home
# OR
umount /dev/sda2

# Now run fsck on the partition:
fsck /dev/sda2

# Specify the file system type using -t option:  
fsck -t ext3 /dev/sda2 OR  # fsck.ext3 /dev/sda2

# fsck will check the file system and ask which problems should be fixed or corrected. If you don't wanna type y every time then you can use pass -y option to fsck: 
fsck -y /dev/sda2

# Please note if any files are recovered then they are placed in /home/lost+found directory by fsck command.

# Once fsck finished, remount the file system:
mount /home

dhclient hinders shutdown?

When shutdown fails, after reboot, look into /var/log/message and find that lots of "Nov 20 18:19:25 wcfCos dhclient[2419]: DHCPREQUEST on eth0 to 192.168.11.60 port 67 (xid=0x4d466692)" appear in the last log until hard reboot. So does dhclient hinder shutdown?

From googling, there is no clear evidence. I now doubt the troublesome NetworkManager may be the culprit. So I just disabled it and see if the problem could be gone.

I also removed /var/lib/dhclient/*.leases except the newest dhclient.leases.

pptp vpn not working

I can't connect to my VPN server from CentOS. In the /var/log/messages, I found: "VPN plugin failed: connect-\failed" etc.

CentOSForum. OpenSuseForum.


sudo modprobe nf_conntrack_pptp

To add the module permananetly, ServerFault gives this:

# /etc/rc.d/rc.sysinit looking for two locations to load modules: /etc/sysconfig/modules/*.modules and /etc/rc.modules.
echo "modprobe nf_conntrack_pptp" >> /etc/sysconfig/modules/pptp.modules
chmod +x /etc/sysconfig/modules/pptp.modules

# If those doesn't work, create a conf file under /etc/modules-load.d/ with nf_conntrack_pptp as it content. See RedHatBugZilla.

Find out centOS version

DirectAdmin.

cat /etc/redhat-release

Find out dependencies

StackOverflow.

repoquery --verbose --requires --recursive --resolve mysql-server

mysql-server-0:5.1.73-5.el6_6.x86_64
openssl-0:1.0.1e-30.el6_6.5.x86_64
bash-0:4.1.2-29.el6.x86_64
chkconfig-0:1.3.49.3-2.el6_4.1.x86_64
perl-DBD-MySQL-0:4.013-3.el6.x86_64
perl-DBI-0:1.609-4.el6.x86_64
libstdc++-0:4.4.7-11.el6.x86_64
mysql-libs-0:5.1.73-3.el6_5.x86_64
coreutils-0:8.4-37.el6.x86_64
libgcc-0:4.4.7-11.el6.x86_64
initscripts-0:9.03.46-1.el6.centos.1.x86_64
perl-Data-Dumper-0:2.125-1.el6.rf.x86_64
perl-4:5.10.1-136.el6.x86_64
shadow-utils-2:4.1.4.2-19.el6_6.1.x86_64
psmisc-0:22.6-19.el6_5.x86_64
zlib-0:1.2.3-29.el6.x86_64
glibc-0:2.12-1.149.el6_6.9.x86_64
mysql-0:5.1.73-5.el6_6.x86_64
perl-File-Temp-0:0.22-1.el6.rf.noarch
glibc-0:2.12-1.149.el6.i686

Ibus not working

  1. Problem: type "Ctrl+SPACE", the chinese input doesn't come out.
  2. Type "im-chooser" on commandline, try to set "Input Method Preferences". It complains "No gtk module found for python".
  3. The culprit is Canopy python! Echo PATH and it says "/home/me/Enthought/Canopy_64bit/User/bin:/usr/bin/...". Set in $HOME/.bashrc the PATH and add /usr/bin before the Canopy path.
  4. Retry "im-chooser" and set "Input Method Preferences". Add Chinese input method.
  5. Wow, now it works when typing Ctrl+SPACE!!!

MP4 support

sudo yum install -y x264 faac

rar/unrar

http://idroot.net/linux/install-rarunrar-centos/

wget -c http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

unrar x (file_name).rar           extract with full path
unrar e -kb (file_name).rar       (Keep broken)
unrar l (file_name).rar           list files inside
unrar e (file_name).rar           dump files excluding folders
rar a (file_name).rar (file_name) create a archive Rar file
rar r (file_name).rar             recover or fix a archive file or files
rar a -p (file_name).rar          create a archive Rar file with password

exFAT support

Rehmert. LogDown.


sudo su
yum install scons gcc -y
yum install fuse-devel -y
yum install rpmbuild -y

cd ~
wget -c http://download1.rpmfusion.org/free/el/updates/6/SRPMS/exfat-utils-1.0.1-1.el6.src.rpm
wget -c http://download1.rpmfusion.org/free/el/updates/6/SRPMS/fuse-exfat-1.0.1-1.el6.src.rpm
rpm -ivh fuse-exfat-1.0.1-1.el6.src.rpm exfat-utils-1.0.1-1.el6.src.rpm
cd ~/rpmbuild/SPECS
rpmbuild -ba fuse-exfat.spec
rpmbuild -ba exfat-utils.spec
cd ../RPMS/x86_64/
yum install exfat-utils*.rpm fuse-exfat*.rpm
rpm -ivh fuse-exfat-1.0.1-1.el6.x86_64.rpm exfat-utils-1.0.1-1.el6.x86_64.rpm
ln -s /usr/sbin/mount.exfat /sbin/mount.exfat

RHEL 6: semanage SELinux Command Not Found

Cyberciti.


yum provides /usr/sbin/semanage
sudo yum -y install policycoreutils-python

Boot up freezes after certmonger starts

CentOSForum.

To fix this,
ssh to your machine after it hangs.
mv /etc/X11/xorg.conf /etc/X11/old_xorg.conf
then reboot. That should fix it.

Gnome


sudo yum -y groups install "GNOME Desktop"
echo "exec gnome-session" >> ~/.xinitrc
startx

EPEL

Configure a CentOS or Red Hat Enterprise Linux system to use the Fedora Extra Packages for Enterprise Linux (EPEL) repository. The EPEL repository provides useful software packages that are not included in the official CentOS or Red Hat Enterprise Linux repositories. // Install EPEL on centos. sudo yum install epel-release #中科大镜像源 高质量源 rpm -Uvh http://mirrors.ustc.edu.cn/centos/7.0.1406/extras/x86_64/Packages/epel-release-7-5.noarch.rpm

Edit /etc/yum.repos.d/epel.repo

ELRepo

Ether driver

CentosOrg. Try kmod-alx from the ELRepo.

Mysql

Install mysql on CentOS


sudo yum install mariadb-server
sudo systemctl start mariadb.service

# Set root password, etc.
sudo mysql_secure_installation

# Remove mysql in order to install mariadb:
# See: StackOverflow: install mariadb on CentOS6.5.
sudo yum remove mysql-server
sudo yum remove mysql
# CAUTION: many app depends on mysql-libs, such as tomcat. Do add --nodeps here!
# Affected deps:
#  MySQL-python        
#  cronie              
#  cronie-anacron      
#  crontabs            
#  perl-DBD-MySQL      
#  php-mysql           
#  postfix             
#  redhat-lsb          
#  redhat-lsb-compat   
#  redhat-lsb-core     
#  redhat-lsb-graphics 
#  redhat-lsb-printing 
#  sysstat          
sudo rpm -e --nodeps mysql-libs
sudo yum install MariaDB-server MariaDB-client

Network Manager Applet(/usr/bin/nm-applet) wants access to the default keyring but it is locked

CSDN. 删除~/.gnome2/keyrings/login.keyring重启即可

Config files

CentOSDocs.

ONBOOT=answer
	where answer is one of the following:
		yes — This device should be activated at boot-time.
		no — This device should not be activated at boot-time.
Why there are two config dirs for networking

StackExchange.



for i in /etc/sysconfig/networking /etc/sysconfig/network-scripts; do echo "==> "; rpm -qf ;done
==> /etc/sysconfig/networking
system-config-network-tui-1.6.0.el6.2-1.el6.noarch
initscripts-9.03.46-1.el6.centos.1.x86_64
==> /etc/sysconfig/network-scripts
initscripts-9.03.46-1.el6.centos.1.x86_64

Common commands

yum


# Check what package provides libGLU.so.1.
yum whatprovides \*/libGLU.so.1

# List package version on server.
yum list cython

rpm


# Check if package is installed.
rpm -qa | grep mutt

Compiling GCC

StackOverflow: error on gnu-stub_32.h no such file.


sudo yum install -y glibc-devel.i686

Network

NetworkManager

Disable it

Wordpress.


# To Stop Network Manager Service
service NetworkManager stop
chkconfig NetworkManager off

# Now Add default Net Manager
chkconfig network on
# Start default Manager
service network start

How to disable automatic connecting of wlan?

Right click on the NM icon, and edit the connections, disable the "connect automatically".

Command line

Redhat.


nmcli general status

nmcli connection show

nmcli connection show -a/--active

nmcli device status

Set IP

CentOSDocs. In "/etc/sysconfig/network-scripts/ifcfg-eth0", set:

# Static
DEVICE="eth0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=192.168.50.2
NAME="System eth0"
HWADDR=00:0C:29:28:FD:4C
GATEWAY=192.168.50.1

Then sudo /etc/init.d/networking restart.

ONBOOT= yes — This device should be activated at boot-time.
        no — This device should not be activated at boot-time.

Set route

In "/etc/sysconfig/network-scripts/route-eth0":

10.10.20.0/24 via 192.168.50.100 dev eth0