Linux shell

shell既是命令也是编程语言,是用户与linux内核交互的平台。

熟悉bash命令

bash只是shell的一种类型,还有很多其他的shell类型

常见命令

ls  -a  全部  -l 长格式输出   -h  人类可读的方式显示   --sort=time 排序  可加路径

cd  切换目录   绝对路径  相对路径  ~ 根目录   .当前目录  ..上级目录

dmesg  查看系统设备消息

pwd  输出当前工作目录  print working directory

cat   查看文件内容

more  /字符串  搜索字符串  n 下一个搜索到的字符串  shift+n 上一个搜索到的字符串  空格(space)下一页

回车(enter)下一行    q(quit) 退出

tail  tali -n 20 查看文档最后20行

watch -n 5 | tail -n 20 /proc/meminfo  每个五秒  输出/proc/meminfo的信息

cp   赋值 -r (recursive迭代)  

rm  -i (interactive)交互   -f(force) 强制   -r(recursive) 迭代

mv  remove or  raname

top  系统运行信息查看   

   kill  pid  结束进程   

   q  退出top

ps 

ps -ef   e=a  

ps -aux  a=e  

基本一致  略有不同

grep  筛选文件信息   grep ss /etc/passwd  |  wc -l  筛选/etc/passwd中的 ss 行 ,输出行数

ifconfig 查看网卡信息  ifconfig eth0 down  ifconfig eth0 up

netstat 查看网络连接

   netstat -pantu (tcp udp)  查看计算机与网络中所有的 tcp和udp连接

netstat -pantu | egrep -v '0:0:0:0|::' | awk '{print $5}' | egrep -v 'and|Address' | cut -d ' ' -f 1 | uniq | sort > ip.txt

find  查找命令   find  / name nmap  从更目录下查找nmap文件

                         find . -name ps*  搜索当前目录ps*

whereis    查找之前  updatedb(更新whereis数据库)   whereis nmap(查找nmap文件)   whereis -b nmap(查找nmap二进制文件)


echo  "字符串"  在终端中输出字符串的内容。


&&  ||  

A&&B  A执行成功才能执行B

A||B     A执行不成功才执行B


Linux vi+shell

#! /bin/bash

echo -n "IP:  "

read ip

echo ${ip}

shell编程 查看路径 http://www.runoob.com/linux/linux-tutorial.html

你可能感兴趣的:(Linux shell)