Linux常用最基础命令总结

  • man命令
    在讲解下面的命令之前,首先介绍一下man命令,习惯说,有问题找男人,当碰见某个命令不知道怎么用的时候,man 该命令,即可得到详细讲解。
  • shutdown关机命令,可以通过man shutdown查看命令详情
    shutdown -h now #现在关机
    halt #等价于shutdown -h now
    shutdown -h 10 #十分钟之后关机
    shutdown -h 18:30 #今天18:30关机
    shutdown -r now #现在重启
    reboot #等价于shutdown -r now
    shutdown -r 10 #十分钟之后重启
  • ls查看目录命令
    ls #查看当前目录下的子目录
    ls / #查看根目录下的子目录
    ls -a #查看当前目录下的所有子目录
    ls -l #查看当前目录下的子目录的详细信息
    ll #等价于ls -l
    ls -al #详细查看当前目录下的所有子目录
  • cd切换目录命令,其中.代表当前目录..代表是上一级目录
    pwd #查看当前目录的绝对路径
    cd / #切换到/目录
    cd /home #切换到home目录
    cd .. #返回上一级目录
    cd ~ #回到当前用户的家目录
    cd #等价于cd ~
  • mkdir创建目录
    mkdir test #创建一个test目录
    mkdir test/hello #在test目录下创建一个hello目录
    mkdir -p a/b/c #p是parents,根据需要创建父目录
  • rmdir删除目录
    rmdir test #删除test目录
    rmdir -p a/b/c #根据需要删除父目录
  • cp拷贝命令
    cp hello.txt / #拷贝hello.txt到根目录
    cp a / #拷贝a目录到根目录(a没有子目录的情况)
    cp -r a / #r是recursive,递归的意思,拷贝a目录及其子目录到根目录
  • rm移除文件或目录
    rm hello.txt #删除hello.txt
    rm -f a #f是force,暴力的意思,强制删除
    rm -r a #递归删除,可以删除其子目录
  • mv移动命令
    mv hello.txt / #移动hello.txt到根目录
    mv a / #移动a目录到根目录
    mv -f a / #移动a目录到根目录,覆盖不提示。
原创文章 483 获赞 395 访问量 10万+

猜你喜欢

转载自blog.csdn.net/HeZhiYing_/article/details/105449352