sg/~cs101
0/
UNIT 1
Computing Fundamentals
NUS
Unit1 - 2
NUS
Unit1 - 3
Hardware
Monitor
and
speaker
(output)
Houses processor,
memory, buses, etc.
Software
Keyboard and
mouse (input)
Set of instructions
to perform tasks to
specifications
Programs are
software
http://www.tutorialspoint.com/computer_fundamentals/computer_quick_guide.htm
NUS
Unit1 - 4
(Computer) Program
Sequence
execute
Programming languages
Languages
Software
NUS
Unit1 - 5
Types of Programs
Machine code
Assembly code
Requires translation
High-level
language program
NUS
Translation of Programs
Unit1 - 6
NUS
Unit1 - 7
Edit
Compile
Execute
Use a compiler
to translate the
source code
into executable
Execute/run the
executable
code
Process is iterative
NUS
Unit1 - 8
NUS
Unit1 - 9
NUS
Unit1 - 10
sunfire UNIX
server
or
SSH/Xshell are programs to
allow users to access a remote
host over a network.
To download SSH for your home
use, go to http
://www.comp.nus.edu.sg/~
cs1010/2_resources/online.html
CS1020
Intro Workshop - 10
NUS
Unit1 - 11
or
NUS
Unit1 - 12
or
NUS
Unit1 - 13
or
NUS
Unit1 - 14
NUS
Unit1 - 15
You may change the settings in SSH (eg: font size, background
colour, text colour, etc.)
NUS
Unit1 - 16
NUS
Unit1 - 17
/home/h/happytan
NUS
Unit1 - 18
NUS
Unit1 - 19
2. source .bashrc
do this only
ONCE.
NUS
Unit1 - 20
NUS
Unit1 - 21
Directory Description
command
File
Description
command
pwd
cp
CoPy file
mv
rm
ReMove file
cat
ls
Print Working
Directory
LiSt files in current
directory
cd
Change Directory
mkdir
MaKe a subDIRectory
rmdir
ReMove an empty
subDIRectory
NUS
Unit1 - 22
Command options
Many UNIX commands come with options, preceded by -
happytan@sunfire [] ~ $ ls
c
happytan@sunfire [] ~ $ ls -F
/c
happytan@sunfire [] ~ $ ls -l
drwx-----2 happytan soc06
happytan@sunfire [] ~ $ ls -a
.
..
.bashrc
.vimrc
happytan@sunfire [] ~ $ ls al
drwx-----3 happytan soc06
drwxr-xr-x 215 happytan root
-rwx-----1 happytan soc06
-rwx-----1 happytan soc06
drwx-----2 happytan soc06
4096
Jun 27 12:58 c
-a displays hidden files (files
beginning with . in their names)
c
4096
8192
434
237
4096
Jun
Jun
Jun
Jun
Jun
30
13
27
27
27
08:45
12:58
12:45
12:45
12:58
.
..
.bashrc
.vimrc
c
NUS
Unit1 - 23
Filename auto-filling
Provides auto-filling of filenames, handy for very long
filenames
Press <tab> for system to fill out the rest of the filename (as
much as it can)
happytan@sunfire
[] ~ $ cd c
happytan@sunfire [] ~/c $ ls
example1.c
example2.c
example3.c
happytan@sunfire [] ~/c $ cat e press <spacebar> after typing e and
observe
System managed to fill filename up to example and stopped,
because there are 3 filenames that begin with example. Type
1, 2, or 3 and press <tab> for system to fill the whole
filename, then press <enter>.
NUS
Unit1 - 24
produces
Execute
Source code
first.c
Compile
Edit
NUS
Unit1 - 25
Edit
Compile
NUS
Edit
Compile
Unit1 - 26
Execute
NUS
Unit1 - 27
Edit
Compile
Compiler
eg: gcc first.c
produces
Executable code
a.out
NUS
Unit1 - 28
Edit
Compile
Execute
Two approaches:
1. Rename a.out after compilation
2. Indicate the desired name of the executable file during
compilation
NUS
Unit1 - 29
Edit
Compile
[]
[]
[]
[]
[]
[]
~/c
~/c
~/c
~/c
~/c
~/c
$
$
$
$
$
$
Execute
gcc Wall -lm example1.c
mv a.out example1
Executable files are
gcc Wall example2.c
mv a.out example2
named example1,
gcc Wall example3.c
example2, example3.
mv a.out example3
NUS
Unit1 - 30
Executing C programs
Edit
Execute
3.61
Source code
produces
Compile
eg: gcc first.c
Execute
eg: a.out
first.c
Executable code
produces
produces
Compile
a.out
Program output
The value of c is 3.
NUS
Unit1 - 31
NUS
Unit1 - 32
NUS
Unit1 - 33
NUS
Unit1 - 34
NUS
Unit1 - 35
NUS
Unit1 - 36
Introductory Workshop
http://www.comp.nus.edu.sg/~cs1010/labs/2016s1/intro_lab/gettingStarted.html)
Objective:
NUS
Unit1 - 37
Summary
NUS
End of File
Unit1 - 38