...
Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Bash
Info |
---|
A Bash is command-line shell and scripting language that allows users to interact with Unix-based operating systems. |
Code Block |
---|
[]$ bash --version GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. |
...
Environment Variables
Code Block |
---|
Info |
An environment variable is a user/system defined value that can read by users/scripts/applications, and be used to affect/influence how something can/should behave. |
Info |
---|
Lets list everything that the session is currently aware of - there’s a lot! This demonstrates that there is a lot of things being defined and configured, behind the scenes, to make your session run as required. |
Code Block |
---|
[]$ env |
Info |
---|
You can view individual environment variables: |
Code Block |
---|
[]$ echo $PATH
# Something of the form:
/home/<username>/.local/bin:/home/<username>/bin:/apps/s/arcc/1.0/bin:/apps/s/slurm/latest/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin |
...
Info |
---|
Let’s check what’s on the system: |
Code Blockinfo |
---|
# GCC stands for a free and open-source collection of compilers #and development tools that support many programming languages, hardware architectures, and operating systems. |
Code Block |
---|
[]$ which gcc
/usr/bin/gcc
[]$ gcc --version
gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)
# Let's look at Python:
|
Info |
---|
Let’s look at Python: |
Code Block |
---|
[]$ which python /usr/bin/python []$ python --version Python 3.9.18 |
...
Let's run a Python script:
Info |
---|
Within your home, create an |
Code Block |
---|
# Create a folder in your home folder: []$ cd [~]$ mkdir intro_to_modules [~]$ cd intro_to_modules/ [intro_to_modules/]$ ls [intro_to_modules]$ ls [intro_to_modules]$ pwd /home/<username>/intro_to_modules [intro_to_modules]$ vim python01.py "python01.py" [New File] # Using vim: Press ESC followed by ‘i’ to INSERT: Start typing: |
Info |
---|
Using
|
Code Block |
---|
import sys
print("Python version: " + sys.version)
print("Version info: " + sys.version_info)
# Using vim: ESC followed by ‘:wq’, then Return |
...
Let's run a Python script: Fixed:
Info |
---|
Try running the Python code: |
Code Block |
---|
[]$ python python01.py
Python version: 3.8.16 (default, May 31 2023, 12:44:21)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]
Traceback (most recent call last):
File "python01.py", line 3, in <module>
print("Version info: " + sys.version_info)
TypeError: can only concatenate str (not "sys.version_info") to str
# Let's update the code:
|
Info | |||
---|---|---|---|
Update the
Now try running again: |
Code Block |
---|
[]$ python python01.py Python version: 3.9.18 (main, Jan 4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] Version info: sys.version_info(major=3, minor=9, micro=18, releaselevel='final', serial=0) |
...
Code Block |
---|
[]$ which R
/usr/bin/which: no R in (/apps/s/arcc/1.0/bin:/apps/s/slurm/latest/bin:/home/<username>/.local/bin:/home/<username>/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
# Is it |
Info |
---|
Is it case-sensitive? |
Code Block |
---|
[]$ which r /usr/bin/which: no r in (/apps/s/arcc/1.0/bin:/apps/s/slurm/latest/bin:/home/<username>/.local/bin:/home/<username>/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin) |
Note |
---|
R is not available on the system by default. |
Infonote |
---|
But I want to use R. What can I do? This is the reason for this module. To demonstrate how you setup your environment to make things available to you. |
You Can’t Break the System
to you. |
...
You Can’t Break the System
Info |
---|
Try removing something that you do not have permissions to delete: |
Code Block |
---|
[]$ ls /usr/bin []$ cd /usr/bin [bin]$ ls []$ pwd /usr/bin # Permissions (ugo:rwx) and Ownership (user:group) [bin]$ ls -al [bin]$ ls -al python* You can't break the system. [bin]$ rm python rm: cannot remove 'python': Permission denied ls []$ pwd /usr/bin [bin]$ ls -al [bin]$ ls -al python* [bin]$ rm python rm: cannot remove 'python': Permission denied |
Info |
---|
Check and confirm by looking at the permissions ( What do you notice? |
...
What is sudo
? Can I use/request sudo
?
Info |
---|
The |
Warning |
---|
sudo: you will not be granted sudo access – do not ask! |
Info |
---|
Similarly: |
Warning |
---|
You can not use You won’t have permissions, and we will not provide you permission - do not ask! |
...