Linux Course Sixth Day study notes

Source: Internet
Author: User
Tags bz2 rsync

#############################
##### 12. File transfer between different systems #####
#############################

####################
[Email protected] desktop]# scp-r/etc/[email protected]:/mnt/# # "-R" copy directory
[email protected] ' s password:
... # #速度太慢, press "CTRL + C" to forcibly interrupt
[Email protected] desktop]# du-sh/etc/# #查看文件或目录的大小
36m/etc/
[[Email protected] desktop]# tar CF etc.tar/etc/# #把 "/etc/" for archiving
Tar:removing leading '/' from member names
--------------------------------------------------------------------------------
Note: If you do not remove the "/", then the absolute path is packaged. The "/etc" will be overwritten when extracting, so the "/" must be removed.
And if it is an absolute path, you can no longer specify the path when extracting it.
--------------------------------------------------------------------------------
[[email protected] desktop]# ls
Etc.tar
[Email protected] desktop]# du-sh Etc.tar # #查看文件或目录的大小
32M Etc.tar
[Email protected] desktop]# scp-r Etc.tar [email protected]:/mnt/# # "-R" copy directory
[email protected] ' s password:
Etc.tar 100% 32MB 31.7mb/s 00:00 # #几乎瞬间就完成
[[email protected] desktop]# ssh [email protected]
[email protected] ' s password:
Last Login:fri Oct 03:07:01 from 172.25.50.250
[Email protected] ~]# ls/mnt/
Etc Etc.tar
[Email protected] ~]# rm-fr/mnt/*
[Email protected] ~]# ls/mnt
####################

################### #1. File Archive ####################
1. File archiving is to turn multiple files into an archive file

2.
Tar C # #创建
F # #指定归档文件名称
t # #显示归档文件中的内容
R # #向归档文件中添加文件
--get # #取出单个文件
--delete # #删除单个文件
-X # #取出归档文件中的所有内容
-C # #指定解档目录
-Z # #gz格式压缩
-J # #bz2格式压缩
-J # #xz格式压缩

You can use "man tar" to see the usage

####################
[[email protected] desktop]# Touch file{1..5}
[[Email protected] desktop]# tar CF File.tar file{1..5}
[[email protected] desktop]# ls
file1 file2 file3 file4 file5 File.tar
[Email protected] desktop]# rm-fr file?
[Email protected] desktop]# Tar XF File.tar
[[email protected] desktop]# ls
file1 file2 file3 file4 file5 File.tar
[Email protected] desktop]# rm-fr file?
[email protected] desktop]# Touch Westos
[Email protected] desktop]# tar RF File.tar Westos
[Email protected] desktop]# tar tf file.tar
File1
File2
File3
File4
File5
Westos
[[email protected] desktop]# ls
File.tar Westos
[Email protected] desktop]# tar f file.tar--get file1
[Email protected] desktop]# tar tf file.tar
File1
File2
File3
File4
File5
Westos
[[email protected] desktop]# ls
File1 File.tar Westos
[Email protected] desktop]# tar f file.tar--delete Westos
[Email protected] desktop]# tar tf file.tar
File1
File2
File3
File4
File5
[Email protected] desktop]# tar XF file.tar-c/mnt/
[Email protected] desktop]# ls/mnt/
file1 file2 file3 file4 file5
####################

####################
[[email protected] desktop]# Touch file{1..5}
[[Email protected] desktop]# tar cvf file.tar file{1..5}
File1
File2
File3
File4
File5
"Tar cvf" # #把文件归档并在输出栏列出
####################

################### #2. Compression ####################
Gz
Gzip Etc.tar # #压缩成gz格式
Gunzip etc.tar.gz # #解压gz格式压缩包
Tar zcf etc.tar.gz/etc # #把文件归档为tar并压缩成gz
Tar zxf etc.tar.gz # #解压并解挡gz格式压缩包

bz2
bzip2 Etc.tar # #压缩成bz2格式
BUNZIP2 etc.tar.bz2 # #解压bz2格式压缩包
Tar jcf etc.tar.bz2/etc # #把文件归档为tar并压缩成bz2
Tar jxf etc.tar.bz2 # #解压并解挡bz2格式压缩包

Xz
XZ Etc.tar # #压缩成xz格式
Unxz ETC.TAR.XZ # #解压xz格式压缩包
Tar Jcf etc.tar.xz/etc # #把文件归档为tar并压缩成xz
Tar jxf etc.tar.xz # #解压并解挡xz格式压缩包

Zip
Zip-r Etc.tar.zip Etc.tar # #压缩成zip格式
Unzip Etc.tar.zip # #解压zip格式压缩包

Note: Zip packaging
cannot be packaged directly into a ". zip", which must first be archived as ". Tar"
Archived files are not deleted after packaging
Package files are not deleted after unpacking

####################
[Email protected] desktop]# tar CF etc.tar/etc/
Tar:removing leading '/' from member names
[[email protected] desktop]# ls
Etc.tar
[Email protected] desktop]# Du-sh Etc.tar
30M Etc.tar

[Email protected] desktop]# gzip Etc.tar
[[email protected] desktop]# ls
Etc.tar.gz
[Email protected] desktop]# Du-sh etc.tar.gz
8.4M etc.tar.gz
[Email protected] desktop]# gunzip etc.tar.gz
L[[email protected] desktop]# ls
Etc.tar

[Email protected] desktop]# bzip2 Etc.tar
[[email protected] desktop]# ls
etc.tar.bz2
[Email protected] desktop]# Du-sh etc.tar.bz2
15M etc.tar.bz2
[Email protected] desktop]# BUNZIP2 etc.tar.bz2
[[email protected] desktop]# ls
Etc.tar.gz

[Email protected] desktop]# XZ Etc.tar
[[email protected] desktop]# ls
Etc.tar.xz
[Email protected] desktop]# Du-sh ETC.TAR.XZ
7.9M ETC.TAR.XZ
[Email protected] desktop]# Unxz ETC.TAR.XZ
[[email protected] desktop]# ls
Etc.tar

[Email protected] desktop]# zip-r etc.tar.zip Etc.tar
Adding:etc.tar (deflated 72%)
[[email protected] desktop]# ls
Etc.tar Etc.tar.zip
[Email protected] desktop]# Du-sh etc.tar.zip
15M Etc.tar.zip
[Email protected] desktop]# RM-FR Etc.tar
[[email protected] desktop]# ls
Etc.tar.zip
[Email protected] desktop]# Unzip Etc.tar.zip
Archive:etc.tar.zip
Inflating:etc.tar
[[email protected] desktop]# ls
Etc.tar Etc.tar.zip
Zip compression and decompression will not delete the original file

[Email protected] desktop]# RM-FR *
[Email protected] desktop]# tar zcf etc.tar.gz/etc/
Tar:removing leading '/' from member names
[[email protected] desktop]# ls
Etc.tar.gz
[Email protected] desktop]# tar jcf etc.tar.bz2/etc/
Tar:removing leading '/' from member names
[[email protected] desktop]# ls
ETC.TAR.BZ2 etc.tar.gz
[Email protected] desktop]# tar Jcf etc.tar.xz/etc/
Tar:removing leading '/' from member names
[[email protected] desktop]# ls
ETC.TAR.BZ2 etc.tar.gz Etc.tar.xz
[[Email protected] desktop]# file * # #查看那文件的类型
ETC.TAR.BZ2:BZIP2 compressed data, block size = 900k
Etc.tar.gz:gzip compressed data, from Unix, last Modified:fri Oct 14 04:03:53 2016
Etc.tar.xz:XZ Compressed data

[Email protected] desktop]# tar zxf etc.tar.gz
[[email protected] desktop]# ls
etc etc.tar.bz2 etc.tar.gz ETC.TAR.XZ
[Email protected] desktop]# RM-FR etc/
[[email protected] desktop]# ls
ETC.TAR.BZ2 etc.tar.gz Etc.tar.xz
[Email protected] desktop]# tar jxf etc.tar.bz2
[[email protected] desktop]# ls
etc etc.tar.bz2 etc.tar.gz ETC.TAR.XZ
[Email protected] desktop]# RM-FR etc/
[[email protected] desktop]# ls
ETC.TAR.BZ2 etc.tar.gz Etc.tar.xz
[Email protected] desktop]# tar jxf etc.tar.xz
[[email protected] desktop]# ls
etc etc.tar.bz2 etc.tar.gz ETC.TAR.XZ
####################

################### #3. File transfer #################### in the system
scp/dir/file [email Protected]:/dir # #上传
SCP [email Protected]:/dir/file/dir # #下载

The SCP can be copied natively or remotely. ":" Activate remote access

rsync [parameter] file [email protected]:/dir
Rsync-r # #同步目录
-L # #不忽略链接
-P # #不忽略文件权限
-T # #不忽略文件时间戳
-G # #不忽略文件所有组
-O # #不忽略文件所有人
-D # #不忽略设备文件

####################
LN is a feature that creates a link to a file in another location
Establish a soft link: ln–s [source] [purpose]. Creates a mirror of a file at the selected location, without consuming disk space,
Establish a hard link: ln [source] [purpose], no parameter-S. Generates a file of the same size as the source file at the selected location
Files are kept in sync, whether it's a soft link or a hard link.
####################

####################
[Email protected] desktop]# ll/dev/pts/
Total 0
Crw--w----. 1 root TTY 136, 1 Oct 14 04:17 1
C---------. 1 root root 5, 2 Oct 21:33 PTMX # #发现块设备
[Email protected] desktop]# rsync-r/dev/pts/mnt/
Skipping non-regular file "PTS/1"
Skipping non-regular file "PTS/PTMX"
[Email protected] desktop]# rsync-dr/dev/pts/mnt/
[Email protected] desktop]# ll/mnt/pts
Total 0
CRW-------. 1 root root 136, 1 Oct 14 04:18 1
C---------. 1 root root 5, 2 Oct 04:18 PTMX # #块设备被同步了过来

[Email protected] desktop]# rm-fr/mnt/*
[Email protected] desktop]# rsync-dr/dev/pts//mnt/
[Email protected] desktop]# ls/mnt/
1 PTMX
Note: "/dev/pts/" is a copy of the file under the directory, "/dev/pts" the directory itself and the files in the file together.
####################

#################
# # # # 11. Manage the Network # #
#################

################### #1. IP Fundamentals ####################
1.ipv4
2 binary 32-bit-----10-binary

172.25.0.10/255.255.255.0
172.25.0.10:ip Address
255.255.255.0: Subnet Mask
Subnet mask 255-bit corresponding IP bit for network bit
Subnet mask 0-bit IP-bit corresponding to main camera

####################
To view IP commands:
1. "Ifconfig", if a network card is configured with dual IP, then use "ifconfig" is not visible
2. "IP addr Show", you can see all the IP
####################

################### #2. Configuring ip####################
1. Graphical
Nm-connection-editor

2. Textual
Nmtui

<< commands >>
Ifconfig NIC IP [netmask subnet mask] # #临时设定, subnet mask can not be written

####################
[Email protected] desktop]# ifconfig eth0 172.25.50.101 netmask 255.255.255.0
[Email protected] desktop]# ifconfig eth0
Eth0:flags=4163<up,broadcast,running,multicast> MTU 1500
inet 172.25.50.101 netmask 255.255.255.0 broadcast 172.25.50.255 # #IP变成 "101"
Inet6 fe80::5054:ff:fe00:320a Prefixlen ScopeID 0x20<link>
Ether 52:54:00:00:32:0a Txqueuelen (Ethernet)
RX packets 40231 Bytes 392882507 (374.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 29748 Bytes 3009571 (2.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[Email protected] desktop]# systemctl Restart Network # #重启网络服务
[Email protected] desktop]# ifconfig eth0
Eth0:flags=4163<up,broadcast,running,multicast> MTU 1500
inet 172.25.50.100 netmask 255.255.255.0 broadcast 172.25.50.255 # #IP变回 "100"
Inet6 fe80::5054:ff:fe00:320a Prefixlen ScopeID 0x20<link>
Ether 52:54:00:00:32:0a Txqueuelen (Ethernet)
RX packets 40231 Bytes 392882507 (374.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 29769 Bytes 3012561 (2.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
####################

NMCLI Connection Add type Ethernet con-name WESTOS ifname eth0 AutoConnect Yes
NMCLI Connection Add type Ethernet con-name WESTOS ifname eth0 ip4 ip/24
NMCLI Connection Delete Westos
NMCLI Connection Show
NMCLI Connection down Westos
NMCLI Connection up Westos
NMCLI connection Modify "Westos" Ipv4.addresses newip/24
NMCLI connection Modify "System eth0" Ipv4.method <auto|manual>
NMCLI Device Connect eth0
NMCLI Device Disconnect Eth0
NMCLI Device Show
NMCLI Device status

####################
"Add" and "Modify" Remember "systemctl Restart Network"

NMCLI connection Down Westos = nmcli device Disconnect eth0
NMCLI connection Up Westos = nmcli device Connect eth0
NMCLI Device status = NMCLI device

[Email protected] desktop]# nmcli connection Modify "System eth0" IPv4.
Ipv4.addresses Ipv4.dns Ipv4.may-fail
Ipv4.dhcp-client-id Ipv4.dns-search Ipv4.method
Ipv4.dhcp-hostname Ipv4.ignore-auto-dns Ipv4.never-default
Ipv4.dhcp-send-hostname ipv4.ignore-auto-routes Ipv4.routes
[Email protected] desktop]# nmcli connection Modify "System eth0" Ipv4.method--help
error:failed to modify Ipv4.method: '--help ' not among [auto, link-local, Manual, GKFX, disabled].
The advantage of NMCLI is that you can double-click "Table" at any time, you can use "--help"
####################

<< Files >>
DHCP # #动态获取
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 # #接口使用设备
BOOTPROTO=DHCP # #网卡工作模式
Onboot=yes # #网络服务开启时自动激活
Name=eth0 # #网络接口名称
: Wq
Systemctl Restart Network

Static|none # #静态网络
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 # #接口使用设备
Bootproto=static|none # #网卡工作模式
Onboot=yes # #网络服务开启时自动激活
Name=eth0 # #网络接口名称
IPADDR=172.25.0.100 # #IP地址
netmask=255.255.255.0 | PREFIX=24 # #子网掩码
: Wq
Systemctl Restart Network

If you want to set multiple IPs on the network card (as if it can set up to 99), can not use netmask, only with prefix

"Setup" command # #红帽6及以前的版本可以使用 "Setup" command to configure IP, Red Hat 7 is not

####################
[Email protected] desktop]# systemctl Restart Network # #重启网络基本服务
[Email protected] desktop]# systemctl restart NetworkManager # #重启网络智能管理服务

[Email protected] desktop]# Systemctl Reload Network
Job for Network.service canceled.
Restart Network Service cannot use reload
####################

This article from the "Schue Linux Learning Notes" blog, declined reprint!

Linux Course Sixth Day study notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.