Shell BasicsShortcuts
Commands
|
Hidden Files and DirectoriesHidden files and directories start with a dot "." and won't show up when you do a simple
|
Environment VariablesOverviewThese are important bash variables that control how your environment is configured. For example: what executables, libraries, header files, etc. are findable by default; information about your Slurm job; MPI settings; GPU configuration; etc. To see all the environment variables that are defined for your session, try running the command:
$PATHThe variable PATH is a
When you try executing any command (e.g.
If you have an executable that you would like to add as a default command for your session, you can add its directory to your PATH. For example:
|
Linux File PermissionsOverviewHPC users may find it useful or necessary to share files and/or directories with collaborators. To do this effectively, it may become necessary to familiarize yourself with the linux file permission system in order to give collaborators access to your files. Linux file permissions involve a few properties. Users are categorized as follows and assigned permissions based on these categories.
Each group is assigned a boolean permission to the following actions:
Viewing File PermissionsBy default, all files and folders you create in your home directory are owned by you, and the group is assigned to your HPC sponsor group. If you are a PI, then this is your personal research group. Permissions and file properties are best viewed from the command line. Use the following command to view the contents of a directory, including permissions:
Here is the output of this command for an example directory:
The first character indicates whether the item is a regular file (dash) or directory (letter "d"). The following nine characters describe the permissions of this file according to the three categories of user and three actions listed above. The first group of three characters refer to the permitted actions of the owner; the middle three characters the group; the final three characters to all other users. The order of actions is the same for each category: read, write, execute. A permitted action is indicated by a letter, and a non-permitted action is indicated by a dash. Let's go through the permissions of each of the above files.
After this string and following the number, there are two net IDs listed. In this case they are the owner "ejahn" and the group "staff". The first net ID is always the owner of the file, and the second is the group assigned to the file. These are important to note because they help determine which users have which set of permissions. File PermissionsAdditionally, file permissions can be altered by the owner of the file using the "chmod" command. The structure of the command is:
The options can either be given in terms of relative (additive/subtractive) actions, or absolute. Relative actions have the structure <who><operator><action>:
For example, if I wanted to remove read access from file test1.txt for group members and others, I could run the command
Then, when I view the file permissions, I can see:
Note that there are only dashes for group members and other users for file test1.txt, indicating that their read permissions have been removed. To add them back, I would change the "-" to a "+" in the chmod command:
Now, we can look at the absolute options. Rather than adding or removing given permissions, this methods set them to a specific setting according to "octal" permissions. Octal refers to the eight possible combinations of r,w,x, each of which is indicated by a number from 0-7 as follows:
Each octal option refers to the permissions assigned to the usual order of owner, group, other. All permissions are thereby indicated by three octal numbers. For example, directory testdir1 above would have octal permissions of 755. If I wanted to remove execute permissions from group and other for this directory, I could run the command:
This sets group and other to read only. Alternatively,
removes all permissions from group and other, but maintains full permissions for the owner. There is no concrete advantage to using either absolute or relative permissions for the chmod command. Use whichever one makes the most sense to you!
|
Compression and ArchivingAre you planning on transferring files to or from HPC? Do you have a lot of them? Then archiving is for you! Archiving files is the process of consolidating one or more files or directories into a single, compressed package or archive file. This simplifies data management, reduces storage space, and streamlines file transfer and backup operations. Transferring a single archived file to an external backup location my result in transfer speeds that are an order of magnitude faster than transferring the same data as an uncompressed directory with thousands (or sometimes millions) of files. Some examples of using archival software such as gzip and tar are shown below. dec tarCreate an archive of a directory
|