RHCE 第五天

natstat -vat

v:verbose

a: all

t: tcp

[root@rhel01 ~]# netstat -vat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:34028 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 localhost:ipp 0.0.0.0:* LISTEN
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN
tcp 0 64 localhost:ssh localhost:49512 ESTABLISHED
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:ipp [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
tcp6 0 0 [::]:56828 [::]:* LISTEN
[root@rhel01 ~]# netstat -vatn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:34028 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 64 192.168.40.131:22 192.168.40.1:49512 ESTABLISHED
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
tcp6 0 0 :::56828 :::* LISTEN

 

如果是 u,则为 udp

查看 ssh 是否开启

netstat -vatn: 看端口号。一般 Linux 看端口号。

 

看 dns 是哪个文件?

/etc/resolv.conf

 

vim: 

:e! 放弃所有更改,重新开始新的编辑

 

dw cw 经常用

r 字符:好像是删除字符

 

wget:

[root@rhel01 ~]# wget ftp://test:test@192.168.1.104/a.txt
--2014-07-19 21:58:24-- ftp://test:*password*@192.168.1.104/a.txt
=> “a.txt”
正在连接 192.168.1.104:21... 已连接。
正在以 test 登录 ... 登录成功!
==> SYST ... 完成。 ==> PWD ... 完成。
==> TYPE I ... 完成。 ==> 不需要 CWD。
==> SIZE a.txt ... 58
==> PASV ... 完成。 ==> RETR a.txt ... 完成。
长度:58 (非正式数据)

100%[=======================================================================================>] 58 --.-K/s 用时 0s

2014-07-19 21:58:24 (3.43 MB/s) - “a.txt” 已保存 [58]

 

 

-r 可以把整个文件 recursive 下来

[root@rhel01 testwget]# pwd
/tmp/testwget
[root@rhel01 testwget]# ls
[root@rhel01 testwget]# !wget
wget -r ftp://test:test@192.168.1.104
--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/
=> “192.168.1.104/.listing”
正在连接 192.168.1.104:21... 已连接。
正在以 test 登录 ... 登录成功!
==> SYST ... 完成。 ==> PWD ... 完成。
==> TYPE I ... 完成。 ==> 不需要 CWD。
==> PASV ... 完成。 ==> LIST ... 完成。

[ <=> ] 167 --.-K/s 用时 0s

2014-07-19 22:14:12 (17.0 MB/s) - “192.168.1.104/.listing” 已保存 [167]

已删除 “192.168.1.104/.listing”。
--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/a.txt
=> “192.168.1.104/a.txt”
==> 不需要 CWD。
==> PASV ... 完成。 ==> RETR a.txt ... 完成。
长度:58

100%[======================================>] 58 --.-K/s 用时 0s

2014-07-19 22:14:12 (6.84 MB/s) - “192.168.1.104/a.txt” 已保存 [58]

--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/b.txt
=> “192.168.1.104/b.txt”
==> 不需要 CWD。
==> PASV ... 完成。 ==> RETR b.txt ... 完成。
长度:58

100%[======================================>] 58 --.-K/s 用时 0s

2014-07-19 22:14:12 (7.00 MB/s) - “192.168.1.104/b.txt” 已保存 [58]

--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/
=> “192.168.1.104/wina/.listing”
==> CWD (1) /wina ... 完成。
==> PASV ... 完成。 ==> LIST ... 完成。

[ <=> ] 108 --.-K/s 用时 0s

2014-07-19 22:14:12 (9.40 MB/s) - “192.168.1.104/wina/.listing” 已保存 [108]

已删除 “192.168.1.104/wina/.listing”。
--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/c.txt
=> “192.168.1.104/wina/c.txt”
==> 不需要 CWD。
==> SIZE c.txt ... 完成。
==> PASV ... 完成。 ==> RETR c.txt ... 完成。

[ <=> ] 0 --.-K/s 用时 0s

2014-07-19 22:14:12 (0.00 B/s) - “192.168.1.104/wina/c.txt” 已保存 [0]

--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/b/
=> “192.168.1.104/wina/b/.listing”
==> CWD (1) /wina/b ... 完成。
==> PASV ... 完成。 ==> LIST ... 完成。

[ <=> ] 111 --.-K/s 用时 0s

2014-07-19 22:14:12 (9.42 MB/s) - “192.168.1.104/wina/b/.listing” 已保存 [111]

已删除 “192.168.1.104/wina/b/.listing”。
--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/b/read.txt
=> “192.168.1.104/wina/b/read.txt”
==> 不需要 CWD。
==> SIZE read.txt ... 完成。
==> PASV ... 完成。 ==> RETR read.txt ... 完成。

[ <=> ] 0 --.-K/s 用时 0s

2014-07-19 22:14:12 (0.00 B/s) - “192.168.1.104/wina/b/read.txt” 已保存 [0]

--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/b/c/
=> “192.168.1.104/wina/b/c/.listing”
==> CWD (1) /wina/b/c ... 完成。
==> PASV ... 完成。 ==> LIST ... 完成。

[ <=> ] 57 --.-K/s 用时 0s

2014-07-19 22:14:12 (2.56 MB/s) - “192.168.1.104/wina/b/c/.listing” 已保存 [57]

已删除 “192.168.1.104/wina/b/c/.listing”。
--2014-07-19 22:14:12-- ftp://test:*password*@192.168.1.104/wina/b/c/bb.xls
=> “192.168.1.104/wina/b/c/bb.xls”
==> 不需要 CWD。
==> PASV ... 完成。 ==> RETR bb.xls ... 完成。
长度:7168 (7.0K)

100%[======================================>] 7,168 --.-K/s 用时 0.002s

2014-07-19 22:14:12 (3.74 MB/s) - “192.168.1.104/wina/b/c/bb.xls” 已保存 [7168]

FINISHED --2014-07-19 22:14:12--
Total wall clock time: 0.07s
Downloaded: 5 files, 7.1K in 0.002s (3.66 MB/s)
[root@rhel01 testwget]# ls
192.168.1.104
[root@rhel01 testwget]#

[root@rhel01 testwget]# wget www.baidu.com
--2014-07-19 22:18:34-- http://www.baidu.com/
正在解析主机 www.baidu.com (www.baidu.com)... 61.135.169.125, 61.135.169.105
正在连接 www.baidu.com (www.baidu.com)|61.135.169.125|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:未指定 [text/html]
正在保存至: “index.html”

[ <=> ] 53,059 --.-K/s 用时 0.04s

2014-07-19 22:18:34 (1.38 MB/s) - “index.html” 已保存 [53059]

[root@rhel01 testwget]# ls
192.168.1.104 index.html

 

firefox

file 协议: file:///etc

links: 非 GUI web browser

links 在 elinks rpm 中

[root@rhel01 Packages]# rpm -ivh elinks-0.12-0.36.pre6.el7.x86_64.rpm nss_compat_ossl-0.9.6-8.el7.i686.rpm nss_compat_ossl-0.9.6-8.el7.x86_64.rpm

 

email and message:

1. Evolution 2. Thunderbird 3. Mutt 4. Pidgin

 

Remte Access & File Transfer

sftp://127.0.0.1

sftp 是 SSH 的一个子协议

SSH 包名 OpenSSH (Secure Remote Shell)

 

scp: secure copy

scp [user@]host:/path/to/file

-r

-p: 权限也 copy 过来

-C: 压缩

包名 OpenSSH

server

client

ssh

 

rpm -qa | grep ssh

rpm -qi OpenSSH

-i: information

 

ifconfig eno16777736 192.168.1.111/24

 

Vmware 虚拟出来两个网卡
Host Only: 使用 VMNet1

NAT: 使用 VMNet8

Bridging: 使用主机物理网卡

 

ssh root@192.168.40.133

ssh 192.168.40.133 ifconfig

~/.ssh/known_hosts

scp /etc/fstab root@192.168.40.133:/tmp/fstab.alllen

scp root@127.0.0.1:/etc/inittab

scp root@192.168.40.133:/tmp/rhel-m2 allen@192.168.40.131:/home/allen

 

rsync: 大量文件需要 copy, 只 copy 变化de

 

加密:对称,非对称

rsa:非对称加密算法

ssh-keygen

ssh-copy-id

#ssh-keygen

#ssh-copy-id -i .ssh/id_rsa.pub 192.168.40.133

#ls ~/.ssh/id*

#ssh 127.0.0.1

 

ftp clients: 

lftp

 

Smaba: smbclient -L //192.168.40.1 -U root %r

ping -C4 192.168.40.1

traceroute www.baidu.com

/etc/gshadow:7已经不用了

密码策略在: /etc/shadow 中

/etc/login.defs

useradd

usermod

userdel -r: 这个 -r 非常重要,否则不安全

一个 boss, 走了,删除没用 -r, 留下 /home/boss,

新来的用户创建用户名时,会自动把 boss 的 /home/boss 的组分给新的用户的。这样新的用户可以访问 boss 的文件夹

 

usermod -l newname oldname

root 的名字也可以改,但是要在 /etc/passwd 和 /etc/shadow 中都改

用户正在登陆呢, root 无法改他的名字

cat /etc/selinux/config

/var/log/dmesg: 内核日志文件

/var/log/secure

 

wc -l /var/log/messages

pam 文件

man usermod

/Lock

考试时主要考组的概念,所以 -G 很重要

 

w:

last:

lastb:

lastlog:

 

umask:

root 的 umask 0022

普通用户的umask 0002

666 777

folder = 777 - umask

file = 666 - umask

 

suid: 调用的用户,调用文件所有者的权限去操作

sgid

rws r-x r-x

u    g   o

suid sgid stid

 

cp mv rm

findmnt: 看分区的文件类型

findmnt /: xfs

ext4, iso9660:光盘镜像格式

man fstab

/iso

Linux 可直接挂载

 

hard link

symbolic (soft) link

ln -s /etc/fstab ~/fs

hard link :增加 inode 个数

soft link: 不增加 inode 个数

加入一个文件有多于一个 inode,如何额找到其他的文件的位置

find / -inum 1348996

ls -l /dev/sr0 (光盘)

ls -l /dev/tty

find / -type p (p 表示 pipe)

 

du -sh /boot

df -h (按照 1024 算)

df -H (按照 1000算)

 

mount /dev/sr0 /media

umount /dev/sr0

cd mnt

mkdir /mnt/floppy

mount /xxxx floppy

光盘 DVD: eject /dev/cdrom

gnome-mount

findmnt

mount|grep sr0

 

低版本中必须

 mount -o loop Desktop/linux.iso /mnt/iso

否则出错

RHEL 7 则不需要加 -o

如何挂载 ntfs,1.编译内核 2.第三方工具

posted @ 2014-07-19 23:04  allenbackpacker  阅读(173)  评论(0)    收藏  举报