Linux系统中常用命令 _1

Ginc
Ginc
管理员
66
文章
0
粉丝
教程干货2293阅读模式
前言 日常使用Linux中常用的命令分享及演示(纯代码方式)。以下内容以Centos系统为准,权限为root用户,其他系统请自行测试。
以下命令演示中[root>NUC11tnhi50L:~]  为自定义内容,默认为[root@NUC11tnhi50L:~]

1、查看系统内核信息:

sudo uname -r    #sudo用于非root用户

演示:

[root>NUC11tnhi50L:~]# uname -r
6.0.11-1.el9.elrepo.x86_64

2、切换root用户:

su

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[ly>NUC11tnhi50L:~]$ su 
密码:                          #此处密码不可见
[root>NUC11tnhi50L:~]#

注:root用户默认为#  其他用户默认为$文章源自今夕何夕兮-https://www.ginc.site/share1070.html

3、查看系统详细信息:

hostnamectl

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:~]# hostnamectl
 Static hostname: NUC11tnhi50L
       Icon name: computer-desktop
         Chassis: desktop ?
      Machine ID: 2d06febe68e94349ba85c67901d9147e
         Boot ID: 8266733923f045b39639c0749c3642fa
Operating System: CentOS Stream 9                 
     CPE OS Name: cpe:/o:centos:centos:9
          Kernel: Linux 6.0.11-1.el9.elrepo.x86_64
    Architecture: x86-64
 Hardware Vendor: Intel_R_ Client Systems
  Hardware Model: NUC11TNHi5

4、查看主机名:

hostname          #跟上一个命令不同,只显示主机名

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:~]# hostname
NUC11tnhi50L

5、查看命令类型:

type

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:~]# type type      #第一个type是查看命令,第二个是查看哪个命令
type 是 shell 内建                    #显示内建是内部命令
[root>NUC11tnhi50L:~]# type ping
ping 是 /usr/bin/ping              #显示路径是外部命令

6、帮助命令:

man

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:~]# man ls     #查看ls命令的帮助信息

LS(1)                                User Commands                               LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information about the FILEs (the current directory by default).  Sort en‐
       tries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..
······

7、进入文件夹命令:

cd

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

root>NUC11tnhi50L:~]# cd /
[root>NUC11tnhi50L:/]# 

8、显示当前路径:

pwd

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:ly]# pwd
/home/ly

9、列出当前目录内容:

ls  [-a  -l  -d]                    #-a全部 -l平铺方式列出详细信息 -d以目录形式列出   ls -l  可缩写为 ll

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

1、
[root>NUC11tnhi50L:/]# ll
总用量 28
dr-xr-xr-x.   2 root root    6  8月 10  2021 afs
lrwxrwxrwx.   1 root root    7  8月 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 12月  7 16:23 boot
drwxr-xr-x.  19 root root 3600 12月  8 15:08 dev
drwxr-xr-x. 132 root root 8192 12月  8 15:49 etc
drwxr-xr-x.   3 root root   16 12月  3 14:10 home
lrwxrwxrwx.   1 root root    7  8月 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9  8月 10  2021 lib64 -> usr/lib64
2、
[root>NUC11tnhi50L:/]# ls -l
总用量 28
dr-xr-xr-x.   2 root root    6  8月 10  2021 afs
lrwxrwxrwx.   1 root root    7  8月 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 12月  7 16:23 boot
drwxr-xr-x.  19 root root 3600 12月  8 15:08 dev
drwxr-xr-x. 132 root root 8192 12月  8 15:49 etc
drwxr-xr-x.   3 root root   16 12月  3 14:10 home
lrwxrwxrwx.   1 root root    7  8月 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9  8月 10  2021 lib64 -> usr/lib64

10、显示当前系统日期:

date

演示:文章源自今夕何夕兮-https://www.ginc.site/share1070.html

[root>NUC11tnhi50L:~]# date
2022年 12月 11日 星期日 21:13:53 CST

11、显示当前月日历:

cal

演示:

[root>NUC11tnhi50L:~]# cal
     十二月 2022    
一 二 三 四 五 六 日
          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   

12、命令与冲突

在Linux系统中素有操作都是基于命令+命令参数格式命令,当有多个命令参数,且命令参数相互冲突时,以最后一个参数为准:

例:

ls命令中-C为多列显示,-l为显示详细信息,两个参数相互冲突。

则演示如下:

[root>NUC11tnhi50L:ly]# ls -Cl
总用量 0
drwxr-xr-x. 2 ly ly  6 12月  3 14:10 公共
drwxr-xr-x. 2 ly ly  6 12月  3 14:10 模板
drwxr-xr-x. 2 ly ly  6 12月  3 14:10 视频
drwxr-xr-x. 2 ly ly 81 12月  4 16:39 图片
drwxr-xr-x. 2 ly ly 39 12月  4 16:54 文档
drwxr-xr-x. 2 ly ly  6 12月  8 15:49 下载
drwxr-xr-x. 2 ly ly  6 12月  3 14:10 音乐
drwxr-xr-x. 2 ly ly 31 12月  3 14:16 桌面

[root>NUC11tnhi50L:ly]# ls -lC
公共  模板  视频  图片  文档  下载  音乐  桌面

 

 

 

转载请注明来自:今夕何夕兮
本站原创内容版权遵循 CC-BY-NC-SA4.0 协议授权,本站部分资源收集于网络,只做学习和交流使用,版权归原作者所有。

weinxin
提示:
若文章中图片、链接等信息出错,请及时反馈,博主将在第一时间更新。谢谢大家!
 
Ginc
  • 本文由 Ginc 发表于2022年12月11日
  • 转载请保留本文链接:Linux系统中常用命令 _1:https://www.ginc.site/share1070.html
评论  2  访客  2
    • TeacherDu
      TeacherDu

      sudo命令仅限于管理员可使用。

        • 今夕
          今夕

          @ TeacherDu sudo是提升非管理员用户权限来执行命令

      匿名

      发表评论

      匿名网友
      确定

      拖动滑块以完成验证