大数据开发基础入门与项目实战(二)Java Web数据可视化之4.Linux基本操作命令和功能

在 Linux 上部署javaWeb项目+图文详解_java web项目部署到linux服务器 最全的Linux教程,Linux从入门到精通第一份《Linux从入门到精通》466页内容简介====本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。 阅读详情

前言

本文主要介绍了Linux的基本操作命令和功能,包括常用Linux命令的基本使用、打包和解包命令、时间日期、搜索查找和vi编辑器的使用,是Linux操作的基础

1.常用Linux命令的基本使用

(1)Linux常用快捷键

Linux中常用的快捷键如下:

快捷键含义
tab键命令或者路径提示及补全
ctrl+c放弃当前输入,终止当前任务或程序
ctrl+l清屏;
clear命令也能达到相同的效果
ctrl + insert复制
鼠标右键粘贴
alt+c断开连接
ctrl + shfit + R重新连接
alt+1/2/3/4/5…切换会话窗口
上下键查找执行行过的命令,也可以使用history命令

(2)命令格式及帮助手册使用

终端的命令格式为:

command [-options] [parameter]

其中:

  • command

    命令名,相应功能的英文单词或单词的缩写。

  • [-options]

    选项, 可用来对命令进行控制,也可以省略。

  • parameter

    传给命令的参数,可以是零个、一个或者多个。

例如ls -l、touch abc.txt等。

因为一个命令有很多可选项,一般不可能全记住,所以需要借助手册查阅,由2种方式:

(1)—help 帮助信息

格式为:

command --help

用于显示 command命令的帮助信息。

例如:

[root@localhost /]# ls --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                     不隐藏任何以. 开始的项目
  -A, --almost-all              列出除. 及.. 以外的任何项目
      --author                  与-l 同时使用时列出每个文件的作者
  -b, --escape                  以八进制溢出序列表示不可打印的字符
      --block-size=SIZE      scale sizes by SIZE before printing them; e.g.,
                               '--block-size=M' prints sizes in units of
                               1,048,576 bytes; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information);
                               with -l: show ctime and sort by name;
                               otherwise: sort by ctime, newest first
...
  -X                         sort alphabetically by entry extension
  -1                         list one file per line

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         显示版本信息并退出

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。


退出状态:
 0  正常
 1  一般问题 (例如:无法访问子文件夹)
 2  严重问题 (例如:无法使用命令行参数)

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告ls 的翻译错误
要获取完整文档,请运行:info coreutils 'ls invocation'

缺点:

虽然可以查询命令的帮助信息,但是没有提供翻页、搜索功能。

(2)man手册

格式为:

man command

查询 command 命令的使用手册。

其中,man是manual 的缩写,是Linux提供的一个手册,包含了绝大部分的命令、函数的详细使用说明。

使用man时的操作键如下:

操作键功能
空格键显示手册的下一屏
Enter键一次滚动一行
b回滚一屏
f前滚一屏
q(quit)退出
/word搜索word字符串
n(next)搜索下一个
N搜索上一个

例如:

stage2 module6 man commond

可以看到,可以查看和操作手册。

常用的命令如下:

命令对应英文作用
lslist查看当前目录下的内容
pwdprint working derectory查看当前所在目录
cd [目录名]change directory切换目录
touch [文件名]touch如果文件不存在,新建文件
mkdir [目录名]make directory创建目录
rm [文件名]remove删除指定的文件名
clearclear清屏

(3)切换目录的命令

pwd查看当前所在路径。

cd切换目录。常见用法如下:

命令含义
cd …切换到上级目录
cd -后退到上一次所在目录
cd /切换到根目录
cd ~切换到家目录,即root目录,也可以用cd命令

其中,cd后的参数可以是绝对路径,也可以是相对路径:

  • 绝对路径:/开始的目录,从根目录开始

  • 相对路径:直接目录,从当前目录开始

如下:

# 查看当前所在目录
[root@localhost /] pwd
/
# 切换到 /usr/local(绝对路径)
[root@localhost /] cd /usr/local/
# 切换到 上一级 /usr
[root@localhost local] cd ..
# 切换到 /usr/tmp (相对路径)
[root@localhost usr] cd tmp/
# 切换回 /usr/local
[root@localhost tmp] cd /usr/local/
# 后退到上一次所在目录
[root@localhost local] cd -
/usr/tmp

(4)展示目录的命令

列出目录内容使用命令ls。

常见选项如下:

选项含义
-a(all)所有,包含隐藏文件
-l查看内容的详细信息,效果等同于ll命令
-h(human)人性化的显示(单位为K、G等)
-R树结构显示某文件夹下的所有文件(包括子文件夹)

使用如下:

# 查看/usr内容
[root@localhost /] cd /usr/
[root@localhost usr]# ls
bin  etc  games  include  lib  lib64  libexec  local  sbin  share  src  tmp

# 查看所有/usr内容(既包含隐藏,也包含非隐藏)
[root@localhost usr] ls -a
.  ..  bin  etc  games  include  lib  lib64  libexec  local  sbin  share  src  tmp
# 查看/usr详细内容
[root@localhost usr] ls -l
总用量 100
dr-xr-xr-x.  2 root root 20480 8月  19 03:24 bin
drwxr-xr-x.  2 root root     6 4月  11 2018 etc
drwxr-xr-x.  2 root root     6 4月  11 2018 games
drwxr-xr-x.  3 root root    23 8月  19 03:23 include
dr-xr-xr-x. 27 root root  4096 8月  19 03:24 lib
dr-xr-xr-x. 37 root root 20480 8月  19 03:24 lib64
drwxr-xr-x. 21 root root  4096 8月  19 03:24 libexec
drwxr-xr-x. 12 root root   131 8月  19 03:23 local
dr-xr-xr-x.  2 root root 12288 8月  19 03:24 sbin
drwxr-xr-x. 76 root root  4096 8月  19 03:24 share
drwxr-xr-x.  4 root root    34 8月  19 03:23 src
lrwxrwxrwx.  1 root root    10 8月  19 03:23 tmp -> ../var/tmp

# 简化查看/usr详细内容
[root@localhost usr] ll
总用量 100
dr-xr-xr-x.  2 root root 20480 8月  19 03:24 bin
drwxr-xr-x.  2 root root     6 4月  11 2018 etc
drwxr-xr-x.  2 root root     6 4月  11 2018 games
drwxr-xr-x.  3 root root    23 8月  19 03:23 include
dr-xr-xr-x. 27 root root  4096 8月  19 03:24 lib
dr-xr-xr-x. 37 root root 20480 8月  19 03:24 lib64
drwxr-xr-x. 21 root root  4096 8月  19 03:24 libexec
drwxr-xr-x. 12 root root   131 8月  19 03:23 local
dr-xr-xr-x.  2 root root 12288 8月  19 03:24 sbin
drwxr-xr-x. 76 root root  4096 8月  19 03:24 share
drwxr-xr-x.  4 root root    34 8月  19 03:23 src
lrwxrwxrwx.  1 root root    10 8月  19 03:23 tmp -> ../var/tmp
# 易懂简化查看/usr详细内容
[root@localhost usr] ll -h
总用量 100K
dr-xr-xr-x.  2 root root  20K 8月  19 03:24 bin
drwxr-xr-x.  2 root root    6 4月  11 2018 etc
drwxr-xr-x.  2 root root    6 4月  11 2018 games
drwxr-xr-x.  3 root root   23 8月  19 03:23 include
dr-xr-xr-x. 27 root root 4.0K 8月  19 03:24 lib
dr-xr-xr-x. 37 root root  20K 8月  19 03:24 lib64
drwxr-xr-x. 21 root root 4.0K 8月  19 03:24 libexec
drwxr-xr-x. 12 root root  131 8月  19 03:23 local
dr-xr-xr-x.  2 root root  12K 8月  19 03:24 sbin
drwxr-xr-x. 76 root root 4.0K 8月  19 03:24 share
drwxr-xr-x.  4 root root   34 8月  19 03:23 src
lrwxrwxrwx.  1 root root   10 8月  19 03:23 tmp -> ../var/tmp


其中,ls -a查看mu录中的所有内容时,.代表当前目录、..代表上一层目录。

(5)创建目录和删除目录

通过 mkdir 命令 创建目录,语法格式为:

mkdir [-p] 要创建的目录

其中, 选项-p为parent,表示可以递归创建目录。

使用如下:

[root@localhost ~]# mkdir aaa
[root@localhost ~]# mkdir -p bbb/ccc
[root@localhost ~]# ls -R
.:
aaa  anaconda-ks.cfg  bbb

./aaa:

./bbb:
ccc

./bbb/ccc:

rmdir 删除一个空的目录。

如果该目录中存在文件或其他目录是该命令是不能删除的。

使用如下:

[root@localhost ~]# rmdir aaa/
[root@localhost ~]# rmdir bbb/
rmdir: 删除 "bbb/" 失败: 目录非空
[root@localhost ~]# cd bbb/
[root@localhost bbb]# rmdir ccc/
[root@localhost bbb]# cd ..
[root@localhost ~]# rmdir bbb/
[root@localhost ~]# ls
anaconda-ks.cfg

(6)创建文件和删除文件

创建文件的命令为:

touch 文件名称

touch 文件名1 文件2 ... 可以创建多个文件。

删除命令语法为:

rm [-参数] 文件/目录

rm对应的英文是remove,含义为删除。

常见的选项如下:

选项英文含义
-fforce(强制)强制删除,忽略不存在的文件,无需提示
-rrecursive(递归)递归地删除目录下的内容,删除文件夹时必须加此参数

Linux ouch rm

常见用法如下:

文件操作命令
touch
文件名:
创建文件
rm:
删除文件或目录
rm
文件名:删除一个文件
rm
-f文件名:不经确认就删除文件
rm
-r
目录:
递归删除一个目录及目录中的内容
n
-rf目录:递归删除一个目录,并且不经确认
rm
-rf
*
:清空当前文件夹
rm
n
-rf/*
自杀行为,
不要尝试

(7)复制与剪切命令

通过 cp 实现复制将指定的 文件 或 目录 复制到 两一个 文件 或 目录中

基本语法如下:

(1)cp source dest (功能描述:复制source文件到dest)
(2)cp -r sourceFolder targetFolder (功能描述:递归复制整个文件夹)

命令 英文 作用
-r recursive (递归) 递归复制目标目录的内容

使用如下:

[root@localhost lxDemo]# touch abc.txt
[root@localhost lxDemo]# cp abc.txt cba.txt
[root@localhost lxDemo]# ls
abc.txt  cba.txt
[root@localhost lxDemo]# cp abc.txt ..
[root@localhost lxDemo]# cp abc.txt ../cba.txt
[root@localhost lxDemo]# ls ..
abc.txt  anaconda-ks.cfg  cba.txt  lxDemo
[root@localhost lxDemo]# mkdir -p aaa/bbb
[root@localhost lxDemo]# cp -r aaa/bbb/ ..
[root@localhost lxDemo]# ls ..
abc.txt  anaconda-ks.cfg  bbb  cba.txt  lxDemo
[root@localhost lxDemo]# mkdir -p aaa/bbb/ccc
[root@localhost lxDemo]# cp -r aaa ..

通过 mv 命令可以用来 移动 文件 或 目录, 也可以给 文件或目录重命名。

基本语法:

(1)mv oldNameFile newNameFile (功能描述:重命名)
(2)mv /temp/movefile /targetFolder (功能描述:递归移动文件)

使用如下:

[root@localhost lxDemo]# mv abc.txt aaabbcc.txt
[root@localhost lxDemo]# ls
aaa  aaabbcc.txt  cba.txt
[root@localhost lxDemo]# mkdir -p 111/222/333
[root@localhost lxDemo]# mv 111 ..
[root@localhost lxDemo]# ls ..
111  aaa  abc.txt  anaconda-ks.cfg  bbb  cba.txt  lxDemo

(8)cat查看文件命令

查看文件内容,从第一行开始显示。
1)基本语法

cat [选项] 要查看的文件

选项:

-b :列出行号,仅针对非空白行做行号显示,空白行不标行号!
-E :将结尾的断行行字节 $ 显示出来;
-n :列出行号,连同空白行也会有行号,与 -b 的选项不不同;
-T :将 [tab] 按键以 ^I 显示出来;
-v :列出一些看不出来的特殊字符
-A :相当于 -vET 的整合选项,可列列出一些特殊字符而不不是空白而已;

使用如下:

[root@instance-6m0ylrf0 lxDemo]# cat abc.txt 
123
                fefsfs

ad
aa



fadfsfv
666 fsd 

奥运

😊 (●'◡'●)

o(* ̄▽ ̄*)ブ

csfdfsfrse
[root@instance-6m0ylrf0 lxDemo]# cat -b abc.txt 
     1  123
     2                  fefsfs

     3  ad
     4  aa



     5  fadfsfv
     6  666 fsd 

     7  奥运

     8  😊 (●'◡'●)

     9  o(* ̄▽ ̄*)ブ

    10  csfdfsfrse
[root@instance-6m0ylrf0 lxDemo]# cat -E abc.txt 
123$
                fefsfs$
$
ad$
aa$
$
$
$
fadfsfv$
666 fsd $
$
奥运$
$
😊 (●'◡'●)$
$
o(* ̄▽ ̄*)ブ$
$
csfdfsfrse$
[root@instance-6m0ylrf0 lxDemo]# cat -n abc.txt 
     1  123
     2                  fefsfs
     3  
     4  ad
     5  aa
     6  
     7  
     8  
     9  fadfsfv
    10  666 fsd 
    11  
    12  奥运
    13  
    14  😊 (●'◡'●)
    15  
    16  o(* ̄▽ ̄*)ブ
    17  
    18  csfdfsfrse
[root@instance-6m0ylrf0 lxDemo]# cat -T abc.txt 
123
^I^Ifefsfs

ad
aa



fadfsfv
666 fsd 

奥运

😊 (●'◡'●)

o(* ̄▽ ̄*)ブ

csfdfsfrse
[root@instance-6m0ylrf0 lxDemo]# cat -v abc.txt 
123
                fefsfs

ad
aa



fadfsfv
666 fsd 

M-eM-%M-%M-hM-?M-^P

M-pM-^_M-^XM-^J (M-bM-^WM-^O'M-bM-^WM-!'M-bM-^WM-^O)

o(*M-oM-?M-#M-bM-^VM-=M-oM-?M-#*)M-cM-^CM-^V

csfdfsfrse
[root@instance-6m0ylrf0 lxDemo]# cat -A abc.txt 
123$
^I^Ifefsfs$
$
ad$
aa$
$
$
$
fadfsfv$
666 fsd $
$
M-eM-%M-%M-hM-?M-^P$
$
M-pM-^_M-^XM-^J (M-bM-^WM-^O'M-bM-^WM-!'M-bM-^WM-^O)$
$
o(*M-oM-?M-#M-bM-^VM-=M-oM-?M-#*)M-cM-^CM-^V$
$
csfdfsfrse$

(9)more和less命令查看文件

cat命令一般用于查看小文件,查看大文件需要用到more和less命令。

more命令用于查看文件内容,一页一页的显示文件内容。

基本语法如下:

more 要查看的文件

使用如下:

操作键含义
空格键(space)向下翻一页
Enter向下翻一行
q代表立刻离开 more ,不再显示该文件内容
Ctrl+F向下滚动一屏
Ctrl+B返回上一屏
=输出当前行的行号

如下:

more use

less 的作用与 more 十分相似,都可以用来浏览文字档案的内容,不同的是 less 允许使用[pageup]、[pagedown]往回滚动。

语法格式如下:

less 要查看的文件

操作说明:

操作键含义
空格键向下翻动一页
pagedown向下翻动一页
pageup向上翻动一页
/字符串向下搜寻字符串;
n向下查找,N向上查找
q退出 less 程序

使用如下:

less use

(10)head命令和tail命令查看文件

head命令用于查看文件内容,只看头几行,优点:对于大文件不必都加载,只显示头几行行即可。

参数如下:

head 文件名 :查看前10行
head -n 3 文件名 :查看文件的前3行
head -c 3 文件名 :查看文件的前3个字符

使用如下:

[root@localhost lxDemo]# head more.txt 
MORE(1)                                             User Commands                                             MORE(1)



NAME
       more - file perusal filter for crt viewing

SYNOPSIS
       more [options] file [...]

[root@localhost lxDemo]# head -n 3 more.txt 
MORE(1)                                             User Commands                                             MORE(1)


[root@localhost lxDemo]# head -c 3 more.txt 
MOR

tail命令用于查看文件内容,只看尾巴几行行,优点:可以查看⽂文件实时追加的内容。

参数如下:

(1)tail -n 10 文件 (功能描述:查看文件头(从末尾开始数)10行行内容,10可以是任意行行数)
(2)tail -f 文件 (功能描述:实时追踪该文档的所有更更新)

使用如下:

[root@localhost lxDemo]# tail more.txt 
       currently in use in the Linux community.  Documentation was produced using several other versions of  the  man
       page, and extensive inspection of the source code.

AVAILABILITY
       The  more  command  is  part  of  the  util-linux  package  and is available from Linux Kernel Archive ⟨ftp://
       ftp.kernel.org/pub/linux/utils/util-linux/⟩.



util-linux                                          September 2011                                            MORE(1)
[root@localhost lxDemo]# tail -n 5 more.txt 
       ftp.kernel.org/pub/linux/utils/util-linux/⟩.



util-linux                                          September 2011                                            MORE(1)
[root@localhost lxDemo]# tail -f more.txt 
       currently in use in the Linux community.  Documentation was produced using several other versions of  the  man
       page, and extensive inspection of the source code.

AVAILABILITY
       The  more  command  is  part  of  the  util-linux  package  and is available from Linux Kernel Archive ⟨ftp://
       ftp.kernel.org/pub/linux/utils/util-linux/⟩.



util-linux                                          September 2011                                            MORE(1)

^Z
[1]+  已停止               tail -f more.txt
[root@localhost lxDemo]# tail -5f more.txt 
       ftp.kernel.org/pub/linux/utils/util-linux/⟩.



util-linux                                          September 2011                                            MORE(1)
^Z
[2]+  已停止               tail -5f more.txt

tail -f 文件一般可以用于监控日志的改变。

(11)重定向输出符号

Linux中的命令组合后,可以实现神奇的功能:

  • append追加

  • replace 替换,覆盖

> 重定向输出

>> 又追加功能;示例:
cat /etc/passwd a.txt将输出定向到a.txt中

cat letc/passwd >> a.txt 输出并且追加

使用如下:

[root@localhost ~]# cd /usr/tmp/
[root@localhost tmp]# rm -rf *
[root@localhost tmp]# touch 1.txt 2.txt
[root@localhost tmp]# vim 1.txt
[root@localhost tmp]# cat 1.txt 
text 1
[root@localhost tmp]# vim 2.txt 
[root@localhost tmp]# cat 2.txt 
text 2
[root@localhost tmp]# ll -ht
总用量 8.0K
-rw-r--r--. 1 root root 7 8月  19 21:38 2.txt
-rw-r--r--. 1 root root 7 8月  19 21:38 1.txt
[root@localhost tmp]# touch 3.txt
[root@localhost tmp]# ll -ht
总用量 8.0K
-rw-r--r--. 1 root root 0 8月  19 21:39 3.txt
-rw-r--r--. 1 root root 7 8月  19 21:38 2.txt
-rw-r--r--. 1 root root 7 8月  19 21:38 1.txt
[root@localhost tmp]# cat 2.txt > 3.txt 
[root@localhost tmp]# cat 3.txt 
text 2
[root@localhost tmp]# cat 1.txt > 3.txt 
[root@localhost tmp]# cat 3.txt 
text 1
[root@localhost tmp]# cat 2.txt >> 3.txt 
[root@localhost tmp]# cat 3.txt 
text 1
text 2
[root@localhost tmp]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.31.155  netmask 255.255.255.0  broadcast 192.168.31.255
        inet6 fe80::25eb:a0e1:77f0:e5ba  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8a:e8:31  txqueuelen 1000  (Ethernet)
        RX packets 289660  bytes 60183298 (57.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 556992  bytes 500904383 (477.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 36  bytes 3132 (3.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36  bytes 3132 (3.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost tmp]# ifconfig >> 3.txt 
[root@localhost tmp]# tail 3.txt 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 36  bytes 3132 (3.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36  bytes 3132 (3.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


(12)管道符及逻辑控制&&

管道符号| 的作用是: 将一个命令的输出作为另一个命令的输入.

配合使用的命令:

ps(Process Status) 进程状态 ps -ef
grep(Global Regular Expression Print) 全局正则表达式版本(搜索)

管道是Linux命令中重要的一个概念, 其作用是将一个命令的输出用作另一个命令的输入。
示例
Is–help|more分页查询帮助信息
ps-ef|grep java查询名称中包含java的进程

使用如下:

[root@localhost tmp]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 15:46 ?        00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2      0  0 15:46 ?        00:00:00 [kthreadd]
root          3      2  0 15:46 ?        00:00:04 [ksoftirqd/0]
root          5      2  0 15:46 ?        00:00:00 [kworker/0:0H]
...
root     111652 111605  0 21:41 ?        00:00:00 /usr/libexec/openssh/sftp-server
root     111659 111605  0 21:41 ?        00:00:00 /usr/libexec/openssh/sftp-server
root     111767 111607  0 21:41 pts/3    00:00:01 top
root     119246      2  0 21:44 ?        00:00:00 [kworker/0:0]
root     126080      2  0 21:47 ?        00:00:00 [kworker/0:2]
[root@localhost tmp]# ps -ef | grep java
root       7827  93428  0 21:53 pts/0    00:00:00 grep --color=auto java
[root@localhost tmp]# ls --help | more
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                     不隐藏任何以. 开始的项目
  -A, --almost-all              列出除. 及.. 以外的任何项目
      --author                  与-l 同时使用时列出每个文件的作者
  -b, --escape                  以八进制溢出序列表示不可打印的字符
      --block-size=SIZE      scale sizes by SIZE before printing them; e.g.,
                               '--block-size=M' prints sizes in units of
                               1,048,576 bytes; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information);
                               with -l: show ctime and sort by name;
                               otherwise: sort by ctime, newest first
  -C                         list entries by columns
      --color[=WHEN]         colorize the output; WHEN can be 'never', 'auto',
                               or 'always' (the default); more info below
  -d, --directory            list directories themselves, not their contents
...
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         显示版本信息并退出

SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。


退出状态:
 0  正常
 1  一般问题 (例如:无法访问子文件夹)
 2  严重问题 (例如:无法使用命令行参数)

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告ls 的翻译错误
要获取完整文档,请运行:info coreutils 'ls invocation'
[root@localhost tmp]# ls --help | grep '递归'
  -R, --recursive               递归显示子目录

命令间的逻辑控制:
命令之间使用&&连接,实现类似逻辑与的功能:
只有在&&左边的命令运行成功时,&&右边的命令才会被执行;
只要左边命令运行失败,后面的命令就不会被执行。
例如:
cp 1.txt 2.txt && cat 2.txt

使用如下:

[root@localhost tmp]# cat 1.txt && touch 4.txt
text 1
[root@localhost tmp]# ll
总用量 12
-rw-r--r--. 1 root root   7 8月  19 21:38 1.txt
-rw-r--r--. 1 root root   7 8月  19 21:38 2.txt
-rw-r--r--. 1 root root 910 8月  19 21:44 3.txt
-rw-r--r--. 1 root root   0 8月  19 22:06 4.txt
[root@localhost tmp]# cat 100.txt && touch 5.txt
cat: 100.txt: 没有那个文件或目录
[root@localhost tmp]# ll
总用量 12
-rw-r--r--. 1 root root   7 8月  19 21:38 1.txt
-rw-r--r--. 1 root root   7 8月  19 21:38 2.txt
-rw-r--r--. 1 root root 910 8月  19 21:44 3.txt
-rw-r--r--. 1 root root   0 8月  19 22:06 4.txt

逻辑控制&&的应用场景:

用在需要把一些命令组合使用的场景下,例如启动服务并查看日志。

因为启动软件通常不会打印启动的日志信息,所以需要再打开对应的日志信息查看。

例如启动tomcat服务器./startup.sh和查看日志tail -100f catalina.out一般不能在一个窗口中同时执行,要是需要在启动服务的同时就查看日志,就可以用&&进行关联,即./startup.sh && tail -50f ../logs/catalina.out,就可以实现在启动tomcat后,再用tail命令查看日志,如果启动失败,则不查看。

(13)history查看历史命令

使用如下:

[root@localhost tmp]# history | tail
'
  209  ls --help | grep '递归'
  210  clear 
  211  cat 1.txt && touch 4.txt
  212  ll
  213  cat 100.txt && touch 5.txt
  214  ll
  215  history | wc -l
  216  clear 
  217  history | tail
[root@localhost tmp]# history > 4.txt 
[root@localhost tmp]# head 4.txt 
    1  ll
    2  ping www.baidu.com
    3  vi /etc/sysconfig/network-scripts/ifcfg-ens33 
    4  systemctl restart network
    5  ping www.baidu.com
    6  ip addr
    7  service status sshd
    8  systemctl status sshd
    9  ping 192.168.43.79
   10  cat /etc/sysconfig/network-scripts/ifcfg-ens33

2.打包和压缩

(1)打tar包和解tar包

打包是将一个文件(或目录)打包为一个文件,打包之后的文件需要以.tar结尾。

tar选项如下:

选项英文含义
ccreate创建打包文件
vverbosely(啰嗦地)报告打包的完整进度
ffile指定创建的文件名称,f后面一定是.tar文件, 所以必须放到最后

示意如下:

将一系列文件打包成 一个大文件

tar -cvf 打包名.tar 被打包的目录 用于打包一个目录

tar -cvf 打包名.tar 被打包的文件1 被打包的文件2 被打包的文件3 用于打包多个文件

使用如下:

[root@localhost lxDemo]$ ls
aaa  aaabbcc.txt  cba.txt  ls.txt  more.txt
[root@localhost lxDemo]$ tar -cvf test.tar more.txt 
more.txt
[root@localhost lxDemo]$ ll -ht
总用量 40K
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
-rw-r--r--. 1 root root  18K 8月  19 19:07 ls.txt
drwxr-xr-x. 3 root root   17 8月  19 18:29 aaa
-rw-r--r--. 1 root root    0 8月  19 18:27 cba.txt
-rw-r--r--. 1 root root    0 8月  19 18:27 aaabbcc.txt
[root@localhost lxDemo]$ tar -cvf abc.tar more.txt ls.txt cba.txt 
more.txt
ls.txt
cba.txt
[root@localhost lxDemo]$ ll -ht
总用量 72K
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
-rw-r--r--. 1 root root  18K 8月  19 19:07 ls.txt
drwxr-xr-x. 3 root root   17 8月  19 18:29 aaa
-rw-r--r--. 1 root root    0 8月  19 18:27 cba.txt
-rw-r--r--. 1 root root    0 8月  19 18:27 aaabbcc.txt

可以看到,打包后的文件更大。

解包是将打包后的文件进行逆向操作、分解成一系列小文件。

选项如下:

选项英文含义
xextract(提取)解包
C(大写)directory(目录)默认保存到当前目录,通过-C更改解压目录,需要保证目录存在

示意如下:

将一个打包后的 分解成 一系列小文件, 分解位置为 当前目录

tar -xvf 打包名.tar

将一个打包后的 分解成 一系列小文件, 分解位置为 指定目录

tar -xvf 打包名.tar -C 解包路径位置

使用如下:

[root@localhost lxDemo]$ rm -rf *.txt
[root@localhost lxDemo]$ ls
aaa  abc.tar  test.tar
[root@localhost lxDemo]$ tar -xvf test.tar 
more.txt
[root@localhost lxDemo]$ ls
aaa  abc.tar  more.txt  test.tar
[root@localhost lxDemo]$ tar -xvf abc.tar -C aaa/
more.txt
ls.txt
cba.txt
[root@localhost lxDemo]$ ls aaa/
bbb  cba.txt  ls.txt  more.txt

小结如下:

打包: tar -cvf 打包之后的文件名.tar 被打包的目录或文件名
解包: tar -xvf 打包之后的文件名.tar [ -C 指定解包位置 ]

(2)压缩与解压缩

打包 和 压缩 是不同的:
打包只是单纯地将多个文件生成一个文件存储;

压缩操作不但要生成一个文件,还要通过压缩工具对文件进行压缩,以减小文件占用存储空间大小。

在 Linux 中, 最常用的压缩文件格式是 xxx.tar.gz
在 tar 命令中有一个选项 -z 可以调用 gzip , 从而可以方便的实现压缩和解压缩的功能

其中,选项如下:

命令英文含义
zgzip使用gzip压缩和解压缩
jbzip2使用bzip2压缩和解压缩

命令格式如下:

压缩文件

tar -zcvf 打包压缩文件名.tar.gz 被压缩的文件/目录

解压缩文件

tar -zxvf 打包文件.tar.gz

解压缩到指定路径

tar -zxvf 打包文件.tar.gz -C 目录路径

使用如下:

[root@localhost lxDemo]$ ll -ht
总用量 52K
drwxr-xr-x. 3 root root   62 8月  19 23:57 aaa
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
[root@localhost lxDemo]$ tar -zcvf more.tar.gz more.txt 
more.txt
[root@localhost lxDemo]$ ll -ht
总用量 56K
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
drwxr-xr-x. 3 root root   62 8月  19 23:57 aaa
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
[root@localhost lxDemo]$ rm -f more.txt 
[root@localhost lxDemo]$ ll -ht
总用量 48K
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
drwxr-xr-x. 3 root root   62 8月  19 23:57 aaa
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
[root@localhost lxDemo]$ tar -xzvf more.tar.gz 
more.txt
[root@localhost lxDemo]$ ll -ht
总用量 56K
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
drwxr-xr-x. 3 root root   62 8月  19 23:57 aaa
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
[root@localhost lxDemo]$ tar -xzvf more.tar.gz -C aaa/
more.txt
[root@localhost lxDemo]$ ll -ht aaa/
总用量 28K
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
-rw-r--r--. 1 root root  18K 8月  19 19:07 ls.txt
drwxr-xr-x. 3 root root   17 8月  19 18:29 bbb
-rw-r--r--. 1 root root    0 8月  19 18:27 cba.txt

可以看到,经过压缩得到的压缩包比原文件更小。

bzip 是压缩的第二种方式
在 Linux 中, bzip2 压缩文件格式是 xxx.tar.bz2
在 tar 命令中有一个选项 -j 可以调用 bzip2 , 从而可以方便的实现压缩和解压缩的功能

命令格式如下:

压缩文件

tar -jcvf 打包压缩文件名.tar.bz2 被压缩的文件/目录

解压缩文件 (绩效潍坊)

tar -jxvf 打包文件.tar.bz2

解压缩到指定路径

tar -jxvf 打包文件.tar.bz2 -C 目录路径

注意事项: 如果报错tar (child): bzip2:无法 exec: 没有那个文件或目录,说明系统中还没有安装bzip2的包,执行yum install -y bzip2即可安装。

使用如下:

[root@localhost lxDemo]$ ll -ht
总用量 56K
drwxr-xr-x. 3 root root   62 8月  20 00:11 aaa
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
[root@localhost lxDemo]$ tar -cjvf more.tar.bz2 more.txt 
more.txt
[root@localhost lxDemo]$ ll -ht
总用量 60K
-rw-r--r--. 1 root root 2.3K 8月  20 00:23 more.tar.bz2
drwxr-xr-x. 3 root root   62 8月  20 00:11 aaa
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt
[root@localhost lxDemo]$ rm -f more.txt 
[root@localhost lxDemo]$ ll -ht
总用量 52K
-rw-r--r--. 1 root root 2.3K 8月  20 00:23 more.tar.bz2
drwxr-xr-x. 3 root root   62 8月  20 00:11 aaa
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
[root@localhost lxDemo]$ tar -xjvf more.tar.bz2 
more.txt
[root@localhost lxDemo]$ ll -ht
总用量 60K
-rw-r--r--. 1 root root 2.3K 8月  20 00:23 more.tar.bz2
drwxr-xr-x. 3 root root   62 8月  20 00:11 aaa
-rw-r--r--. 1 root root 2.2K 8月  20 00:08 more.tar.gz
-rw-r--r--. 1 root root  30K 8月  19 23:51 abc.tar
-rw-r--r--. 1 root root  10K 8月  19 23:49 test.tar
-rw-r--r--. 1 root root 5.3K 8月  19 19:07 more.txt

小结如下:

打包压缩: tar -jcvf 打包之后的文件名.tar.bz2 被打包压缩的目录或文件名
解包解压缩: tar -jxvf 打包之后的文件名.tar.bz2 [ -C 指定解包位置 ]

3.时间日期

date命令用于显示时间。

显示当前时间常用命令如下:

(1)date (功能描述:显示当前时间)
(2)date +%Y (功能描述:显示当前年年份)
(3)date +%m (功能描述:显示当前月份)
(4)date +%d (功能描述:显示当前是哪一天)
(5)date +%Y%m%d … (功能描述:显示当前年年月日各种格式 )
(6)date “+%Y-%m-%d %H:%M:%S” 或者单引号也可以 (功能描述:显示年年⽉月⽇日时分秒)

显示非当前时间常用命令如下:

(1)date -d ‘1 days ago’ (功能描述:显示前一天日期)
(2)date -d yesterday +"%Y-%m-%d"(同上)
(3)date -d next-day +"%Y-%m-%d" (功能描述:显示明天日期)
(4)date -d ‘next monday’ (功能描述:显示下周一时间)

date设置系统时间的基本语法如下:

date -s 字符串时间

使用如下:

[root@localhost lxDemo]$ date
2021年 08月 20日 星期五 00:26:19 CST
[root@localhost lxDemo]$ date +%Y
2021
[root@localhost lxDemo]$ date +%m
08
[root@localhost lxDemo]$ date +%d
20
[root@localhost lxDemo]$ date "+%Y-%m=%d %H:%M:%S"
2021-08=20 00:27:52
[root@localhost lxDemo]$ date "+%Y-%m-%d %H:%M:%S"
2021-08-20 00:27:59
[root@localhost lxDemo]$ date -d '1 days ago'
2021年 08月 19日 星期四 00:28:29 CST
[root@localhost lxDemo]$ date -d yesterday +%Y-%m-%d
2021-08-19
[root@localhost lxDemo]$ date -d next-day +%Y-%m-%d
2021-08-21
[root@localhost lxDemo]$ date -d 'next monday'
2021年 08月 23日 星期一 00:00:00 CST
[root@localhost lxDemo]$ date -s '2021-08-19 22:02:30'
2021年 08月 19日 星期四 22:02:30 CST
[root@localhost lxDemo]$ date
2021年 08月 19日 星期四 22:02:36 CST

上面显示的都是字符串描述的时间,不是当前时间。

cal命令用于查看日历。

基本语法如下:

cal [选项] (功能描述:不加选项,显示本月日历)

常见选项如下:

-3 ,显示系统前一个月,当前月,下一个月的日历
具体某一年年,显示这一年年的日历。

使用如下:

[root@localhost lxDemo]$ cal
      八月 2021     
日 一 二 三 四 五 六
 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

[root@localhost lxDemo]$ cal -3
      七月 2021             八月 2021             九月 2021     
日 一 二 三 四 五 六  日 一 二 三 四 五 六  日 一 二 三 四 五 六
             1  2  3   1  2  3  4  5  6  7            1  2  3  4
 4  5  6  7  8  9 10   8  9 10 11 12 13 14   5  6  7  8  9 10 11
11 12 13 14 15 16 17  15 16 17 18 19 20 21  12 13 14 15 16 17 18
18 19 20 21 22 23 24  22 23 24 25 26 27 28  19 20 21 22 23 24 25
25 26 27 28 29 30 31  29 30 31              26 27 28 29 30      
                                                                
[root@localhost lxDemo]$ cal 2021
                               2021                               

        一月                   二月                   三月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                1  2       1  2  3  4  5  6       1  2  3  4  5  6
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    7  8  9 10 11 12 13
10 11 12 13 14 15 16   14 15 16 17 18 19 20   14 15 16 17 18 19 20
17 18 19 20 21 22 23   21 22 23 24 25 26 27   21 22 23 24 25 26 27
24 25 26 27 28 29 30   28                     28 29 30 31
31
        四月                   五月                   六月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
             1  2  3                      1          1  2  3  4  5
 4  5  6  7  8  9 10    2  3  4  5  6  7  8    6  7  8  9 10 11 12
11 12 13 14 15 16 17    9 10 11 12 13 14 15   13 14 15 16 17 18 19
18 19 20 21 22 23 24   16 17 18 19 20 21 22   20 21 22 23 24 25 26
25 26 27 28 29 30      23 24 25 26 27 28 29   27 28 29 30
                       30 31
        七月                   八月                   九月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
             1  2  3    1  2  3  4  5  6  7             1  2  3  4
 4  5  6  7  8  9 10    8  9 10 11 12 13 14    5  6  7  8  9 10 11
11 12 13 14 15 16 17   15 16 17 18 19 20 21   12 13 14 15 16 17 18
18 19 20 21 22 23 24   22 23 24 25 26 27 28   19 20 21 22 23 24 25
25 26 27 28 29 30 31   29 30 31               26 27 28 29 30

        十月                  十一月                 十二月       
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                1  2       1  2  3  4  5  6             1  2  3  4
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    5  6  7  8  9 10 11
10 11 12 13 14 15 16   14 15 16 17 18 19 20   12 13 14 15 16 17 18
17 18 19 20 21 22 23   21 22 23 24 25 26 27   19 20 21 22 23 24 25
24 25 26 27 28 29 30   28 29 30               26 27 28 29 30 31
31


4.搜索查找

(1)find查找命令

find命令用来查找文件或者目录,是根据文件的属性进行查找,如文件名、文件大小、所有者、所属组、是否为空、访问时间、修改时间等。

语法格式如下:

 find path [options]

常见命令如下:

(1)按照文件名查找

(1)find /etc -name yum.conf #在/etc目录下文件yum.conf
(2)find /etc -name ‘yum’ #使用通配符*(0或者任意多个)。表示在/etc目录下查找文件名中含有
字符串‘yum’的文件

(3)find . -name ‘yum*’ #表示当前目录下查找文件名开头是字符串‘yum’的文件

使用如下:

[root@localhost lxDemo]$ find /etc/ -name yum.conf
/etc/yum.conf
[root@localhost lxDemo]$ find /etc/ -name 'yum'
/etc/yum
/etc/logrotate.d/yum
[root@localhost lxDemo]$ find /etc/ -name yum*
/etc/yum.repos.d
/etc/yum
/etc/logrotate.d/yum
/etc/yum.conf

(2)按照文件特征查找

(1)find / -atime -2 # 查找在系统中最后48小时访问的文件 (Access Time,文件读取访问时
间)
(2)find / -empty # 查找在系统中为空的文件或者文件夹
(3)find / -group corley # 查找在系统中属于group为corley的文件
(4)find / -mtime -1 #查找在系统中最后24小时里修改过的文件 (modify time)
(5)find / -user corley #查找在系统中属于corley这个用户的文件
(6)find / -size +10000c #查找出大于10000字节的文件(c:字节,w:双字,k:KB,M:MB,G:GB)
(7)find / -size -1000k #查找出小于1000KB的文件

使用如下:

[root@localhost lxDemo]$ find / -atime -2 | head
/
/boot
/boot/efi
/boot/efi/EFI
/boot/efi/EFI/centos
/boot/grub2
/boot/grub2/device.map
/boot/grub2/i386-pc
/boot/grub2/i386-pc/gcry_rmd160.mod
/boot/grub2/i386-pc/acpi.mod
[root@localhost lxDemo]$ find / -empty | tail
find: ‘/proc/79712/task/79712/fd/6’: 没有那个文件或目录
find: ‘/proc/79712/task/79712/fdinfo/6’: 没有那个文件或目录
find: ‘/proc/79712/fd/5’: 没有那个文件或目录
find: ‘/proc/79712/fdinfo/5’: 没有那个文件或目录
/usr/local/share/man/man9x
/usr/local/share/man/mann
/usr/local/src
/usr/src/debug
/usr/src/kernels
/home
/media
/mnt
/opt
/srv
[root@localhost lxDemo]$ find / -group corley
find: ‘corley’ 不是已存在用户组的名称
[root@localhost lxDemo]$ find / -mtime -1 | head
/
/boot
/boot/efi
/boot/efi/EFI
/boot/grub2
/boot/grub2/device.map
/boot/grub2/i386-pc
/boot/grub2/i386-pc/gcry_rmd160.mod
/boot/grub2/i386-pc/acpi.mod
/boot/grub2/i386-pc/gcry_rsa.mod
[root@localhost lxDemo]$ find / -size +10000c | tail
find: ‘/proc/80196/task/80196/fd/6’: 没有那个文件或目录
find: ‘/proc/80196/task/80196/fdinfo/6’: 没有那个文件或目录
find: ‘/proc/80196/fd/5’: 没有那个文件或目录
find: ‘/proc/80196/fdinfo/5’: 没有那个文件或目录
/usr/libexec/postfix/nqmgr
/usr/libexec/postfix/qmgr
/usr/libexec/microcode_ctl/check_caveats
/usr/libexec/man-db/globbing
/usr/libexec/man-db/manconv
/usr/libexec/sudo/group_file.so
/usr/libexec/sudo/libsudo_util.so.0.0.0
/usr/libexec/sudo/sesh
/usr/libexec/sudo/sudo_noexec.so
/usr/libexec/sudo/sudoers.so
[root@localhost lxDemo]$ find / -size -1000k | head
/
/boot
/boot/efi
/boot/efi/EFI
/boot/efi/EFI/centos
/boot/grub2
/boot/grub2/device.map
/boot/grub2/i386-pc
/boot/grub2/i386-pc/gcry_rmd160.mod
/boot/grub2/i386-pc/acpi.mod

(3)使用混合查找方式查找文件

参数有: !,-and(-),-or(-o)。

常见命令如下:

(1)find /tmp -size +10c -and -mtime +2 #在/tmp目录下查找大于10字节并在2天前修改的文
件
(2)find / -user root -or -user corley #在/目录下查找用户是root或者corley的文件文件
(3)find /tmp ! -user corley #在/tmp目录中查找所有不属于corley用户的文件

使用如下:

[root@localhost lxDemo]$ find /usr/ -size +10c -and -mtime +2 | head
/usr/bin/cp
/usr/bin/gzip
/usr/bin/alias
/usr/bin/csplit
/usr/bin/bash
/usr/bin/cut
/usr/bin/zcat
/usr/bin/fmt
/usr/bin/zcmp
/usr/bin/bashbug-64

(2)grep过滤查找

grep是根据文件的内容进行查找,会对文件的每一行按照给定的模式(patter)进行匹配查找。

语法格式如下:

grep [options] 范围

主要选项如下:

选项含义
-c只输出匹配行的计数
-i不区分大小写
-n显示匹配行及行号
-w显示整个单词
-r递归查询

如下:

1)在workspace.xml文件中查找project
2)查找project统计行号
3)统计value的个数
4)查找component并忽略大小写
5)查找java单词
6)递归查询/usr目录下 含有project字段的文件

使用如下:

[root@localhost lxDemo]$ grep project workspace.xml 
<project version="4">
    <property name="project.structure.last.edited" value="Modules" />
    <property name="project.structure.proportion" value="0.15" />
    <property name="project.structure.side.proportion" value="0.2" />
</project>
[root@localhost lxDemo]$ grep -n project workspace.xml 
2:<project version="4">
55:    <property name="project.structure.last.edited" value="Modules" />
56:    <property name="project.structure.proportion" value="0.15" />
57:    <property name="project.structure.side.proportion" value="0.2" />
214:</project>
[root@localhost lxDemo]$ grep -c workspace.xml 
^Z
[2]+  已停止               grep --color=auto -c workspace.xml
[root@localhost lxDemo]$ grep -c value workspace.xml 
64
[root@localhost lxDemo]$ grep -i component workspace.xml 
  <component name="AnalysisUIOptions">
  </component>
  <component name="AutoImportSettings">
  </component>
  <component name="ChangeListManager">
  </component>
  <component name="CompilerWorkspaceConfiguration">
  </component>
  <component name="FileTemplateManagerImpl">
  </component>
  <component name="GitSEFilterConfiguration">
  </component>
  <component name="ProjectId" id="1v7SYRLnEwwh6D3nuxbRekj7XeX" />
  <component name="ProjectViewState">
  </component>
  <component name="PropertiesComponent">
  </component>
  <component name="RecentsManager">
  </component>
  <component name="RunManager" selected="Application.JDBCPreparedStatementTest">
  </component>
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
  <component name="TaskManager">
  </component>
  <component name="TypeScriptGeneratedFilesManager">
  </component>
  <component name="XDebuggerManager">
  </component>
[root@localhost lxDemo]$ grep -i java workspace.xml 
    <property name="Repository.Attach.JavaDocs" value="false" />
    <property name="settings.editor.selected.configurable" value="preferences.sourceCode.Java" />
      <recent name="C:\Users\LENOVO\Desktop\Study\BigData_Lagou\Exercise\javase\resources" />
      <recent name="C:\Users\LENOVO\Desktop\Study\BigData_Lagou\Exercise\javase\src\com\stage1\module3" />
      <module name="javase" />
      <module name="javase" />
      <module name="javase" />
      <module name="javase" />
        <breakpoint enabled="true" type="java-exception">
          <properties class="java.lang.NullPointerException" package="java.lang" />
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/ShapeRectTest.java</url>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/ShapeRectTest.java</url>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/Shape.java</url>
[root@localhost lxDemo]$ grep -iw java workspace.xml 
    <property name="settings.editor.selected.configurable" value="preferences.sourceCode.Java" />
        <breakpoint enabled="true" type="java-exception">
          <properties class="java.lang.NullPointerException" package="java.lang" />
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/ShapeRectTest.java</url>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/ShapeRectTest.java</url>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/com/stage1/module2/Shape.java</url>
[root@localhost lxDemo]$ grep -r project /usr/ | head
匹配到二进制文件 /usr/bin/cp
匹配到二进制文件 /usr/bin/csplit
匹配到二进制文件 /usr/bin/cut
匹配到二进制文件 /usr/bin/fmt
匹配到二进制文件 /usr/bin/test
匹配到二进制文件 /usr/bin/timeout
匹配到二进制文件 /usr/bin/fold
匹配到二进制文件 /usr/bin/touch
匹配到二进制文件 /usr/bin/tr
匹配到二进制文件 /usr/bin/groups

5.vi编辑器

(1)vi编辑器的使用

vi编辑器在Linux中具有至关重要的地位。

在Linux下一般使用vi编辑器来编辑文件。
vi既可以查看文件也可以编辑文件。
而vim是vi的升级版本,具备更多的功能。
vi如果目标文件不存在,会创建新的文件。但是如果新文件没做编辑,退出后还会消失。

vi three mode

三种模式(状态):编辑、底行、命令模式
切换到编辑模式:按i、o、a键;
切换到底行模式:按:(冒号);
切换到命令行模式:按Esc键;
更多详细用法,可以查询文档。

三种模式之间的切换如下:

vi change mode

编辑模式(插入模式):对文本进行输入和修改
底行模式:退出vim或者查找、替换功能
命令模式(一般模式):通过快捷命令操作数据,打开vi默认就是命令模式

如果vim命令不能使用,需要执行yum -y install vim-enhanced安装。

命令模式按下:i、o、a进入编辑模式:
i:光标不动
o:另起一行
a:光标到下一个字符
按ESC退出编辑模式,进入命令模式

使用示意如下:
vi edit

命令模式下,按‘:’或者‘/’进入底行模式,可以输入命令
1)退出vim:(重点重点重点)
:q 未编辑时退出vim
:q! 编辑后,退出并且不保存
:wq 编辑后,退出且保存
:x 编译后保存

撤销上次操作(扩展—一般模式下):

u 撤销上一次操作(ctrl + z windows操作)
ctrl + r 恢复上一次被撤销的操作 (ctrl + y windows操作)

设置行号(了解) 底行模式
:set nu 显示行号
:set nonu 不显示行号

示意如下:

vim command

4)替换文本(了解)
😒/old/new/ 用new替换old,替换当前行的第一个匹配
😒/old/new/g 用new替换old,替换当前行的所有匹配
:%s/old/new/ 用new替换old,替换所有行的第一个匹配
:%s/old/new/g 用new替换old,替换整个文件的所有匹配
5)查找 (一般模式)
/文本 搜索指定文本,高亮显示,按n显示下一个,按N显示前一个
:整数 快捷跳转到指定行

示意如下:

vim replace search

(2)vi编辑器复制与剪切

vi编辑器复制与剪切的命令如下:

p(pause) 将之前dd或yy的数据粘贴到光标位置
yy 复制光标所在行
5yy 复制光标及下面共5行
dd 剪切当前行
5dd 剪切光标及下面共5行

示意如下:

vim cut paste

总结

Linux中是通过命令来进行相关操作的,与Windows等系统可以直接点选等方式不一样,因此要想使用好Linux系统,就必须熟悉操作的命令和常用参数。

2020年大数据学习路线指南(最全知识点总结)零基础入门大数据学习必备系统教程和学习目录 大数据是对海量数据进行存储、计算、统计、分析处理的一系列处理手段,处理的数据量通常是TB级,甚至是PB或EB级的数据,这是传统数据处理手段所无法完成的,其涉及的技术有分布式计算、高并发处理、高可用处理、集群、实时性计算等,汇集了当前IT领域热门流行的IT技术。 系统的学习知识点我 大数据入门,需要学习以下这些知识点: 先附上一张自己总结的学习线路图 1、Java编程技... 阅读详情

相关推荐

学习大数据要什么基础知识?学到什么程度才能从事大数据行业?

因为大数据前景好,薪资高,很多人想通过参加学习大数据,然后进入大数据行业发展。但是因为大数据的门槛较高,对于学习人员有一定的要求,那么学习大数据需要什么基础知识呢? 首先我们了解下对于大数据学习者本身的学历水平的要求 目前大多数的机构,对于大数据学习者要求必须是大专学历以上,而且大专学历还要求是计算机相关专业的,如果是本科及本科以上的,则对专业要求适当的放宽。同时大数据分为两大方向:大数据...

qq_41800874的博客 4360

大数据开发基础入门与项目实战(二)Java Web数据可视化之1.MySQL基础和SQL入门

本文主要介绍了MySQL基础和SQL入门:数据库的概念,包括数据库的基本概念和常见的数据库软件;MySQL的安装及配置,包括MySQL的安装、MySQL的卸载、MySQL配置环境变量、MySQL的启动和关闭、命令行登录MySQL、SQLYog的介绍和安装、MySQL的目录结构、数据库管理系统和数据库表;SQL,包括SQL的概念、SQL通用语法、SQL的分类、DDL操作数据库之创建和查询、MySQL自带数据库的介绍、DDL操作数据库之修改和删除、MySQL常见数据类型、DDL操作数据表和DML增删改等。

CUFEECR的博客 1454

刚毕业应聘大数据开发工程师,有机会吗?

本科应届生想去应聘大数据开发工程师的岗位有没有机会? 我平时用的语言是Java和Python,看过《机器学习实战》(python)和《Hadoop权威指南》,确实很多地方一知半解,也没有实践过。 关于数据的经验的话,之前没用Hadoop,只用Python做过一个有关PM2.5的预测监测平台,我想问下各位大佬,作为18届应届生,我投大数据开发工程师有没有机会?(我看到很多跟数据相关的岗都硬性要求...

大数据开发 2754

python中如何将一个文件的内容分开写到另外两个文件中

目的如题,原先的数据格式如下:每一行代表一个数据,第一类为标签,后面的列表为数据,因为这是原始数据,我现在想要把标签和数据分别存到不同的文件中去。 代码如下: data_path = './train1.txt' with open(data_path,'r',encoding='utf-8') as file1,\ open('train_label.txt','w',encoding='utf-8') as file2,\ open('train_data.txt','w',encod

weixin_44305115的博客 2463

Java Web从入门到实战

Java Web从入门到实战,十万+字符,一文带你从零到实战,内含Linux、Tomcat、Servlet、JSP、Mysql、JDBC、Mybatis、js、jQuery等超多内容

HelloCode 3万+

Java web数据可视化实现原理解析

主要介绍了Java web数据可视化实现原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

基于java web和echarts的数据可视化项目

EchartDemo 项目介绍 基于java web和echarts的数据可视化项目 主要分析浙江省各市区的gdp和固定资产投资、以及房产数据,数据源浙江省经济社会发展统计,数据经过整理后插入数据库中。 主页面: 固定资产页面: 将excel中的数据导入mysql数据库 所需jar包百度云 数据库的连接配置在dbcpconfig.properties文件中,注意更换自己的用户名、密码等信息...

你说_的博客 1万+

STK与Matlab连接报错?手把手教你解决mexConnect函数执行问题(附完整避坑指南)

本文针对STK与Matlab连接时常见的“mexConnect函数执行”报错,提供了完整的诊断与解决方案。文章深入剖析了错误根源在于路径冲突或文件损坏,并手把手指导用户通过定位STK连接器文件、正确配置Matlab路径(包括使用addpath命令)以及执行初始化测试三步走策略,彻底解决问题。同时附上版本兼容性检查、安装避坑指南及构建稳健工作流的建议,帮助用户建立可靠的STK-Matlab联合仿真环境。

yolo5detector的博客 472

ssm毕设项目动态个人网站8j9pz(java+VUE+Mybatis+Maven+Mysql+sprnig)

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。ssm毕设项目动态个人网站8j9pz(java+VUE+Mybatis+Maven+Mysql+sprnig)ssm + mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;...

计算机程序设计 4274

Windows下Nginx发布DEM地形瓦片数据全流程(含Cesium调用避坑指南)

本文详细介绍了在Windows环境下使用Nginx发布DEM地形瓦片数据的完整流程,并提供了Cesium前端调用的详细配置与避坑指南。重点讲解了Nginx的核心配置、跨域问题解决以及CesiumTerrainProvider的关键参数设置,帮助开发者快速搭建本地地形服务,实现高效的三维地形可视化。

weixin_29212867的博客 433

生信人填坑记 orthofinder的安装和基础使用

其中常用的有两个结果,第一个是Orthogroups文件夹下的Orthogroups.GeneCount.tsv,这个文件里保存着每个家族在每个物种里的成员数量。(写到这儿饭点到了,吃饭要紧…在国内使用conda的同学我相信很多人都会遇到-|- -|- -|- -|- -|- -|- -|- -|- 一直转圈。软件的是由很简单,将你要跑的物种的蛋白质文件放在work/data目录下,文件名都用物种缩写,后缀统一就行。当然,很多软件都会自带一个这样的文件,conda装不了的时候可以去软件官网溜达溜达。

qq_43337286的博客 5381

大数据项目实战——基于某招聘网站进行数据采集及数据分析(一)

大数据项目实战 第一章 项目概述 文章目录大数据项目实战第一章 项目概述学习目标一、项目需求和目标二、预备知识三、项目架构设计及技术选取总结 学习目标 掌握项目需求和目标 了解项目架构设计和技术选型 了解项目环境和相关开发工具 理解项目开发流程 在人力资源管理领域,网络招聘近年来早已凭借其范围广、信息量大、时效性强、流程简单而效果显著等优势,成为企业招聘的核心方式。随着大数据渐渐融入人类社会生活的各个领域,如何使用大数据优化企业招聘管理,提升企业招聘有效性,是值得深入探讨的现实课题。文章通过一个招聘网站

weixin_52465547的博客 2万+

从零开始用QP框架开发STM32:事件驱动编程实战指南(附状态机设计技巧)

本文详细介绍了如何使用QP框架在STM32上实现事件驱动编程,包括状态机设计技巧和嵌入式开发实践。通过对比传统前后台系统和RTOS,展示了QP框架在资源占用、实时性和代码可维护性方面的优势,并提供了从环境搭建到高级状态机设计的完整指南。

h6i7j8的博客 1173

史上最新最全面的java大数据学习路线(新手小白必看版本)

第一阶段:大数据基础Java语言基础阶段 1.1:Java开发介绍 1.1.1 Java的发展历史 1.1.2 Java的应用领域 1.1.3 Java语言的特性 1.1.4 Java面向对象 1.1.5 Java性能分类 1.1.6 搭建Java环境 1.1.7 Java工作原理   1.2:熟悉Eclipse开发工具 1.2.1 Eclipse简介与下载 1.2.2 安...

程序员日常 1万+

汽车电缆选型实战:基于ISO 19642-3~12的7类电缆电压/材料/场景对照表

本文详细解析了基于ISO 19642-3~12标准的7类汽车电缆选型实战,涵盖电压等级、导体材料和场景应用的对照表。通过全参数速查表和典型选型陷阱分析,帮助工程师快速掌握从低压信号线到高压动力电缆的选型逻辑,提升新能源汽车与智能驾驶技术的安全性和可靠性。

weixin_29043895的博客 364

AXI总线详解完结篇

经过几个月的整理和发文,AXI总线详解系列正式迎来最终篇,内容基本涵盖了上一篇文章的全部内容。 所有文章的链接如下: 1、 AXI总线详解 2、AXI总线详解-总线和接口以及协议 3、AXI协议中的通道结构 4、AXI总线详解-AXI4读写操作时序及AXI4猝发地址及选择 5、AXI4交换机制 6、ZYNQ中DMA与AXI4总线-DMA简介 7、AXI总线详解-不同类型的DMA 8、AXI总线详解-DMA内部寄存器的读写方式 9、AXI总线详解-几种应用DMA的场合 10、Altera Scatter-G.

OpenFPGA的博客 5483

【Linux】部署web项目

Linux服务器部署web项目的步骤和方法

爱干饭的猿的博客 8365

MOSFET关断尖峰电压的机理与抑制

MOSFET在电力电子系统中存在开关尖峰电压/电流问题,主要源于寄生电感、密勒电容及开关瞬态特性。尖峰会引发过压击穿、功率损耗和EMI干扰。抑制措施包括优化驱动电路、添加缓冲网络(RC/RCD)、降低寄生电感(改进PCB布线/封装)、使用快速二极管及远端负载特殊处理(电抗器/滤波器)。系统性的器件选型与电路设计是确保功率电子稳定运行的关键。

硬核科技 1824

【SpringBoot零基础入门到项目实战②】安装Java和Maven,创建你的第一个项目

通过本文的学习,你已经完成了Spring Boot的安装和第一个项目的创建。这只是Spring Boot世界的一小步,而你的学习之旅刚刚开始。不断地探索、实践,你将逐渐成为一个熟练的Spring Boot开发者。祝你学有所成,编写出优雅、高效的Java应用!😊🙏Java面试技巧Java面试八股文 - 掌握面试必备知识(目录篇)Java学习路线2023年完整版Java学习路线图AIGC人工智能Chat GPT是什么,初学者怎么使用Chat GPT,需要注意些什么Java实战项目。

学IT,找陈寒 1万+

目前固态激光雷达在机器人领域的应用难点汇总

固态激光雷达在机器人领域面临性能与成本的双重挑战:探测性能上,动态范围不足(60-80dB)导致高/低反射物体识别困难,近距盲区(30-50cm)与长距精度(±3cm)矛盾突出;结构上视场角与点云密度难以平衡,多雷达拼接又带来同步误差。成本方面,核心元件(SPAD/OPA芯片)良率低(<50%)、校准工序复杂,单机成本超200美元。环境适应性上,粉尘附着、振动偏移(±2°)和光衰(1万小时衰减15%)制约可靠性。

start_up_go的博客 480

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

大数据开发基础入门与项目实战(二)Java Web数据可视化之3.Linux概述、安装和结构

本文主要介绍了Linux概述、安装和结构:Linux概述,包括Linux简介和Linux的应用领域及版本介绍;安装Linux,包括VMWare的安装、使用VMWare构建虚拟机器、安装CentOS操作系统、配置静态IP、给虚拟机设置快照和客户端连接工具的介绍和使用;Linux结构,包括Linux组成和Linux目录结构。Linux is not Unix,Linux是一套免费使用和自由传播的类Unix操作系统,有很多发行版,包括Ubuntu、RedHat和CentOS,有着开源的特点和强大完善的功能。

CUFEECR的博客 631

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

大数据工程师和Java后台开发的技术要求区别

每家公司对大数据工作和java开发的要求不尽相同,目前长期从事数据库管理、挖掘、编程工作的人,包括传统的量化分析师、hadoop方面的工程师,以及任何在工作中需要通过数据来进行判断决策的管理者,比如某些领域的运营经理等,都可以尝试大数据工程师职位。 一、大数据工程师和后台开发的技能差别有多大? 本人非计算机专业出身,java没系统学过,喜欢写代码,要找工作了。 现在很迷茫,不知道应该往哪...

bobo79888的博客 3639

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Linux基础命令和项目部署

Linux的基本认识、基础命令、java web的部署操作

weixin_64015613的博客 464

Java 开发者必备:Linux 常用命令与 Web 项目部署指南

本文介绍了Linux系统常用的基础命令和Java环境部署方法。主要内容包括:1)文件目录操作命令如ls、cd、mkdir等;2)文本处理命令cat、grep、vim等;3)进程和网络管理命令ps、netstat;4)文件传输工具scp的使用;5)通过apt工具安装JDK等软件包。文章详细说明了各命令的语法、功能及常用选项,并配有示例,是Linux入门和Java环境搭建的实用指南。

双吉堡工程专业的一名27届Javaer。 672

搭建java部署环境以及部署Web项目到Linux

一、搭建java部署环境 1.yum 2.JDK 3.Maven 4.Tomcat 5.MySQL 二、部署Web项目到Linux 1.数据库建表 2.构建项目并打包,将打好的包拷贝到Tomcat中 3.访问项目链接

crazy_xieyi的博客 2054
上一篇: 大数据开发基础入门与项目实战(二)Java Web数据可视化之3.Linux概述、安装和结构
下一篇: 大数据开发基础入门与项目实战(三)Hadoop核心及生态圈技术栈之3.数据仓库工具Hive基础
东哥说AI
博客等级 码龄7年 5934粉丝 385原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东哥说AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值