zoukankan      html  css  js  c++  java
  • Linux常用命令

    1.压缩/解压

    01-.tar格式
    解包:[*******]$ tar xvf FileName.tar
    打包:[*******]$ tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)
    02-.gz格式
    解压1:[*******]$ gunzip FileName.gz
    解压2:[*******]$ gzip -d FileName.gz
    压 缩:[*******]$ gzip FileName
    
    03-.tar.gz格式
    解压:[*******]$ tar zxvf FileName.tar.gz
    压缩:[*******]$ tar zcvf FileName.tar.gz DirName
    
    04-.bz2格式
    解压1:[*******]$ bzip2 -d FileName.bz2
    解压2:[*******]$ bunzip2 FileName.bz2
    压 缩: [*******]$ bzip2 -z FileName
    
    05-.tar.bz2格式
    解压:[*******]$ tar jxvf FileName.tar.bz2
    压缩:[*******]$ tar jcvf FileName.tar.bz2 DirName
    
    06-.bz格式
    解压1:[*******]$ bzip2 -d FileName.bz
    解压2:[*******]$ bunzip2 FileName.bz
    
    07-.tar.bz格式
    解压:[*******]$ tar jxvf FileName.tar.bz
    
    08-.Z格式
    解压:[*******]$ uncompress FileName.Z
    压缩:[*******]$ compress FileName
    
    09-.tar.Z格式
    解压:[*******]$ tar Zxvf FileName.tar.Z
    压缩:[*******]$ tar Zcvf FileName.tar.Z DirName
    
    10-.tgz格式
    解压:[*******]$ tar zxvf FileName.tgz
    
    11-.tar.tgz格式
    解压:[*******]$ tar zxvf FileName.tar.tgz
    压缩:[*******]$ tar zcvf FileName.tar.tgz FileName
    
    12-.zip格式
    解压:[*******]$ unzip FileName.zip
    压缩:[*******]$ zip FileName.zip DirName
    
    13-.lha格式
    解压:[*******]$ lha -e FileName.lha
    压缩:[*******]$ lha -a FileName.lha FileName
    
    14-.rar格式
    解压:[*******]$ rar a FileName.rar
    压缩:[*******]$ rar e FileName.rar      
    rar请到:下载!
    解压后请将rar_static拷贝到/usr/bin目录(其他由$PATH环境变量
    指定的目录也行):[*******]$ cp rar_static /usr/bin/rar
    

    2.查看文件状态

    stat <file name>
    

    3.复制文件/文件夹
    1)复制远程文件到本地

    [root@51dev shijingjing]# scp root@120.26.128.110:/home/shijingjing/mydir/test.txt .
    

    远程文件地址: root@120.26.128.110:/home/shijingjing/mydir/test.txt
    本地文件夹: .

    2)复制本地文件到远程

    [root@51dev shijingjing]# scp ./test.txt root@120.26.128.110:/home/shijingjing
    

    远程文件地址: root@120.26.128.110:/home/shijingjing/mydir/test.txt
    本地文件夹: .

    3)复制远程文件夹到本地

    [root@51dev shijingjing]# scp -r root@120.26.128.110:/home/shijingjing/mydir .
    

    远程文件夹地址: root@120.26.128.110:/home/shijingjing/mydir
    本地文件夹: .

    4)复制本地文件夹到远程

    [root@51dev shijingjing]# scp -r . root@120.26.128.110:/home/shijingjing
    

    4.清空文件内容

    echo > test.txt
    

    5.查看系统版本
    1)查看系统内核

    uname -a
    

    2)查看操作系统版本

    cat /proc/version
    

    6.创建父子目录

    mkdir /dir1/dir2 # 报错 mkdir: cannot create directory ‘dir1/dir2’: No such file or directory
    mkdir -p /dir1/dir2
    

    7.更新环境变量

    export PATH=$PATH:/home/qyx/spark/bin
    

    8.本地复制文件,文件夹
    复制source文件夹,到dest目录下

    cp -r /source/ /dest
    

    复制source文件夹下的所有文件(不包括source文件夹本身),到dest目录下

    cp -r /source/* /dest
    

    9.复制网站镜像

    wget -r -p -np -k http://xxx.com/xxx
    

    10.安装sz rz

    yum install -y lrzsz
    

    11.开机自启动
    1)把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd。

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
     
    touch /var/lock/subsys/local
    /usr/local/apache/bin/apachectl start
    

    2)把写好的启动脚本添加到目录/etc/rc.d/init.d/,然后使用命令chkconfig设置开机启动。
    例如:我们把httpd的脚本写好后放进/etc/rc.d/init.d/目录,使用

    chkconfig --add httpd
    chkconfig httpd on
    
  • 相关阅读:
    STM32 F4 DAC DMA Waveform Generator
    STM32 F4 General-purpose Timers for Periodic Interrupts
    Python第十四天 序列化 pickle模块 cPickle模块 JSON模块 API的两种格式
    Python第十三天 django 1.6 导入模板 定义数据模型 访问数据库 GET和POST方法 SimpleCMDB项目 urllib模块 urllib2模块 httplib模块 django和web服务器整合 wsgi模块 gunicorn模块
    查看SQL Server服务运行帐户和SQL Server的所有注册表项
    Pycharm使用技巧(转载)
    SQL Server 2014内存优化表的使用场景
    Python第十天 print >> f,和fd.write()的区别 stdout的buffer 标准输入 标准输出 从控制台重定向到文件 标准错误 重定向 输出流和输入流 捕获sys.exit()调用 optparse argparse
    Python第七天 函数 函数参数 函数里的变量 函数返回值 多类型传值 函数递归调用 匿名函数 内置函数
    Python第六天 类型转换
  • 原文地址:https://www.cnblogs.com/shijingjing07/p/9334997.html
Copyright © 2011-2022 走看看