Basic UNIX Commands
This document provides descriptions of selected UNIX commands.
The command alias new_command 'command' creates an alias of command as new_command. One example is to alias rm so that it does a rm -i so that it asks if you really want to rm that file, the syntax is: alias rm 'rm -i'. Aliases can be placed in your .cshrc login script so that they are avaiable when you logon to the machine.
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.
The command cp file_1 file_2 copies the contents of file_1 into the file file_2. To indicate that the new file is to have the same name as file_1, 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.
The command echo MY_VARIABLE displays the current value of environment variables. Two variables that might interest you at some point are $HOME and $DISPLAY. Environment variables almost always have a $ as the first character
The command grep string filename searches filename for string. It outputs every line which contains string. The form "grep -v string filename" outputs every line which does not contain string. The argument string is read by grep as a regular expression.
The command kill process_id sends a terminate signal to the process specified by the process_id (PID). In cases where the terminate signal does not work, the command "kill -9 process_id" sends a kill signal to the process. For info on getting the PID for a process, see ps.
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).
The command man command displays the UNIX manual page for command. The manual pages describe usage and options for every UNIX command.
The command mkdir new_dir creates a new subdirectory named new_dir in the current directory.
The command more my_file displays the text of my_file one page (screen) 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; to goto the bottom of a file type shift-G.
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.
The command passwd allows you to change the password you use to login to the computer. The process is self-explanatory once you type the command.
The command ps lists the processes running on your machine. The form ps -u loginid lists only your processes. The form ps -a lists all processes running on the machine. The PID column of the listing, provides the information required by the kill command.
The command pwd prints the pathname of the current, or working, directory.
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. I would highly recommend placing the rm -i alias in your .cshrc.
The command rmdir my_dir removes the directory my_dir. The directory must be empty before it can be deleted.
note: If you get an error message that a directory is not empty when it appears to be, check for invisible files (see ls).