Unix commands (including Cygwin)
Back to DEX-Install/Tutorial
Here are some basic Unix
commands for navigating and exploring data. Since Unix is often run in a
command-line environment, you will have to type commands to see, edit and
change the files and move between them. Here are the very basic commands you
will need to know to run DEX with confidence.
files and folders, type:
- Lists the files and folders in the current directory
- ls -lt
- Lists more information about all the files/folders in the current
directory, one file/folder per line
Example: “ls time*” will list
every file that starts with the word “time” while the command
time*.dat” will match everything in the folder that begins with “time”
and ends with “.dat”. This is a very powerful feature of Unix and should
be used to reduce the number of commands are need to execute a program.
“Tab” button will complete the name of a file or folder if it is
unique. For example, if there is only one file that begins with
“time-2” then simply typing “ls time-2
(Tab)“ will complete the file without having to type the rest of
the letters. This saves a lot of time when most of the files are
- Ctrl d - This
is typed if you have finished typing part of a filename and you need to
find out which files have that same beginning part in their names.
For example, typing “ls time-2 (Ctrl d)”
will display all the files that have that beginning of the filename
“time-2”. After typing this, you can see what the exact name of the
file you wish is named and type in the rest of the name. When you
combine “Ctrl d” with the Tab button, you typically only need to type a
few letter per name, even if it is long. This saves a considerable
amount of time.
arrow - Typing the up
arrow on the command line will show you the last command that was
executed. You can just modify this one or run it again to see the
results of the same or new file.
folders/manipulation of folders
- cd folder-name
- folder-name is the name of the folder you want to move to
- Displays what folder you are currently in
- Creates a folder (directory)
- Removes a folder (directory) but it must be empty
- cp old-filename new-filename
- Copies the old file to the new filename without
erasing the old file
- mv old-filename new-filename
- Changes the old file to the new filename and erases
the old file
- rm filename
- Removes the filename you type
- lpr –Pprinter-name
- printer-name is the name of the Unix networked printer. If you do
not have a printer setup with the Unix commands, you will have to find the
file in the window system and print how you would normally print it.
Cygwin users: You can open regular text files in MS Word and
save and print them normally.
contents of a file
- vi filename
- vi is a visual program to view the text in a file such as the results
from a program.
- head filename
- Shows the first 10 lines of a file
- tail filename
- Shows the last 10 lines of a file.
- To execute a program, you
only need to type its name. You may need to type “./” before the
name, if your system does not check for executables in that file.
- Ctrl c
- This command will cancel a program that is running or won’t automatically
quite. It will return you to the command line so you can run
Once you type the command
above, the window will display the text. Unlike a regular document
program, vi does not let you just type using the keyboard. Instead, each
key has a function, such as move the cursor left or down. Here are the
basic commands you can use to edit and save the commands. You can use the
arrow keys just like normal, and must be used to move the cursor to the place
you want to start typing/editing. The mouse will not work in the standard
“vi” program, only the keyboard is used. This takes some getting used
- insert is similar to “a” but is to the left of where the cursor is.
- appends to the data, after typing “a” you can use the keyboard to type
in letter/numbers like a normal word processing program. When you
are done typing what you want at that location, you need to hit the “Esc”
button before you can return to the regular mode.
- escape ends the current mode you are in (i.e. typing mode) and takes you
back to the original.
- Typing “x” lowercase will erase the character on the cursor, like the
“Backspace” key does in a normal word processing program. The
“Delete” button will do the same thing in the regular mode.
- saves all the changes you made to a existing file name.
- :w new-filename
- saves all the changes you made to a new filename you specify.
- Capital ZZ. This will save and quit the “vi” program and bring you
back to the command line.
- This will quite the “vi” program without saving the last changes you
- This is undo, and will undo the last action you have completed.
- This will erase the entire line. Tying a number before typing “dd”
will remove the number of lines chosen.
- :se nu -
This is to “set number lines” which will temporarily number the lines of
the document for you.
- Ctrl f -
This will page down the document by one screen length.
- Ctrl b -
This will page up the document by one screen length.
- This will move the cursor to the end (bottom) of the document
- This will move the cursor to the top of the document