CSC121A - Basic "Unix" Commands - Spring 2005

Nadeem Abdul Hamid - Berry College

Open CSserve folder
SSH to Csserve

  • Display files in a directory: ls
     
  • Copying files: cp
     
  • Moving/renaming files: mv
     
  • What's in a file? more, less, cat
     
  • Deleting files: rm
     
  • Reading a manual page: man
     
  • Information on a person: finger
     
  • HOW DO I QUIT!?: logout or exit

Long Descriptions

cat filename(s)
Prints out (to the screen) the contents of the named file(s). Can also be used to concatenate files. Say you want file1 and file2 to be all together in one file named file3: use "cat file1 file2 > file3".


cp filename(s) path
Copies files from one directory/filename to another. "cp f1 f2" makes a file "f2" identical to "f1". "cp *.c src/" copies all files that end in ".c" into the "src" subdirectory.


finger [login-name]
If you don't specify a login-name, finger shows who is currently logged onto the system. With a login-name, you get more detailed information about a person, including anything stored in a person's ".plan" file.


less filename
Displays a file on the screen, allowing you to scroll forward and backward (unlike more) through it to view its contents (using the up and down arrows). Press the Q key to stop viewing the file.


ls [directory]
Shows directory listing. If no directory or file is specified, ls prints the names of the files in the current directory.

ls -l [directory]
Shows long directory listing. If you type "ls -l" in a directory, you might get something like this:

-rw-rw-rw-   1 nhamid  nhamid     212 12 Feb 10:14 example1.html
-rw-r--r--   1 nhamid  nhamid     662 12 Feb 10:13 example2.html
dr-xr-xr-x   9 nhamid  nhamid     306  2 Feb 12:00 fig21_02_03
drwxr-xr--   4 nhamid  nhamid     136 14 Jan 21:24 i-Packages
The first part of the line tells you the file's access permissions. For example the "i-Packages" file permissions start with a "d" which tells that it is a directory. The next three characters, "rwx" show that the owner (nhamid- me) has read, write, and execute permissions on this file. The next three characters, "r-x" show that people in the same group as the owner have read and execute (no write) permissions. And finally the last three characters "r--" show that everyone else only has read permission on that file. (To be able to enter a directory, you need read and execute permission.)

man [section] name
Shows the full manual page entry for the command/system call "name". Without a section number, "man" may give you any or all of the manual pages for that "name". For example "man write" will give you the manual pages for the write command, and "man 3 printf" will give you the system call for the printf function (usually from the C programming language).

man -k pattern
Shows all manual entries which have the "pattern" somewhere in their description.


more filename
Displays the contents of a file on the screen, allowing you to scroll forward through it (using the space key). Press the Q key to stop viewing the file.


mv filename path
Moves "filename" to "path". This might result in a simple renaming of the file, "mv file1 file2", moving the file to a new directory, "mv file1 /tmp/", or both "mv file1 /tmp/file2".


rm filename(s)
Removes (deletes files). Be careful with this one - it is irreversible.


 

Based on http://www.emba.uvm.edu/CF/basic.html

Last modified: Thu Feb 17 11:03:15 EST 2005