shell 之hello world

Dear 丶 2021-06-24 16:09 438阅读 0赞

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

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

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

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

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

  1. [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编辑文件

输入以下内容

  1. #!/bin/sh echo "hello,world!"

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

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

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

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

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

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

发表评论

表情:
评论列表 (有 0 条评论,438人围观)

还没有评论,来说两句吧...

相关阅读

    相关 RxJava Hello World

    原理介绍 什么是RxJava RxJava 就是异步 RxJava 的异步实现,是通过一种扩展的观察者模式来实现的。 一个响应式编程框架 观察者

    相关 Hello World

    Hello World 一、简述          简单的Hello World程序。(时间久了就会忘,趁着还有印象先记下)     1、C语言:  控制台程序、有窗体

    相关 shell hello world

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