0 added
0 removed
Original
2026-01-01
Modified
2026-02-21
1
<h3>Important notes</h3>
1
<h3>Important notes</h3>
2
<p>Note that the correct way of creating new variables is without any spaces: VAR=42, not VAR = 42 or VAR =42 or VAR= 42.</p>
2
<p>Note that the correct way of creating new variables is without any spaces: VAR=42, not VAR = 42 or VAR =42 or VAR= 42.</p>
3
<h5>Permissions and execution</h5>
3
<h5>Permissions and execution</h5>
4
<p>If you try to create your own bash-script file and run it, Bash will complain about permissions. The reason is, your new text file is not set to be an executable program.<a>Learn more about permissions from Wikibooks</a>or just google "unix permissions".</p>
4
<p>If you try to create your own bash-script file and run it, Bash will complain about permissions. The reason is, your new text file is not set to be an executable program.<a>Learn more about permissions from Wikibooks</a>or just google "unix permissions".</p>
5
<p>To quickly fix your issue, do chmod +x your_bash_script_file. This will add executable to your file's permissions, and you'll be able to run it.</p>
5
<p>To quickly fix your issue, do chmod +x your_bash_script_file. This will add executable to your file's permissions, and you'll be able to run it.</p>
6
<h5>Program in the working directory</h5>
6
<h5>Program in the working directory</h5>
7
<p>./program just means "run program that is located in the working directory". . stands for the working directory, and / is just a part of the path, same as in /home/something.</p>
7
<p>./program just means "run program that is located in the working directory". . stands for the working directory, and / is just a part of the path, same as in /home/something.</p>
8
<p>If your program's location is in PATH variable already, then you don't need to add ./ even if you're in the same directory with the program, because Bash already knows where to look for your program.</p>
8
<p>If your program's location is in PATH variable already, then you don't need to add ./ even if you're in the same directory with the program, because Bash already knows where to look for your program.</p>
9
<h3>Lesson notes</h3>
9
<h3>Lesson notes</h3>
10
<ul><li>env to view environment variables</li>
10
<ul><li>env to view environment variables</li>
11
<li>VAR=value to set a new environment variable named VAR with value value (e.g. BUILDING_NAME=Tory)</li>
11
<li>VAR=value to set a new environment variable named VAR with value value (e.g. BUILDING_NAME=Tory)</li>
12
<li>echo $VAR to print out the value of VAR</li>
12
<li>echo $VAR to print out the value of VAR</li>
13
<li>VAR=value ./myscript to run myscript bash script file so that it knows the VAR variable</li>
13
<li>VAR=value ./myscript to run myscript bash script file so that it knows the VAR variable</li>
14
<li>export VAR=value to export a variable to all sessions (it will appear in the env list)</li>
14
<li>export VAR=value to export a variable to all sessions (it will appear in the env list)</li>
15
<li>PATH=/home/joe/apps:$PATH to add /home/joe/apps to the PATH variable. Bash will look inside /home/joe/apps when searching for commands and programss from now on.</li>
15
<li>PATH=/home/joe/apps:$PATH to add /home/joe/apps to the PATH variable. Bash will look inside /home/joe/apps when searching for commands and programss from now on.</li>
16
</ul>
16
</ul>