简洁明了的Linux常用命令

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

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://www.fly63.com/article/detial/7506

kubernetes 命令方式 部署、访问应用

Kubernetes 命令的方式运行应用:默认情况下,所有Pod只能在集群内部访问,为了能够外部访问应用,需要将容器端口映射到节点的端口,15672 就是容器中端口。15672端口已经映射到了12732端口,端口号是随机分配的

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

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

Linux常用命令总汇

ls命令就是list的缩写,通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录、文件夹、文件权限)查看目录信息等等

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

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

npm常用命令与操作

npm常用命令与操作:npm i/install moduleName安装模块;i是install的缩写,两者功能是一样的;npm ls 查看所有局部安装的模块; npm从5.0版本开始添加了package-lock.json文件(下称lock文件);用于保证再次安装模块时能安装同样的版本;

Linux常用命令

玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令

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

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

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

NodeJS 构建现代化的命令行工具

这是一篇关于如何使用 NodeJS 构建高性能、高可读性的现代化命令行工具的博客。每当我们想要创建一个基于 NodeJS 的命令行工具时,就会衍生出一堆问题需要解决,比如如何准备开发环境,如何打包转译代码

python常用命令

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

点击更多...

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