ubuntu删除目录文件命令(linux打开文件命令六种方法)

来源:国外服务器 在您之前已被浏览:1 次
导读:目前正在解读《ubuntu删除目录文件命令(linux打开文件命令六种方法)》的相关信息,《ubuntu删除目录文件命令(linux打开文件命令六种方法)》是由用户自行发布的知识型内容!下面请观看由(国外主机 - www.2bp.net)用户发布《ubuntu删除目录文件命令(linux打开文件命令六种方法)》的详细说明。
笨笨网美国主机,w ww.2 b p .n e t

基础命令

Linux系统的命令通常都是如下所示的格式:

命令名称 [命名参数] [命令对象]

获取登录信息

获取登录信息 – 「w」 / 「who」 / 「last」/ 「lastb」

maoli@ubuntu:~$ w08:07:38 up 2 min,  1 user,  load average: 0.83, 0.64, 0.27USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHATmaoli    tty7     :0               08:06    2:38   2.29s  0.31s /sbin/upstart -maoli@ubuntu:~$ whomaoli    tty7         2020-05-28 08:06 (:0)maoli@ubuntu:~$ lastmaoli    tty7         :0               Thu May 28 08:06    gone - no logoutreboot   system boot  4.15.0-99-generi Thu May 28 08:04   still runningmaoli    tty7         :0               Fri May  1 15:20 - down   (01:26)reboot   system boot  4.15.0-99-generi Fri May  1 15:20 - 16:47  (01:26)maoli    tty7         :0               Fri May  1 10:12 - crash  (05:08)wtmp begins Fri May  1 10:12:22 2020maoli@ubuntu:~$ sudo lastb[sudo] maoli 的密码: btmp begins Fri May  1 15:20:29 2020

查看自己使用的Shell

查看自己使用的Shell – 「ps」

Shell也被称为“壳”或“壳程序”,它是用户与操作系统内核交流的翻译官,简单的说就是人与计算机交互的界面和接口。目前很多Linux系统默认的Shell都是bash(Bourne Again SHell),因为它可以使用tab键进行命令和路径补全、可以保存历史命令、可以方便的配置环境变量以及执行批处理操作。

maoli@ubuntu:~$ ps  PID TTY          TIME CMD 3621 pts/1    00:00:00 bash 5082 pts/1    00:00:00 ps

查看命令的说明和位置

查看命令的说明和位置 – 「whatis」 / 「which」 / 「whereis」

maoli@ubuntu:~$ whatis psps (1)               - report a snapshot of the current processes.maoli@ubuntu:~$ whatis pythonpython (1)           - an interpreted, interactive, object-oriented programmi...maoli@ubuntu:~$ whereis psps: /bin/ps /usr/share/man/man1/ps.1.gzmaoli@ubuntu:~$ whereis pythonpython: /usr/bin/python3.5m-config /usr/bin/python /usr/bin/python3.5 /usr/bin/python3.5m /usr/bin/python2.7 /usr/bin/python3.5-config /usr/lib/python3.5 /usr/lib/python2.7 /etc/python /etc/python3.5 /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/include/python3.5 /usr/include/python3.5m /usr/share/python /usr/share/man/man1/python.1.gzmaoli@ubuntu:~$ which ps/bin/psmaoli@ubuntu:~$ which python/usr/bin/python

清除屏幕上显示的内容

清除屏幕上显示的内容 – 「clear」

查看帮助文档

查看帮助文档 – 「man」 / 「info」 / 「help」 / 「apropos」

maoli@ubuntu:~$ ps --helpUsage:ps [options]Try 'ps --help <simple|list|output|threads|misc|all>' or 'ps --help <s|l|o|t|m|a>'for additional help text.For more details see ps(1).maoli@ubuntu:~$ man psPS(1)                                User Commands                                PS(1)NAME       ps - report a snapshot of the current processes.SYNOPSIS       ps [options]DESCRIPTION...

查看系统和主机名

查看系统和主机名 – 「uname」 / 「hostname」

maoli@ubuntu:~$ unameLinuxmaoli@ubuntu:~$ hostnameubuntu

时间和日期

时间和日期 – 「date」 / 「cal」

maoli@ubuntu:~$ date2020年 05月 28日 星期四 08:13:25 CSTmaoli@ubuntu:~$ cal     五月 2020         日 一 二 三 四 五 六                 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16  17 18 19 20 21 22 23  24 25 26 27 28 29 30  31                    maoli@ubuntu:~$ cal 5 2020     五月 2020         日 一 二 三 四 五 六                 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16  17 18 19 20 21 22 23  24 25 26 27 28 29 30  31        

重启和关机

  • 重启和关机 – 「reboot」 / 「shutdown」
  • maoli@ubuntu:~$  shutdown -h +5   #五分钟关机Shutdown scheduled for 四 2020-05-28 08:19:24 CST, use 'shutdown -c' to cancel. [root ~]# maoli@ubuntu:~$ shutdown -cmaoli@ubuntu:~$ shutdown -r 12:00Shutdown scheduled for 四 2020-05-28 12:00:00 CST, use 'shutdown -c' to cancelmaoli@ubuntu:~$ shutdown -c

    说明:在执行shutdown命令时会向登录系统的用户发出警告,可以在命令后面跟上警告消息来替换默认的警告消息,也可以在-h参数后通过now来表示立刻关机。

    退出登录

    退出登录 – 「exit」 / 「logout」

    查看历史命令

    查看历史命令 – 「history」

    maoli@ubuntu:~$ history...  625  date  626  cal  627  cal 5 2020  628  shutdown -c  629  shutdown -r 12:00  630  shutdown -c  631  historymaoli@ubuntu:~$ !631  

    说明:查看到历史命令之后,可以用!历史命令编号来重新执行该命令;通过history -c可以清除历史命令。

    实用程序

    文件和文件夹操作

    创建/删除空目录

    创建/删除空目录 – 「mkdir」 / 「rmdir」

    [root ~]# mkdir runsen[root ~]# mkdir -p abc/runsen[root ~]# rmdir runsen

    创建/删除文件

    创建/删除文件 – 「touch」 / 「rm」

    maoli@ubuntu:~$ touch readme.txtmaoli@ubuntu:~$  rm readme.txt rm: remove regular empty file ‘readme.txt ’? y[root ~]# rm -rf xyz
    • touch命令用于创建空白文件或修改文件时间。在Linux系统中一个文件有三种时间: 更改内容的时间 – mtime。更改权限的时间 – ctime。最后访问时间 – atime。
    • rm的几个重要参数: -i:交互式删除,每个删除项都会进行询问。-r:删除目录并递归的删除目录中的文件和目录。-f:强制删除,忽略不存在的文件,没有任何提示。

    切换和查看当前工作目录

  • 切换和查看当前工作目录 – 「cd」 / 「pwd」
  • 说明:cd命令后面可以跟相对路径(以当前路径作为参照)或绝对路径(以/开头)来切换到指定的目录,也可以用cd ..来返回上一级目录。返回到上上一级目录应该给cd ../../命令。

    查看目录内容

    查看目录内容 – 「ls」

    • -l:以长格式查看文件和目录。
    • -a:显示以点开头的文件和目录(隐藏文件)。
    • -R:遇到目录要进行递归展开(继续列出目录下面的文件和目录)。
    • -d:只列出目录,不列出其他内容。
    • -S / -t:按大小/时间排序。

    查看文件内容

    查看文件内容 – 「cat」 / 「tac」 / 「head」 / 「tail」 / 「more」 / 「less」 / 「rev」 / 「od」

    maoli@ubuntu:~$  wget https://www.csdn.net/--2020-05-28 08:25:01--  https://www.csdn.net/正在解析主机 www.csdn.net (www.csdn.net)... 47.95.164.112正在连接 www.csdn.net (www.csdn.net)|47.95.164.112|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度: 未指定 [text/html]正在保存至: “index.html”index.html              [  <=>               ] 420.39K  1.53MB/s    in 0.3s    2020-05-28 08:25:02 (1.53 MB/s) - “index.html” 已保存 [430482]maoli@ubuntu:~$ cat index.html<!DOCTYPE html>...maoli@ubuntu:~$ head -10 index.html<!DOCTYPE html><html><head>   <meta charset="utf-8">   <meta http-equiv="X-UA-Compatible" content="IE=Edge">   <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">   <meta name="apple-mobile-web-app-status-bar-style" content="black">   <meta name="referrer"content="always">   <meta name="msvalidate.01" content="3189512127C34C46BC74BED5852D45E4" />   <title>CSDN-专业IT技术社区</title>maoli@ubuntu:~$ tail -2 index.html <script src=/upload/kook/big/b112339.png alt=四十一、Linux基础命令,用户管理和文件系统总结>

    改变文件所有者

  • 「chown」 – 改变文件所有者。
  • maoli@ubuntu:~/backup$ ls -l总用量 424-rw-r--r-- 2 maoli maoli 430482 5月  28 08:30 csdn.htmlmaoli@ubuntu:~/backup$ sudo chown root csdn.html[sudo] maoli 的密码: maoli@ubuntu:~/backup$ ls -l总用量 424-rw-r--r-- 2 root maoli 430482 5月  28 08:30 csdn.html
  • 「chgrp」 – 改变用户组。
  • 本文已收录 GitHub,传送门~[1] ,里面更有大厂面试完整考点,欢迎 Star。

    Reference

    笨笨网美国主机,w ww.2 b p .n e t
    提醒:《ubuntu删除目录文件命令(linux打开文件命令六种方法)》最后刷新时间 2025-03-21 11:16:49,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《ubuntu删除目录文件命令(linux打开文件命令六种方法)》该内容的真实性请自行鉴别。