㈠ github上面下载的C++代码怎么都是readme.md,难道都是必须在linux下运行,不是的话为什么后缀是.md
你下的不是代码,而是一个说明文档……
md文件:http://www.hu.com/question/20958887
㈡ kali linux如何使用GIT clone
在linux下搭建git环境
1、创建Github账号,https://github.com
2、Linux创建SSH密钥:
[plain] view plain
01.ssh-keygen ##一直默认就可以了
3、将公钥加入到Github账户信息Account Settings->SSH Key
4、测试验证是否成功。
[plain] view plain
01.ssh -T [email protected]
02.Hi someone! You've successfully authenticated, but GitHub does not provide shell access.
同步github到本地
1、复制项目到本地:
[plain] view plain
01.git clone git://github.com:xxxx/test.git ##以gitreadonly方式克隆到本地,只可以读
02.git clone [email protected]:xxx/test.git ##以SSH方式克隆到本地,可以读写
03.git clone https://github.com/xxx/test.git ##以https方式克隆到本地,可以读写
04.git fetch [email protected]:xxx/xxx.git ##获取到本地但不合并
05.git pull [email protected]:xxx/xxx.git ##获取并合并内容到本地
本地提交项目到github
1、本地配置
[plain] view plain
01.git config --global user.name 'onovps'
02.git config --global user.email '[email protected]' #全局联系方式,可选
2、新建Git项目并提交到Github。
[plain] view plain
01.mkdir testdir & cd testdir
02.touch README.md
03.git init #初始化一个本地库
04.git add README.md #添加文件到本地仓库
05.git rm README.md #本地倒库内删除
06.git commit -m "first commit" #提交到本地库并备注,此时变更仍在本地。
07.git commit -a ##自动更新变化的文件,a可以理解为auto
08.git remote add xxx [email protected]:xxx/xxx.git #增加一个远程服务器的别名。
09.git remote rm xxx ##删除远程版本库的别名
10.git push -u remotename master #将本地文件提交到Github的remoname版本库中。此时才更新了本地变更到github服务上。
分支版本操作
1、创建和合并分支
[plain] view plain
01.git branch #显示当前分支是master
02.git branch new-feature #创建分支
03.git checkout new-feature #切换到新分支
04.vi page_cache.inc.php
05.git add page_cache.inc.php
06.git commit -a -m "added initial version of page cache"
07.git push origin new-feature ##把分支提交到远程服务器,只是把分支结构和内容提交到远程,并没有发生和主干的合并行为。
2、如果new-feature分支成熟了,觉得有必要合并进master
[plain] view plain
01.git checkout master #切换到新主干
02.git merge new-feature ##把分支合并到主干
03.git branch #显示当前分支是master
04.git push #此时主干中也合并了new-feature的代码
git命令使用思维图:【非常有料】
㈢ linux下如何安装已经从github下载好的代码
㈣ Linux系统上怎样安装Git
最近在使用github,感觉不错。在windows下,可使用github提供的windows客户端(http://windows.github.com/)。很傻瓜,很方便。如何使用?详见:http://www.cr173.com/html/15618_1.html。(有图是王道)最近发现,在公司电脑上安装github的windows客户端时,可能由于公司网络限速和限流量限得太死,怎么也安装不成功。在家的github windows的图形客户端的同步也经常出问题。没办法,也只能通过文本界面来连接github了。如果已在windows系统中成功安装github的客户端,则除了可使用图形客户端外,还可使用github bash这个文本客户端。在我电脑上,当图形客户端同步出现问题时,文客户端还是能同步成功的。如果安装不上github的客户端,还可安装其他的git bash来连接github,如msysgit (http://msysgit.github.io/)等。因为以上软件都是以git为基础的,所以语法与linux使用的命令相同。
在linux下我仅使用了文本界面,所以安装了个文本形式的git客户来连接github。
1. 安装git
我用的是centos系统,在使用yum install git时,系统提示没有找到git包。所以,仅能通过以下方法来安装git。方法详见:http://www.cnblogs.com/Neddy/archive/2011/02/28/1967548.html。以上方法中有一个问题:方法中给出的git的下载源http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz 似乎无效了,于是,我在网上的这里下载了个git的最新安装包,安装到了centos上。Linux下git的官方网址为:http://git-scm.com/download,可能因为我网慢打不开,不知道读者您那里如何。如果打不开,可以在网上其他地方找找安装包,应该可以找到的。
2. 使用git连接github
使用git连接github时,需要将linux下产生的一个ssh公钥放到github上。具体步骤详见:http://blog.sina.com.cn/s/blog_6b706e15010199p1.html。主要命令有:
1ssh-keygen -t rsa -C"[email protected]"
然后系统提示输入文件保存位置等信息,连续敲三次回车即可,生成的SSH key文件保存在中~/.ssh/id_rsa.pub文件中。
用文本编辑工具打开该文件,在linux下可以用cat命令显示id_rsa.pub中的内容(cat ~/.ssh/id_rsa.pub),让后复制其内容。
接着拷贝.ssh/id_rsa.pub文件内的所以内容,将它粘帖到github帐号管理中的添加SSH key界面中。
注意,使用vim读取git_home/.ssh/id_rsa.pub中的公钥内容时,可能会有较多的空格和换行,复制到github网站上时必需删除。所以建议使用cat来读取ssh公钥。将ssh公钥成功加入github后,可使用命令ssh -T [email protected]来验证是否成功。如果出现象:hi xxx. You've successfully authenticated, but GitHub does not provide shell access.则说明连接成功。
非常不幸,我未能连接成功。可使用命令ssh -Tv [email protected]来查找failure的原因。通过详细的debug过程,我发现象我把自己的ssh密钥信息放到了/home/admin/.ssh/下,而测试时使用的账户是root,寻找ssh密钥的路径为root/.ssh,所以permission denied的啦。su到admin下,就可以连接成功啦~~
3. 使用git与github管理代码
3.1 新建一个repository
这里就使用github官网上的教程吧。请保证git的版本至少为1.7.10,否则可能无法成功。详细如何使用,请参见:https://help.github.com/articles/set-up-git。linux下无法新建一个repo,只能对github中已有的repo进行修改。所以,当要新建一个repo时,必须在github.com上新建,再通过linux下的git向此repo中新添内容。
3.2 修改repo中的代码
github的官网上也有修改repo代码的教程。详情请参见:https://help.github.com/articles/
㈤ Debian linux中有一个不能识别的硬件,找到有人在github上的驱动源码,如何安装到系统中。
./configure
./make
./make install
不对啊,你这个链接是内核源码的代码,编译安装这个得需要编译内核。
下载你的系统内核源码,然后编译安装系统内核吧。
具体的操作步骤度娘知道。
㈥ linux中安装了一个插件,这个插件装完后正常的情况在终端输入./phpxujh -p pid可查看当前PID的运行情况,
目录
开始之前
系统环境
监控内容
所需软件包
CentOS7重要变化
配置开发环境
同步时间
关闭Selinux
使用CRT上传软件包
安装邮件服务
监控主机安装
常用到的命令
安装nagios所需要的运行环境
增加用户
安装nagios
配置权限
安装插件
安装nrpe
远程主机安装
常用到的命令
配置运行环境
安装nagios-plugin
安装nrpe
启动nrpe
监控主机安装PNP
配置开发环境
安装pnp4nagios (版本号为0.6)
配置pnp4nagios
图表展示
问题集合
在首次配置了nagios监控端后,在浏览器输入地址后连接不上
启动nrpe后却不能互相通信
安装pnp4nagios后出现The requested URL /pnp4nagios/graph was not found on this server.
出现“CHECK_NRPE: Error - Could not complete SSL handshake.”的错误
执行 ./configure时报错:configure error cannot find ssl headers
解压./configure 后,在nagios-4.0.8进行make all报错
安装nrpe时执行.configure出错
错误:perfdata directory "/usr/local/pnp4nagios/var/perfdata/" is empty
开始之前
声明:本文中的命令都经过了测试,但难免有所纰漏,如果你发现命令粘贴后运行有错,可能是由于符号的格式(尤其是破折号)导致的,此时你应该自己手打一遍命令。对于本文中发现的错误和建议,请发送邮件给我:
[email protected],请在邮件主题里注明“关于nagios的问题(建议)”。
--------------------------------------分割线 --------------------------------------
在Ubuntu下配置Mrtg监控Nginx和服务器系统资源 http://www.linuxidc.com/Linux/2013-08/88417.htm
使用 snmp+Mrtg 监控 Linux 系统 http://www.linuxidc.com/Linux/2012-11/73561.htm
Mrtg服务器搭建(监控网络流量) http://www.linuxidc.com/Linux/2012-07/64315.htm
网络监控器Nagios全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm
Nagios搭建与配置详解 http://www.linuxidc.com/Linux/2013-05/84848.htm
Nginx环境下构建Nagios监控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm
在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm
CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm
Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用 http://www.linuxidc.com/Linux/2013-11/93047.htm
--------------------------------------分割线 --------------------------------------
系统环境
一共3台机器,全都按照CentOS7最小化模式安装系统
系统版本号
[root@localhost ~]# cat /etc/RedHat-release
CentOS Linux release 7.0.1406 (Core)
监控主机
(一台)
IP地址:192.168.1.204
主机名称:nagios_server_204
远程主机
(两台)
IP地址:192.168.1.112
主机名称:nagios_slave_112
IP地址:192.168.1.113
主机名称:nagios_slave_113
分区情况
安装时使用默认分区(使用 df 命令来查看)
[root@localhost ~]# df -h
监控内容
要监控的服务
监控命令
cpu负载
(check_linux_state.pl -C)
当前用户登录数量
(check_users)
磁盘使用情况
(check_disk)
总进程数
(check_procs)
内存使用情况
(check_linux_stats.pl -M)
负载均衡
(check_load)
磁盘IO
(check_linux_stats.pl -I)
网络流量
(check_linux_stats.pl -N)
打开的文件数量
(check_linux_stats.pl -F)
socket连接数
(check_linux_stats.pl -S)
进程使用的内存和CPU
(check_linux_stats.pl -T)
指定的网站是否可连接
(check_http)
系统在线时长
(check_uptime)
所需软件包
监控主机
软件包
下载地址
nagios-4.0.8.tar.gz
请到我的github地址里下载:
https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_server
注明:我的github项目install_nagios_automatically是一个一键自动化安装nagios的项目(能运行,但还在完善中)
nagios-plugins-2.0.3.tar.gz
nrpe-2.15.tar.gz
pnp4nagios-0.6.25.tar.gz
Sys-Statistics-Linux-0.66.tar.gz
libxml2-2.7.1.tar.gz
远程主机
软件包
下载地址
nagios-plugins-2.0.3.tar.gz
请到我的github地址里下载:
https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_client
nrpe-2.15.tar.gz
Sys-Statistics-Linux-0.66.tar.gz
Centos7重要变化
Centos7相比较以前的Centos有一些涉及到常用命令的变化,如果不事先了解,会在使用命令的时候造成巨大的困扰
Centos7默认没有ifconfig和netstat两个命令了,ip addr命令代替了ifconfig,只要安装上net-tools包就可以继续使用ifconfig和netstat两个命令了
systemctl命令的出现(systemctl可以看作是service和chkconfig的组合),虽然仍然可以使用以前的命令,但是会重定向到新的命令中,下面以http服务为例
job
以前的系统
CentOS7
服务开机启动
chkconfig --level 3 httpd on
systemctl enable httpd.service
服务不开机启动
chkconfig --level 3 httpd off
systemctl disable httpd
服务状态
service httpd status
systemctl status httpd
所有服务的启动状态
chkconfig --list
systemctl
启动服务
service httpd start
systemctl start httpd.service
停止服务
service httpd stop
systemctl stop httpd.service
重启服务
service httpd restart
systemctl restart httpd.service
配置开发环境
同步时间
把监控系统里的所有机器都同步一次网络时间(非常重要)
[root@localhost ~]timedatectl #该命令用来检查当前时间和时区
如果发现所有机器的时区不一致,此时就要使用命令
[root@localhost ~]timedatectl list-timezones #该命令列出了所有的时区
[root@localhost ~]timedatectl set-timezone Asia/Shanghai #该命令把时区设置为上海
ntpdate time.nist.gov #该命令同步网络当前的时间
如果提示没有ntpdate命令,则安装ntp,并且配置系统自动更新时间
[root@localhost ~]# yum install ntp -y
[root@localhost ~]# /usr/sbin/ntpdate time.nist.gov
[root@localhost ~]# echo '#time sync'>>/var/spool/cron/root
[root@localhost ~]# echo '*/10**** /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1'>>/var/spool/cron/root
关闭Selinux
不关闭selinux可能会导致一些难以察觉的错误,为了保险起见,首先关闭selinux:
[root@localhost ~]vi /etc/selinux/config
重启机器
检查selinux是否关闭:
[root@localhost ~]getenforce #如果显示enforcing则没有关闭
使用SecureCRT上传软件包
我在这里使用的SSH连接工具是SecureCRT7.2,通过这个工具上传文件到Linux的步骤如下:
1. 首先在Linux中安装传送文件命令:
[root@localhost ~] yum install lrzsz -y
2. 然后在Linux中跳转到/usr/local/src目录下
[root@localhost ~] cd /usr/local/src
3. 运行CRT的传送文件命令
安装邮件服务
因为邮件报警服务需要安装mail功能
[root@localhost ~]yum install –y mailx
[root@localhost ~]yum install –y sendmail
[root@localhost ~]systemctl restart sendmail.service
[root@localhost ~]mail –s Test [email protected](你的邮箱地址)
#此时进入输入模式,输入完邮件内容后按ctrl + d退出并且发送
监控主机安装
常用到的命令
命令内容
命令格式
检查nagios的配置文件是否有错
/etc/init.d/nagios checkconfig
或者
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
启动nagios
systemctl start nagios.service
或者
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
修改了nagios的配置文件后重新加载配置文件
/etc/init
安装nagios所需要的运行环境
[root@localhost ~]# yum install gcc glibc glibc-common -y
[root@localhost ~]# yum install php php-gd perl -y
[root@localhost ~]# yum install httpd gd gd-devel openssl openssl-devel -y
[root@localhost ~]# systemctl enable httpd.service #设置CentOS开机启动服务
增加用户
[root@localhost ~]useradd -m nagios
并将nagios以及apache用户加入到nagcmd组中
[root@localhost ~]groupadd nagcmd
[root@localhost ~]usermod -G nagcmd nagios
[root@localhost ~]usermod -a -G nagcmd apache #把apace用户添加到与nagios的一个组(apache用户会在安装apache时自动创建)
安装nagios
[root@localhost src]# tar -zxvf nagios-4.0.8.tar.gz
[root@localhost src]# cd nagios-4.0.8
首先初始化和建立编译的环境
[root@localhost nagios-4.0.8]#./configure --with-command-group=nagcmd
如果能看到下面的基本配置信息则说明初始的环境已经成功配置完成:
之后按照提示执行命令来进行编译:
[root@localhost nagios-4.0.8]# make all
[root@localhost nagios-4.0.8]# make install
[root@localhost nagios-4.0.8]# make install-init
[root@localhost nagios-4.0.8]# make install-config
[root@localhost nagios-4.0.8]# make install-commandmode
[root@localhost nagios-4.0.8]# make install-webconf
安装完成之后,在/usr/local/nagios目录下如果能够看到这些目录:
就表示Naigos安装成功了。
Nagios的样例配置文件默认安装在/usr/local/nagios/etc目录下,配置这些文件就可以使得nagios按要求运行(详细的配置过程请参考我的另一篇博文:nagios服务配置详解)
此时应该为email指定您想用来接收nagios警告信息的邮件地址,默认是本机的nagios用户:
[root@localhost]# vi /usr/local/nagios/etc/objects/contacts.cfg
email nagios@localhost #把描红的地方修改为你的email地址
创建一个登录nagios web程序的用户(用户名配置为nagiosadmin则不需要配置权限,设置为其他用户名就要配置权限),我在这里把用户名设置为kylinlin,密码为123456,这个用户帐号在以后通过web登录nagios认证时所用:
[root@localhost ~]# htpasswd -bc /usr/local/nagios/etc/htpasswd.users kylinlin 123456 #把描红的地方修改为你的用户名和密码
配置权限
如果在上面创建登陆nagios web程序的用户名不是nagiosadmin(我在上面已经设置为kylinlin),在登陆nagios的web界面后(此时我们还不能登录,但如果你忽略了这一小节的配置,那么在后面的登陆中就会看到如下的界面),点击Hosts或Services会显示图片红色的错误提示
是因为nagios默认把全部的权限给nagiosadmin,所以可以通过修改cgi.cfg文件赋予kylinlin权限,切换到/usr/local/nagios/etc目录下
[root@localhost etc]# sed -i 's#nagiosadmin#kylinlin#g' cgi.cfg #这条命令将nagiosadmin用户名替换为kylinlin
[root@localhost etc]# grep kylinlin cgi.cfg #这条命令检查是否修改成功
以上过程配置结束以后需要重新启动httpd:
[root@localhost etc]# systemctl restart httpd.service
检查其主配置文件的语法是否正确:
[root@localhost etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
或者使用下面这个命令来检查语法
[root@localhost etc]# /etc/init.d/nagios checkconfig
显示错误数为0才正确
配置成功
安装插件
刚才已经提到Nagios主程序只是一个控制中心,而能够起到服务监测和系统监测等功能的是众多Nagios的插件,没有插件的Nagios系统其实只是一个空壳。因此在安装了Nagios平台之后我们还需要安装插件。
Nagios插件同样是在其官方网站下载,目前版本是1.4.15。我将下载的源码包放到/usr/local目录下,按照下面的步骤进行解压,编译和安装:
[root@localhost src]# tar zxf nagios-plugins-2.0.3.tar.gz
[root@localhost src]# cd nagios-plugins-2.0.3
[root@localhost nagios-plugins-2.0.3]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@localhost nagios-plugins-2.0.3]#make
[root@localhost nagios-plugins-2.0.3]#make install
通过下面的命令查看安装了多少个插件
[root@localhost nagios-plugins-2.0.3]#ls /usr/local/nagios/libexec/|wc -l
然后把Nagios加入到服务列表中以使之在系统启动时自动启动:
[root@localhost nagios-plugins-2.0.3]# chkconfig --add nagios
[root@localhost nagios-plugins-2.0.3]# chkconfig nagios on
执行下面的命令来验证Nagios的样例配置文件:
[root@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg