序列
随機數
stat
cp /etc/skel/. /test/ -rf
cp -Rvp
vim
0 $ gg G gg=G
指令行快捷鍵
Ctrl + u 删除目前到行首
Ctrl + k 删除目前到行尾
Ctrl + a 跳轉行首
Ctrl + e 跳轉行尾
Ctrl + s 解救-->Ctrl + q
v V
Ctrl + shift + c 複制
Ctrl + shift + v 粘貼
ntpdate pool.ntp.org
rdate IP
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum -y groupinstall "Additional Development" "Development tools" "Desktop Platform Development" "Server Platform Development"
yum -y install vim-common vim-enhanced
vim /etc/sysconfig/selinux
chkconfig --list|awk '{print $1}'
for i in `chkconfig --list|awk '{print $1}'`;do chkconfig $i off;done
for i in sshd network rsyslog;do chkconfig $i on;done
vim /etc/sysconfig/network-scripts/ifcfg-eth0
vim /etc/ssh/sshd_config
UseDNS no
GSSAPIAuthentication no
yum -y install sysstat
sar
解決:
Cannot open /var/log/sa/sa30: No such file or directory
sar -o 1 2
sar -n DEV
yum -y install strace
yum -y install lsof
gdb
ldd
lsof
ps
pstack
strace
ipcs
top
free
vmstat
iostat
readelf
objdump
nm
size
wget
scp
mount -o remount,rw /
Linux 釋放記憶體
echo 3 > /proc/sys/vm/drop_caches
開機-BIOS-mbr-grub-核心-init-inittab-sysinit-fstab-rc.local-登入
find指令
crontab
分 時 日 月 周
nfs 服務建立步驟
複制隐藏檔案
cp -Rvp /aaa/. /bbb
快速啟動:(删除)
rhgb quiet
yum -y install xinetd
chkconfig xinetd on
簡單時間伺服器:37 端口
time-dgram
time-stream
disable = no
------------------------------------------------------------------------------------------------------------------
托管ssh到xinetd前:
[root@localhost ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1238/sshd
tcp 0 0 :::37 :::* LISTEN 1355/xinetd
tcp 0 0 :::873 :::* LISTEN 1355/xinetd
tcp 0 0 :::22 :::* LISTEN 1238/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1158/dhclient
udp 0 0 :::37 :::* 1355/xinetd
[root@localhost ~]# which ssh
/usr/bin/ssh
[root@localhost ~]# which sshd
/usr/sbin/sshd
[root@localhost ~]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
對比和rsync差别
[root@localhost ~]# cat /etc/xinetd.d/ssh
service ssh
protocol = tcp
server = /usr/sbin/sshd
server_args = -i
tcp 0 0 :::37 :::* LISTEN 1234/xinetd
tcp 0 0 :::873 :::* LISTEN 1234/xinetd
tcp 0 0 :::22 :::* LISTEN 1234/xinetd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1160/dhclient
udp 0 0 :::37 :::*
log_type = FILE /var/log/servicelog
port = 2222 需要先修改裡面的端口号:/etc/services 對應端口号
disable = yes
log_type = FILE /var/log/ssh_xinetd.log
-------------------------------------------------------------------------------------------------------------------------
事務:作為單個邏輯工作單元執行的一系列操作
ACID:
原子性:事務不可再分
一緻性:前後狀态一直
隔離性:未送出不可見
持久性:一送出永久有效
隔離級别:
未送出讀
已送出讀
可重複讀
串行化
日志
例如ssh:
SyslogFacility AUTHPRIV
#LogLevel INFO
日志裝置 日志級别
vim /etc/rsyslog.conf
# The authpriv file has restricted access.
authpriv.* /var/log/secure
綜上所述:ssh 日志 /var/log/secure
------------------------------------------------------------------------------------------------------------------------------
date +%F_%H_%M_%S
修改ssh日志存放:
Starting sshd: /etc/ssh/sshd_config line 37: unsupported log facility 'FILE'
[FAILED]
改為local0-local7
Unspecified GSS failure:已解決GSSAPIAuthentication no
1.sshd 是獨立服務
SyslogFacility local0
local0.* /var/log/ssh.log
分别重新開機上述服務:service sshd restart service rsyslog restart
2.sshd 托管到xinetd
log_type = FILE /var/log/ssh_xinetd.log
重新開機service xinetd restart
man xinetd.conf
SYSLOG syslog_facility [syslog_level]
The log output is sent to syslog at the
specified facility. Possible facility names
include: daemon, auth, authpriv, user,
mail, lpr, news, uucp, ftp local0-7. Pos-
sible level names include: emerg, alert,
crit, err, warning, notice, info, debug.
If a level is not present, the messages
will be recorded at the info level.
FILE file [soft_limit [hard_limit]]
The log output is appended to file which
will be created if it does not exist. Two
limits on the size of the log file can be
optionally specified. The first limit is a
soft one; xinetd will log a message the
first time this limit is exceeded (if
xinetd logs to syslog, the message will be
sent at the alert priority level). The
second limit is a hard limit; xinetd will
stop logging for the affected service (if
the log file is a common log file, then
more than one service may be affected) and
will log a message about this (if xinetd
logs to syslog, the message will be sent at
the alert priority level). If a hard limit
is not specified, it defaults to the soft
limit increased by 1% but the extra size
must be within the parameters LOG_EXTRA_MIN
and LOG_EXTRA_MAX which default to 5K and
20K respectively (these constants are
defined in xconfig.h).
log_type = SYSLOG local0 info
然後
-------------------------------------------------------------------------------------------------------------
時區時間:
/etc/sysconfig/clock 和 hwclock 相關
時區存放目錄:/usr/share/zoneinfo/
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 或者做軟連接配接
強制覆寫:
[root@localhost ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@localhost ~]# \cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
互動式:
[root@localhost ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: overwrite `/etc/localtime'? y
克隆eth0 eth1
[root@localhost ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:50:56:36:1E:AC
vim /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:36:1E:AC",
ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
修改完畢
日志集中化管理:
Starting system logger: -r option only supported in compatibility modes 0 to 2 - ignored
主伺服器:(集中化管理端)
vim /etc/rsyslog.conf
$ModLoad imtcp
$InputTCPServerRun 514
$template RemoteLogs,"/var/log/%FROMHOST-IP%/%PROGRAMNAME%.log" *
*.* ?RemoteLogs
& ~
用戶端:
*.* @@10.10.10.174:514