Wednesday, March 18, 2009

Commonly Used UNIX Commands

There are a few things you need to remember when entering UNIX commands:

  • UNIX commands are typed at a prompt. Very often the prompt is a percent sign %. Sometimes it is the name of the machine followed by the %. The cursor may be a blinking white square on a black background, a blinking black square on a white background, or a blinking color square on a color background.
  • UNIX commands are case sensitive and are usually lower case. This means that ls and LS are completely different commands. At the end of this section is a chart of some commonly used UNIX commands.
  • Spaces are very important. There is always a space between the command and the file or directory it acts upon. In the following example of a command line, cd is the command and /afs/andrew/course/76/271-Summer/dheagy is the directory.
    Example: cd /afs/andrew/course/76/271-Summer/juser
  • In order for a UNIX command to be executed, you must press Enter at the end of a command line. If all goes well, the prompt and cursor appear on the next line waiting for the next command. It often looks like you haven’t done anything, but unless there is an error message, your command has been executed. If there is a problem, you will generate an error message, such as “Command not found.” If you generate this type of error, you probably typed something incorrectly. Try again.
  • If you type something and you want to get out of it, press Ctrl + C.

Command

Action

cat

Print contents of file in the command window

cd

Change directories

cp

Copy the contents of file into file2

history

List history of all commands issued at system prompt

ls

List the files and subdirectories in a directory

ls -F

List the difference between files and directories (directories will have a /)

ls -l

List files with status information (list the long way)

ls -lt

List file information in long format, sorted by time with newest files (or newly changed files appearing first

ls -a

List all the files in a directory, including dot files

mkdir

Make a directory

mv

Move file to file 2

pwd

Print the pathname of the current directory

rm

Remove, or delete, files

rmdir

Remove directory

fs la

List access rights for (for more information on access rights, read File and Directory Protections)

source

No comments: