作业1:file.sh
===========================
#!/bin/bash
if [ $# -ne 1 ] ; then echo "参数个数必须为一个" ; exit ; fi
cd $1
for x in `ls` ; do
if [ -f $x ] ; then echo $x >> ~/1.txt ; else echo $x >> ~/2.txt ; fi
done
作业2:case2.sh
============================
#!/bin/bash
if [ $# -ne 1 ] ; then echo "参数个数必须为一个" ; exit ; fi
case $1 in
[0-9] ) echo "是数字" ;;
[a-zA-Z] ) echo "是字母" ;;
* ) echo "其他" ;;
esac
作业3:file2.sh (递归)
==========================
#!/bin/bash
if [ $# -ne 2 ] ; then echo "参数个数必须为2个" ; exit ; fi
cd $1
for x in `ls` ; do
# 判断目录中的文件中是否包含第二个参数
if [ -f $x ] ; then
# 是否包含关键字
if [ `grep -i $2 $x` ] ; then
echo $x >> ~/1.txt
fi
fi
done
压缩:
gzip
归档
tar
tar -xzvf jdk.tar.gz -C /soft
符号链接
硬链接
ln filename linkname
软链接(符号链接)
ln -s filename linkname
变量:
name=tom
echo $PATH
echo ${PATH}
echo "$PATH"
命令提示符格式
echo $PS1
永久修改命令提示符格式
sudo nano /etc/profile ==> export PS1="[\[email protected]\h \w]\$ "
生效环境变量
source /etc/profile
\u //用户名
\h //主机名
\w //全路径
\W //当前目录
\t //时间
\d //日期
`pwd` //自定义命令
Linux高级命令
| //管道符
//分割多个命令,前一个命令的输出作为后一个命令的输入
ls --help | more
xargs: 多行转单行
ll | xargs
//将当前目录下含有helloworld字符内容的文件拷贝到~/t下
grep -rl helloworld . | cp `xargs` ~/t
Linux网络命令
ip addr //查看当前ip
ifconfig //查看当前ip
ifdown //禁用指定网卡设备
//sudo ifdown ens33
ifup //启用指定网卡设备
//sudo ifup ens33
service network restart | start | stop |xxx
//重启网卡
netstat //查看网络进程
Linux系统命令
service network restart | start | stop |xxx
//重启网卡
service [servicename] restart | start | stop |xxx
//服务的重新启动 | 启动 | 关闭
systemctl start | stop | enable | disable | restart | status [servicename]
mysqld //d = daemon
//守护进程
//
ps //process
//ps -Af
//ps -ef
//查看nano进程
//ps -ef | grep nano
//如何通过ps命令查看ssh的进程id
//ps -ef | grep ssh
磁盘命令:
df -h
内存命令
free -h
Linux进程命令
=================================
1、将进程放在后台运行
nano 1.txt &
ctrl + z
2、查看后台进程
jobs
3、将后台进程放在前台
fg %1
4、杀死进程
kill %1
kill PID
netcat:
=================================
模拟tcp udp连接的软件
1、消息传输
2、文件传输
windows端netcat
nc -h //查看帮助
通过服务端开启连接(端口)
nc -l -p 4444
客户端通过端口连接到服务端
nc localhost 4444
centos端netcat
安装netcat
sudo yum install nc
通过服务端开启连接(端口)
nc -l -p 4444
客户端通过端口连接到服务端
nc localhost 4444
windows端和Linux端进行消息传输
windows作为服务端:ok
Linux作为服务端:
关闭Linux防火墙
systemctl stop firewalld
禁止防火墙开机自启
systemctl disable firewalld
查看防火墙状态
systemctl staus firewalld
继续即可
文件传输
Linux -> Windows
windows作为服务端:接收数据
nc -l -p 4444 > 1.txt
Linux作为客户端:传输数据
nc 192.168.15.57 4444 < 1.txt
Windows -> Linux
Linux作为服务端:接收数据
nc -l -p 4444 > 1.txt
Windows作为客户端:传输数据
nc 192.168.79.100 4444 -w 1 < 1.txt
-w //无连接后一秒关流
Linux:
基本命令
//--help
//help xxx
//man xxx
文件和文件夹增删改查
目录和权限
//- 普通文件
//d 文件夹
//l 符号链接
// /home
// /usr => Unix/User System Resources 系统或用户的资源文件
// /root root用户家目录
// /etc 配置文件所在目录
权限
//user + group + other
//rwx
//421
//chmod ugo+rwx
//chmod 777
//chmod -R
用户和用户组
//chown centos:centos xxx
//chgrp centos xxx
//chown -R
yum //
NAT //Vmnet8虚拟网卡管理。相当于交换机
//宿主机与客户机之间网络互通
//客户机与客户机之间网络可以互通
//没有互联网也可以互通
桥接 //使用物理网卡管理
//和宿主机使用同一块物理网卡
//如果缺少交换机/路由器无法互通
仅主机
//NAT - 互联网
jdk
tar
gzip
ln
环境变量
大数据讲解:
========================
转载于:https://www.cnblogs.com/luochunbigdata/p/11542410.html