Linux入门笔记五
Shell脚本及其成分
Shell是一个功能强大的编程语言。用Shell编写的批处理文件称为Shell脚本、
Shell脚本的成分
-注释部分
以#开头的行
-命令
在Shell脚本中可以出现任何在交互方式下可以使用的命令
-变量
既可以使用用户自定义的变量,也可以使用系统环境变量
-流程控制
对命令的执行流程进行控制(顺序、分支、循环)
练习
more /etc/httpd/
vi hello
ls
date
whoami
pwd
date;whoami;pwd
在hello里写上
#/bin/bash
#this script is display current user,time and path
#it is display current time
echo "current time is"
date
#it is display current user
echo "current user is"
whoami
#it is display current path
echo "current path is"
pwd
执行bash hello
练习
ls -l
-rwxr-xr-- Root IT abctxt
Root 作为所有者 看前三项 rwx
执行chmod u+x hello
ls -l hello
IT 作为所有组 看中间三项 r-x
其他所有组 看后三项 r--
常见的环境变量
HOME 用户主目录
PATH 命令搜索路径
PS1 命令提示符号
PWD 用户当前工作路径
SHELL 用户shell类型
TERM 终端类型
LANG 语言环境
x=abc
echo x
echo $x
x=asdfsaf
echo $x
echo $SHELL
echo $PATH
修改环境变量
PATH=$PATH:/root
echo $hello
相关文档:
1, 下载 VMWare Player
http://www.vmware.com/products/player/
简
单注册一下,就可以下载了。
2, 生成 VMWare 的种子文件
http://www.easyvmx.com/new-easyvmx.shtml
3,
下载 你想要的Linux 的 ISO 文件。
4, 解压缩 2 中的 VMWare种子文件, 双击其中的
扩展名为vmx的文件。 然后在VMWarePlayer 中 设置 ......
#include <fcntl.h>
int main(void)
{
typedef union un{
short s;
char c[sizeof(short)];
}un;
un myun;
myun.s = 0x0102;
......
serv_addr.sin_family=AF_INET;
serv_addr.sin_port=htons(SERVPORT);
inet_pton(AF_INET,"127.0.0.1",&serv_addr.sin_addr);
IP地址转换函数有:inet_pton,inet_addr,inet_aton,inet_ntoa,inet_ntop
前三个是将ASCII字符转换成网络字节序;
最后两个是将网络字节序转换成ASCII字符。
现在推荐使用ine ......
uname -a 查看内核版本
ls -al 显示所有文件的属性
pwd   ......