Skip to content

Latest commit

 

History

History
87 lines (68 loc) · 6.85 KB

common_commands.md

File metadata and controls

87 lines (68 loc) · 6.85 KB

Common Commands

Here are common terminal commands for your use

General Terminal Commands 💻

Command Description Example Notes
pwd print working directory returns where you are in the file system pwd Use this anywhere to show where you are in the file system
ls ls lists the contents of the directory you are in. Directory is the same as folder ls Use ls -a to show "hidden" files and directories (those that start with a period like ".config")
cd change directory allows you to go to a different folder. cd my_folder goes from your current folder into the subfolder called "my_folder". Just entering cd will take you back to the home directory (~)! cd my_folder Use cd .. to go up one directory
mv move or rename a file. mv old_name.png new_name.png, mv foo.txt my_folder/foo.txt Use mv to rename a file or move it to a different directory
cp copy a file. cp foo.txt my_folder/foo.txt Use cp -r to copy a directory
rm remove a file. rm foo.txt Use rm -r to remove a directory
mkdir make directory. mkdir my_folder Use mkdir -p to make a directory and any parent directories that don't exist
rmdir remove directory. rmdir my_folder Use rmdir -p to remove a directory and any parent directories that are empty
touch creates an empty file touch foo.txt
cat catenate and print files. cat foo.txt Use cat to print the contents of a file to the terminal

Text Editors 📝

Command Description Example Notes
nano a simple terminal text editor nano foo.txt
vim a more advanced terminal text editor vim foo.txt

File Permissions 🔒

Command Description Example Notes
chmod change mode of a file or directory chmod +x foo.txt to allow the file to be executed Use chmod to change the permissions of a file or directory
chown change owner of a file or directory chown user:group foo.txt Use chown to change the owner of a file or directory

Conda 🐍

Command Description Example Notes
conda create create a new conda environment conda create -n my_env python=3.8
conda activate activate a conda environment conda activate my_env
conda deactivate deactivate the current conda environment conda deactivate
conda list list all packages in the current conda environment conda list
conda install install a package into the current conda environment conda install numpy -c anaconda Specify the "channel" you use with the -c flag. Find the channel why youf search it. E.g., searching "numpy conda" will show that numpy is from the anaconda channel
conda remove remove a package from the current conda environment conda remove numpy
mamba install a faster alternative to conda install mamba install numpy Please install mamba as one of the first things you install and then use mamba install instead of conda install

Git/GitHub :octocat:

Command Description Example Notes
git clone clone a repository into a new directory git clone [email protected]:sasank-desaraju/med-ai-workflow.git What you use to "get" a git repository
git status show the working tree status git status
git pull fetch from and integrate with another repository or a local branch git pull run this whenever you start working
git add add file contents to the index git add foo.txt, git add -A first step to saving your changes on GitHub, git add -A adds everything in the repo
git commit record changes to the repository git commit -m "Added a new feature" second step
git push update remote refs along with associated objects git push third and final step
git branch list, create, or delete branches git branch, git branch new_feature
git checkout switch branches or restore working tree files git checkout new_feature
git diff show changes between commits, commit and working tree, etc git diff

HiPerGator 🚀

This is a SLURM-based system, so you'll need to use SLURM commands to submit jobs. Here are some common commands:

Command Description Example Notes
ssh secure shell. Connect to a remote computer using SSH ssh [email protected] Use ssh to connect to HiPerGator
sbatch submit a job to the cluster sbatch foo.sh Use sbatch followed by a bash script (foo.sh) to submit a job to the cluster
squeue shows the state of the jobs in the queue squeue Use squeuemine to show only your jobs
scancel cancel a job scancel 12345 Use scancel [job_id] to cancel a job
ShowAssoc show what HPG accounts a user has access to ShowAssoc -u albert.gator The username is your username to learn about yourself
ShowQos show what resources (CPUs, GPUs) an account has ShowQos -A my_account The account is usually your PI's HPG username or the class you're in
srun run a command on the cluster srun -N 1 -t 1:00:00 echo "Hello, world!" Use srun to run a command on the cluster
sinfo shows the state of the nodes and partitions on the cluster sinfo Use sinfo -N to show the nodes and their states
salloc allocate resources for an interactive job salloc -N 1 -t 1:00:00 Use salloc to allocate resources for an interactive job

File Transfer 📥 📤

Command Description Example Notes
sftp secure file transfer protocol. Securely transfer files between computers using SSH sftp user@remote_host Use sftp to transfer files between computers
scp secure copy. Copy files between computers using SSH scp foo.txt user@remote_host:/remote/directory Use scp to copy files between computers
rsync a fast, versatile, remote (and local) file-copying tool rsync -avz foo.txt user@remote_host:/remote/directory Use rsync to copy files between computers or directories