为了账号安全,请及时绑定邮箱和手机立即绑定

【Linux】linux常用基本命令

标签:
Linux

Linux中许多常用命令是必须掌握的,这里将我学linux入门时学的一些常用的基本命令分享给大家一下,希望可以帮助你们。


这个是我将鸟哥书上的进行了一下整理的,希望不要涉及到版权问题。


1、显示日期的指令: date

https://img1.sycdn.imooc.com//60e47b480001dedf07410313.jpg

2、显示日历的指令:cal

https://img1.sycdn.imooc.com//60e47b6c0001befb08480373.jpg

https://img1.sycdn.imooc.com//60e47b8d0001104709180475.jpg

https://img1.sycdn.imooc.com//60e47b9d00011bcd06280372.jpg

3、简单好用的计算器:bc


https://img1.sycdn.imooc.com//60e47bb300014eb109100289.jpg

https://img1.sycdn.imooc.com//60e47be80001ee3d09190600.jpg
https://img1.sycdn.imooc.com//60e47c020001dc3a06140231.jpg

怎么10/100会变成0呢?这是因为bc预设仅输出整数,如果要输出小数点下位数,那么就必须要执行 scale=number ,那个number就是小数点位数,例如:

https://img1.sycdn.imooc.com//60e47c1f0001024208220373.jpg

4、重要的几个热键[Tab],[ctrl]-c, [ctrl]-d 


[Tab]按键---具有『命令补全』不『档案补齐』的功能




[Ctrl]-c按键---让当前的程序『停掉』




[Ctrl]-d按键---通常代表着:『键盘输入结束(End Of File, EOF 戒 End OfInput)』的意思;另外,他也可以用来取代exit




5、man

退出用q,


man -f man

https://img1.sycdn.imooc.com//60e47c3b0001969909310314.jpg

6、数据同步写入磁盘: sync


输入sync,那举在内存中尚未被更新的数据,就会被写入硬盘中;所以,这个挃令在系统关机戒重新启劢乀前, 径重要喔!最好多执行几次!

https://img1.sycdn.imooc.com//60e47c550001a04805600066.jpg

7、惯用的关机指令:shutdown

https://img1.sycdn.imooc.com//60e47c7400013a0409240580.jpg

https://img1.sycdn.imooc.com//60e47c830001f21e09190233.jpg

此外,需要注意的是,时间参数请务必加入指令中,否则shutdown会自动跳到 run-level 1 (就是单人维护的登入情况),这样就伤脑筋了!底下提供几个时间参数的例子吧:

https://img1.sycdn.imooc.com//60e47c9d0001142b09360554.jpg

重启,关机: reboot, halt,poweroff

https://img1.sycdn.imooc.com//60e47cb700012ff208110177.jpg

8、切换执行等级: init


Linux共有七种执行等级:

--run level 0 :关机

--run level 3 :纯文本模式

--run level 5 :含有图形接口模式

--run level 6 :重新启动

使用init这个指令来切换各模式

如果你想要关机的话,除了上述的shutdown -h now以及poweroff之外,你也可以使用如下的指令来关机:  

https://img1.sycdn.imooc.com//60e47d0900014bc004670056.jpg

9、改变文件的所属群组:chgrp

https://img1.sycdn.imooc.com//60e47d230001d00e09300528.jpg

10、改变文件拥有者:chown


他还可以顸便直接修改群组的名称

https://img1.sycdn.imooc.com//60e47d460001673709200634.jpg

11、改变文件的权限:chmod


权限的设定方法有两种, 分别可以使用数字或者是符号来进行权限的变更。



--数字类型改变档案权限:

https://img1.sycdn.imooc.com//60e47d7b00011f5b09330460.jpg

--符号类型改变档案权限:

https://img1.sycdn.imooc.com//60e47d960001c92609560409.jpg

https://img1.sycdn.imooc.com//60e47dad0001003f09490408.jpg

12、查看版本信息等

https://img1.sycdn.imooc.com//60e47dc90001147609320465.jpg

13、变换目录:cd

https://img1.sycdn.imooc.com//60e47deb0001460108890408.jpg

https://img1.sycdn.imooc.com//60e47e120001b74709340409.jpg

14、显示当前所在目录:pwd

https://img1.sycdn.imooc.com//60e47e3c0001c45309370700.jpg

15、建立新目录:mkdir

https://img1.sycdn.imooc.com//60e47e5f0001a9e609080635.jpg

https://img1.sycdn.imooc.com//60e47e73000190b409340447.jpg

不建议常用-p这个选项,因为担心如果你打错字,那么目录名称就回变得乱七八糟的

 

16、删除『空』的目录:rmdir

https://img1.sycdn.imooc.com//60e47eb70001e40e09060591.jpg

https://img1.sycdn.imooc.com//60e47ec900019bcb09240231.jpg

17、档案与目录的显示:ls

https://img1.sycdn.imooc.com//60e47ee5000199ac09400589.jpg

https://img1.sycdn.imooc.com//60e47ef70001643e09320539.jpg

18、复制档案或目录:cp

https://img1.sycdn.imooc.com//60e47f1e000133a909310648.jpg

https://img1.sycdn.imooc.com//60e47f5b000107a409510135.jpg

https://img1.sycdn.imooc.com//60e47f6e00011eaa09270601.jpg

https://img1.sycdn.imooc.com//60e47f7e0001215709490604.jpg

https://img1.sycdn.imooc.com//60e47f9100017c0809330421.jpg

https://img1.sycdn.imooc.com//60e47fa800012c6109270637.jpg

https://img1.sycdn.imooc.com//60e47ff10001af6209320592.jpg

https://img1.sycdn.imooc.com//60e4800200010b4809370359.jpg

19、移除档案或目录:rm

https://img1.sycdn.imooc.com//60e48021000177d809080508.jpg

https://img1.sycdn.imooc.com//60e480320001901509020153.jpg

https://img1.sycdn.imooc.com//60e480430001b2fa09280585.jpg

https://img1.sycdn.imooc.com//60e480530001ab7809380425.jpg

20、移动档案与目录,或更名:mv

https://img1.sycdn.imooc.com//60e4806e00011b9709140619.jpg

https://img1.sycdn.imooc.com//60e480810001504509340618.jpg

21、取得路径的文件名与目录名:basename,dirname

https://img1.sycdn.imooc.com//60e4809e00019f8708340417.jpg

22、由第一行开始显示档案内容:cat

https://img1.sycdn.imooc.com//60e480bb0001912608450615.jpg

https://img1.sycdn.imooc.com//60e480d00001534309260609.jpg

23、从最后一行开始显示:tac(可以看出 tac 是 cat 的倒着写)

https://img1.sycdn.imooc.com//60e480e80001199109000234.jpg

24、显示的时候,顺道输出行号:nl

https://img1.sycdn.imooc.com//60e481050001958d08310688.jpg

https://img1.sycdn.imooc.com//60e481220001283109340698.jpg

https://img1.sycdn.imooc.com//60e48149000165f107050251.jpg

25、一页一页的显示档案内容:more

https://img1.sycdn.imooc.com//60e4819300015a6109960690.jpg

26、与 more 类似,但是比 more 更好的是,他可以往前翻页:less

https://img1.sycdn.imooc.com//60e481b90001ecf608670691.jpg

27、只看头几行:head



28、只看尾几行:tail

https://img1.sycdn.imooc.com//60e481ed000158e409320418.jpg

https://img1.sycdn.imooc.com//60e482010001603909350340.jpg

29、以二进制的放置读取档案内容:od

https://img1.sycdn.imooc.com//60e482290001f11209040471.jpg

https://img1.sycdn.imooc.com//60e4823c0001530c09110325.jpg

https://img1.sycdn.imooc.com//60e4825100015f3708740205.jpg

https://img1.sycdn.imooc.com//60e482630001c24109420603.jpg

30、修改档案时间或新建档案:touch

https://img1.sycdn.imooc.com//60e4828500017ef109460386.jpg

https://img1.sycdn.imooc.com//60e482920001212e09370455.jpg

https://img1.sycdn.imooc.com//60e482a50001b22809310370.jpg

https://img1.sycdn.imooc.com//60e482b20001396109200443.jpg

https://img1.sycdn.imooc.com//60e482c50001dab709450425.jpg

31、档案预设权限:umask

https://img1.sycdn.imooc.com//60e482de00016d5b09550552.jpg

https://img1.sycdn.imooc.com//60e482ed0001b81808780301.jpg

32、配置文件档案隐藏属性:chattr

https://img1.sycdn.imooc.com//60e483130001e27e09290453.jpg

https://img1.sycdn.imooc.com//60e4832600010e9d09380487.jpg

https://img1.sycdn.imooc.com//60e4833d00012a9609210683.jpg

https://img1.sycdn.imooc.com//60e483570001f03809020509.jpg

33、显示档案隐藏属性:lsattr

https://img1.sycdn.imooc.com//60e48374000194fa08770415.jpg

https://img1.sycdn.imooc.com//60e4838a00010c5809540614.jpg

35、寻找【执行挡】:which

https://img1.sycdn.imooc.com//60e483b1000164f709370379.jpg

https://img1.sycdn.imooc.com//60e483c300018afd09390462.jpg

https://img1.sycdn.imooc.com//60e483dc0001f49f09400676.jpg

36、寻找特定档案:whereis

https://img1.sycdn.imooc.com//60e483f90001ae0309420504.jpg

https://img1.sycdn.imooc.com//60e484070001139a07940208.jpg

37、寻找特定档案:locate

https://img1.sycdn.imooc.com//60e4841f000178f507700536.jpg

38、寻找特定档案:find

https://img1.sycdn.imooc.com//60e484480001204409350400.jpg

https://img1.sycdn.imooc.com//60e484620001855108680415.jpg

https://img1.sycdn.imooc.com//60e484750001cd7f08130349.jpg

39、压缩文件和读取压缩文件:gzip,zcat

https://img1.sycdn.imooc.com//60e4849300018ec409360425.jpg

https://img1.sycdn.imooc.com//60e484a80001d47409300399.jpg

https://img1.sycdn.imooc.com//60e484bf000180d509330664.jpg

40、压缩文件和读取压缩文件:bzip2,bzcat

https://img1.sycdn.imooc.com//60e484ec0001d60109250763.jpg

https://img1.sycdn.imooc.com//60e485000001e5e909380267.jpg

41、压缩文件和读取压缩文件:tar

https://img1.sycdn.imooc.com//60e485210001a98909280656.jpg

https://img1.sycdn.imooc.com//60e485360001f13a09470457.jpg

https://img1.sycdn.imooc.com//60e4854e000146c709070550.jpg

https://img1.sycdn.imooc.com//60e4856300012da509480571.jpg

https://img1.sycdn.imooc.com//60e485770001f95709110532.jpg

https://img1.sycdn.imooc.com//60e4858a00019ddb09470482.jpg

https://img1.sycdn.imooc.com//60e485a100015da609390572.jpg

好了,累死了,终于搞完了,希望能对的大家有所帮助。

————————————————

版权声明:本文为CSDN博主「xiaoguaihai」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/xiaoguaihai/article/details/8705992

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消