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

    1. su

    // 需要输入切换账号的密码
    // -, -l, --login
    su - anotherUserName;  // 切换到anotherUserName
    su -            // 切换到root
    su              // 仅切换到root,工作目录不会切换

     2. sudo

    // 需要输入当前账号密码
    sudo command    // 以root身份执行command,工作目录不会切换

    3. cp

    // 复制文件
    cp test.txt /tmp
    cp test.txt /tmp/newName.txt
    // 复制目录 (-r 或者 -a)
    cp -r tmpDir /tmp
    cp -r tmpDir /tmp/newName

    4. gzip

    // 命令执行结束原文件会消失
    // 压缩
    gzip fileName
    // 解压, -d, --decompress
    gzip -d fileName

    5. tar

    -c,打包 (--create, create a new archive)
    -t,查看打包文件内容 (--list, list the contents of an archive)
    -x,解包 (--extract, extract files from an archive)
    -z,使用gzip进行压缩/解压
    -j,使用bzip2进行压缩/解压
    -v,在压缩/解压的过程中,将正在处理的文件名显示出来。(--verbose)
    -f,(--file)
    -C,解包到特定目录 (--directory DIR, change to directory DIR)
    
    // 打包              
    tar cvf test.tar test1.txt test2.txt test3.txt
    // 解包              
    tar xvf test.tar
    // 解包到特定目录
    tar xvf test.tar /tmp
    // 使用gzip压缩 
    tar zcvf test.tar.gz  test1.txt test2.txt test3.txt
    // 使用gzip解压  
    tar zxvf test.tar.gz
    // 使用bzip2压缩
    tar jcvf test.tar.bz2  test1.txt test2.txt test3.txt
    // 使用bzip2解压
    tar jxvf test.tar.bz2
    tar xvJf  ***.tar.xz

    6. zip

    // 压缩
    zip -r target.zip *.txt
    // 查看压缩文件内容
    unzip -v target.zip
    // 解压, -d 指定解压目录
    unzip target.zip -d target

    Linux命令之date

    Linux命令之find

    参考链接:

    Linux系统中切换用户身份su与sudo的用法与实例

  • 相关阅读:
    iptables阐述防火墙
    升级openssh基于openssl
    Linux密钥认证错误解决
    keychain实现ssh对秘钥免登陆免输入密码
    rpcbind服务死活启动不了
    samba温故知新
    Linux下umask的缺省默认权限
    tomcat在线部署且查看堆栈状态
    mariadb多实例搭建
    rarlinux基于linux-x64
  • 原文地址:https://www.cnblogs.com/gattaca/p/6135252.html
Copyright © 2011-2022 走看看