当前位置:Gxlcms > 数据库问题 > 零基础学习云计算及大数据DBA集群架构师【Linux系统环境及权限管理2015年12月25日周五】

零基础学习云计算及大数据DBA集群架构师【Linux系统环境及权限管理2015年12月25日周五】

时间:2021-07-01 10:21:17 帮助过:2人阅读

2015.12.25/Fri 2 *************摘要************** 3 压缩和解压 zip gzip bzip2 xz 4 打包 tar 5 bash history alias Tab > >> < << 6 远程连接 ssh scp 7 8 9 10 11 压缩 12 1.压缩的作用: 13 1)节省系统资源和带宽资源 14 2)将内核压缩,可以提升启动速度 15 2.压缩的原理 16 压缩字典 17 3.linux上常见的压缩程序 18 zip 19 gzip 20 bzip2 21 xz 22 4.压缩方式 23 zip 压缩文件名(自拟) 目标文件 24 zip test.zip bigfile testfile 可以同时压缩多个文件 25 gzip 目标文件 ==>会自动生成一个以目标文件名开始以.gz结尾的压缩文件 26 bzip2 目标文件 ==>会自动生成一个以目标文件名开始以.bz2结尾的压缩文件 27 xz 目标文件 ==>会自动生成一个以目标文件名开始以.xz结尾的压缩文件 28 5.特征 29 zip最快 30 xz最慢 31 压缩比取决于不同压缩程序的压缩方式以及源数据流. 32 默认情况下,zip会保留源文件.但是gzip,bzip2,和xz都会删除源文件. 33 zip 可以压缩目录,但是其它程序不行 34 解压 35 1.用法:unzip xxxx.zip 36 -d 可以指定解压的位置 37 unzip root.zip -d /home/ 38 会保留压缩后的文件.用于解压zip压缩的文件. 39 2.用法:gunzip xxxx.gz 40 用于解压gzip压缩的文件,不会保留压缩后的文件. 41 3.用法:bunzip2 xxxxx.bz2 42 用于解压bzip2压缩的文件,不会保留压缩后的文件. 43 4.用法:unxz xxxxx.xz 44 用于解压xz压缩的文件,不会保留压缩后的文件. 45 46 创建大文件的方式:dd if=/dev/zero of=/tmp/bigfile bs=1M count=50 47 48 ============================================ 49 打包:他可以将零碎的文件做成一个整体,方便后续的管理. 50 作用:归档,备份,压缩时会用到. 51 1.打包的命令 52 tar 53 创建打包的方式 54 tar -cf tar包名 参数(可以有多个) ==>f一定要放在最后 55 tar -cf test.tar bigfile testfile 56 查看包里包含的内容 57 tar -tf tar包名 58 tar -tf test1.tar 59 60 tar -czf xxxxx.tar.gz 目标名称 ==>f要放在最后,在打包的过程中,调用gzip程序进行压缩 61 tar -cjf xxxxx.tar.bz2 目标名称 ?==>f要放在最后,在打包的过程中,调用bzip2程序进行压缩 62 tar -cJf xxxxx.tar.xz 目标名称 ?==>f要放在最后,在打包的过程中,调用xz程序进行压缩 63 同样可以通过?tar -tf test1.tar.gz 来查看压缩后的tar包里有哪些文件. 64 2.解包 65 tar -xf xxxx.tar 66 tar -xf test1.tar.gz ,tar会自动调用相对应的程序来自动解压. 67 也可以指定解压过程中调用哪些程序 68 tar -xzf 调用gzip程序 69 tar -xjf 调用bzip2程序 70 tar -xJf 调用xz程序 71 72 3.路径 73 如果使用绝对路径去打包,则会把路径一同打包进去,但是会取消路径前的/ 74 [root@rhel6 tmp]# tar -czf /tmp/conf.tar.gz /etc/a*.conf 75 tar: Removing leading `/ from member names 76 [root@rhel6 tmp]# tar -tf /tmp/conf.tar.gz 77 etc/asound.conf 78 etc/autofs_ldap_auth.conf 79 [root@rhel6 tmp]# tar -xf conf.tar.gz 80 [root@rhel6 tmp]# ll 81 total 8 82 -rw-r--r--. 1 root root 430 Dec 25 14:02 conf.tar.gz 83 drwxr-xr-x. 2 root root 4096 Dec 25 14:03 etc 84 85 可以通过-C来指定路径 86 tar -xf conf.tar.gz -C /home 87 88 89 90 ============================================== 91 92 bash 功能 93 1.历史命令 94 1)上下按键来调用之前的命令 95 2)history 命令可以用来查看当前用户使用过的命令记录 96 [root@rhel6 tmp]# history 97 3)!编号,来调用对应编号下的命令(编号可以通过history去查看) 98 4)!字符,调用以该字符开头,离现在最近的一条命令. 99 5)!$,调用上一个命令的最后一个参数. =alt+. 100 6)默认情况下,保留1000条历史命令. 101 7)HISTSIZE变量默认被存放在/etc/profile文件当中. 102 103 2.别名 104 用alias命令查看当前用户的别名信息 105 [root@rhel6 tmp]# alias 106 alias cp=cp -i 107 alias l.=ls -d .* --color=auto 108 alias ll=ls -l --color=auto 109 alias ls=ls --color=auto 110 alias mv=mv -i 111 alias rm=rm -i 112 alias which=alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde 113 114 这就是我们root用户使用rm命令为什么会出现交互式的原因. 115 定义别名的方式:alias cpp="cp -p" 116 特点:临时生效. 117 118 3.tab键补全 119 按一下tab键,可以自动帮你补全文件名,也可以补全命令. 120 按两下tab键,可以罗列匹配之前字符串的所有文件.如果没有输入字符串,则将该目录下所有文件名罗列出来,包括隐藏文件. 121 122 4.快捷键 123 ctrl+L 清屏 124 ctrl+A 跳行首 125 ctrl+e 跳行尾 126 ctrl+c 中断命令,可以在命令执行的过程中中断,也可以在命令行直接中断 127 128 =============================== 129 ssh 用法 130 ssh 身份@ip地址/主机名 131 /etc/hosts文件,专门用来解析ip地址和主机名的对应关系. 132 scp 远程复制 133 用法 134 1)scp 源文件 目标IP地址:绝对路径 135 scp test1 172.25.0.10:/tmp 136 2)scp 远程主机IP地址:源文件绝对路径 本机的目标位置 137 scp 172.25.0.10:/tmp/carolfile /tmp 138 3)scp 复制目录需要加上-r选项 139 140 ================================================ 141 计算机五大部件 142 运算器、控制器 --> cpu 143 存储器 -->内存 144 input device 145 output device 146 147 input 数据的来源 148 output 数据的目的地 149 150 stdout:标准输出 ==>/dev/stdout 1 151 stdin:标准输入 ==>/dev/stdin 0 152 stderr:标准错误输出 ==>/dev/stderr 2 153 对于这三者,都有一个文件描述符 154 [root@rhel6 ~]# ll /dev/stdin /dev/stdout /dev/stderr 155 lrwxrwxrwx. 1 root root 15 Dec 25 09:24 /dev/stderr -> /proc/self/fd/2 156 lrwxrwxrwx. 1 root root 15 Dec 25 09:24 /dev/stdin -> /proc/self/fd/0 157 lrwxrwxrwx. 1 root root 15 Dec 25 09:24 /dev/stdout -> /proc/self/fd/1 158 159 >标准输出覆盖重定向。 160 >>追加重定向 161 162 重定向:改变输入的位置或者输出的流向。 163 164 2>标准错误覆盖重定向 165 2>>标准错误追加重定向 166 167 [root@rhel6 ~]# ls /varr 2> /tmp/test 168 [root@rhel6 ~]# cat /tmp/test 169 ls: cannot access /varr: No such file or directory 170 [root@rhel6 ~]# ls /varr 2>> /tmp/test 171 [root@rhel6 ~]# cat /tmp/test 172 ls: cannot access /varr: No such file or directory 173 ls: cannot access /varr: No such file or directory 174 175 可以通过一条命令,将错误的输出和正确的输出定义到不同的文件当中去 176 ls /varr > /tmp/true 2> /tmp/false 177 178 &>无论是标准错误输出还是标准输出都重定向到同一个文件中,会覆盖文件里之前的内容 179 [root@rhel6 ~]# ls /varr &> /tmp/full.out 180 [root@rhel6 ~]# cat /tmp/full.out 181 ls: cannot access /varr: No such file or directory 182 [root@rhel6 ~]# ls /var &> /tmp/full.out 183 [root@rhel6 ~]# cat /tmp/full.out 184 account 185 cache 186 crash 187 cvs 188 db 189 empty 190 games 191 192 &>>代表无论是标准输出还是标准错误输出,都以追加的方式重定向到同一个文件中。 193 [root@rhel6 ~]# ls /varr &>> /tmp/full.out 194 [root@rhel6 ~]# tail -n1 /tmp/full.out 195 ls: cannot access /varr: No such file or directory 196 [root@rhel6 ~]# tail -n2 /tmp/full.out 197 yp 198 ls: cannot access /varr: No such file or directory 199 200 2>&1 201 用法:ls -l asdfasdfadf > /tmp/find.out 2>&1 代表无论是标准输出还是标准错误输出,都以覆盖的方式重定向到同一个文件中 202 ls -l asdfasdfadf >> /tmp/find.out 2>&1 代表无论是标准输出还是标准错误输出,都以追加的方式重定向到同一个文件中 203 204 205 输入重定向 206 < 207 某些命令可能默认带有输入重定向的功能 208 [root@rhel6 ~]# cat 209 123 210 123 211 234 212 234 213 ^C 214 ======================== 215 [root@rhel6 ~]# cat < /etc/fstab 216 217 # 218 # /etc/fstab 219 # Created by anaconda on Thu Jul 2 15:35:54 2015 220 # 221 # Accessible filesystems, by reference, are maintained under /dev/disk 222 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 223 224 ================= 225 [root@rhel6 ~]# cat > /tmp/fs < /etc/fstab 226 这句话表示将 /etc/fstab文件,以覆盖的方式写入到/tmp/fs文件中去 227 228 229 [root@rhel6 ~]# cat >> /tmp/fs < /etc/hosts 230 这句话表示,将/etc/hosts文件内容以追加的方式写入到/tmp/fs文件当中去 231 232 << HERE DOCUMENT 在此处生成文档 233 ENDF 234 EOF 235 236 [root@rhel6 ~]# cat > /tmp/ok <<ENDF 237 238 > 1 239 > 2 240 > 3 241 > 4 242 > ENDF 243 244 245 [root@rhel6 ~]# cat /tmp/ok 246 247 1 248 2 249 3 250 4 251 252 [root@rhel6 ~]# cat > /tmp/ok <<abc 253 254 > carol 255 > lucky 256 > christmas 257 > abc 258 [root@rhel6 ~]# cat /tmp/ok 259 260 carol 261 lucky 262 christmas 263 264 [root@rhel6 ~]# cat >> /tmp/ok <<abc 265 266 carol 267 lucky 268 christmas 269 abc 270 271 [root@rhel6 ~]# cat /tmp/ok 272 273 carol 274 lucky 275 christmas 276 277 carol 278 lucky 279 christmas 280 281 282 管道:只会将标准输出向后传递,标准错误输出是不会向后传递的。

 

零基础学习云计算及大数据DBA集群架构师【Linux系统环境及权限管理2015年12月25日周五】

标签:

人气教程排行