正在筛选分类:linux 下的文章 清除筛选 ✕
2016
07
15
06:40

linux查看磁盘是ssd还是hdd

Linux或freebsd,如果是vps,好像必须得是KVM的才能查看。

SSD是非转动磁盘

cat /sys/block/sda/queue/rotational

返回 0, 就是 SSD。

2015
12
08
13:52

Depends: init-system-helpers (>= 1.18~) but it is not installable

Depends: init-system-helpers (>= 1.18~) but it is not installable
E: Unable to correct problems, you have held broken packages.

Working on debian wheezy…

I added backports to my apt repo “deb http://ftp.de.debian.org/debian wheezy-backports main” and performed a “apt-get update”. Afterwards, the apt-get install docker-engine completed fine.

Personally, I’m leaving backports commented out for now but in my conf as a reminder…

2015
12
07
18:55

How to Disable a Services in Linux

In Red Hat based distributions such as Fedora and CentOS, make use of a script called ‘chkconfig‘ to enable and disable the running services in Linux.

For example, lets disable the Apache web server at the system startup.

[avishek@tecmint]# chkconfig httpd off
[avishek@tecmint]# chkconfig httpd –del

In Debian based distributions such as Ubuntu, Linux Mint and other Debian based distributions use a script called update-rc.d.

For example, to disable the Apache service at the system startup execute the following command. Here ‘-f’ option stands for force is mandatory.

[avishek@tecmint]# update-rc.d -f a

2015
05
03
11:02

Android手机装上Linux系统

昨天发现手机安装linux脚本已经自动化了,直接下载一个应用即可全自动安装,就在闲置的手机上安装了下;像:

Linux Installer https://play.google.com/store/apps/details?id=com.zpwebsites.linuxonandroid

手机都需要root。尝试了下Linux Installer,教程比较详细

http://android.galoula.com/en/LinuxInstall/

需要注意一个地方是,最后install linuxchroot script时,注意设置linuxinstaller的系统可写权限,不然安装无响应或者提示写权限出错。

我装的是Debian Linux的arm发行版,apt-get用起来很方便。

2014
08
19
17:47

linux 下查看机器是cpu是几核的

几个cpu

 

more /proc/cpuinfo |grep “physical id”|uniq|wc -l

 

每个cpu是几核(假设cpu配置相同)

 

more /proc/cpuinfo |grep “physical id”|grep “0”|wc -l

 

cat /proc/cpuinfo | grep processor

 

1. 查看物理CPU的个数

#cat /proc/cpuinfo |grep “physical id”|sort |uniq|wc -l

 

2. 查看逻辑CPU的个数

#cat /proc/cpuinfo |grep “processor”|wc -l

 

3. 查看CPU是几核

#cat /proc/cpuinfo |grep “cores”|uniq

 

4. 查看CPU的主频

#cat /proc/cpuinfo |grep MHz|uniq

 

 

# uname -a

Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux

(查看当前操作系统内核信息)

 

# cat /etc/issue | grep Linux

Red Hat Enterprise Linux AS release 4 (Nahant Update 5)

(查看当前操作系统发行版信息)

 

# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz

(看到有8个逻辑CPU, 也知道了CPU型号)

 

# cat /proc/cpuinfo | grep physical | uniq -c

4 physical id : 0

4 physical id : 1

(说明实际上是两颗4核的CPU)

 

# getconf LONG_BIT

32

(说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit)

 

# cat /proc/cpuinfo | grep flags | grep ‘ lm ‘ | wc -l

8

(结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit)

 

 

如何获得CPU的详细信息:

linux命令:cat /proc/cpuinfo

用命令判断几个物理CPU,几个核等:

逻辑CPU个数:

# cat /proc/cpuinfo | grep “processor” | wc -l

物理CPU个数:

# cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l

每个物理CPU中Core的个数:

# cat /proc/cpuinfo | grep “cpu cores” | wc -l

是否为超线程?

如果有两个逻辑CPU具有相同的”core id”,那么超线程是打开的。

每个物理CPU中逻辑CPU(可能是core, threads或both)的个数:

# cat /proc/cpuinfo | grep “siblings”

2014
06
17
06:10

Linux定时执行任务命令概述:at和crontab

在Linux下要定时执行任务,可以有两种方法实现:at命令和crontab。如果我们只是想要让特定任务运行一次,则可以使用at监控程序;如果是无人作业的情况,那么可以使用cron服务。

 

AD:

 

本文介绍在Linux下的两种定时执行任务的方法:at命令,以及crontab服务。

 

(1)at命令

 

假如我们只是想要让特定任务运行一次,那么,这时候就要用到at监控程序了。

 

设置at命令很简单,指示定运行的时间,那么就会在哪个时候运行。at类似打印 进程,会把任务放到/var/spool/at目录中,到指定时间运行它 。at命令相当于另一个shell,运行at time命令时,它发送一个个命令,可以输入任意命令或者程序。at now + time命令可以在指示任务。

 

假设处理一个大型数据库,要在别人不用系统时去处理数据,比如凌晨3点10分。那么我们就应该先建立/home/kyle/do_job脚本管理数据库,计划处理/home/kyle/do_job文件中的结果。正常方式是这样启动下列命令:

 

# at 2:05 tomorrow

at>/home/kyle/do_job

at> Ctrl+D

AT Time中的时间表示方法

 

———————————————————————–

时 间 例子 说明

———————————————————————–

Minuteat now + 5 minutes任务在5分钟后运行

Hour at now + 1 hour 任务在1小时后运行

Days at now + 3 days 任务在3天后运行

Weeks at now + 2 weeks 任务在两周后运行

Fixed at midnight 任务在午夜运行

Fixed at 10:30pm任务在晚上10点30分

注意:一定要检查一下atq的服务是否启 动,有些操作系统未必是默认启动的,linux默认为不启动,而ubuntu默认为启动的。检查是否启动,用service atd检查语法,用service atd status检查atd的状态,用service atd start启动atd服务。

 

查看at执行的具体内容:一般位于/var/spool/at目录下面, 用vi打开,在最后一部分就是你的执行程序

 

(2)crontab

 

cron是一个linux下 的定时执行工具,可以在无需人工干预的情况下运行作业。由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动、关闭这个服务:

 

/sbin/service crond start//启动服务

/sbin/service crond stop //关闭服务

/sbin/service crond restart //重启服务

/sbin/service crond reload//重新载入配置

/sbin/service crond status//查看服务状态

你也可以将这个服务在系统启 动的时候自动启动:

 

在/etc/rc.d/rc.local这个脚本的末尾加上:

 

/sbin/service crond start

现在Cron这个服务已经在进程里面了,我们就可以用这个服务了,Cron服务提供以下几种接口供大家使用:

 

1、直接用crontab命令编辑

 

cron服务提供 crontab命令来设定cron服务的,以下是这个命令的一些参数与说明:

 

crontab -u //设定某个用户的cron服务,一般root用户在执行这个命令的时候需要此参数

crontab -l //列出某个用户cron服务的详细内容

crontab -r //删除某个用户的cron服务

crontab -e //编辑某个用户的cron服务

比如说root查看自己的cron设置:crontab -u root -l

 

再例如,root想删除fred的cron设置:crontab -u fred -r

 

基本格式 :

 

*****command

分  时  日  月  周  命令

第1列表示分钟1~59 每分钟用*或者 */1表示

第2列表示小时1~23(0表示0点)

第3列表示日期1~31

第4列表示月份1~12

第5列标识号星期0~6(0表示星期天)

第6列要运行的命令

crontab文件的一些例子:

 

#每晚的21:30重启apache。

30 21 * * * /usr/local/etc/rc.d/lighttpd restart

 

#每月1、10、22日

45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart

 

#每天早上6点10分

10 6 * * * date

 

#每两个小时

0 */2 * * * date

 

#晚上11点到早上8点之间每两个小时,早上8点

0 23-7/2,8 * * * date

 

#每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点

0 11 4 * mon-wed date

 

#1月份日早上4点

0 4 1 jan * date

2014
06
10
14:07

putty中文乱码问题解决

###putty中文乱码问题解决

 

用putty从windows xp连接ubuntu server或者FreeBSD系统,其中中文部分乱码,经常遇到这个问题的时候,会觉得很郁闷。现共享一些解决这个问题的方法。

 

 

###方法一:

打开putty主程序,选择window-〉Appearance-〉Font settings-〉Change Settings,选择Fixedsys字体,字符集选择CHINESE_GB2312。

在window-〉Appearance-〉 Translation中,Received data assumed to be in which character set 中,把Use font encoding改为UTF-8

如果经常使用,把这些设置保存在session里面.

保存方法:再做完以上操作的同时选中以下两项:

在window-〉Appearance-〉 Translation中,选中:TReat CJK ambiguous characters as wide和Caps Lock acts as Cyrillic switch即可。

 

###方法二:

编辑/etc/sysconfig/i18n

 

把第1句“LANG=”zh_CN.UTF-8″”改为“LANG=”zh_CN.GB18030″”,完成后保存重新登录即可。

 

##方法三:

打开putty,登录成功后,在shell中输入

# export LC_ALL= ‘zh_CN.utf8′

 

# vi ~/.bash_profile

 

LANG=zh_CN.GB18030

 

LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN

 

export LANG LANGUAGE