shell 之hello world

以前接触linux的比较少,比较常用的几个命令能够使用,接下来的项目中需要使用Linux,所以最近希望能够增强一点Linux的知识,那么就从hello world开始吧

第一步:了解Linux文件的权限

[root@ibm mwq]# ls -l
总用量 8
drwxr-xr-x. 2 root root 4096  6月 25 17:35 hello
-rwxr--r--. 1 root root   33  6月 25 17:56 hello.awk
-rw-r--r--. 1 root root    0  6月 25 17:35 hello.txt

 以上中对于hello目录,其第一位为d,对于文件,其第一位为-(短横线),短横线表示缺少权限,r为读,w为写,x表示可以进入目录或者可以执行文件。

第二步:了解chmod(change mode)命令,可以改变文件的权限,现在了解一下命令的含义

[root@ibm mwq]# chmod u+x hello.awk 

 使用man chmod可以看到以下信息

写道
The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for directories) (x), execute/search only if the file is a directory
or already has execute permission for some user (X), set user or group ID on execution (s), restricted deletion flag or sticky bit (t). Instead of one or more of these let-
ters, you can specify exactly one of the letters ugo: the permissions granted to the user who owns the file (u), the permissions granted to other users who are members of the
file’s group (g), and the permissions granted to users that are in neither of the two preceding categories (o).

 该命令可以使文件可执行

第三步:通过vim hello.awk编辑文件

输入以下内容

#!/bin/sh

 echo "hello,world!"

 “#!”称为幻数,“#!/bin/sh”表示通过bin/sh进行文件内容的解释

那么echo则表示,通过回显,在命令行中输出hello,world!

第四步:通过:q退出文件编辑模式后,使用sh hello.awk执行文件

[root@ibm mwq]# sh hello.awk 
hello,world!

 好了,以上简单学习的步骤就结束了。

以后有空闲时间一步步学习。。。。。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值