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

    最近为了方便管理托管的服务器,开始部署vmserver了。db服务器打算部署成linux的,目前采用的是ubuntu,server版本的系统装好之后傻了眼,全命令行的。。。所以开始大肆搜集有用到的命令,放在这里做个备忘吧。

    1、强制卸载、安装网卡,用于强制从dhcp获取ip

    sudo ifdown eth0

    sudo ifup eth0

    (类似sudo dhclient -r之类的,目前使用情况来看,貌似没生效。回头发现什么再补充吧。)

    2、关机、重启

    sudo shutdown –p 0 在0秒后关机并关闭电源

    sudo shutdown –r 0 在0秒后关机并重启

    3、ubuntu server设置静态IP

    $sudo vi /etc/network/interfaces 编辑IP设置文件

    -------------------------------------------------分割线------------------------------------------------

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    # The loopback network interface
    auto lo
    iface lo inet loopback
    # This is a list of hotpluggable network interfaces.
    # They will be activated automatically by the hotplug subsystem.
    mapping hotplug
    script grep
    map eth0
    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 192.168.0.100 # This is your IP
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1

    -------------------------------------------------分割线------------------------------------------------

    sudo /etc/init.d/networking restart 重启网络连接

    4、解压tar.gz包

    tar –xzf  不打印解压进度

    tar –xvzf 打印解压进度

    5、移动文件夹或重命名文件夹

    mv from to

    6、新增用户、用户组

    groupadd usergroup 增加用户组

    useradd –r – g user usergroup 增加用户到组

    7、变更文件夹所属owner及 group(.表示所有文件及文件夹)

    chown –R user .

    chgrp –R user .

    8、复制文件

    cp from to

    9、修改用户密码

    passwd [username]

    10、显示当前路径

    pwd

    11、路径重定向

    cd [路径]

    cd - 回到上次目录

    cd 回到主目录

    cd ~ 回到主目录

    cd !$ 把上个命令的参数作为输入

    12、查找文件

    find <指定目录> <指定条件> <指定动作>

    - <指定目录>: 所要搜索的目录及其所有子目录。默认为当前目录。
    - <指定条件>: 所要搜索的文件的特征。
    - <指定动作>: 对搜索结果进行特定的处理。

    find . -name 'sftp*': 在当前目录下,查找名称为sftp开头的文件或文件夹

    13、查看磁盘使用情况

    df -h

    其他待续吧

  • 相关阅读:
    php对接网易云信视频直播
    python基础--1.数据操作
    pytest自动化7:assert断言
    pytest自动化6:pytest.mark.parametrize装饰器--测试用例参数化
    pytest自动化5:pytest-html插件--生成html报告
    pytest自动化4:fixture之yield实现teardown
    pytest自动化3:fixture之conftest.py实现setup
    pytest自动化2:测试用例setup和teardown
    pytest自动化1:兼容unittest代码实例
    排序
  • 原文地址:https://www.cnblogs.com/rayz/p/3021378.html
Copyright © 2011-2022 走看看