Unix/Linux alapok - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Unix/Linux alapok

Description:

Title: Unix/Linux alapok Author: hallgato Last modified by: hallgato Created Date: 1/1/1601 12:00:00 AM Document presentation format: Egy ni Other titles – PowerPoint PPT presentation

Number of Views:159
Avg rating:3.0/5.0
Slides: 42
Provided by: hallg150
Category:

less

Transcript and Presenter's Notes

Title: Unix/Linux alapok


1
Unix/Linux basics
Operating systems lab Gergely Windisch
2
Unix
  • It was created around the 70s for mini
    computers. It has spread to the mainframes,
    workstations and then to personal computers
  • Simplicity was always an aim
  • The kernel was written in C (almost from the
    beginning) -gt new
  • The many flavors of Unix and the incompatiblity
    that came with it is still around
  • Multiple unix versions good, because competition
    enhances ?? there is no one accepted solution
    (incompatiblity)
  • Standardization work, multiple standards (the
    important is what, not how)
  • Commercially avalable Unix versions Sun/Solaris,
    HP/HP-UX, IBM/AIX
  • Interesting Mac OS X (BSD based)
  • Multiuser, multitask operting system

3
A Linux
  • Born in 1991 Linus Torvalds x86
  • Started life as a terminal app for minix
  • Nowdays an alternative to Unix and Windows
    systems
  • Linux is not Unix, but similar
  • Unix like in appearance and programming API,
    different under the hood
  • The kernel is not held by one company but is
    developed by the community (with centralized
    management - Linus)
  • The code base is developed by the community
  • Wide spectrum of supported hardware architectures
  • There are some pioneer solutions, but there are
    also some weak spots compared to the big Unix
    versions (thread management in the 2.4 kernels
    for example)

4
Linux - distributions
  • Linux distributions
  • A Linux distribution (also called GNU/Linux by
    some vendors and users) is a member of the family
    of Unix-like software distributions built on top
    of the Linux kernel. Such distributions (often
    called distros for short) consist of a large
    collection of software applications such as word
    processors, spreadsheets, media players and
    database applications. The operating system will
    consist of the Linux kernel and, usually, a set
    of libraries and utilities from the GNU project,
    with graphics support from the X Window System.
    - Wikipedia
  • http//upload.wikimedia.org/wikipedia/commons/8/8c
    /Gldt.svg

5
Linux distros (contd)
  • Even more colorful than unix
  • free and commercial as well
  • Most important commercial versions RedHat and
    Suse
  • Free versions Debian and co. (debian based),
    Fedora (RedHat based) and openSuse
  • Live CD try without installation
  • Knoppix http//www.knoppix.org/ (Debian
    GNU/Linux)
  • Demolinux http//www.demolinux.org/ (Mandrake)
  • More at
  • http//en.wikipedia.org/wiki/Live_CD

6
Useful links
  • http//www.hup.hu Hungarian Unix Portal
  • Only in hungarian ? for those of you who are
    interesten in the language
  • http//www.kernel.org Place of the linux kernel
  • http//www.distrowatch.com home of practically
    all the distributions

7
Where can I practice?
  • Downloading linux
  • www.ubuntu.com, www.debian.org,
    www.slackware.com, www.suse.de, en.opensuse.org,
    www.distrowatch.com
  • VMWARE pre-built imageshttp//www.vmware.com/vmt
    n/appliances/directory/cat/45

8
Where can I get help?
  • Everywhere!
  • The Hungarian Unix Portalhttp//hup.hu (again,
    for the eager minded)
  • Linux Knowledge Base and Tutorial
    http//www.linux-tutorial.info
  • http//en.wikipedia.org/wiki/Linux
  • Linux Shell Scripting Tutorialhttp//www.freeos.
    com/guides/lsst/
  • http//www.google.com

9
The graphical world
  • Distributions
  • RedHat (www.redhat.com)
  • Ubuntu (www.ubuntu.com)
  • Debian (www.debian.org)
  • Slackware (www.slackware.com)
  • Mandriva (www.mandriva.com)
  • Suse (opensuse.org)
  • Lets look at some of them

10
Linux basics
  • Linux is like Unix API and the command line is
    unix compatible
  • As far as we get into the subject, all the
    distros are the same
  • Makes no difference which one we install

11
Linux basics (contd)
  • Multiuser we do not rule the whole machine
    just one session (many concurrent users)
  • Authentication before being able to do anything
    user password
  • System access is restricted we can only modify
    those to which we have the permissions
  • Simple users cannot change (break) the system
    (for that would affect others)!

12
  • Because of the multiuser environment, linux is
    somewhat different to other pc operating systems
    one machine, multiple terminals. Still apparent
    today virtual console
  • Text based mode (shell) and graphical interface
    (X)
  • GUI is spreading like mushroom after the rainy
    season - but the main interface for setting the
    system up is still the console.
  • Terminal access via TCP/IP, earlier it was via
    RS-232 (serial port)
  • In a PC based desktop solution the machine and
    the view isnt separated, however it is still
    separated underneath (modularity)

13
Root user
  • Every OS needs a superuser who can access
    everything, set things up
  • In Unix, the role is called root. Root has total
    control over the machine
  • There can only be one root, its task cannot be
    given to multiple users
  • Possible solutions
  • sudo, RBAC (hasnt really caught on)
  • Security Enhanced Linux

14
Lets start linux!
  • VMWare workstation
  • Ubuntu8.10, XUbuntu8.10, Ubuntu 8.10 Server
  • Credentials
  • hallgato / nik119
  • Take a good look around the system
  • Try programs like gimp, openoffice, kate, xcalc,
    gmplayer, firefox etc.
  • Install software using Synaptic
  • Packages vs. source

15
Command line
  • Login can be
  • Local (console or terminal)
  • Remote telnet, ssh, putty (Windows ssh client)
  • On-Line help man reference, not a tutorial?
    practice, practice, practice
  • user
  • hallgatonik119
  • Commands
  • who am i
  • uname -a
  • ls
  • ls /
  • man ls

16
Take a look around!
  • Ubuntu 8.10 tty1
  • Last login When did we log in last
  • 2.6.27-2-386 current kernel
  • there can be multiple kernels on the machine
  • Ubuntu Server does not have X

17
Kernel
  • Three number versioning scheme
  • Kernel version
  • Major revision
  • Minor revision
  • Fourth number for immediate patches (2.6.8.1)
  • 1991 Linux 0.01
  • 1994 Linux 1.0
  • 1996 Linux 2.0
  • 1999 - Linux 2.2.0
  • 2001 - Linux 2.4.0
  • 2003 - Linux 2.6.0

18
Console
  • The character interface is called console (or
    terminal)
  • Virtual consoles. Switch altF1 altF6
  • Command line interpreter is BASH (shell)
  • Use tab key to complete commands
  • mortab more
  • cd /sbitab cd /sbin
  • press tab twice if nothing happens

19
Parancsok
  • man Manual reference
  • There is a manual for almost every command
  • man ls
  • ls help
  • man man
  • Commands
  • command
  • switch -
  • full name of switch --
  • eg ls -a ls --all

20
Where are we? Who are we?
  • uname -a
  • who
  • who am i (whoami)
  • w
  • last
  • ls
  • ls /

21
Directories
  • Important directories
  • / root directory
  • /etc home of the configuration files
  • /bin executable commands
  • /var files that change a lot log, spool, mail
  • /home users own directories
  • /usr/local files of installed applications

22
Könyvtárak
  • /sbin executables reserved for root
  • /boot stuff for booting
  • /root own directory of the root
  • /proc system data (dynamic)
  • cat /proc/cpuinfo (later)

23
Partitioning
  • / root
  • /home
  • Swap
  • /boot
  • /usr
  • /var

24
File basics
  • All files are byte streams
  • Files are denoted by their names
  • Filename can be quite long
  • There is no extension can contain .
  • Hierarchical structure
  • Directory separator / (and not \ !!!)

25
File alapok (2)
  • echo Hello gt apple.txt
  • ls
  • ls -l
  • cat apple.txt
  • echo Leo gtgt apple.txt
  • cat apple.txt
  • echo Hello World gt apple.txt
  • cat apple.txt

26
  • touch orange.txt
  • ls
  • ls -l
  • Joker characters
  • Denotes any number of chars
  • ? Denotes just one char

27
Tricky filenames (1)
  • echo Hallo gt apple
  • echo Welt gt appletree
  • echo Higt applewine
  • cat appletree
  • cat applewine
  • cat appleEscape character '\' --gt cat apple\

28
Tricky filenames (2)
  • echo apple gt aa
  • echo orange gt bb
  • echo fruit gt 'aa bb'
  • ls
  • cat aa bb
  • cat 'aa bb'

29
Print contents of file (1)
  • cat applewine
  • cat /bin/catWhat happened to the console?

30
Print contents of file (2)
  • cat applewine
  • cat /bin/catWhat happened to the console?cat
    should only be used for printing text files
  • /usr/bin/cat is a binary, with control codes
  • Print contents of any file od
  • od /bin/cat
  • od -c /bin/cat

31
File type
  • Extension does not always help
  • file command
  • file /usr/bin/file
  • Uses file headers
  • Try tricking it into making a mistake
  • cp /usr/bin/apt-get . (use tab!)
  • file apt-get
  • mv apt-get something.mp3
  • file something.mp3

32
File commands
  • Remove rm
  • rm apt-get
  • rm r remove recursively (subdirectories as
    well)
  • Copy cp
  • cp apple.txt orange.txt
  • ls
  • Move mv
  • mv apple.txt orange.txt
  • ls

33
Directories
  • cwd current working directory
  • pwd command returns cwd
  • own directory of user
  • echo
  • /home/user (/root) default dir to the user
  • . current directory
  • .. parent directory

34
Directories
  • Relative pathlt--gt absolute path
  • ls /etc
  • pwd
  • ls ../../etc
  • ls ..
  • ls .
  • PATH
  • echo PATH
  • ./program

35
Directories
  • Moving around
  • cd
  • cd /etc
  • cd etc
  • cd jumps to the user home directory
  • cd jumps to the user home directory
  • cd .. jumps to the parent directory
  • cd / jumps to the root directory

36
Directories
  • Create directory mkdir
  • mkdir fruit
  • touch fruit/apple
  • touch fruit/orange
  • ls -l orange
  • ls R, ls list subdirectories
  • delete directories rmdir

37
Hidden files
  • Everything that starts with '.' is hidden
  • touch orange
  • touch .orange
  • ls
  • ls a
  • orange and .orange are completely different

38
Multiple commands
  • command1 command2
  • Run command 2 after command 1
  • ls l / echo success
  • ls l /homme echo success
  • command1 command2
  • run command2 after command 1 if command 1 failed
  • ls l / echo failure
  • ls l /homme echo failure

39
Pipe, background
  • pipe
  • ls l /etc more
  • start command in background (later)?
  • command

40
Practice (for it makes perfect)
Create the following directory structure

directory1
directory2
directory3
directory4
directory41
directory21
directory11
directory12
directory22
directory111
directory23
directory112
Bonus create a shell script which creates
directories like so (creatdir directory113
directory 11 and 1 are created)
directory113
41
Practice
Create files in each directory where the name of
the file is fileltnumbergt. The ltnumbergt should be
the number of the directory (eg directory131
file131) Use touch, gt, gtgt to create files Use
TAB Use relative and full path Use your
imagination For bonus points create a shell
script that when gets a filename like this, will
create the directory and put the file in it
Write a Comment
User Comments (0)
About PowerShow.com