Sei sulla pagina 1di 2

Script

Sequence/list of system commands stored in a single file.

ls/dir -- list directory (what is the differene between ls and dir command)

pwd -- prints name of directory

date -- shows us a date and time

****Create a file which has DOS commands in it***

vi first_script.sh (also can use .bash extension)

use c for insert and start typing

#!/bin/bash
ls
pwd
date ( type each command in seperate line)

(save and exit Vi editor by pressing ESC and typing :wq which means write changes
to file and quit)

**** Change script file permission

first check what permissions are set

clear ( clear the screen)

ls -l ( -l is the argument to ls command , it shows us about the extended


information about files and directories such as permissions and ownership)

ls -l first_script.sh ( we will now see only information about our script)

it will be like that:

-rw-r--r--1 root root 25 Sep 3 05:49 first_script.sh

here ,
-rw-r--r-- = permission part

In Unix type systems permissions are divided into three categories:


1. first category( here it is rw) = permission of ownership
2. second (r) = group file ownership
3. third category(r)= others

root root = ownership part

Characters in permission
r = read permission
w= write permission
x = execute permission

***Change Permissions***
1. Adding Execute permission to all(a) users

chmod a+x first_script.sh

a= all three categories change permission


x = grant execute permission

2. Removing Execute permission from all users

chmod a-x first_script.sh

=========
Source

Udemy - Linux Bash Shell Scripting Complete Guide (incl. AWK SED)

Potrebbero piacerti anche