skip to main content

UNIX/LINUX COMMAND-LINE INTERFACE TUTORIAL

Managing Files

Listing your files (ls):

You can quickly and easily get a listing of all files in your home directory by typing the command ls. ls stands for list. If you change directories, ls will give a list of files in the directory that you changed to. If you want a more detailed list of files including file creation and modification dates and file permissions, use ls -l where l stands for long view. If you want to display hidden account configuration files use ls -a where a stands for all.

Creating directories/folders (mkdir):

You can group files together in directories/folders for better organization by creating directories and moving files into them. In order to create a directory use the command mkdir dirname where dirname is the name of the directory you want to create. Once a directory is created you can change to that directory by using the command cd which stands for change directory.

Moving (mv) and copying (cp) files to different directories:

Directories are useless unless you can get files into them. In order to move files from one directory to another, type mv Filename DirToMoveTo where Filename is the file that you want to move and DirToMoveTo is the directory where you want the file to be moved to. Copying file works exactly the same way. Just substitute cp for mv in the above command.

Removing (rm) files and directories:

In order to ensure that files in your user account do not exceed quota limits, it is a good idea to delete old files when you no longer need them. In order to delete a file, simply enter rm Filename where Filename is the name of the file you wish to delete. In order to remove an entire directory and all files contained in it use rm -rf DirName where DirName is the name of the directory that you wish to delete. NOTE: use extreme caution with the rm -rf command since accidentally deleting large amounts of files accidentally is easy. If you encounter many confirmation prompts during this process, cancel the command with control-c and type unalias rm and then re-enter your rm command. This will turn off prompting which has been enabled by default for your own protection.

 

Managing Programs (Processes)

Running a program:

Running a program that has been installed on EWS workstations is simple. Simply enter the name of the program at the command prompt and press enter. The program should begin running. If you are having problems you can check our software page for application specific instructions. However, if the program is something that you have installed or made in your own directory, you must change directories to the directory containing the program and then type ./ProgramName where ProgramName is the name of the program that you are trying to run.

Running a program in the background:

In order to run a program in the background (that WILL terminate when you log off) such as a graphical program that doesn't use the terminal, simply add a '&' to the end of the program's name. For example, in order to run mozilla in the background, use firefox& .

Canceling a running programs:

If a program is behaving incorrectly, you can normally terminate it by pressing control-c in the xterm (command prompt) window where the program is running. However, if the program is a graphical program running in the background you will need to use the pkill command to terminate the program. For example, if firefox has locked up on your workstation, simply type pkill firefox in order to force firefox to end. If you still encounter problems from a program after trying this, see a lab operator for assistance.

Switching a program running in the foreground to running in the background:

In order to move a program running in the foreground to running in the background, press control-z in the xterm (command prompt) window in which the program is running. You should see (Program Suspended) or something similar after this. In order to bring this program back to the foreground use the command fg.

Get Help

Questions about this topic? Don't see what you're looking for?

Email engrit-help [at] illinois.edu, call the Help Desk at 217-333-1313, or contact your primary IT support professional.