简洁明了的Linux常用命令

更新日期: 2020-02-20 阅读: 2.6k 标签: 命令

1、ls 命令

查看当前目录下可见的文件、文件夹及其相关权限 常用参数:-l 列表式查看 -al 查看所有,包括隐藏的文件、文件夹  

[root@qinshengfei bin]# ls --color 以彩色显示 
[root@qinshengfei bin]# ls -l     详情列出目录文件
[root@qinshengfei bin]# ls -a     显示所有文件,包括隐藏文件
[root@qinshengfei bin]# ls -al    列表显示所有文件
[root@qinshengfei bin]# ls -al|more 將目录內容分布显示

2、mkdir 创建文件夹

常用参数 : 直接接文件夹名称  

[root@qinshengfei /home]# mkdir test

3、pwd 显示当前工作目录

[root@qinshengfei bin]#  pwd
/usr/bin  <== 显示当前工作目录

4、cd 切换目录

[root@qinshengfei /root]#  cd ..       <== 回到上一级目录
[root@qinshengfei /]#  cd          <== 回到home目录
[root@qinshengfei root]#  cd /usr/bin  <== 到 /usr/bin 這一個目录

5、rmdir 删除指定目录

如果要删除的目录里面有文件或文件夹,是无法移动的,这时,就需要加上参数 -rf 来强制操作删除。
[root@qinshengfei /root]#   rmdir ./test       <== 删除目录
[root@qinshengfei /root]#  rmdir ./test2 -rf       <== 删除目录及子目录、文件

6、rm 删除指令文件

[root@qinshengfei /root]# rm test

7、cp 就是 copy 的意思。例如我们要把 .bashrc 这个文件复制到/home目录下,可以:

[root@qinshengfei /root]# cp .bashrc /home

8、mv 移动文件、文件夹

[root@qinshengfei /root]# mv test.txt /home

9、cat 打印文件内容在控制台上,例如要打印mysql的配置文件到控制上

[root@qinshengfei /mysql.conf.d]# cat mysqld.cnf

10、tail 按行显示文件内容

[root@qinshengfei /mysql.conf.d]# tail -n 5  mysqld.cnf

11、less

less命令可查看文件。 它使用起来速度更快,而且您不会无意间修改文件。 使用更少的光标,您可以使用向上和向下箭头键,PgUp和PgDn键以及Home和End键在文件中前后滚动。 按Q键退出少。
[root@qinshengfei /mysql.conf.d]# less  log.txt

12、grep 管道,输出指定文件内容

例如使用 ps -aux 查询进程,我们只需要知道 tomcat 有不有运行,就可以使用管道指令『|』加入 grep 这个命令同时操作。
[root@qinshengfei /]# ps -aux|grep tomcat

13、find 查找文件

[root@qinshengfei /]#  find / -name bin

14、tar -cvf 压缩文件

[root@qinshengfei /root]# tar  -zcvf  app.tar.gz app 

15、gzip 压缩

也是一压缩命令,跟compress 很相似,指令的用法也相同!只是压缩后缀名 .gz !
[root@qinshengfei /root]# gzip  -d  xxxxx.gz

16、unzip 解压文件

[root@qinshengfei /root]# unzip app.zip 解压一个叫做 'app.zip'的文件 

18、exit 退出登录


[root@qinshengfei /root]# exit

19、ping 与windows下的ping 一样 ,测试两台电脑之间是否连通


[root@qinshengfei /root]# ping baidu.com

20、telnet 与windows下的一样 ,测试目标机端口开放

[root@qinshengfei /root]# telnet 47.2.30.289 8080

21、who 查看当前登录的所有用户

[root@qinshengfei /root]# who

22、su 切换用户

[root@qinshengfei /root]# su  qinshengfei

23、uname uname会显示出关于系统的重要信息,如内核名称、主机名、内核版本、处理机类型等等,使用uname -a可以查看所有信息。

[root@qinshengfei /]# uname -a
Linux qinshengfei 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@qinshengfei /]# 

24、alias

使用alias命令可以给命令或命令序列指定自己的名称。 然后,您可以输入您的简称,然后Shell将为您执行命令或命令序列。
[root@qinshengfei /]# alias pf="ps -e | grep $1"
[root@qinshengfei /]# pf tomcat

25、chmod 修改文件、文件夹权限的命令

0: No permission
1: Execute permission
2: Write permission
3: Write and execute permissions
4: Read permission
5: Read and execute permissions
6: Read and write permissions
7: Read, write and execute permissions
[root@qinshengfei /]# chmod 777 app -r <== -r 连同子目录权限一起修改

26、chown

可以使用chown更改文件的所有者或组,或两者。 必须提供所有者和组的名称,以:字符分隔。 
[root@qinshengfei /]# chown dave:mary example.txt

27、curl

curl命令是从统一资源定位器(URL)或Internet地址检索信息和文件的工具
[root@qinshengfei /]# curl http://www.baidu.com index.html

28、echo

echo命令将文本字符串打印(回显)到终端窗口。也可以将字符串打印到文件。
[root@qinshengfei /]# echo "hello world"
hello world
[root@qinshengfei /]# 

29、free

free命令为您提供计算机内存使用情况的摘要。 它对主随机存取存储器(RAM)和交换存储器都执行此操作。 -h(人类)选项用于提供人类友好的数字和单位。 没有此选项,数字以字节为单位。
[root@qinshengfei /]# free
              total        used        free      shared  buff/cache   available
Mem:        8000348     1554508     4549432         576     1896408     6194856
Swap:             0           0           0
[root@qinshengfei /]# 

30、history

history命令列出了您先前在命令行上发出的命令。 您可以通过键入感叹号来重复历史记录中的任何命令! 以及历史记录列表中的命令编号。
[root@qinshengfei /]# 
[root@qinshengfei /]# history
    1  yum install docker
    2  yum install nginx
    3  yum -y install docker-ce
   

31、kill

我们将使用上面关于别名命令的部分中的ps和grep技巧。 我们可以搜索快门过程并获取其PID,如下所示:

[root@qinshengfei /]# ps -ef|grep nginx
root     31884 22980  0 16:19 pts/0    00:00:00 grep --color=auto nginx
root     32400     1  0 Feb18 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx    32401 32400  0 Feb18 ?        00:00:00 nginx: worker process
nginx    32402 32400  0 Feb18 ?        00:00:00 nginx: worker process
[root@qinshengfei /]# kill -9 32400

32、passwd

passwd命令使您可以更改用户密码。 只需键入passwd即可更改您自己的密码。
[root@qinshengfei /]# sudo passwd mary

33、ssh

使用ssh命令建立与远程Linux计算机的连接并登录到您的帐户。 要建立连接,您必须提供您的用户名以及远程计算机的IP地址或域名。 在此示例中,用户mary以192.168.4.23登录到计算机。 建立连接后,将要求她输入密码。
[root@qinshengfei /]# ssh mary@192.168.4.23
mary@192.168.4.23's password: 

35、df 查看系统磁盘的使用情况

[root@qinshengfei /]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs         3986836       0   3986836   0% /dev
tmpfs            4000172       0   4000172   0% /dev/shm
tmpfs            4000172     576   3999596   1% /run
tmpfs            4000172       0   4000172   0% /sys/fs/cgroup
/dev/vda1       52417516 4031296  48386220   8% /
overlay         52417516 4031296  48386220   8% /var/lib/docker/overlay2/650e5470981551bdd57ee3f9da79da55ef5170d11017e282c318f801b5c5ac4b/merged
tmpfs             800032       0    800032   0% /run/user/0
[root@qinshengfei /]# 

36、ps 显示系统进程

ps命令列出了正在运行的进程。 使用不带任何选项的ps会导致它列出当前shell中正在运行的进程。
[root@qinshengfei /]# ps
  PID TTY          TIME CMD
 9191 pts/0    00:00:00 ps
16776 pts/0    00:00:00 bash
17212 pts/0    00:00:00 mysql
22980 pts/0    00:00:00 bash
23524 pts/0    00:00:44 java
[root@qinshengfei /]# 
要查询关键字进程,可以结合管道命令。
[root@qinshengfei /]# ps -ef|grep nginx
root     10377 22980  0 16:26 pts/0    00:00:00 grep --color=auto nginx
root     32400     1  0 Feb18 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx    32401 32400  0 Feb18 ?        00:00:00 nginx: worker process
nginx    32402 32400  0 Feb18 ?        00:00:00 nginx: worker process
[root@qinshengfei /]# 

37、top 显示系统进程

[root@qinshengfei /]# top

38、reboot 重新计算机

[root@qinshengfei /]# reboot

39、shutdown

使用不带参数的关机将在一分钟内关闭计算机。

[root@qinshengfei /]# shutdown
使用 now 参数 ,立刻关机
[root@qinshengfei /]# shutdown -h now
使用 -r 参数 重启 与reboot效果一样 ,shutdown -r 可以定时
[root@qinshengfei /]# shutdown -r now

40、yum

centos环境下安装软件的命令
[root@qinshengfei /]# yum install nginx

本文内容仅供个人学习、研究或参考使用,不构成任何形式的决策建议、专业指导或法律依据。未经授权,禁止任何单位或个人以商业售卖、虚假宣传、侵权传播等非学习研究目的使用本文内容。如需分享或转载,请保留原文来源信息,不得篡改、删减内容或侵犯相关权益。感谢您的理解与支持!

链接: https://fly63.com/article/detial/7506

相关推荐

python常用命令

#查看django版本;创建一个项目mysite;在当前目录下启动manage.py;创建一个polls应用;在当前目录下针对models生成sql语句;根据生成的sql语句生成数据库

常用的搜索命令_高级搜索指令大全

作为一名资深SEO,不懂得搜索引擎高级指令的使用显然是说不过去的。搜索引擎高级指令就如同语言一样,用来建立搜索引擎与SEO人员直接沟通的“通道”,下面就为大家整理下常用的高级搜索命令

10个常用Nginx 常用命令

Nginx 是一个免费、开源、高性能、可伸缩、可靠、功能全面且流行的 HTTP和反向代理服务器,一个邮件代理服务器,以及通用的 TCP/UDP 代理服务器。

FFmpeg常用命令合集

视频裁剪滤镜(播放器大小裁剪): ffmpeg -i killer.mp4 -vf crop=in_w-200:in_h-200 -c:v libx264 -c:a copy out.mp4;视频裁剪(按时间裁剪): ffmpeg -i shanguangshaonv.mp4 -ss

常用Vim命令及实用Vim按键映射配置详解

Vim按键映射可用于设置Vim命令或命令串的别名,完成个性化Vim按键设置。Vim命令虽然很多,但是常用的Vim命令却被使用者所熟知。Vim可视化模式下, > 用于增加缩进;而 gv 命令可以用于重新选取上一次由可视模式所选择的文本范围。

node.js中使用yargs来处理命令行参数

yargs库能够方便的处理命令行参数。读取命令行参数argv 对象用来保存命令行参数,传递参数时,参数名以 -- 开头,中间使用 = 或 空格,然后接上值 。argv 有一个 下划线 属性,该属性用来获取非连词线开头的参数

git常用命令

git init创建/初始化一个的存储库;git status显示工作目录和暂存区的状态;git add将文件添加到索引/暂存区;git commit:提交更改到存储库;git checkout:切换分支

ping命令使用图文教程

ping命令对于新手小白用户会不太清楚的用法的,而对于那种经常用这个工具的网友习惯了这个命令操作便捷,就觉得不一样了可以惯性的行为打开这个Ping命令。Ping命令其实是一个非常好的网络故障诊断工具。在大家遇到网络问题时,可以试试小编分享的方法

Flutter 常用命令

查看flutter是否安装到位 环境是否正常;查看版本号;升级环境flutter upgrade;获取flutter packages包 (现在基本上已经是保存就自动导入的了 );以release 模式运行

每个Web开发者都该了解的12条命令行

在开发者的弹药箱里,命令行是最具生产力的工具之一。掌握它们可以给你的工作流程带来非常积极的影响。因为,许多日常任务都可以用一条命令然后按回车来解决。

点击更多...

内容以共享、参考、研究为目的,不存在任何商业目的。其版权属原作者所有,如有侵权或违规,请与小编联系!情况属实本人将予以删除!