x
Cookies help us deliver our services. By using our services, you agree to our use of cookies.Learn more.
OK
Serving the Multimedia Community since 1989.
UNIX Basics
UNIX Basic
  • UNIX is a multi-user, multi-tasking operating system. (i.e. UNIX can support multiple users, each running mutiple processes simultaneously.)
  • UNIX file and directory names can be composed of the following: letters of the alphabet (A-Z, a-z), numerical digits (0-9), ., - and _.
  • Files beginning with . are hidden files and can only be seen when using the ls -a command.
  • UNIX is case-sensitive. (i.e. MYFILE.TXT is NOT the same as myfile.txt!)
  • The current directory is referenced by the ./ symbol. The parent directory (one directory above the current directory) is referenced with the ../ symbol.
  • Pathnames that start with / are absolute and reference all files and directories with respect to the root directory.
  • Pathnames that do not start with / are relative and reference all files and directories with respect to the current directory.
  • The * symbol can be used as a wildcard. (e.g. ls m*.c will list all files beginning with m and ending with .c.)
  • Deleting a directory that isn't empty can be tricky. Use the rm command with the -r flag. (e.g. rm -r directory)

Basic UNIX Commands

Some selected UNIX commands.

cd

The command cd my_dir changes your position to the directory specified, in this case my_dir. The command cd without an argument moves you to your home directory.

cp

The command cp first_file copy_file copies the contents of first_file into the file copy_file. To indicate that the new file is to have the same name as first_file, use a period (.) instead of of providing a name for the second file. (In this case, the files must be in separate directories, as two files cannot have the same name if they are in the same directory.) For example: cp some_directory/my_file . copies my_file, located in some_directory, and creates a file named my_file in the current working directory.

ls

The command ls lists the files in the current directory. The form ls -F shows the difference between directories and ordinary files. The form ls -a lists all files, even those that are normally invisible in UNIX (files whose names start with a period, i.e. .xstartup).

mkdir

The command mkdir new_dir creates a new subdirectory named new_dir in the current directory.

more

The command more my_file displays the text of my_file one page at a time. To see the next page, hit the space bar; to see the previous page, type b; to quit paging the file, type q.

mv

The command mv file_name dir_name moves the file file_name from the current directory into the directory dir_name, where dir_name is a subdirectory of the current directory. The form mv old_file new_file renames old_file and calls it new_file.

pwd

The command pwd prints the pathname of the current, or working, directory.

rm

The command rm my_file deletes my_file. The form rm -i my_file asks if you really want to remove the file my_file before it proceeds.

rmdir

The command rmdir my_dir removes the directory my_dir. The directory must be empty before it can be deleted.