0. Command line basics
Many digital preservation tasks require use of the command prompt (Windows) or terminal (Unix) – generically referred to as the command line – so a basic familiarity with how to work in this interface is very useful.
Windows and Unix have different command line syntaxes, meaning a Windows user and Linux or Mac OS user will use different commands to accomplish the same task. The Windows command prompt is case-insensitive, while the Unix terminal is case-sensitive.
Most UTL workstations are Windows environments, so there is generally more institutional familiarity with the Windows command prompt and support for Windows tools. For an introduction to the Unix shell, see Unix (Linux/macOS) command line basics and this Library Carpentry lesson.
Current working directory (cwd
)
This is like your “open” window in Windows Explorer or Finder. It indicates which folder your commands will be run in by default. It’s shown to the left of your cursor, and you can’t delete it, so your commands will always begin to the right of your cwd
. On Windows, the cwd
and cursor are separated by >
, while Unix uses $
. Unix also shows the name of the active user, to the left of the cwd
.
Filepaths
Every file and folder has a location on disk, called a path. A file path lists all the folders and subfolders that a given file or folder is nested within. On Windows, a file path always starts with a drive letter, colon and backslash (such as C:\
), and each drive generally corresponds to a separate hard drive or network volume. Unix treats every disk and volume as a folder, so file paths don’t start with drive letters.
Knowing the full path of the folders you’re going to work with is important for running commands on those folders. On Windows 10, you can open “This PC” to see the drive letters for each disk or volume.
On Windows, folders and files are separated by backslashes (“\
”), while Unix uses forward slashes (“/
”).
“C:
” is the drive letter, “Users
” and “dab4457
” are folders. “dab4457
” is inside “Users
”
“dab4457@LIB-PCLAL102
” is the active user, “mnt
” and “benson
” are folders. “benson
” is inside “mnt
”
Changing the cwd
To change the current working directory, use the “cd
” command, followed by the path to the directory you want to set as the new cwd
. This command is the same in both Windows and Unix, though the file paths will use different slash directions. If the new file path contains blank spaces, wrap the file path in quotes.
Changing the cwd
from the “dab4457
” folder to the “Box
” folder, then to the “Digitization Services
” folder
To navigate up a folder, use “cd ..
” (two periods)
On Windows, to change the cwd
to a directory on another drive letter, you first need to change the active drive. You do this by typing the drive letter you want to change to, followed by a colon.
On Windows, using cd
with a path on another drive will set the default open directory on that drive, but it won’t actually change the cwd
to that drive. In this case, the “Y:
” command changes the current working directory to “Y:\digital_processing
” because of the cd
command in the first line
Any file path you enter has to be exactly correct, or you’ll receive an error saying the system can’t find the path you’ve provided. Remember that Unix file paths are case sensitive, so if you are having trouble changing to a particular folder on Unix, check your capitalization.
The easiest way to avoid typos is to hit the Tab key to autocomplete any file paths you’ve begun to type. On Windows, hitting Tab will cycle through all possible matches based on what you’ve typed (and Shift + Tab will cycle backwards). On Unix, hitting Tab twice will show all possible matches, or insert the match if there is only one. As long as you auto-complete all your file paths, you should avoid most file not found errors.
Listing directory contents
To show the contents of a folder, use “dir
” (“directory”, Windows) or “ls
” (“list”, Unix), followed by the path to the folder. If no folder path is provided, the cwd
will be used.
Default output of the “dir
” command in Windows
Default output of the “ls
” command on Unix
The content and structure of what is displayed can be changed by adding any number of “options” or “parameters” after the command. For example, use “dir /b
” to display a “bare” list of directory contents, without timestamps or other metadata:
The equivalent in Unix is “ls -1
”, which displays 1 line per item in the directory
There are often dozens of options/parameters you can add to a command to make the process run a specific way or display output a specific way. These options are useful for performing specific operations and chaining commands together (called "piping" in Unix). There are many guides and manuals online that list and explain these, just search “<command>
options”.
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.