4921662 Introduction to Linux 2
-
Upload
nadiir-adan -
Category
Documents
-
view
216 -
download
0
Transcript of 4921662 Introduction to Linux 2
-
8/6/2019 4921662 Introduction to Linux 2
1/29
Introduction to Linux
Lei Zhang
UCLA Linux Users Group
http://linux.ucla.edu/~leiz/linuxintro.ppt
-
8/6/2019 4921662 Introduction to Linux 2
2/29
What is Linux?
UNIX-like Operating System
Developed by Finnish computer science
student Linus Torvalds as an OS project in
1991.
Made available on the net and has beendeveloped ever since
-
8/6/2019 4921662 Introduction to Linux 2
3/29
Why Use Linux?
Multi-Tasking / Multi-User
Stability / Reliability
Portable
Comes with a complete development
enviroment (C, C++, Fortran, Java, Perl,Python, etc...)
-
8/6/2019 4921662 Introduction to Linux 2
4/29
Why Use Linux?
It's Free Software
Free as in beer
Free as in speech
It's Open Source
You can see the source code
You can modify the source code
-
8/6/2019 4921662 Introduction to Linux 2
5/29
Users in Linux
Every User has:
username, group(s), password, home
directory Root User vs Regular User
Root == Administrator == God
Use sparingly, only when necessary Remember, it's your bed, don't Sh** in it
Regular Users
Limited privileges
-
8/6/2019 4921662 Introduction to Linux 2
6/29
Home Dir and Path
Home Directory
Location of user files
Start point when logging in
Path
Used to search for commands
Colon separated
e.g. /usr/bin:/bin:/usr/X11R6/bin
-
8/6/2019 4921662 Introduction to Linux 2
7/29
The filesystem (fs)
Linux supports many filesystems
Native fs (ext2, ext3, reiserfs, etc)
UNIX permissions, links, special devices
Microsoft fs (fat, ntfs)
Read/write support for fat, readonly for ntfs
Network fs (nfs, smb, afs, etc) Support for accessing files on other computers
-
8/6/2019 4921662 Introduction to Linux 2
8/29
Structure of fs
The fs is conceptualised as a tree
/ is the root directory and everything is a
subdirectory of it branching downwards
Other drives are attached to the tree
No C drive
Attach other filesystem using the mount and
umount command
umount is the unmount command, not a typo
Normally only root can (un)mount
-
8/6/2019 4921662 Introduction to Linux 2
9/29
Tree Structure/
/bin
/boot
/dev
/etc
/home/lib
/mnt
/opt
/proc
/root
/sbin
/tmp
/usr
/usr/bin
/usr/lib
/usr/sbin/var
root directory
essential user programs
kernels and boot loader
device files
configuration files
home directories essential libraries and kernel modules
mount point for other filesystems
addon (optional) software
system internals
the root user's home directory
essential system binaries
temporary files
user programs (not as essential)
| similar hierachy to root dir
various other files (lo s, mail, etc)
-
8/6/2019 4921662 Introduction to Linux 2
10/29
Types of files
Everything is a file!
Ordinary files - text, data or programs
Directories - contain other files/directories
Links - pointers to other files
Special filesDevices - represent hardware (e.g. /dev/fd0)
Others - pipes, sockets
-
8/6/2019 4921662 Introduction to Linux 2
11/29
The Linux User Interface
Command line interface (CLI)
Command line type commands at a prompt
Can be more flexible / powerful
Graphical user interface (GUI)
Point and click windows interface
Familiar / easy to use
-
8/6/2019 4921662 Introduction to Linux 2
12/29
The GUI X Window System
underlying graphics system
Desktop Environments (the actual GUI)e.g. KDE, GNOME
Useful Apps
Konsole runs a shell (the CLI)
OpenOffice wordprocessor/spreadsheet
Mozilla Web Browser
Gaim AIM / MSN / Yahoo IM client
-
8/6/2019 4921662 Introduction to Linux 2
13/29
The Shell (CLI)
Command Interpreter
Runs programs on the user's behalf
varieties csh, tcsh, bash, zsh, etc
Bash is the most popular
The prompt e.g.user@computer:/current_dir$
-
8/6/2019 4921662 Introduction to Linux 2
14/29
Command Line Cycle
Display Prompt
User types command and enter
Shell executes the command
-
8/6/2019 4921662 Introduction to Linux 2
15/29
Getting Help (The Manual)
Man command
man sections:
e.g. man 3 printf
n. New
8. System Management7. Miscellaneous
6. Games5. File Format + conversion
4. Devices3. Library Calls
2. System Calls1. User Commands
-
8/6/2019 4921662 Introduction to Linux 2
16/29
ls output
Permissions
links
owner
owners group
size of file/dir date of last modification
name of file/dir
-
8/6/2019 4921662 Introduction to Linux 2
17/29
Permissions
Multi-user OS needs access mechanism for
files
Each file/dir has permissions for its owner,
its owners group and everyone else on the
system (u,g,o)
The permissions are for the ability to read,
write and execute a file/dir
-
8/6/2019 4921662 Introduction to Linux 2
18/29
RWX
Output of ls -l
if permission is on a letter appears if it is off
there will be a minus sign (-)
first one is - for a file or d for dir
next 3 are the users perms next 3 are the groups perms
last 3 are everyone else's perms
-
8/6/2019 4921662 Introduction to Linux 2
19/29
Examples of permissions
-rw-r--r-- foo
dr-xr-xr-x bar
-rwxr-xr-- prog.c
lrwxrwxrwx prog
-
8/6/2019 4921662 Introduction to Linux 2
20/29
Changing permissions
Chmod command - has 2 modes
number (convert bits to decimal number)
directly set the permission read = 4, write = 2, execute = 1
e.g. 750 is equivalent to rwxr-x---
add/remove perms: {a,u,g,o} {+,-} {r,w,x}
chmod permission
e.g. chmod a+x foo
e.g. chmod 644 bar
-
8/6/2019 4921662 Introduction to Linux 2
21/29
Navigation
Absolute - full pathnames (/)
Relative - pathnames relative to were you
are in the fs (. .. ~)
Shortcuts
. is current directory
.. is the parent of current directory
~ is your home directory
-
8/6/2019 4921662 Introduction to Linux 2
22/29
Wildcards and Filename
completion The wildcard character is * and matches
zero or more characters.
*.txt = all files that end in .txta* = all files that start with the letter a
d*.c = all files that start with d and have .c at
the end Filename completion - type first few
characters of a file/command and press tab,the shell will fill in the rest
-
8/6/2019 4921662 Introduction to Linux 2
23/29
Basic commands
cd change directory
e.g. cd /usr/bin
cp copy files e.g. cp ~/cs111/source.c /mnt/floppy
mv move files
e.g. mv /tmp/mystuff/* ../somewhere rm remove files
e.g. rm ee115c/hwk*
mkdir, rmdir make and remove directories
-
8/6/2019 4921662 Introduction to Linux 2
24/29
Standard input/output
3 special file handles for input/output of
programs
standard input (stdin) file handle 0
standard output (stdout) - file handle 1
standard error (stderr) - file handle 2
By default for programs:
stdout and stderr are the screen
stdin is the keyboard
-
8/6/2019 4921662 Introduction to Linux 2
25/29
Pipes
The pipe character is: |
The output of the command on the left of
the pipe becomes the input to the command
on the right
ls | wc -l output of ls as input to wc
Can create complex commands to perform
difficult tasks
-
8/6/2019 4921662 Introduction to Linux 2
26/29
Processes
ps command lists processes on the system
e.g. ps auwx shows all processes running on
the system at the time
Processes can be killed
Using the kill command
You must be owner of process, or root
e.g. kill 500 will kill process #500
Can also be used to send processes signals
-
8/6/2019 4921662 Introduction to Linux 2
27/29
Compiling Programs gcc GNU C Compiler
Simple compiler usage
gcc o hello hello.c
Compile only
gcc c hello.c
gcc c functions.c
Link files together gcc o newhello hello.o functions.o
Run the program
./hello
-
8/6/2019 4921662 Introduction to Linux 2
28/29
Network Utils
ping - tells if a machine is on the network
e.g. ping www.ucla.edu will keep sending
packets until CTRL + C
traceroute - shows all points between
machine and machine you are looking for
e.g. traceroute www.yahoo.com shows all the
hops to yahoo
netstat - show network connections
-
8/6/2019 4921662 Introduction to Linux 2
29/29
The End
(For Now)