Bash

CLI
tool
Bash is a command line tool and language.

Files

List files

Number of files in a provided directory
ls [myDirectory] | wc -l 

Manipulate Files

Remove directory tree with all its contents
rm -rf [myDirectory]

File Permissions

Show access permissions of file in directory
ls -l [myDirectory]
Change permissions of file
chmod u=rwx,g=rwx,o=rwx [myFile]

Explanation

Control structures

Use commandline arguments
while getopts :c:t flag
do
    case "${flag}" in
        c) 
            config=${OPTARG}
            python3 file_to_be_called.py -c $config
            ;;
        t)
            python3 file_to_be_called.py -t
            ;;
        :) 
            echo "No arguments passed"
            exit 1
            ;;
        ?) 
          echo "Please call the script like this: bash_script.sh [-c config_file]"
          exit 1
          ;;
    esac
done

The : before the flag-character c lets you handle errors yourself (e.g. no arguments passed and wrong arguments passed). The : after the flag-character c indicates that a value is required after the flag.

Processes

List running processes
htop
Commands
Help

h

Kill process k
Order processes by memory consumption

Shift-M

Filter processes by user

U

Display files used by the selected process

L

Display user threads

Shift-H

Kill process
kill -9 [process-PID]
Info on resource usage & processes on NVidia graphic cards
nvidia-smi