Code Snippets
I use them to manage our lab’s server all the time, so I put them here for easy reference.
Unix Server Commands
Use setfacl to control file access groups
- Grant
siconghuangread, write, and execute access to the/data/datasets/directorysetfacl -R -m u:siconghuang:rwx /data/datasets/
- Grant
Use tmux to create a persistent window for long experiments or persistent processes
- Create a new persistent window named
sicongtmux new -s sicong - Detach from a persistent window
Press
Ctrl+B, then pressD - list all existing persistent windows
tmux ls - attach to the persistent window named
sicongtmux a -t sicong - If you (sadly) don’t have tmux, try screen
- Create a new persistent window named
To check server space
To find a file or directory from a scoped directory
- Use find to locate directories with keyword
MNISTfrom/data/datasets/directoryfind /data/datasets/ -type d -name "MNIST"
- Use find to locate directories with keyword
To reload swap memory memory
- Use swapoff/swapon to switch on and off
free -m; swapoff -a; swapon -a; free -m
- Use swapoff/swapon to switch on and off
To limit your job’s resource usage
To send files/data to another server
- Use scp to send files from your current machine/server to another
- Securely sending your
saved_modelsdirectory to your home directory on another serverscp -r ~/saved_models/ [username]@[server address]:~