SoFunction
Updated on 2025-03-10

Issues to write .sh scripts and grant permissions for Linux

When I packaged and compiled the project today, I found that a script for git pull to update the project was missing, so I wrote a script on Linux to achieve the requirements of updating the project.

1. First, vi  or use vim editor.

2. Content

#!/bin/sh (first line)cur_dir=$(pwd) 
cd $cur_dir/mobcb-platform
git checkout -B demo -t origin/demo
git pull

3. Save and exit

4. chmod  +x        Grant executable permissions

5. ./Execute script

Supplement: Let's take a look at the following Linux adding execution permissions to the sh script file

chmod is the abbreviation of the permissions mode of a file. .

u represents the owner, x represents the execution permission. + means to increase permissions.

chmod u+x means adding executable permissions to the owner of the file in the current directory.

Summarize

The above is the issue of writing .sh scripts and granting permissions from Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!