栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

学习笔记——Linux命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学习笔记——Linux命令

pwd命令:

    功能:查看当前所在的工作目录

  示例:
[root@localhost /]# cd ~
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd 20220421
[root@localhost 20220421]# ls
dir01  dir02  file01  file02
[root@localhost 20220421]# cd dir01
[root@localhost dir01]# pwd
/root/20220421/dir01


ls命令:

    功能:显示目录内容

  用法及示例:
  1.  ls -a 列出文件下所有的文件,包括以“.“开头的隐藏文件
    [root@localhost dir01]# ls -a 
    .   dir01   File01  file06  file2    tardir          targiz
    ..  file01  file02  file1   gzipdir  tarfile.tar.gz  targiz.tar.gz
    
  2.  ls -l 列出文件的详细信息,而且一行显示一个文件
    [root@localhost dir01]# ls -l
    总用量 8
    drwxr-xr-x. 2 root root   6 4月  20 21:19 dir01
    -rw-r--r--. 1 root root   0 4月  20 21:26 file01
    -rw-r--r--. 1 root root   0 4月  20 21:27 File01
    -rw-r--r--. 1 root root   0 4月  20 21:42 file02
    -rw-r--r--. 1 root root   0 4月  20 21:29 file06
    -rw-r--r--. 1 root root   0 4月  20 21:17 file1
    -rw-r--r--. 1 root root   0 4月  20 21:19 file2
    drwxr-xr-x. 2 root root   6 4月  20 22:09 gzipdir
    drwxr-xr-x. 2 root root   6 4月  20 22:05 tardir
    -rw-r--r--. 1 root root 126 4月  20 22:06 tarfile.tar.gz
    drwxr-xr-x. 2 root root  34 4月  20 22:22 targiz
    -rw-r--r--. 1 root root 128 4月  20 22:14 targiz.tar.gz
    
  3.  ls -al 多个短格式组合使用
    [root@localhost dir01]# ls -al
    总用量 8
    drwxr-xr-x. 6 root root 187 4月  20 22:15 .
    drwxr-xr-x. 4 root root  60 4月  20 21:11 ..
    drwxr-xr-x. 2 root root   6 4月  20 21:19 dir01
    -rw-r--r--. 1 root root   0 4月  20 21:26 file01
    -rw-r--r--. 1 root root   0 4月  20 21:27 File01
    -rw-r--r--. 1 root root   0 4月  20 21:42 file02
    -rw-r--r--. 1 root root   0 4月  20 21:29 file06
    -rw-r--r--. 1 root root   0 4月  20 21:17 file1
    -rw-r--r--. 1 root root   0 4月  20 21:19 file2
    drwxr-xr-x. 2 root root   6 4月  20 22:09 gzipdir
    drwxr-xr-x. 2 root root   6 4月  20 22:05 tardir
    -rw-r--r--. 1 root root 126 4月  20 22:06 tarfile.tar.gz
    drwxr-xr-x. 2 root root  34 4月  20 22:22 targiz
    -rw-r--r--. 1 root root 128 4月  20 22:14 targiz.tar.gz
    

cd命令:       功能: 在不同的目录间切换,即更改当前工作目录   用法: 
  • 可以使用绝对路径或相对路径 
  • 如果没有参数,表示切换到当前登录用户的主目录
  • cd  .   进入当前目录
  • cd  ..  进入上一级目录
  • cd  -   进入上次所在的目录
  • cd  ~ 进入当前登录用户的主目录
示例:
[root@localhost 20220421]# cd dir01
[root@localhost dir01]# pwd
/root/20220421/dir01
[root@localhost dir01]# cd .
[root@localhost dir01]# cd ~
[root@localhost ~]# cd -
/root/20220421/dir01
[root@localhost dir01]# cd ..
[root@localhost 20220421]# pwd
/root/20220421
[root@localhost 20220421]# ls
dir01  dir02  file01  file02
[root@localhost 20220421]# cd /root/20220421/dir01
[root@localhost dir01]# pwd
/root/20220421/dir01

 cat命令:

    功能:在标准输出设备上显示文件内容

  用法:
  • cat   filename 显示文件内容包括空行
  • cat  -n  filename 显示所有行的行号
  示例: 
[root@localhost dir01]# cat file01
agfdj
dsafd
fdsaf
cdc

ffa
yjdr

fds

hhh
l
rty
[root@localhost dir01]# cat -n file01
     1	agfdj
     2	dsafd
     3	fdsaf
     4	cdc
     5	
     6	ffa
     7	yjdr
     8	
     9	fds
    10	
    11	hhh
    12	l
    13	rty

head命令:

    功能:显示文件开头若干行内容,默认显示前10行

  用法:
  • head   filename 默认显示文件前10行
  • head  -n  number  filename  显示前number行
  示例:
[root@localhost dir01]# head file01
agfdj
dsafd
fdsaf
cdc

ffa
yjdr

fds

[root@localhost dir01]# head -n 6 file01
agfdj
dsafd
fdsaf
cdc

ffa

tail命令: 

    功能:显示文件结尾若干行内容,默认显示后10行 

  用法:
  • tail   filename 默认显示文件后10行
  • tail  -n  number  filename  显示文件结尾的 number 
  示例:
[root@localhost dir01]# tail file01
cdc

ffa
yjdr

fds

hhh
l
rty
[root@localhost dir01]# tail -n 3 file01
hhh
l
rty

more命令/less命令: 

    功能:分页显示文件,即一次显示一页内容 

    less的作用与more十分相似,不同点为less命令允许用户向前或向后浏览文件,而more命令只  能向前浏览 。其次less命令还可以使用PageUp键向上翻页,PageDown键向下翻页。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/837643.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号