美文网首页
linux常用命令

linux常用命令

作者: 琉璃_xin | 来源:发表于2019-10-29 23:40 被阅读0次
    1. ip 查询
      ip addr / ifconfig 查看网卡信息
    [root@VM_0_5_centos ~]# ip addr
    
    1. 清除
      control + l / clear
    [root@VM_0_5_centos ~]# clear
    
    1. 开启网络
      将配置文件的ONBOOT=no改为ONBOOT=yes,然后重启网络
      vim 命令:

    i 开启插入模式 esc命令模式,然后输入:q(不保存)或者:wq(保存) 退出

    [root@VM_0_5_centos ~]# vi etc/sysconfig/network-scripts/ifcfg-eth0 
    

    重启:

    [root@VM_0_5_centos ~]# service network restart
    
    1. 创建文件 / 目录
    [root@VM_0_5_centos ~]# touch test.txt / mkdir a
    
    1. 删除文件
      rm [options] name
    • -i删除前逐一确认
    • -f直接删除无需确认
    • -r将目录及以下文档逐一删除
    [root@VM_0_5_centos ~]# rm -f test.txt
    
    1. 查看当前路径
    [root@VM_0_5_centos ~]# pwd
    
    1. 切换最近使用过的两个目录
    [root@VM_0_5_centos ~]# cd -
    
    1. ping
      查看网络是否通畅
    [root@VM_0_5_centos ~]# ping 127.0.0.1
    
    1. 关机
    [root@VM_0_5_centos ~]# init 0
    
    1. 重启
    [root@VM_0_5_centos ~]# init 6
    
    1. mac远程
      通过mac自带的终端进行远程连接
    $ ssh -q -l root -p 22 xxx.xxx.xxx.xxx
    
    1. 历史命令
    [root@VM_0_5_centos /]# history
    

    如何使用之前的命令, 使用之前的命令(30为打印的编号):

    [root@VM_0_5_centos /]# !30
    
    1. 修改文件名/移动文件
    [root@VM_0_5_centos /]# mv a.txt a.html / mv a.txt ./src/
    
    1. 复制文件
    [root@VM_0_5_centos mnt]# cp index.html ./a/
    [root@VM_0_5_centos mnt]# cp index.html index_copy.html
    
    1. 查看文件
    [root@VM_0_5_centos mnt]# cat index.html
    enter something
    
    1. 批量创建删除文件
    [root@VM_0_5_centos mnt]# touch file{1..10}.html
    [root@VM_0_5_centos mnt]# rm -rf file{1..10}.html
    
    1. 查看文件前n行 / 后n行
    [root@VM_0_5_centos mnt]# cat index.html | head -3 
    enter something
    
    the thrid line
    [root@VM_0_5_centos mnt]# cat index.html | tail -3
    
    1. 查找文件内容
      -i忽略大小写
    [root@VM_0_5_centos mnt]# cat index.html | grep -i t
    
    1. 查找文件
      find 目录 -name 文件名
    [root@VM_0_5_centos mnt]# find / -name index.html
    
    1. 快速查找
    [root@VM_0_5_centos mnt]# updatedb
    [root@VM_0_5_centos mnt]# locate index.html
    
    1. 创建目录
    [root@VM_0_5_centos mnt]# mkdir testdir
    
    1. 复制目录
    [root@VM_0_5_centos mnt]# cp ./a -rf ./testdir/
    
    1. tree
      安装:[root@VM_0_5_centos mnt]# yum install tree
    [root@VM_0_5_centos mnt]# tree
    .
    ├── a
    │   └── index.html
    ├── b.html
    ├── index_copy.html
    ├── index.html
    └── testdir
        └── a
            └── index.html
    
    3 directories, 5 files
    
    1. zip 压缩
      -r 递归目录
    [root@VM_0_5_centos mnt]# ls
    a  b.html  index_copy.html  index.html  testdir
    [root@VM_0_5_centos mnt]# zip -r a.zip ./a/
      adding: a/ (stored 0%)
      adding: a/index.html (stored 0%)
    [root@VM_0_5_centos mnt]# ls
    a  a.zip  b.html  index_copy.html  index.html  testdir
    
    1. unzip 解压 / 查看
    [root@VM_0_5_centos mnt]# unzip -l a.zip
    Archive:  a.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
            0  10-29-2019 20:40   a/
            0  10-29-2019 20:40   a/index.html
    ---------                     -------
            0                     2 files
    [root@VM_0_5_centos mnt]# unzip a.zip -d aaa
    Archive:  a.zip
       creating: aaa/a/
     extracting: aaa/a/index.html
    
    1. tar 压缩/ 解压
    [root@VM_0_5_centos mnt]# tar cvf aaa.tar ./aaa/
    [root@VM_0_5_centos mnt]# tar xvf aaa.tar
    
    1. gz 压缩/ 解压/ 查看
    [root@VM_0_5_centos mnt]# tar czvf aaa.tar.gz ./aaa
    [root@VM_0_5_centos mnt]# tar xzvf aaa.tar.gz
    [root@VM_0_5_centos mnt]# tar tf aaa.tar.gz
    
    1. 别名 添加/卸载/查看
    [root@VM_0_5_centos mnt]# alias test='ls ./aaa/'
    [root@VM_0_5_centos mnt]# test
    a
    [root@VM_0_5_centos mnt]# unalias test
    [root@VM_0_5_centos mnt]# alias
    
    1. 添加用户/设置密码/删除用户
    [root@VM_0_5_centos home]# useradd dongwudi
    [root@VM_0_5_centos home]# passwd dongwudi
    [root@VM_0_5_centos home]# userdel -rf dongwudi
    

    相关文章

      网友评论

          本文标题:linux常用命令

          本文链接:https://www.haomeiwen.com/subject/rcvyvctx.html