HOWTO
Use Various Commands in Unix/Linux
1. Listing Files
To list the contents of a directory, use ls:
callisto ~> ls
a.out* distance.o hw2.c hw5.c*
ascii.c examples/ hw2.o* mail/
ascii.o* hw1.c hw3.c multiple.c
distance.c hw1.o* hw4.c multiple.o*
callisto ~>
Note: The * indicates an executable file.
The / indicates a directory.
2. Copying Files
To copy a file from one place to another:
cp [source-file] [target-file]
callisto ~> cp hw1.c hw3.c
callisto ~>
You now made a copy of hw1.c, which is called hw3.c.
3. Moving Files
3. To move a file:
mv [source-file] [target-file]
callisto ~> mv hw1.c hw3.c
callisto ~>
Now, hw1.c no longer exists. It is now called hw3.c. Be careful!
4. Deleting Files
To delete a file:
rm [filename]
callisto ~> rm hw1.bad
rm: remove hw1.bad (yes/no)? yes
callisto ~>
Now, hw1.bad no longer exists. Be VERY careful!!!
5. Manual (man) Pages
To learn about other commands, use the man(ual) pages:
callisto: ~> man nano
will tell you more than you ever wanted to know about nano...
To exit the man page, type 'q'.
6. Examining Files
Using "more" or "less" allows you to look at files:
callisto ~> more distance.c
/* ------------------------------------------------------------ */
/* Program Example -- Distance */
/* */
/* This program computes the distance between two points. */
/* ------------------------------------------------------------ */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare and initialize variables */
double x1 = 1, y1 = 5, x2 = 4, y2 = 7;
double side_1, side_2, distance;
/* Compute the sides of the triangle */
side_1 = x2 - x1;
side_2 = y2 - y1;
distance = sqrt(side_1*side_1 + side_2*side_2);
/* Print the distance */
--More--(77%)
(Hit space bar to continue)
"more" will only allow you to look forwards in a file (not
backwards)--use the space bar to do so. Using "less", you can
look both backward and forward by using the "Page Up" and "Page Down"
keys, as well as the "Up Arrow" and "Down Arrow" keys to move backward
or forward one line at a time. Type 'q' to exit when using "less"./* ------------------------------------------------------------ */
/* Program Example -- Distance */
/* */
/* This program computes the distance between two points. */
/* ------------------------------------------------------------ */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare and initialize variables */
double x1 = 1, y1 = 5, x2 = 4, y2 = 7;
double side_1, side_2, distance;
/* Compute the sides of the triangle */
side_1 = x2 - x1;
side_2 = y2 - y1;
distance = sqrt(side_1*side_1 + side_2*side_2);
/* Print the distance */
--More--(77%)
(Hit space bar to continue)
7. Piping the Output of One Command into the Input of Another Command
You can pipe the output of one command to another using "|"
callisto
~> deg_to_rad.o | more
Degrees to
Radians
0 0.000000
10 0.174533
20 0.349066
30 0.523599
40 0.698132
50 0.872665
60 1.047198
70 1.221731
80 1.396264
90 1.570796
100 1.745329
110 1.919862
120 2.094395
130 2.268928
140 2.443461
150 2.617994
160 2.792527
170 2.967060
180 3.141593
190 3.316126
200 3.490659
--More--
0 0.000000
10 0.174533
20 0.349066
30 0.523599
40 0.698132
50 0.872665
60 1.047198
70 1.221731
80 1.396264
90 1.570796
100 1.745329
110 1.919862
120 2.094395
130 2.268928
140 2.443461
150 2.617994
160 2.792527
170 2.967060
180 3.141593
190 3.316126
200 3.490659
--More--


