Title: Welcome to Linux
1Welcome to Linux
- A quick overview of some ideas and commands of
most frequent use to programmers using Linux
2Two interface options
- The modern graphical desktop interface
- Objects are represented as colorful icons
- Users operate mainly by clicking the mouse
- Its intuitive (like Macintosh or Windows)
- The legacy command-line interface
- Objects are accessed by their file-names
- Users operate by typing in commands
- Its flexible and powerful, but demands
knowledge!
3Toggle between interfaces
- If your workstation is configured for the
Graphical Desktop Interface by default (also
known as runlevel 5), it is easy to switch to
the Command-Line Interface by typing a
keystroke-combination - ltCNTRLgtltALTgt-Fn (for n 1, 2, ..., 6)
- You can return to your Graphical Desktop by
typing ltALTgt-F7
4All Linuxs objects are files
- All ordinary files are sequences of bytes
- Some store data, others store programs
- Also there are some special files (such as
directories, device-files, and pseudo-files) - Each file has a unique name
- Each file has a specific owner
- Each file has a set of access permissions
5File permissions
Owner
Group
All
r
w
x
r
w
x
w
w
x
Legend r read access
(1 yes, 0 no) w write access (1 yes, 0
no) x execute access (1 yes, 0 no)
Bitmap-example 110-100-100 Octal
representation 0644 ASCII-representation
rw-r--r--
6Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
Linux organizes its hundreds of thousands of
files into a tree-like hierarchy.
For a current Linux installation (such as Fedora
Core 5), the topmost directory (named
/) will typically contain only about two-dozen
sub-directories.
7Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/root
/parr
/brooks
/cruse
superuser
The /home directory contains a sub-directory
for each authorized user.
8Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/System.map
/vmlinuz
/grub
compressed kernel
The /boot directory contains the files and
directories that are needed to select, load,
decompress, and begin executing the Linux kernel
9Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/X11
/hosts
/fstab
/inittab
The /etc directory stores files concerned with
the systems configuration-options.
10Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/mkdir
/chown
/kill
The /bin directory contains about a hundred of
the most necessary and basic binary-executables
(such as the programs which implement the minimal
set of commands you need for system-recovery in
the unlikely event of a crash ).
11Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/local
/lib
/src
/include
/bin
The /usr directory contains about a dozen
sub-directories which organize the vast majority
of the various kinds files needed for a useful
work-environment. Together these sub-directories
contain tens of thousands of files and programs.
12Directory Tree
/
/var
/usr
/etc
/bin
/boot
/home
/lock
/log
/spool
The /var directory contains about two-dozen
sub-directories that pertain to various
value-added resourses (such as system log-files
or users email).
13Unique filenames
- To give each file a name thats unique, the
directory-tree hierarchy is utilized
/
/home
/brooks
/cruse
/hello
/hello
/home/cruse/hello
/home/brooks/hello
14The online manual
- Linux offers online documentation for all of its
commands (and for its library functions) - You type man ltcommand-namegt to view the
relevant page of this online manual - Example man ls view ls options
- Some commands have numerous options that are
explained (but seldom illustrated)
15Command-usage examples ls
- The LiSt command ls
- ls files in present working directory
- ls / files in the topmost (root) directory
- ls files in YOUR home-directory
- ls l files with their attributes
- ls a files (all including the hidden
ones) - ls .c files having the .c filename-suffix
- ls files in every immediate sub-directory
- ls .. files in the parent-directory
- ls my files whose names begin with my
16My own top-30 commands
- cd Change Directory
- cp CoPy file (or files)
- mv MoVe file (or files)
- rm ReMove file (or files)
- rename RENAME a file (or files)
- who who else is using station
- mkdir MaKe a new DIRectory
- rmdir ReMove DIRectory
17My top-30 (continued)
- scp Secure CoPy
- ssh Secure Shell
- lpr Line-Printer
- cat conCATenate file(s)
- grep global reg-expr printer
- uname -r shows kernel-release
- ln s creates a soft link
18My top-30 (continued)
- vi VIsually edit a text file
- gcc Gnu C Compiler
- g Gnu C compiler
- as Assembler
- ld Linker
- make compile-and-link script
- objdump -d disassemble program
19My top-30 (continued)
- tar uncompresses a file
- diff compares two textfiles
- exit terminates a user-session
- time time a programs execution
- chmod change files access-mode
- su Substitute User
- more view textfile page-at-a-time
20Recommend keeping a journal
- Some notes I find useful for reference
- For extracting a new Linux kernel release
- tar xvf linux-2.6.16.6.tar
- For combining several files of a new project
- tar cvf linux-2.6.16.6.tar
21Some practice exercises
- Switch from your Graphical Desktop to a Text-Mode
Console Interface (6 choices) - Switch from one text-console to another
- Login to that console
- Type the ls command
- Log out from that console
- Return to your Graphical Desktop
22Some exploration exercises
- Use cat to look at one of the hidden files in
your own home directory, like this - cat .bash_history
- Use ls to look at the names of all the files in
your own Desktop directory, like this - ls -a Desktop
- Use cd to change your current directory to the
root directory, like this - cd /
23An advanced exercise
- Create a subdirectory named bin in your own
home directory, like this - cd is your home-directory
- mkdir bin creates bin sub-directory
- Copy a program-file from a class-website, then
compile it, move the executable into your /bin
subdirectory, and finally execute it, like this - cp /home/web/cruse/cs630/dump.cpp .
- g dump.cpp -o dump
- mv dump bin
- dump dump.cpp