Friday,July-30th
 

转载备忘:设置修改CentOS系统时区

 

在我们使用CentOS系统的时候,也许时区经常会出现问题,有时候改完之后还是会出错,下面我们就来学习一种方法来改变这个状况。如果没有安装,而你使用的是 CentOS系统 那使用命令 yum install ntp

然后:ntpdate us.pool.ntp.org 。

因为CentOS系统是用rhas的源码再编译的,很多地方是完全一样的。

rhas5的时区是以文件形式存在的,当前的时区文件是在/etc/localtime

那么其他时区的文件存放在哪里呢?

在/usr/share/zoneinfo下

我们用东八区,北京,上海的时间

#cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#reboot

重启之后,date查看时间、查看当前时区   date -R、查看/修改Linux时区和时间

一、时区

1. 查看当前时区
date -R

2. 修改设置时区
方法(1)
tzselect
方法(2) 仅限于RedHat Linux 和 CentOS系统
timeconfig
方法(3) 适用于Debian
dpkg-reconfigure tzdata

3. 复制相应的时区文件,替换CentOS系统时区文件;或者创建链接文件
cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
在中国可以使用:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

二、时间

1、查看时间和日期
date

2、设置时间和日期
将CentOS系统日期设定成1996年6月10日的命令
date -s 06/22/96
将CentOS系统时间设定成下午1点52分0秒的命令
date -s 13:52:00

3. 将当前时间和日期写入BIOS,避免重启后失效
hwclock -w

三、定时同步时间
# /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1

这样我们就完成了关于设置修改CentOS系统时区的问题了。希望大家可以学习到更多的知识。

 

转:CentOS中找不到setup命令

 

setup
-bash: setup: command not found

通常情况下,这是因为你安装的linux是minimal版,就是说最小安装,不包含某些工具包。

解决方法:yum

[root@v2httpd ~]# yum install setuptool

可是运行时只有 Authentication configuration Firewall configuration 两项 , 没有时区、系统服务等其他他几项

 

这个是因为安装系统的时候你们只装了开发工具,   没有装基本系统,里面的基本软件,   选上基本软件安装就可以了

 

# ntsysv

在CentOS5.4新系统yum update后无service、ntsysv命令,提示command not found。

解决方法:
先在命令行中输入
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:
回车
这样你可以临时恢复环境变量设置,
然后就可以用了。想一直有用的话
#或者$ cd ~
vi .bashrc或者vi .bash_profile
然后把上边那句写进去,好象要加点什么吧。
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:$PATH 
下次使用bash的时候就生效了。


 

rsync 配置详解(z)

rsync 服务器配置
rsync的配置文件一般都放在/etc/下面 分别是 rsyncd.conf(rsync配置文件) rsyncd.secrets(用户名密码存放文件,文件名可自定义)

阅读全文>>

 

关于Linux 2.6 kernel udev 漏洞的检测及修补[转]

最近闹的很凶的Linux udev漏洞对2.6系列的CentOS/RHEL 5.x(除了5.3)都有效,而对2.4系列的则无效,对于CentOS/RHEL 4.x 经过测试,按本文攻击方法无效,但是否真的无效还有待真正高手验证!请大家必须打起12分精神。赶紧升级。ExtMail团队已经将所有我们掌控的Linux服务器(2.6 kernel,5.x 系列)全部升级完毕。以下是检测方法和升级方法,请路过使用受影响的linux系统的朋友一定要参考并升级,否则很容易出问题。这次可以通过任意web程序来实现攻击,而且成功率几乎100%。

检测方法:

1)下载攻击脚本:
wget http://www.linuxidc.com/system/systembak/exploit-udev-8478.txt

阅读全文>>

 

ls 文件排序

按照创建时间倒叙排列

ls -lrt

 

阅读全文>>

 

drop_caches vs swappiness

from http://www.linuxinsight.com/proc_sys_vm_swappiness.html

Linux kernel is really doing a good job managing memory, but if you prefer to push it in specific direction, there's another tunable with which you can achieve the desired effect: /proc/sys/vm/swappiness 

swappiness is a parameter which sets the kernel's balance between reclaiming pages from the page cache and swapping process memory. The default value is 60.

If you want kernel to swap out more process memory and thus cache more file contents increase the value. Otherwise, if you would like kernel to swap less decrease it.

More info:2.6 swapping behavior

 

 

 

/proc/sys/vm/drop_caches , how to free up memory

/proc/sys/vm/drop_caches (since Linux 2.6.16)

Writing to this file causes the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;

to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;

to free pagecache, dentries and inodes, use echo 3 > /proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects are not freeable, the user should run sync(8) first. 

释放前最好sync一下,防止丢数据

 

 

Invalidating the Linux Buffer Cache

 Reprint an article

http://www.webpronews.com/expertarticles/2007/01/10/invalidating-the-linux-buffer-cache

When you write data, it doesn't necessarily get written to disk right then. The kernel maintains caches of many things, and disk data is something where a lot of work is done to keep everything fast and efficient.

That's great for performance, but sometimes you want to know that data really has gotten to the disk drive. This could be because you want to test the performance of the drive, but could also be when you suspect a drive is malfunctioning: if you just write and read back, you'll be reading from cache, not from actual disk platters.

So how can you be sure you are reading data from the disk? The answer actually gets a little complicated, particularly if you are testing for integrity, so bear with me.

Obviously the first thing you need to do is get the data in the cache sent on its way to the disk. That's "sync", which tells the kernel that you want the data written. But that doesn't mean that a subsequent read comes from disk: if the requested data is still in cache, that's where it will be fetched from. It also doesn't necessarily mean that the kernel actually has sent the data along to the disk controller: a "sync" is a request, not a command that says "stop everything else you are doing and write your whole buffer cache to disk right now!". No, "sync" just means that the cache will be written, as and when the kernel has time to do so.

Traditonally, the only way to be sure you were not reading back from the cache was to overwrite the cache with other data. That required two things: knowing how big the cache is at this moment, and having unrelated data of sufficient size to overwrite with. On older Unixes with fixed sized buffer caches, the first part was easy enough, and since memory was often expensive and in shorter supply than it is now, the cache wasn't apt to be all that large anyway. That's changed radically: modern systems allocate cache memory dynamically and while the total cache is still small compared to disk drives, it can now be gigabytes of data that you need to overwrite.

阅读全文>>

 

freebsd,Linux 下设定时区

(adjkerntz = adjust kernal timezone)

方法一

# tzsetup (图形界面)

 

 # adjkerntz -a

方法二

#cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
#adjkerntz -a

阅读全文>>

 

命令行ssh登陆

    写下来备忘

 ssh -l用户名 -p端口 hostip

ssh root@x.x.x.x -p port