Linux IntroductionLecturer: Võ Tấn Dũng votandung@yahoo.com http://sites.google.com/site/votandungsg/ Information Technology College of HoChiMinh city Faculty of Information Technology
Trang 1Linux Introduction
Lecturer: Võ Tấn Dũng
votandung@yahoo.com http://sites.google.com/site/votandungsg/
Information Technology College of HoChiMinh city
Faculty of Information Technology
Course: Fundamentals of Linux OS
Unit 1
Trang 2Before Linux
• In 80’s, Microsoft’s DOS was the dominated OS for PC
• Apple MAC was better, but expensive
• UNIX was much better, but much, much more expensive
Only for minicomputer for commercial applications
• People was looking for a UNIX based system, which is
cheaper and can run on PC
• Both DOS, MAC and UNIX were proprietary, i.e., the source code of their kernel is protected
• No modification is possible without paying high license fees
Trang 3What is Unix?
• A multi-task and multi-user Operating System
• Developed in 1969 at AT&T’s Bell Labs by
– Ken Thompson (Unix)
– Dennis Ritchie (C)
– Douglas Mcllroy (Pipes)
• Some other variants: System V, Solaris, SCO Unix, SunOS,
4.4BSD, FreeBSD, NetBSD, OpenBSD, BSDI,…
VÕ TẤN DŨNG
Trang 4Beginning of Linux
Minix , a simplified version of UNIX that runs on PC
commercial use
Computer Science at the University of Helsinki,
developed the preliminary kernel of Linux, known as
Linux version 0.0.1
Trang 5After that…
–Soon more than a hundred people joined the Linux camp
Then thousands Then hundreds of thousands
–It was licensed under GNU General Public License, thus
ensuring that the source codes will be free for all to copy,
study and to change
–Linux has been used for many computing platforms: PC,
PDA, Supercomputer,…
–Not only character user interface but graphical user interface
is available
–Commercial vendors moved in Linux itself to provide freely
distributed code They make their money by compiling up
various software and gathering them in a distributable format
VÕ TẤN DŨNG
Trang 6• Many Linux Distributions
– Slackware (one of the oldest, simple and stable distro.)
– Redhat
• RHEL (commercially support)
• Fedora (free)
– CentOS (free RHEL, based in England)
– SuSe ( based in German)
– Gentoo (Source code based)
– Debian (one of the few called GNU/Linux)
– Ubuntu (based in South Africa)
– Knoppix (first LiveCD distro.)
– And now, ANDROID of Google
Linux Today
Trang 7 Shell interprets the command and
request service from kernel
Similar to DOS but DOS has only
one set of interface while Linux
can select different shell
– Bourne shell (bash)
– Korn shell
– C shell
Different shell has similar but different functionality
Bash is the default for Linux
Graphical user interface of Linux is in fact an application
program work on the shell
Variety of Linux Shell
VÕ TẤN DŨNG
Trang 8The File System
– Linux supports many file-systems: ext, ext2, ext3, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs,
affs,…
– Common Linux Subdirectories:
Trang 9Some important directories
– The starting point (/) is called the root directory
– /usr: contains executable commands, system administration utilities, and library routines
– /etc: contains system configuration files
– /home: contains the user‘s home directory
– /dev: contains files which are pointers to device names
– /root : the root user's home directory
– /bin : important Linux commands available to the average user
– /boot : the files necessary for the system to boot
– /lib : contains system libraries
– /mnt : contains mount points When you temporarily load the contents
of a CD-ROM, USB drive or a HDD partition, you typically use a
special name under /mnt
– /sbin : contains essential commands that are only for the system
administrator
VÕ TẤN DŨNG
Trang 10Log in your Linux system
– You must have a user account on the system to log in The user
account is defined in the /etc/passwd file
– The “root” account is the system administration account
– File /etc/passwd : each entry in this file is made up of seven fields
separated by a colon
– Placeholder, that is /etc/shadow file, it maintains the field for
the password The /etc/shadow file contains encrypted
passwords
– These two files can only be read by the system administrator
– Example: #cat /etc/passwd OR #cat /etc/shadow
Trang 11Log in, log out
• Start up your computer, then type in your username and
password:
– login: (type in your username here)
– password: (type in your password here)
• If you want to log out your Linux current session, using exit
command or key-combination <Ctrl-D>:
– exit
– <ctrl-D>
VÕ TẤN DŨNG
Trang 12• Using passwd command for changing the user password
$ passwd Changing password for cis1
Old password:
New password:
Retype new password:
Hashed database not in use, only /etc/passwd text file updated
$
Changing User Password
Trang 13• whoami , tells you who is currently logging in to a
terminal
$ whoami user1
$
• To see more details about the user who is currently
Trang 14• The who command, will tell you who are log-in right now
jlp tty0 sep 20 10:05
you tty2 sep 22 10:34
Current log-in users
[root@redhat9 tmpdocs]#
host name
If # , that means user root If $ , that means regular user (not user root)
Trang 15• hostname command displays the name of the host
computer you have logged into
$hostname
redhat9
$
Viewing hostname
• To change the host name:
$hostname <type in a new name here>
VÕ TẤN DŨNG
Trang 16Shutdown your Linux system
– Some CLI commands to shutdown your Linux: halt, poweroff,
reboot, shutdown, init 0
Examples:
#shutdown -r 5 “It will be rebooted in 5 minutes!”
#shutdown -h 3 “Your system will be turned off in 3 minutes“
Trang 17Using runlevel
– A runlevel is a mode of operation of the Linux OS, that
provides a particular set of services
– File : /etc/inittab
– Using init command to switch between levels
VÕ TẤN DŨNG
Trang 18Displaying Man Pages
commands
Command Format
man <name-of-a-command>
$ man cd
Reformatting page Wait done
CD(1) NAME
cd, chdir, pushd, popd, dirs - change working directory SYNOPSIS
Example:
Trang 19VÕ TẤN DŨNG
Scrolling in Man Pages
while using the man command:
Trang 20Command-Line Syntax
The general format for Linux commands is:
#command [option (s)] [argument[s]]
At the shell prompt, you can type commands
Commands are instructions which tell the system to
perform an action
Trang 21VÕ TẤN DŨNG
Command-Line Syntax (cont.)
Examples:
ls -a -l /etc/mydir useradd -u 503 -g sales alan mkdir -p /mnt/ docs/xls/priv
cp -i sales.doc /mydoc cat /mnt/ploppydisk/baitap.txt head -6 /usr/dict/words
tar -xvf /home/backup.tar
Trang 22Some Linux’s commands
mkdir – make directories
ls – list directory contents
cd – changes directories
pwd print name of current working directory
cp – copy files and directories
mv – move (rename) files
rm remove files or directories
find – search for files in a directory hierarchy
history – prints recently used commands
cat – concatenate files and print on the standard output
echo – display a line of text
wc print the number of newlines, words, and bytes in files
sort – sort lines of text files
su – change user ID or become superuser
Trang 23VÕ TẤN DŨNG
Control Characters
Control characters are used to perform specific tasks such as
stopping and starting screen output When displayed on the
screen, the Control key is represented by the caret symbol (^) To enter a sequence of control characters, hold down the Control key and press the appropriate character on the keyboard
Trang 24END OF UNIT 1
• remember to do your homework
(see http://sites.google.com/site/votandungsg/)