1.  [root@localhost ~]#  的含义 ?

   【登录的用户  机器的名称 家目录】

2. 查看当前光标所在的目录   pwd

[root@localhost ~]# pwd
/root

3. 切换目录 cd

[root@localhost ~]# cd /home
[root@localhost home]# pwd
/home

  root用户 家目录 /root 规定
  xxx用户 家目录 /home/xxx 默认

回退家目录 的三种方法:

[root@localhost home]# cd -
/root
[root@localhost ~]# cd /home
[root@localhost home]# cd ~
[root@localhost ~]# cd /home
[root@localhost home]# cd /root
[root@localhost ~]#

cd ../ 回退上一层目录
cd ../../ 回退上2层目录

[root@localhost ~]# cd /home/linux/
[root@localhost linux]# pwd
/home/linux
[root@localhost linux]# cd ../
[root@localhost home]# pwd
/home
[root@localhost home]# cd /home/linux
[root@localhost linux]# pwd
/home/linux
[root@localhost linux]# cd ../../
[root@localhost /]# pwd
/
[root@localhost /]#

4.目录 文件夹  路径

  ·绝对路径 /根目录 以根目录

  ·相对路径 不以根目录为开始,以当前光标所在的目录为开始

5.clear  清空屏幕

6.ls查看当前光标所在的目录下,文件和文件夹都有哪些

其中ls 、ll的区别,其中ll 就是ls -l:

[root@localhost /]# ls
bin dev home lost+found misc net proc sbin srv tftpboot usr
boot etc lib media mnt opt root selinux sys tmp var
[root@localhost /]# ll
总计
drwxr-xr-x root root - : bin
drwxr-xr-x root root - : boot
drwxr-xr-x root root - : dev
drwxr-xr-x root root - : etc
drwxr-xr-x root root - : home
drwxr-xr-x root root - : lib
drwx------ root root - : lost+found
drwxr-xr-x root root - : media
drwxr-xr-x root root - : misc
drwxr-xr-x root root - : mnt
drwxr-xr-x root root - : net
drwxr-xr-x root root -- opt
dr-xr-xr-x root root - : proc
drwxr-x--- root root - : root
drwxr-xr-x root root - : sbin
drwxr-xr-x root root - : selinux
drwxr-xr-x root root -- srv
drwxr-xr-x root root - : sys
drwxr-xr-x root root - : tftpboot
drwxrwxrwt root root - : tmp
drwxr-xr-x root root - : usr
drwxr-xr-x root root - : var
[root@localhost /]#

 小结:

  ls -l ==> 等价于ll
  ls -l -a 查看当前的文件文件夹+ 隐藏文件文件夹   以.开头
  ll -h 文件的大小

  ll -rt 按时间排序

ls
ls -l
ls -a
ls -l -a ==> ls -la

实例:

[root@localhost /]# cd /home/linux/
[root@localhost linux]# ls
Desktop file1.txt file2.txt ml
[root@localhost linux]# ls -l
总计
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]# ls -a
. .eggcups .gstreamer-0.10 .redhat
.. .emacs .gtkrc-1.2-gnome2 .scim
.bash_history file1.txt .ICEauthority .ssh
.bash_logout file2.txt .kde .Trash
.bash_profile .gconf .metacity .viminfo
.bashrc .gconfd ml .xsession-errors
.chewing .gnome .mozilla .zshrc
Desktop .gnome2 .nautilus
.dmrc .gnome2_private .recently-used.xbel
[root@localhost linux]# ls -l -a
总计
drwx------ linux linux - : .
drwxr-xr-x root root - : ..
-rw------- linux linux - : .bash_history
-rw-r--r-- linux linux -- .bash_logout
-rw-r--r-- linux linux -- .bash_profile
-rw-r--r-- linux linux -- .bashrc
drwx------ linux linux - : .chewing
drwxr-xr-x linux linux - : Desktop
-rw------- linux linux - : .dmrc
drwxr-x--- linux linux - : .eggcups
-rw-r--r-- linux linux -- .emacs
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwx------ linux linux - : .gconf
drwx------ linux linux - : .gconfd
drwxrwxr-x linux linux - : .gnome
drwx------ linux linux - : .gnome2
drwx------ linux linux - : .gnome2_private
drwxrwxr-x linux linux - : .gstreamer-0.10
-rw-r--r-- linux linux - : .gtkrc-1.2-gnome2
-rw------- linux linux - : .ICEauthority
drwxr-xr-x linux linux - : .kde
drwx------ linux linux - : .metacity
drwxrwxr-x linux linux - : ml
drwxr-xr-x linux linux - : .mozilla
drwxr-xr-x linux linux - : .nautilus
-rw-rw-r-- linux linux - : .recently-used.xbel
drwxrwxr-x linux linux - : .redhat
drwx------ linux linux - : .scim
drwx------ linux linux - : .ssh
drwx------ linux linux - : .Trash
-rw------- linux linux - : .viminfo
-rw-r--r-- linux linux - : .xsession-errors
-rw-r--r-- linux linux -- .zshrc
[root@localhost linux]# ls -la
总计
drwx------ linux linux - : .
drwxr-xr-x root root - : ..
-rw------- linux linux - : .bash_history
-rw-r--r-- linux linux -- .bash_logout
-rw-r--r-- linux linux -- .bash_profile
-rw-r--r-- linux linux -- .bashrc
drwx------ linux linux - : .chewing
drwxr-xr-x linux linux - : Desktop
-rw------- linux linux - : .dmrc
drwxr-x--- linux linux - : .eggcups
-rw-r--r-- linux linux -- .emacs
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwx------ linux linux - : .gconf
drwx------ linux linux - : .gconfd
drwxrwxr-x linux linux - : .gnome
drwx------ linux linux - : .gnome2
drwx------ linux linux - : .gnome2_private
drwxrwxr-x linux linux - : .gstreamer-0.10
-rw-r--r-- linux linux - : .gtkrc-1.2-gnome2
-rw------- linux linux - : .ICEauthority
drwxr-xr-x linux linux - : .kde
drwx------ linux linux - : .metacity
drwxrwxr-x linux linux - : ml
drwxr-xr-x linux linux - : .mozilla
drwxr-xr-x linux linux - : .nautilus
-rw-rw-r-- linux linux - : .recently-used.xbel
drwxrwxr-x linux linux - : .redhat
drwx------ linux linux - : .scim
drwx------ linux linux - : .ssh
drwx------ linux linux - : .Trash
-rw------- linux linux - : .viminfo
-rw-r--r-- linux linux - : .xsession-errors
-rw-r--r-- linux linux -- .zshrc
[root@localhost linux]#

7.查询命令帮助  ls  --help

[root@localhost linux]# ls  --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort. 长选项必须用的参数在使用短选项时也是必须的。
-a, --all 不隐藏任何以 . 字符开始的项目
-A, --almost-all 列出除了 . 及 .. 以外的任何项目
--author 和 -l 同时使用时列出每个文件的作者
-b, --escape 以八进制溢出序列表示不可打印的字符
--block-size=大小 块以指定<大小>的字节为单位
-B, --ignore-backups 不列出任何以 ~ 字符结束的项目
-c 配合 -lt:根据 ctime 排序及显示 ctime (文件
状态最后更改的时间)
配合 -l:显示 ctime 但根据名称排序
否则:根据 ctime 排序
-C list entries by columns
--color[=WHEN] control whether color is used to distinguish file
types. WHEN may be `never', `always', or `auto'
-d, --directory list directory entries instead of contents,
and do not dereference symbolic links
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -lst
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append `*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
-G, --no-group like -l, but do not list group
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
--si likewise, but use powers of not
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode with -l, print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k like --block-size=1K
-l 使用较长格式列出信息
-L, --dereference 当显示符号链接的文件信息时,显示符号链接所指示
的对象而并非符号链接本身的信息
-m 所有项目以逗号分隔,并填满整行行宽
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars 以 ? 字符代替无法打印的字符
--show-control-chars 直接显示无法打印的字符 (这是默认方式,除非调用
的程序名称是“ls”而且是在终端机画面输出结果)
-Q, --quote-name 将项目名称括上双引号
--quoting-style=方式 使用指定的 quoting <方式>显示项目的名称:
literal、locale、shell、shell-always、c、escape
-r, --reverse 逆序排序
-R, --recursive 递归列出所有子目录
-s, --size 和 -l 同时使用时以块为单位列出每个文件的大小
-S 根据文件大小排序
--sort=WORD 以下是可选用的 WORD 和它们代表的相应选项:
extension -X status -c
none -U time -t
size -S atime -u
time -t access -u
version -v use -u
--time=WORD 和 -l 同时使用时显示 WORD 所代表的时间而非修改时
间:atime、access、use、ctime 或 status;加上
--sort=time 选项时会以指定时间作为排序关键字
--time-style=STYLE 和 -l 同时使用时根据 STYLE 代表的格式显示时间:
full-iso、iso、locale、posix-iso、+FORMAT。
FORMAT 即是“date”所用的时间格式;如果 FORMAT
是 FORMAT1<新行>FORMAT2,FORMAT1 适用于较旧
的文件而 FORMAT2 适用于较新的文件;如果 STYLE
以“posix-”开头,则 STYLE 仅在 POSIX 语系之外
生效。
-t 根据修改时间排序
-T, --tabsize=宽度 自行指定 tab 的<宽度>,而非 个字符
-u with -lt: sort by, and show, access time
with -l: show access time and sort by name
otherwise: sort by access time
-U do not sort; list entries in directory order.
In combination with one_per_line format `-',
it will show files immediately and it has no
memory limitations.
-v sort by version
-w, --width=COLS 自行指定萤幕宽度而不使用目前的数值
-x 逐行列出项目而不是逐栏列出
-X 根据扩展名排序
- 每行只列出一个文件 SELinux options: --lcontext Display security context. Enable -l. Lines
will probably be too wide for most displays.
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
--scontext Display only security context and file name. --help 显示此帮助信息并退出
--version 输出版本信息并退出 [大小]可以是以下的单位(单位前可加上整数):
kB ,K ,MB ,M ,还有 G、T、P、E、Z、Y。 By default, color is not used to distinguish types of files. That is
equivalent to using --color=none. Using the --color option without the
optional WHEN argument is equivalent to using --color=always. With
--color=auto, color codes are output only if standard output is connected
to a terminal (tty). The environment variable LS_COLORS can influence the
colors, and can be set easily by the dircolors command. Exit status is if OK, if minor problems, if serious trouble. 请向 <bug-coreutils@gnu.org> 报告错误。
[root@localhost linux]#

ls --help

8.mkdir 创建文件夹

[root@localhost linux]# ll
总计
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
You have new mail in /var/spool/mail/root
[root@localhost linux]# mkdir a
[root@localhost linux]# mkdir -p b/c/d
[root@localhost linux]# mkdir
[root@localhost linux]# ll
总计
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - : a
drwxr-xr-x root root - : b
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]#

9.mv移动

  始终只有1份  cp拷贝 原文件不动,新增一份

[root@localhost linux]# ll
总计
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - : a
drwxr-xr-x root root - : b
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]# mv file2.txt /
[root@localhost linux]# ll /
总计
-rw-rw-r-- linux linux - : file2.txt

10.如何创建一个空文件 或者把一个文件设置为空

  touch rz.log 如何创建一个空文件
  echo "" > rz.log1 慎用
  cat /dev/null > ruoze.log20191113 把一个文件设置为空

[root@localhost ]# ll
总计
[root@localhost ]# touch rz.log
[root@localhost ]# echo "" > rz.log1
[root@localhost ]# ll
总计
-rw-r--r-- root root - : rz.log
-rw-r--r-- root root - : rz.log1
[root@localhost ]# cat /dev/null > ruoze.log20191113
[root@localhost ]# ll
总计
-rw-r--r-- root root - : ruoze.log20191113
-rw-r--r-- root root - : rz.log
-rw-r--r-- root root - : rz.log1
[root@localhost ]#

11.查看文件内容 

 cat 文件内容一下子全部显示
  more 文件内容一页一页的往下翻,按空格键往下,回退不了,按q退出
  less 文件内容 往下 往上 按上下箭头的按键 按q键退出

12.实时 tail -f xxx.log 和 ail -F xxx.log 的查看日志的区别:

  配置文件 内容较少 cat more less
  log日志 内容较多   

  实时查看 :

    tail -f xxx.log
    tail -F xxx.log -f+ retry
    flume exec source 切记使用 -F
    xxx.log log4j代码项目 配置输出的日志
    

  规则: xxx.log 保留10份 100M

    aaa-->xxx.log 99m
    xxx.log 100m
    mv xxx.log xxx.log1
    touch xxx.log 空文件

13.当发生ERROR 如何快速定位

  a.文件内容很小 几十兆,上传给window,用editplus工具打开

    上传下载 yum install -y lrzsz

  b.文件内容很大 几百兆 2G
    cat xxx.log | grep ERROR

14.命令输出结果 | 命令输入的 管道符

  grep过滤:

cat xxx.log | grep -A  ERROR 后10行
cat xxx.log | grep -B ERROR 前10行
cat xxx.log | grep -C ERROR 前后各30行 经常用 迅速定位ERROR上下文 tail -300f messages 实时查看倒数300行文件
tail -300F messages 不能这样写
tail: option used in invalid context --

数据仓库001 - 复习Linux shell命令 - pwd mkdir mv tail -f xxx.log 和 ail -F xxx.log的更多相关文章

  1. 数据仓库002 - 复习Linux shell命令 - echo bash_profile bashrc which命令的理解 alias history

    1.echo 打印 . echo 的作用是在屏幕上打印输出内容,与文件和持久化可以理解为没有丝毫关联.如:在屏幕上打印“ echo 的作用是打印文字! ” 实例1:输出系统的环境变量名称 $PATH ...

  2. 数据仓库005 - 复习Linux shell命令 - crontab调度 sh脚本 后台执行 软连接

    一.crontab调度 对于linux 自带crontab而言,      xxx.sh的一般编写格式以#!/bin/bash 解释器开头,可在脚本中加入: date 但是,shell脚本执行 需要 ...

  3. 数据仓库004 - 复习Linux shell命令 - vi 进程 端口号 系统命令 高危命令 wget yum rpm压缩

    一.复习 1.vi的使用方法: 1.1 .正常编辑一个文件,保存退出 1.2. 粘贴的坑:必须在i键 编辑模式 2.找error cat xxx.log | grep -C 10 ERROR > ...

  4. 数据仓库003 - 复习Linux shell命令 - 用户用户组 sudo 权限 du-sh find 

    一.用户用户组 [root@localhost ~]# ll /usr/sbin/user* -rwxr-x--- root root -- /usr/sbin/useradd -rwxr-x--- ...

  5. Java文件操作API功能与Windows DOS命令和Linux Shell 命令类比

    Java文件操作API功能与Windows DOS命令和Linux Shell 命令类比: Unix/Linux (Bash) Windows(MS-DOS) Java 进入目录 cd cd - 创建 ...

  6. 73条日常Linux shell命令汇总,总有一条你需要!

    转载: 73条日常Linux shell命令汇总,总有一条你需要! 1.检查远程端口是否对bash开放: echo >/dev/tcp/8.8.8.8/53 && echo &q ...

  7. [Python2.x] 利用commands模块执行Linux shell命令

    用Python写运维脚本时,经常需要执行linux shell的命令,Python中的commands模块专门用于调用Linux shell命令,并返回状态和结果,下面是commands模块的3个主要 ...

  8. java使用Runtime.exec()运行windwos dos或linux shell命令

    使用Runtime.exec()运行windwos dos或linux shell命令,按实际情况具体测试     实例代码: package com.bookoo.test.command; imp ...

  9. Linux shell命令中expr

    在Linux shell命令中expr虽然不是很起眼,但是它的作用是非常大的!到目前为止,我个人看来最大的作用就是两个——四则运算和字符串的操作. 先说四则运算,在Shell中四则运算不能简简单单的加 ...

随机推荐

  1. 推荐书单(网课)-人生/编程/Python/机器学习-130本

    目录 总计(130本) 一.在读 二.将读 三.已读 非专业书单(77本) 四.已读 专业书单(53本) 五.已看网课(8个) 六.在看网课 一个人如果抱着义务的意识去读书,便不了解读书的艺术.--林 ...

  2. java之运算符的优先级

    优先级 运算符 结合性 1 () [] 从左往右 2 ! +(正) -(负) ++ -- 从右往左 3 * / %  从左往右 4 << >> >>> 从左往 ...

  3. 【Sublime Text】sublime修改默认浏览器及使用不同浏览器打开网页的快捷键设置

    #第一步:安装SideBarEnhancements插件 下载插件,需要“翻墙”,故提供一下该插件的github地址:https://github.com/titoBouzout/SideBarEnh ...

  4. 怎么在ubuntu下安装使用pycharm

    1.安装jdk 先下载jdk: https://pan.baidu.com/s/1o7MqvKA 解压到本地: 方法一:直接点击右键,点“提取此文件 方法二:使用命令行sudo tar -zxvf j ...

  5. ubuntu 16.04上源码编译和安装cgal并编写CMakeLists.txt | compile and install cgal on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/39ab7ed9/,欢迎阅读最新内容! compile and install cgal on ubuntu 16.04 Guide ...

  6. CRF 详细推导、验证实例

    逐帧softmax CRF主要用于序列标注问题,可以简单理解为是给序列中的每一帧都进行分类,既然是分类,很自然想到将这个序列用CNN或者RNN进行编码后,接一个全连接层用softmax激活,如下图所示 ...

  7. ZooKeeper(二):多个端口监听的建立逻辑解析

    ZooKeeper 作为优秀的分布系统协调组件,值得一探究竟.它的启动类主要为: 1. 单机版的zk 使用 ZooKeeperServerMain 2. 集群版的zk 使用 QuorumPeerMai ...

  8. OpenGL光照2:材质和光照贴图

    本文是个人学习记录,学习建议看教程 https://learnopengl-cn.github.io/ 非常感谢原作者JoeyDeVries和多为中文翻译者提供的优质教程 的内容为插入注释,可以先跳过 ...

  9. Java开发桌面程序学习(13)——Javafx多线程 下载功能

    普通使用 Task<Void> task = new Task<Void>() { @Override protected void succeeded() { super.s ...

  10. MySQL UNION 查询

    UNION 用来合并多个 SELECT 结果. 考察如下两个表: # t1 +----+---------+ | id | pattern | +----+---------+ | 1 | Divot ...