Software Engineering 265 Lab: Week 1: Every Lab Record Your Attendance by Browsing To
Software Engineering 265 Lab: Week 1: Every Lab Record Your Attendance by Browsing To
Lab: Week 1
http://webhome.csc.uvic.ca/
~bgorman/attend/
1
2014-09
A B O U T Lab
Exercises in the use of Unix tools. Unix
Skills are important career skills.
SEng 265 of interest to Co-op employers.
What does that tell you?
Languages C and Python.
Scripting and Version control (SVN).
Understand the UNIX shell processes.
2
LINUX
Command Cheat Sheet Provided
(Connex: Seng265 tab/Lecture slides/
Lab Resources/Week01)
ls [-al] [ a means show all (including hidden
files)]
[ l means format it nicely]
--help option (Works for all linux system
commands)
Ex: ls al
ls --help
3
LINUX
mkdir <directoryname>
Makes a directory in the working directory (where
you are right now)
Make a directory called Seng265Labs in your
home dir (~) now
pwd
Shows where you are right now (your working
directory)
*Literally means print working directory
cd <directoryname>
*NOTE: . and .. can be used here
TAB COMPLETION (+double-tap)
4
LINUX
. (Dot) means here
.. (Double Dot) means go up one level (or
go out of this directory/folder)
Ex: (pwd between cd commands)
cd . [does nothing]
cd .. [Go up]
Go into your Seng265Labs directory
5
L I N U X
Side Note:
~ means users home cd ~ from
anywhere
/ means root cd root ls cd ~
You do not have permissions to make
changes above your user space.
6
L I N U X
touch <filename> [If file doesnt exist,
creates it empty careful with this
command]
In the Seng265Labs directory you created,
create a directory (mkdir) called Lab01
and go into it (cd)
Use the touch command to create a file
called thisfile
7
L I N U X
mv <filesource> <filedestination>
Moves a file from source to destination
If the source and destination are the same
directory mv will rename the file
Ex: mv thisfile thatfile [renames thisfile
to thatfile]
Ex: mv thisfile ../anotherfile
Ex: mv ../anotherfile yetanotherfile
8
L I N U X
vim <filename> [Your command-line text
editor!]
Go to where thisfile is located and open it:
vim thisfile
Vim Commands:
esc enter command mode (You start here!)
i insert (start writing)
:w write (save file)
:q quit ( :q! to force quit)
:syntax on
9
L I N U X
Edit the file thisfile in some way and save
the contents
After inserting text, press esc to enter
cmd mode
Save and quit by using :w then :q
OR
Save and quit at the same time by
using :wq
Try pico and nano and gedit
10
L I N U X
rm <filename>
rm r <directoryname> [Dangerous!
Deletes everything!]
Create a new directory called todelete
(mkdir)
Go into it (cd)
Create two files called file1 and file2
Remove file2
rm file2
Go up, out of the directory todelete
11
L I N U X
Remove the directory todelete
rm r todelete
Check what is in the Lab01 directory (ls
al)
Be careful with rm r it does not prompt
the user at all and will delete everything in
the specified directory
12
L I N U X
chmod [options] <filename/directoryname>
Options: Combine the following:
u, g, and/or o (user, group, other aka the
world)
+, -, or = (add, remove, set permissions)
r, w, x, and/or - (read, write, execute, none)
Ex: chmod u+rwx thisfile
chmod o=- thisfile
chmod g+w thisfile
13
L I N U X
Time to compile code!
Download the file test.c from the Week01
folder on Connex
Move it to your Lab01 directory
(Depending on browser, it might be in ~/
Downloads/)
In this case, the command looks like this:
mv ~/Downloads/test.c .
Assumes you are in Lab01
Yay! We used .
14
L I N U X
The test.c file should be in your Lab01
directory. Go to it.
Compile by using the command
gcc test.c
Check to see that the class file was
created
ls al (there should be an a.out file)
Run the program
./a.out you will often forget the ./
15
L I N U X
SSH into other machines
ssh <user>@<host>
Ex:
ssh <userid>@a<your machine
name>.seng.uvic.ca
use the cmd exit to close the session
16
DONE
17