Welcome! This workshop is designed for users that are new or reviewing basic Linux principals. This workshop also covers details on connecting to CS servers.
Details for connecting to the Linux SSH login cluster known as portal
Network Requirements: none
To SSH to the portal login cluster, from your personal computer, open a terminal and enter the following command, replacing <userid> with your computing ID
Temporary passwords are sent via email when your CS account is created initially. After logging in for the first time, you will be required to change your password
Note, for the first time you connect via SSH, you will see the following output
Are you sure you want to continue connecting (yes/no)?
Enter yes to continue
On Linux / MacOS, one application option is named Terminal
~$ ssh <userid>@portal.cs.virginia.edu
On Windows, the application can be either Command Prompt or PowerShell
C:\Users\username> ssh <userid>@portal.cs.virginia.edu
For more information, see our wiki page about our (Logging in via SSH)
Note, the NoMachine cluster does not have GPU enabled systems.
Network requirements: none
After downloading the NoMachine client application from the (NoMachine Website), open the NoMachine application and follow the steps listed below
Name: UVA CS Remote Linux DesktopHost: nxfront.cs.virginia.eduPort: 4000Protocol: NX<userid> with your computing IDUsername: <userid>Password: <cs password>Thereafter, you'll be prompted for a few configuration options that are user specific.
For more information, see our wiki page about our (NoMachine cluster)
Note, the RDP Windows server is not a GPU enabled system.
Network Requirements:
For windows systems, the application Remote Desktop Connection or RDP is installed by default. To connect to the remote desktop server
Computer: winsrv01User name: CSDOM\<userid>For more information, see our wiki page about our general purpose (Windows Server)
Remote development is possible for most common software and options are listed below. Generally, you simply need to enter your CS credentials to log in.
For further reading about SSH connections, see our (SSH wiki page)
For further reading about remote development, see our (Remote Development wiki page)
Note, for all applicable examples, replace <path> with the location of the file or directory
To change/move to another directory
~$ cd <path>
Note, the tilde character ~ specifies to use your home directory location. Further, simply using cd will move you to your home directory. The following are all equivalent to move to your home directory
~$ cd OR ~$ cd ~ OR ~$ cd ~/ OR ~$ cd /u/<userid>
Note, when using dot . this specifies to reference relative to your current location (the current working directory)
~$ cd ./my_directory
Note, when using a double dot .., this specifies to reference the parent directory relative to your current location (the current working directory)
~$ pwd /u/<userid>/my_directory ~$ cd ../ ~$ pwd /u/<userid>
Note, the absolute path is the full path to a file or directory location. For example, if a directory with the path /u/<userid>/my_directory/ exists
// relative path to the current working directory, // assuming the current working directory is /u/<userid> ~$ cd ./my_directory/ OR ~$ cd my_directory/ // absolute path, current working directory does not matter ~$ cd /u/<userid>/my_directory/
To print the current working directory (i.e. your current location)
~$ pwd
To list all files and directories under a given path
~$ ls <path> // for example ~$ ls cs_workshop/ dir0 file0 file1
To list all files and directories in the current working directory
~$ ls .
To list all files and directories of a directory relative to your current working directory
~$ ls ./my_directory
To list all files and directories of a directory regardless of your current working directory, use the aboslute path
~$ ls /u/<userid>/my_directory
The following modifiers can also be applied to alter the output of an ls command
To list one file or directory for each line, including file/directory permissions, ownership, and modified timestamps
~$ ls -l ~/my_directory total 10 drwx------+ 2 <userid> <groupname> 2 Jun 11 00:01 dir0 -rw------- 1 <userid> <groupname> 4 Jun 11 00:02 file0 -rw------- 1 <userid> <groupname> 6 Jun 11 00:03 file1
To list ALL files and directories, including hidden
~$ ls -al ~/cs_workshop/ total 23 drwx------+ 3 <userid> <groupname> 6 Jun 11 00:01 . drwx--x---+ 36 <userid> <groupname> 68 Jun 11 00:01 .. drwx------+ 2 <userid> <groupname> 2 Jun 11 00:01 dir0 -rw------- 1 <userid> <groupname> 4 Jun 11 00:02 file0 -rw------- 1 <userid> <groupname> 6 Jun 11 00:03 file1 -rw------- 1 <userid> <groupname> 7 Jun 11 00:05 .hidden_file0
To list ALL files and directories, placing the most recent at the top
~$ ls -alt ~/cs_workshop/ total 23 drwx--x---+ 36 <userid> <groupname> 68 Jun 11 00:01 .. -rw------- 1 <userid> <groupname> 7 Jun 11 00:05 .hidden_file0 -rw------- 1 <userid> <groupname> 6 Jun 11 00:03 file1 -rw------- 1 <userid> <groupname> 4 Jun 11 00:02 file0 drwx------+ 3 <userid> <groupname> 6 Jun 11 00:01 . drwx------+ 2 <userid> <groupname> 2 Jun 11 00:01 dir0
To show information about a specific file or directory
~$ stat <path> ~$ stat ~/cs_workshop
Note, for all applicable examples, replace <src path> with the starting location, replace <dest path> with the destination location
To create an empty directory
~$ mkdir <path> ~$ mkdir ~/my_new_directory/
To create an empty file
~$ touch <path> ~$ touch ~/my_new_directory/my_new_file
To move an individual file
Note, if you specify a file name, the file's name will change to it
~$ mv <src path> <dest path> ~$ mv ~/my_new_directory/my_new_file ~/my_old_directory/
To rename a file
~$ mv <path to current file> <path to new file> ~$ ~/my_new_directory/my_new_file ~/my_new_directory/another_file
To move a directory and its contents
~$ mv <src path> <dest path> ~$ mv ~/my_new_directory ~/my_collection
To rename a directory
~$ mv <path to current directory> <path to new directory> ~$ ~/my_new_directory ~/my_collection
To copy a file
Note, if you specify the full path and/or a different name, the file will copy to the path under the name specified
~$ cp <src path> <dest path> // preserve the filename ~$ cp ~/my_new_directory/my_new_file ~/my_new_directory ~$ cp ~/my_new_directory/my_new_file ~/my_new_directory/my_new_file // change the filename ~$ cp ~/my_new_directory/my_new_file ~/my_new_directory/another_filename
To copy a directory and its contents to another directory, include the recursive option
~$ cp -r <src path> <dest path> ~$ cp -r ~/my_new_directory ~/my_collection
To copy a directory's contents (not the directory itself), include the recursive option and a trailing /.
~$ cp -r <src path>/. <dest path> ~$ cp -r ~/my_new_directory/ ~/my_collection
Files/directories stored in a HOME directory (/u) are assigned default permissions and rarely need to be modified.
Files/directories stored in a PROJECT directory (/p) are assigned default permissions and rarely need to be modified.
Files/directories stored in SCRATCH/VOLATILE storage (/bigtemp) are NOT assigned default permissions and may need to be modified.
For a given file, we'll use exmaple output from a stat command, ommitting several details to focus on file permissions
~$ stat my_file Access: (0700/-rwx------) Uid: (12345/ <userid>) Gid: (54321/<groupname>)
Note, the syntax for Access: (0700/-rwx------) shows both forms of a file or directory's permissions. The first '0' is for the file's SUID/SGID/Sticky bit. For the purpose of this explanation, we will ignore this part and focus on the last three. The first dash '-' shows if the result is a file (denoted with a dash '-' character) or directory (denoted with a 'd' character).
A linux file or directory has three octals to determine access. The three octals for access/permissions are broken down as follows
The octals can be represented numerically
As shown in the above example, three dashes represent the respective octal (excluding the first dash), represented instead using characters
The resulting permissions are the sum of the allowed access. Using the above example, where the permissions are 700, we can see that the ONLY the OWNER (<userid>) of the file has Read (4 or r), Write (2 or w), and Execute (1 or x). In other words, 4 + 2 + 1. The GROUP <groupname> and OTHER have no access.
For another example, observe the file
~$ stat my_directory Access: (0604/-rw----r--) Uid: (12345/ <userid>) Gid: (54321/<groupname>)
The resulting permissions here are that the OWNER (<userid>) of the file has Read and Write (or 4 + 2). Everyone else or OTHER, has only Read (4) access.
To change the permissions of a respective file, the form is to set each of the three respective octals
~$ chmod <permission octals> <path> // set so that only the owner can read/write ~$ chmod 600 ~/my_file // set so that only the owner can read/write/execute ~$ chmod 700 ~/my_program.py // set so that only the owner and group members can read/write to a file ~$ chmod 660 /p/my_project/shared_file // set so that the owner can read/write, and make it globally accessible (i.e. readable by a web server) ~$ chmod 604 ~/public_html/index.html
To view the total usage of an individual file or directory
~$ du -h <path>
To view all usage of files and directories, showing usage for each, in a given directory (i.e. your home directory)
~$ du -h --max-depth=1 <path> ~$ du -h --max-depth=1 /u/<userid>
At times, it can be helpful to run a process in the background instead. In such cases, redirecting output can also be helpful
To launch a process in the background, append the & character
~$ ./<command or program> &
Alternatively, you can move a process from the foreground to the background by pressing ctrl + z
~$ ./my_python_program.py // ctrl + z, enetered [1]+ Stopped ./my_python_program.py
Then, you can resume a process in the background
~$ bg 1 [1]+ ./my_python_program.py
To view all running processes
~$ jobs
Another option is to list processes using
~$ ps -aux | grep <userid>
At times, it can be helpful to redirect output of a command or process to a log file
To redirect STDOUT (standard output)
~$ <command or program> > ~/output.log
To redirect STDERR (standard error)
~$ <command or program> 2> ~/error.log
To redirect both STDOUT and STDERR
~$ <command or program> > ~/full_output.log 2>&1
To suppress or ignore output, you can send either or both streams to /dev/null as shown
~$ <command or program> > ~/full_output.log 2>&1
There are several options for editing files. Two common text editors are nano and vim
For example, to open a file for editing using nano
~$ nano my_file
Note, vim is a powerful tool and has a learning curve, be sure to look up a reference cheat sheet
To exit without saving from editing a file with vim, hold shift, then press the colon / semi-colon key :, then enter q!
~$ vim my_file
There is a command named vimtutor that can be used for practicing and learning vim interactively
~$ vimtutor
To view the resources you're using on a given system, you can either start a process in the background, or open a second terminal to the server that your process is running on
This command will show the respective CPU and Memory usage of your processes. Note, you can also replace the environment variable $USER with your userid
~$ top -U $USER OR ~$ top -U <userid>
Another option is to list processes using
~$ ps -aux | grep <userid>
Note, this section is for GPU enabled systems only. Login clusters such as portal and NoMachine do not have GPUs to view.
The most common command for viewing GPU usage is
~$ nvidia-smi
More in-depth output can be obtained using nvtop, which requires loading the software module
~$ module load gcc ~$ module load nvtop ~$ nvtop
Note, this data is updated hourly.
To quickly view home directory usage
~$ storagecheck -h
To quickly view project directory usage, enter the path to the project directory
~$ storagecheck -p /p/<project directory name>