Using Linux
EE 599-006: Real-Time Digital Systems
Fall 2006
Introduction
• Designed to meet POSIX specification
• Graphical interface available (X11)
• We will focus on systems programming and
relevance to real-time systems
Command Line Interface
• More arcane, but more composable than GUI
• Many small, simple programs composed to to
a single task
• Most commands can get input from stdin
• Most commands can send output to stdout
• Connect processes with pipes, redirection
Filesystem Layout
• Files organized in a tree
•
•
•
•
•
Navigation and File
Manipulation
• GUI file manager
• Command line:
- cd dir
- ls [ dir ]
- cp file1 file2 ; cp file1 [ file2 ... filen ] dir
- mv file1 file2 ; mv file1 [ file2 ... filen ] dir
- rm file1 [ file2 ... filen ]
More Command-Line...
• mkdir dir
• rmdir dir
• Use <tab> for file completion
• !! # do the last command
• <up arrow>, <down arrow>
File Name Globbing
• ‘*’ matches any string
• ‘?’ matches any one character
• “[adf-m]” matches ‘a’, ‘d’, and any char. ‘f’ - ‘m’
• Examples:
- ls *.h
- ls foo.?
- ls [g-t]*.c
File Viewing/Searching
• less file1 [ ... filen ]
• egrep expr file1 [ ... filen ]
• cat file1 [ ... filen ]
• find dir -name “file” -print
Files and Permissions
• Accounts, permissions, and users
rwxr-x--- 1 dieter dieter 12 Aug 4 2002 foo
• chmod ugo file
• Network file system
• Limited root privileges with sudo
Text Editing
• GUI
• vi
• emacs
• pico
Code Development
• Text editor
• gcc opts file1.c file2.c
• make [ target ]
• man subject
GCC Example
#include <stdio.h>
int main(int argc, char *argv[]) {
printf(“Hello, world\n”);
return 0;
}
• gcc -Wall -O2 -o hello hello.c
• ./hello
Makefiles
CCFLAGS= -O2 -Wall
all: hello hello2
hello: hello.c
gcc -O2 -Wall -o hello hello.c
hello2: hello2a.o hello2b.o
gcc ${CCFLAGS} -o hello2 hello2a.o hello2b.o
Network Access
• Remote access
- ssh host
- scp user1@host1:path1 user2@host2:path2
• Windows interface
- Putty
- WinSCP
Redirecting stdin and
stdout
• Redirect stdout with ">" or ">>"
• Redirect stdin with "<"
• Redirect stdout of prog1 to stdin of prog2
with "prog1 | prog2"
• find . -name “*.h” -print | egrep “hello”