linux解压,寻址学习(解压,寻址,源码安装)

几个基本命令:

tar --- 归档命令 
        //格式::tar [选项] 打包文件名 被打包的源文件或目录列表
         c 创建.tar格式文件  x 释放.tar格式文件 t 查看包中的文件列表
         v 表示在命令执行时显示详细的提示信息
         f 包文件名 用于指定包文件名。
                当与-c选项一起使用时,创建的tar包文件使用该选项指定的文件名
                当与-x选项一起使用时,则释放该选项指定的tar包文件
         p 打包时保留文件及目录的权限
         z 以gzip格式压缩或解压缩文件
         j 以bzip2格式压缩或解压缩文件
         J 使用xz压缩(.tar.xz)xz的压缩率通常比bzip2更高

zip --- 归档和压缩的工具,可以压缩目录

gzip --- 压缩命令

bzip2 --- 压缩命令

xz、unxz --- 压缩命令

sftp --- 交互式文件传输程式
 
xftp --- 在xshell上的交互式传输模式

scp --- 远程验证拷贝文件  

rz --- 本地文件批量上传到远程Linux服务器
sz --- 多个文件从远程服务器下载到本地
//无法下载文件夹格式,需要解压才能下载

shell --- 壳文件

type --- 查看命令类型(file,alisa,builtin)

alias --- 文件别名

hash --- 看命令缓存
    -p 命令路径  -d 删除指定命令缓存 -r 清空缓存

history --- 查看命令历史


快捷方式   ctrl -c   ctrl-z   ctrl-l       

帮助:    man     help

shell 符号:  * []   [^]  [!]  {}   ' '   " "  ``   $  $?

压缩命令:

几个压缩命令:zip,gzip,bzip2,xz,tar
区别:相比而言,zip和tar使用的更多,但是zip会存在乱码问题(跨平台乱码),xz则只能压缩单个文档,gzip性能较全面。tar则为商业不开源

zip命令 :.zip

//zip压缩文件
[root@localhost ~]# zip test1.zip test1
  adding: test1 (stored 0%)
[root@localhost ~]# ls test*
test1  test1.zip  test2  test3
//增加压缩文件
[root@localhost ~]# zip -m test1.zip test2
  adding: test2 (stored 0%)
//删除压缩文件
[root@localhost ~]# zip -d test1.zip test2
deleting: test2
//unzip解压文件
[root@localhost ~]# unzip test1.zip 
Archive:  test1.zip
replace test1? [y]es, [n]o, [A]ll, [N]one, [r]ename: 

 gzip命令:.gz

//使用gzip压缩文件
[root@localhost ~]# gzip test1
[root@localhost ~]# ls test*
test1.gz  test1.zip  test3
//gzip同样可以压缩目录下文件(压缩后源文件消失)
[root@localhost ~]# ls
111               Desktop    initial-setup-ks.cfg  new_wenjian  Templates  test3
anaconda-ks.cfg   Documents  list                  Pictures     test1.gz   Videos
CentOS-Base.repo  Downloads  Music                 Public       test1.zip

 bzip2命令:

//以bzip2的格式压缩test3
[root@localhost ~]# bzip2 -z test3
//此时ls test* 查看所有被压缩项
[root@localhost ~]# ls test*
test1.gz  test1.zip  test3.bz2

xz命令: 

//xz命令压缩test4文件
[root@localhost ~]# xz test4
//列出test*的文件
[root@localhost ~]# ls test*
test1.gz  test1.zip  test3.bz2  test4.xz
//解压缩test文件
[root@localhost ~]# unxz test4.xz 
//列出带test的文件
[root@localhost ~]# ls test*
test1.gz  test1.zip  test3.bz2  test4

文件传输命令:

sftp:

//sftp是属于ssh的加密传输
[root@localhost ~]# sftp  root@192.168.220.132
The authenticity of host '192.168.220.132 (192.168.220.132)' can't be established.
ECDSA key fingerprint is SHA256:jy0EtFt7IuRKPmUUE7QudvMPCukUlKiFgbnddo1oR34.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.220.132' (ECDSA) to the list of known hosts.
root@192.168.220.132's password: 
Permission denied, please try again.
root@192.168.220.132's password: 
Connected to root@192.168.220.132.
sftp> ls
Desktop                 Documents               Downloads               Music                   
Pictures                Public                  Templates               Videos                  
anaconda-ks.cfg         at_test                 cron_test               initial-setup-ks.cfg    
named.localhost         
sftp> lls
111		  Desktop    initial-setup-ks.cfg  new_tar	Public	   test4
anaconda-ks.cfg   Documents  list		   new_wenjian	Templates  Videos
CentOS-Base.repo  Downloads  Music		   Pictures	test3
sftp> 

//ls查看的是此时连接的主机的目录
//lls则是查看主机本地的目录
//sftp的下载为get,从服务器下载到本机
//上传为put,从本机上传到服务器

//下载at_test到本机的根目录下
sftp> get at_test /
Fetching /root/at_test to /at_test
//上传test3 到192.168.220.132的根目录下
sftp> put  tes
test3  test4  
sftp> put  test3   /
Uploading test3 to /test3
test3                                                          100%    0     0.0KB/s   00:00    
sftp> exit 

//此时查看本机的根目录
[root@localhost ~]# cd /
[root@localhost /]# ls
at_test  boot  dir1  dir3  home  lib64  mnt          opt   root  sbin  sys  usr
bin      dev   dir2  etc   lib   media  new_wenjian  proc  run   srv   tmp  var

scp命令: 

//scp传输命令只是单次的传输命令,和sftp一样需要验证机制
//此时从192.168.220.132目录上拷贝new文件到本机的/下
[root@localhost ~]# scp root@192.168.220.132:/new  /
root@192.168.220.132's password: 
new                                                            100%    0     0.0KB/s   00:00    
//查看本机的/目录
[root@localhost ~]# cd /
[root@localhost /]# ls
at_test  boot  dir1  dir3  home  lib64  mnt  new_wenjian  proc  run   srv  tmp  var
bin      dev   dir2  etc   lib   media  new  opt          root  sbin  sys  usr

//此时创建old文件并发送文件到192.168.220.132的/目录下
[root@localhost /]# touch old
//此时要注意发送scp时需要在地址后加上:
[root@localhost /]# scp old root@192.168.220.132:/
root@192.168.220.132's password: 
old                                                            100%    0     0.0KB/s   00:00    

//此时查看192.168.220.132的目录
[root@localhost /]# ls
bin   dev  home  lib64  mnt  old  proc  run   srv  test3  usr  www
boot  etc  lib   media  new  opt  root  sbin  sys  tmp    var

rz命令和sz命令:

rz和sz命令需要下载相关组件,而xshell携带的xftp则可以直接交互式传输文件(虚拟机与主机)

shell内部指令:

  • 一般设置用户的环境变量在/root/.bashrc或者的/root/.bash_profile
  • 全局变量的位置在/etc/bashrc下或者/etc/profile中

环境变量,普通变量:

环境变量有暂时生效和永久生效两种格式

//设置环境变量一般有两种方式
//export和declare命令是暂时生效(仅限当前登录)
// /root/.bashrc下则是设置全局变量(永久生效型)

//设置变量alias ll='ll -s'
[root@localhost ~]# cat /root/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ll -s'

//此时ll等同于ll-s

history命令:

//history是查阅命令历史记录

//histroy -n 是查询最近的n条历史,开始查阅最近5条历史
[root@localhost ~]# history 5
  273  ls test
  274  ls test*
  275  ls
  276  history 
  277  history 5
//history -c 则是清空查阅历史
此时无法读取history缓存

手册与帮助:

//man手册是linux的比较常用的查找历史的工具
//同样的可以使用 -- help 来获取帮助

man手册
空格键         向下翻一页
PaGe down      向下翻一页
PaGe up,b     向上翻一页
home           直接前往首页
end            直接前往尾页
/              从上至下搜索某个关键词,如“/linux”
?              从下至上搜索某个关键词,如“?linux”
n              定位到下一个搜索到的关键词
N              定位到上一个搜索到的关键词
q              退出帮助文档

//liunx同样也支持快捷键

ctrl+d     输入已结束,相当于exit 
ctrl+c     中断请求,终止当前的命令 
Ctrl+a     移动到当前行的开头 
Ctrl+e     移动到当前行的结尾 
Ctrl+l     清屏 
Ctrl+u     剪切命令行中光标所在处之前的所有字符(不包括自身) 
Ctrl+k     剪切命令行中光标所在处之后的所有字符(包括自身) 
Ctrl+R     可以使用该快捷键来搜索历史命令

//linux同样也有很多的通配符
比如:
*       匹配任意字符
?      匹配单个字符
[]      匹配括号中任意一个字符,不能用来创建文件和目录!!!
[^]     匹配方括号中的任意一个字符或数字后进行取反,等同于[! ]
[!]     表示范围可以用".."或"—", 用于查找和删除目录和文件,不用于创建目录和文件
[?-?] 匹配方括号范围内任意一个,用于查询、删除,但不能用于创建目录和文件

源码安装:

解包 —— tar
解包、释放出源代码文件
配置 —— ./configure
针对当前系统、软件环境,配置好安装参数
编译 —— make
将源代码文件变为二进制的可执行程序
安装 —— make install
将编译好的程序文件复制到系统中
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值