· learnings · 6 min read
Linux学习日志 Ⅳ
“ps”显示系统进程
-a列出所有的进程
-au 显示较详细的资讯
-aux 显示所有包含其他使用者的行程
-e 显示系统进程(list process on the system)
-c
-o
Ex. Listings of only the PIDs for all “bash” processes
ps –o pid –C bash
*********************************************
Nice processes: low priority processes
Not nice processes: high priority processes
Normal process has nice value 0
范围为 -20 (最高优先序) 到 19 (最低优先序)
******************************************
“top” 实时更新进程
“kill”关闭进程
kill -
-s (signal) : 其中可用的讯号有 HUP (1), KILL (9), TERM (15), 分别代表着重启, 关闭, 终止; 详细的信号可以用 kill -l
-p : pid ,
-l (signal) : 列出所有可用的信号名称
EX.:
将 pid 为 323 的进程kill :
kill -9 323
将 pid 为 456 的进程重启 (restart) :
kill -HUP 456
“killall
*********************************
Daemons是在服务器后台运行的服务
common port numbers显示在/etc/services
服务设置文件位置: /etc/xinetd.d
*********************************
配置telnet服务器:
开启telnet service: #vi /etc/xinetd.d/telnet
service telnet
{
disable = no <==预设就是激活 telnet 服务
bind = 131.181.0.11 <==只允许经由这个适配卡的封包进来
only_from = 210.45.160.0/24 <==只允许 210.45.160.0/24 这个网段的主机联机进来使用 telnet 的服务
only_from = .edu.cn<==重复设定,只有教育网才能联机!
no_access = 192.168.25.{10,26}<==不许这些 PC 登入
log_type = FILE /var/log/telnetlog <==日志的类型和路径
access_times = 1:00-9:00 20:00-23:59 <==每天只有这两个时段开放服务
}
--------------------------------------------------------------------- 指示符 描述
socket_type 网络套接字类型, 流或者数据包
protocol IP 协议, 通常是TCP或者 UDP
wait yes/no, 等同于inetd的wait/nowait
user 运行进程的用户 ID
server 执行的完整路径
server_args 传递给server的变量,或者是值
instances 可以启动的实例的最大的值
start max_load 负载均衡
log_on_success 成功启动的登记选项
log_on_failure 联机失败的时候的日志信息
only_from 接受的网络或是主机
no_access 拒绝访问的网络或是主机
disabled 用在默认的 {} 中 禁止服务
log_type 日志的类型和路径 FILE /SYSLOG
nice 运行服务的优先级
id 日志中使用的服务名
---------------------------------------------------------------------
最后开启服务: service xinetd restart
登陆telnet: “telnet
配置SSH服务器:
ssh的配置文件是/etc/ssh/ssh_config,一般不要修改!
#service sshd start
使用SSH客户端:
1、基于口令的验证方式
直接登陆
[root@yoh /]#ssh 131.181.0.11
则登陆用户名为客户机当前用户名!
指定用户名登陆
[root@yoh /]#ssh [email protected]
2、基于密匙的验证方式
使用密匙的验证方式,用户先需要为自己创建一对密匙:公匙和私匙。(公匙用在要登陆的服务器上)
OpenSSH公开密匙的密码体制有RSA、DSA!
创建密匙:
[root@yoh /]#ssh-keygen –t rsa
(回车后,要求输入使用密匙时的口令!这样便生成了公匙和私匙:放在用户主目录下的.ssh目录下,文件名:id_rsa.pub和id_rsa!必须将公匙复制到登陆的服务器的~/.ssh/目录下,并改名为:authorized_keys!然后,便可使用密匙方式登陆!)
File Transfer Services
–FTP: Insecure
–SCP: Secure
本地系统和远程系统间文件的传输
#scp a.txt [email protected]:/b.txt
#scp [email protected]:/b.txt /c.txt
=================================================================
sftp命令
Sftp 命令和ftp命令类似,它是OpenSSH提供的网络传输文件的小工具,它更加安全,使用和ftp相似的命令:主要有如下几个:
1、登陆
#ftp 131.181.0.11
2、ftp 会话的打开与关闭
打开:open 210.45.160.27
关闭:close
3、文件的传输
从ftp服务器上得到文件:
Get a.txt
向ftp上放文件
Put a.txt
4、退出ftp
Bye
5、其他
bell:每个命令执行完毕后计算机响铃一次
Cd ,ls 等一些常见命令也可以在ftp服务器目录中使用!
=================================================================
**************************************************************************
P2P的类别:
Peer-to-Peer Only File Sharing Networks
Server Initiated Peer-to-Peer File Sharing Networks
Advantages
● Not necessary to have high capacity web server to distribute files
● Distribution load shared amongst participants
● If copy of file is available locally, possible to obtain most of the file from local source
– Reduces bandwidth demands
Disadvantages
● No single authoritative source for requested file
● Requesters are typically sharers as well
– Outgoing bandwidth is also used
● May not be able to verify that file is genuine, particularly if using peer-to-peer only network
– Could possibly be malicious
● Easy distribution of illegal material
***************************************************************************