Linux(一) 操作指令

目录

一、基础操作指令

1.man

2.ls(list) 

3.mkdir 

4.rmdir

5. touch

6.type

7.cd

8.pwd

9.rm

10.nano

11.cp

12.mv

13.cat/tac

14.echo

15.tree

16.stat

17.more

 18.less

19.head

20.tail

​编辑 21.grep

22.wc

 23.xargs

 24.date

​编辑 25.cal

26.find

27.which

28.whereis

29.alias

30.zip/unzip

31.tar

32.uname

33.ln

34.mkfifo

35.su

36.yum

37.ldd + filename (查看文件的动态库)

38.file + filename (查看文件属性) 

39.readelf

40.ps (查看当前终端下对应的进程)

41.top (相当于任务管理器)

42.ls /proc (用文件的方式查看进程)

43.vmstat(CPU监控命令)

44.sar 主要帮助我们掌握系统资源的使用情况,特别是内存和CPU的使用情况

45.netstat 查看网络连接状态

46.free 查看内存资源状态

47.df 查看磁盘分区资源状态

48.objdump 反汇编工具 告诉我们可执行程序是有地址的

49.ipcs 查看众多ipc资源

二、几个重要的热键


一、基础操作指令

1.man

an interface to the on-line reference manuals 


       1   Executable programs or shell commands
       2   System calls (functions provided by the kernel)
       3   Library calls (functions within program libraries)
       4   Special files (usually found in /dev)
       5   File formats and conventions eg /etc/passwd
       6   Games
       7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
       8   System administration commands (usually only for root)
       9   Kernel routines [Non standard]

2.ls(list) 

list directory content 

-l use a long list format

-a all

3.mkdir 

make directories

mkdir -p dir1/dir2  #创建一连串路径

4.rmdir

remove empty directories

5. touch

update the access and modification times of each FILE to  the current time

6.type

命令可以用来查看 shell 命令的类型,即它是内置命令还是外部命令。命令类型有如下几种:

  • alias:表示是别名。
  • keyword:关键字,shell 保留字。
  • function:函数,shell 函数。
  • builtin:内置命令。
  • file:文件,外部命令。
  • :空表示没找到。

Linux命令之查看命令类型type_type命令-CSDN博客 具体type用法

7.cd

cd .. #返回上一层
cd ~  #返回当前用户的家目录
cd /  #返回根目录
cd -  #返回上一个路径
cd + 绝对路径/相对路径

8.pwd

print name of working directory

9.rm

remove files or directories

-r : recurive 

-rf : recurive force 

-i : prompt before every removal

*通配结构 (*.c  表示所有.c文件)(*表示所有文件) 

10.nano

a small ,free and friendly editor

11.cp

copy files or directories

-rf : recurive force

12.mv

move(rename) files

13.cat/tac

concatenate files and print on the standard output

Linux中的13个基本Cat命令示例 - 知乎 (zhihu.com)

14.echo

diaplay a line of text

>:输出重定向(覆盖式的写入)

echo aaa > test.txt # 1.创建没有的文件 2.将本该输出到显示器的内容输出到了文件里

>>:追加重定向(追加式的写入)

<:输入重定向,本该从键盘中输入改为从文件中输入

echo $? // 获取最近一个进程执行完毕的退出码

15.tree

list contents of directories in a tree-like format

tree root

16.stat

display file or file system status

Modification time (mtime):当该文件的『内容数据』变更时,就会更新这个时间! 『内容数据』指的是文件中记录的内容,而不包括文件属性和权限等!

Change time (ctime):当该文件的『状态 (status)』改变时,就会更新这个时间,举例来说, 像是文件权限、属性、inode号等被更改了,都会更新这个时间。

Access time (atime):当我们访问该文件时,就会更新这个时间为最后一次访问该文件的时间 。 当我们使用 cat 、more、less等命令读取文件信息的时候,就会更新 atime 了。

17.more

可以把一个文件内容打印至屏幕占满,用于阅读长文本,需要逐行阅读,只能向前移动

more -5 xxx #打印前五行

 18.less

与more相似,但可以前后移动,重新回到开始,输入g

19.head

output the first part of files

head -30 xxx

20.tail

output the last of files 

提取999-1009行

1.利用临时文件

2.利用管道

head -1010 n.txt | tail -11

 21.grep

print lines maching a pattern

行文本过滤器,比less和more功能更强大

grep大小写敏感

-i 不区分大小写

-v 不显示xxx

grep -E ^a test.txt #找到文件test.txt含有以a字母为行开头的内容

-E选项可以用来扩展选项为正则表达式

$表示匹配文件末尾,字符需要在$之前表示以字符结尾  a$表示以a结尾

^表示匹配文件起始,字符需要在^之后表示以字符起始  ^a表示以a起始

22.wc

print newline,word and bype counts of each file

wc -l #计算文件行数

 23.xargs

build and excute command lines from standard input

 24.date

date +%Y:%m:%d-%H:%M:%S

date +%Y:%m:%d-%H:%M:%S +@xxx # xxx为时间戳

 25.cal

display a calendar

26.find

search for files in a directory hierachy

find常用选项很多,先了解按name寻找文件

find ~ -name xxx #在~家目录下找名字为xxx的文件

find . -name "*.c" -maxdepth 1 | xargs rm  

    find . -name "*.c" -maxdepth 1 找到当前目录下.*结尾的文件,目录深度为1

    xargs是一个强有力的命令,它能够捕获一个命令的输出,然后传递给另外一个命令,用于很多不支持|管道来传递参数的命令

相当于将前边命令的执行结果,也就是查找到的文件名,传递给后边的rm指令进行删除

find . -name "*.c" | xargs rm 没有进行深度控制,删除的不仅是当前目录下的文件,会将子目录下的文件也删除

linux下快速查找文件_linux查找文件-CSDN博客

27.which

show the full path of (shell) commands

只有设置了环境变量才可以搜索到

28.whereis

locate binary, source and manual page files for a command

寻找特定文件,只能用于查找二进制文件、源代码文件和man手册页

29.alias

 给一条命令起别名,只能在当前有效

30.zip/unzip

package and compress(archive) files

zip name.zip xxx -r #将目录里所有文件或目录压缩,不加-r只能压缩xxx

unzip name.zip -d 要解压的路径

31.tar

32.uname

print system information

 

33.ln

make links between files

ln -s xxx name.link 

34.mkfifo

make FIFOs(name pipes)

mkfifo f

35.su

run a command with substitute user and group ID

su + usr #切换到用户

su          #切换到root

36.yum

yum list

yum install

yum remove [-y]

37.ldd + filename (查看文件的动态库)

38.file + filename (查看文件属性) 

39.readelf

40.ps (查看当前终端下对应的进程)

ps axj #查看当前系统中所有的进程

ps axj | head 1 && ps axj | grep 'myproc'

41.top (相当于任务管理器)

42.ls /proc (用文件的方式查看进程)

43.vmstat(CPU监控命令)

报告关于内核线程、虚拟内存、磁盘、陷阱和 CPU 活动的统计信息

44.sar 主要帮助我们掌握系统资源的使用情况,特别是内存和CPU的使用情况

45.netstat 查看网络连接状态

46.free 查看内存资源状态

47.df 查看磁盘分区资源状态

48.objdump 反汇编工具 告诉我们可执行程序是有地址的

49.ipcs 查看众多ipc资源

ipcs -m 查看共享内存

ipcrm -m shmid 删除id为shmid的共享内存

50.ulimit 命令

ulimit -a 查看所有相关命令
改变Shell进程的Resource Limit允许core文件最大为1024K: $ ulimit -c 1024

51.rpm 

rpm -qa 查询所有rpm包

52.systemctl

systemctl start mysqld.service
 

二、几个重要的热键

  • 26
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值