some command for centos

来源:互联网 发布:河南卫生统计网络直报 编辑:程序博客网 时间:2024/05/16 11:09
===== How to use yum in centos (http://www.centos.org/docs/5/html/yum/sn-yum-proxy-server.html)
 in /etc/yum.conf, add "proxy=http://192.168.0.59:8080"
 yum update // update current package
 yum list installed | wc -l  // package count of installed
 yum search xxx // search from yun repo by "xxx"
 yum install xxx // install "xxx"
 yum localinstall tsclient-0.132-4.i386.rpm //manual install
 

 

 ====== YUM Repository (https://www.digitalocean.com/community/articles/how-to-set-up-and-use-yum-repositories-on-a-centos-6-vps)
 yum -y install yum-fastestmirror //speed up
 yum -y remove yum-fastestmirror //speed up
**** CentOS Official Repository Mirrors
defined in /etc/yum.repos.d/CentOS-Base.repo, "http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
for me, it is "http://mirrorlist.centos.org/?release=6.4&arch=i386&repo=os"

http://mirrors.neusoft.edu.cn/centos/6.4/os/i386/
http://mirrors.grandcloud.cn/centos/6.4/os/i386/
http://mirrors.163.com/centos/6.4/os/i386/
http://centos.ustc.edu.cn/centos/6.4/os/i386/
http://mirrors.hustunique.com/centos/6.4/os/i386/
http://mirror.esocc.com/centos/6.4/os/i386/
http://mirrors.btte.net/centos/6.4/os/i386/
http://mirrors.yun-idc.com/centos/6.4/os/i386/
http://mirrors.tuna.tsinghua.edu.cn/centos/6.4/os/i386/
http://ftp.tc.edu.tw/Linux/CentOS/6.4/os/i386/


 ***Use Additional repositories
 Available YUM Repository configuration file options are:
    * Repository ID - One word unique repository ID (example: [examplerepo])
    * Name - Human readable name of the repository (example: name=Example Repository)
    * Baseurl - URL to the repodata directory. You can use file://path if repository is located locally or ftp://link, http://link, https://link if repository is located remotely - HTTP Authentication available http://user:password@www.repo1.com/repo1 (example: baseurl=http://mirror.cisp.com/CentOS/6/os/i386/)
    * Enabled - Enable repository when performing updates and installs (example: enabled=1)
    * Gpgcheck - Enable/disable GPG signature checking (example: gpgcheck=1)
    * Gpgkey - URL to the GPG key (example: gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6)
    * Exclude - List of the packages to exclude (example: exclude=httpd,mod_ssl)
    * Includepkgs - List of the packages to include (example: include=kernel)


    * CentOS Official Repository Mirrors
http://www.centos.org/modules/tinycontent/index.php?id=30
    * EPEL Repository Mirrors
http://mirrors.fedoraproject.org/publiclist/EPEL/
    * RPMforge Repository
http://wiki.centos.org/AdditionalResources/Repositories/RPMForge
    * ElRepo Repository
http://elrepo.org/tiki/tiki-index.php


http://mirror.cisp.com/CentOS/6/os/i386/


/etc/yum.repos.d/example.repo
[examplerepo]
name=Example Repository
baseurl=http://mirror.cisp.com/CentOS/6/os/i386/
enabled=1
gpgcheck=1
gpgkey=http://mirror.cisp.com/CentOS/6/os/i386/RPM-GPG-KEY-CentOS-6

*** Use Centos DVD as repo
http://mirror.lihnidos.org/CentOS/6.4/isos/i386/CentOS-6.4-i386-LiveDVD.iso
mount -o loop /path/to/iso /mnt
/etc/yum.repos.d/centosdvdiso.repo
[centosdvdiso]
name=CentOS DVD ISO
baseurl=file:///mnt
enabled=1
gpgcheck=1
gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-6

 
 *** Custom YUM Repository
 yum install createrepo
 mkdir /repository1
 wget http://mirror.lihnidos.org/CentOS/6/os/i386/Packages/NetworkManager-0.8.1-43.el6.i686.rpm
 mv /path/to/rpm /repository1
 cp /path/to/rpm /repository1
 createrepo /repository1 // Every time we add additional RPM package files to our Custom YUM Repository, we need to re-create Repository metadata with "createrepo" command.
 /etc/yum.repos.d/custom.repo
[customrepo]
name=Custom Repository
baseurl=file:///repository1/
enabled=1
gpgcheck=0


*** add epel repo
export http_proxy=http://192.168.0.59:8080
wget http://mirrors.hustunique.com/epel/6/i386/epel-release-6-8.noarch.rpm
yum install epel-release-6-8.noarch.rpm
find file epel*.repo in /etc/yum.repos.d



 ===== command of centos
 rpm -qa //check installed packages
 rpm -qa | grep java // check package name with java
 rpm -e --nodeps tzdata-java-2012c-1.el6.noarch // uninstall
 rpm -ivh jdk-7-linux-x64.rpm // install, jdk in /usr/java
 rpm -qa | wc -l  //count of installed package
 in /etc/ssh/sshd_config, add " ClientAliveInterval 60 ClientAliveCountMax 1 TCPKeepAlive yes", restart with "/etc/init.d/sshd restart"
 source /etc/profile   //take effective immediatlly
 
vi + /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0
JRE_HOME=/usr/java/jdk1.7.0/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH

find . -name 'my*' -ls
find . -type f -mmin -10 // last 10 minutes,common file
whereis grep // from harddisk
which grep // from PATH

mkdir /mnt/cdrom
mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom
umount /mnt/cdrom


df-h //uasge for disk
du /usr -sh // size of file
free / top / w / id
ps -aux | grep xxx
cat /proc/loadavg // loading of system
netstat -lntp //all listening port
netstat -antp // all connection
netstat -s //
crontab -l // check the job/plan
crontab -r // delete job/plan
chkconfig --list | grep on // all started service
chkconfig --list // all service

shutdown –h now // guanJi
ls /usr -s -S -l // sort by size
rm -rf * // delete force and dir
cat 1.txt >> 2.txt // append
cat 1.txt 2.txt> 3.txt // replace 3.txt with 1.txt and 2.txt

nohup myserver & // run in background
ps -aux | grep myserver // to check the job of myserver

tar –zxvf foo.tar.gz
tar –jxvf linux-2.4.20tar.bz2

tar –cZvf prcture.tar.Z *.tif


**** user management (http://linux.vbird.org/linux_basic/0410accountmanager.php)
/etc/passwd  // keep users, no password
for example "root:x:0:0:root:/root:/bin/bash"

/etc/shadow
for example "root:$1$/30QpE5e$y9N/D0bh6rAACBEz.hqo00:14126:0:99999:7:::  "

passwd gary
userdel -r gary



原创粉丝点击