Notes on Basic UNIX Commands

Introduction to UNIX

Enter these as prompted by the OS:

login name
password

All Unix Commands look like this.  We will go over some basic ones.

<name> - <options(s)> argument(s)

1.  Managing Files:



Unix is an OS.  It therefore manages your files.  All file systems are the same.  They
are based on a tree structure of directories (folders) and files.  We will first look at
managing files inside a directory.

-----------------------------------------------------------------------------


ls: list files in the directory presently occupied.  It works like dir in DOS

options
	a - show all hidden (dot) files.  These files configure your account.  Do
	not discard or modify them until you know what you are doing!
	l - show files in long format


usage:  ls -<options> <directory>

This lists files in the directory <directory>.  If no directory is given, it lists
them in your current directory.
-----------------------------------------------------------------------------

touch <fileName>

	creates an empty file with name <fileName>
	this is one of many ways to create a file in UNIX.

Advice on filenames:

	1.  Do NOT put spaces in 'em.
	2.  start with a letter. Use only letters, numbers or underscore.
	3. the character . has a special meaning. It demarcates a file extension.

Here are common file extensions in UNIX:

.cpp  - c++ source file
.c    - c source file
.tex  - tex source file
.html - web page content
.jpeg - graphical format
.bmp  - bitmap graphical format
.py   - python source file
.gif  - graphical interchange format
.
Example of extension usage:

quack.cpp - this is a c++ program named "quack"
integrals.tex - this is a tex file named "integrals"

Placing an extension on a file identifies it as belonging to a particular
applicaton.  Doing so also triggers syntax coloring in vi.  This coloring is a 
powerful productivity tool that will save you endless mistakes and hours of work.


----------------------------------------------------------------------------

mv:

changes the name of a file.  It works like ren in DOS.

usage:  mv <oldFileName> <newFileName>

----------------------------------------------------------------------------

rm 

removes a file

rm <fileName>

	removes the specified file.  Once it's gone, it's gone forever!

options
	i - asks if you are sure before file is removed.
-----------------------------------------------------------------------------
_____________________________________________________________________________

Directories

Directories are just like folders in Windows or MacOS.  They hold files and other
diredctories.  

Tree structure of UNIX.

-----------------------------------------------------------------------------

pwd - print working directory. Answers the question: Where am I?

usage:  

pwd
-----------------------------------------------------------------------------
cd - change directory; this allows you to navigage the direcdtory structure.

usage

cd - take me to my home directory.  Everyone has a home directory.  It is named ~<userName>
cd <directory>  - take me to the named directory
cd ..  climb up one in the directory structure
-----------------------------------------------------------------------------

We will create a directory structure and navigate in it.
-----------------------------------------------------------------------------
mkdir <name> 

makes a directory with indicated name. The directory is born empty.
-----------------------------------------------------------------------------
rmdir <name>

removes the directory with name <name>.  This command will *not* work if there are files
present in the directory. This is to protect you from your own stupidity!  To remove a directory with 
files in it, cd into the directory and remove its contents.

mv

you can use this command to move a file to a directory

mv <fileName> <directory>

moves a fileName into the indicated directory.
-----------------------------------------------------------------------------
_____________________________________________________________________________

Wildcards:  

UNIX has a feature called regular expressions.  For now we will look at the simplest 
regular expressions (regexes).  

Type ls a*

this lists all fies whose names begin with a

the * character is a wildcard; it means "any string of characters". 

------------------------------------------------------------------------------

Get the program WinSCP to transfer files from a 'doze box to your unix account.
The interface is simple and straightforward.

Back to the index page