SlideShare a Scribd company logo
1 of 71
Welcome to Unix
Crafted by the CSUA at Berkeley
http://csua.berkeley.edu
Presented 8/29/2002
Redistribution
• The authors (nor anyone else) provides no
warranty or claim of accuracy of this
document. Use at your own risk.
• You may use this document in whole or part
according to the terms of the GPL. See
http://www.gnu.org/copyleft/gpl.html for
details.
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
What is it and where do you get it?
• An operating system used on everything
from servers to embedded systems.
• To you, probably a prompt:
~> type stuff here
• You get a temporary account when you take
a CS class. Get a (more) permanent
account from the OCF or CSUA. Or buy a
If you know only one thing,
know how to RTFM.
~>man command
• gives you help on that command.
~>apropos keyword
• tells you all man pages that contain keyword.
How to get help.
• Come to the CSUA office, 343 Soda.
• HKN is next door the CSUA.
• Go to the OCF in the MLK Heller Lounge
when someone is holding staff hours.
• Post your question to a newsgroup (like
your class newsgroup).
• Hit the man pages/web first !
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
Files and Directories:
Naming something gives you power over it.
Absolute Addressing
Addressing relative to your home dir.
Addressing relative to your current dir.
File system commands
• pwd - report your current directory
• cd <to where> - change your current directory
• ls <directory> -list contents of directory
• cp <old file> <new file> - copy
• mv <old file> <new file> - move (or rename)
• rm <file> -delete a file
• mkdir <new directory name> -make a directory
• rmdir <directory> -remove an empty directory
getting recursive
• remove a directory and its contents:
rm -r <directory>
• copy a directory and its contents:
cp -r <directory>
File permissions.
• There are 3 kinds of people in the world: you (user),
your friends (group) and everyone else (other).
• Each sort of person may or may not be able to read,
write, or execute a file.
>ls -l .forward
-rw-r--r-- 1 darin csua 23 Jan 23 2002 .forward
>ls -l .cshrc.local
-rwxr-xr-- 1 darin csua 2988 May 19 00:48
.cshrc.local*
executing
• “executing” a file means running it as a
program.
• “executing” a directory means setting your
current directory to it using cd.
Changing File Permissions
• make a file readable to your friends:
chmod g+r <filename>
• change who owns a file:
chown <user> <filename>
• change to which group the file belongs:
chgrp <group> <filename>
touch
• look at the full listing again:
>ls -l .forward
-rw-r--r-- 1 darin csua 23 Jan 23 2002
.forward
• Each file has a date stamp of when it was modified.
• Use touch to set the timestamp to the current clock.
touch <filename>
• Touch creates the file if it didn’t exist beforehand.
Symbolic Links
• use ln -s <old file> <second name> to create a
symbolic link to a file.
>ls -l .forward*
-rw-r--r-- 1 darin csua .forward
lrwxr-xr-x 1 darin csua .forward.link@
-> .forward
• The first “l” tells you that it’s a symbolic link.
• Symbolic links can be used as if it were its target.
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
what’s a shell?
• The shell is the program that
runs when you log in. It prints
the prompt and reads what you
type, invokes programs, etc.
• your window to the Unix world.
• use “chsh <new shell>” to change your shell
File Globbing
• some commands can work on many files at once:
~> rm file1 file2 file27
• Use * to match any number of unknown characters
~> rm file*
• Use ? to match one unknown character.
~> rm file?
(un)aliasing
• create shortcuts for yourself
~>alias ll “ls -la”
• Use alias with no arguments to discover
current aliases
~>alias
rm rm -i
ll ls -la
• Type “unalias rm” to remove alias.
shell variables, echo
(tcsh) ~>setenv BOB “joe”
(tcsh) ~>printenv BOB
joe
(tcsh) ~>echo $BOB
joe
PATH: a very important shell variable
>echo $PATH
/
home/d/da/darin/bin:/opt/local/bin:/opt/local/bin/pbmuti
ls:/usr/bin:/usr/sbin:/opt/SUNWspro/bin:/usr/ccs/bin:/op
t/local/X11/bin:/usr/dt/bin:/usr/openwin/bin:/opt/local/
gnu/bin:/opt/local/games/bin:/usr/ucb:./
• If a program (like ls) is in one directory found in
your path, then typing it (~>ls <enter>) will execute
it.
• Otherwise you can type the full absolute address to
finding things in your PATH.
• Type “which <command>” to find the location
of the program which would be run when you
type <command>.
• If you don’t remember if it was chgrp or
chgroup, type “ch<control-d>” to get a list of
commands that starts with ch.
• when all else fails, use “find” to find a file.
Other useful pre-defined shell variables
• HOST what computer you’re logged into
• PAGER program used display man pages
• PWD current directory
• GROUP what group you’re in
• USER your login
Shell scripts.
• If you have a bunch of commands you’d like to
automate, you can put them on separate lines of a
file. Then type “source <file>” to run the script.
• If the first line of your script looks like
#!<program name>
then you can make the script executable. When it
executes, it uses <program name> to interpret the
contents of the script.
Login scripts
• Most people have a script that executes
when they log in. It is commonly used to
set up one’s PATH and aliases.
• Ask someone to help you start your own
login script.
screen is your friend
• You can use the program “screen” to run several
shells from one window.
• create a new shell by pressing <ctrl-a> c
• switch shells by pressing <ctrl-a> <number>
• use “<ctrl-a> d” to detach a session and come back
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
Your Options
• Abstinence
(switch majors, unplug your computer)
• monogamy
(use only one computer, do not use network)
• protection
(also known as encryption)
What not to use.
• telnet, ftp, rlogin
• all your data (including your password) is
transmitted plain text over the network.
• from library machines you can use the java
ssh client from a web browser.
using ssh keys
• use “ssh-keygen” to generate a
public/private set of keys. You keep the
private key and append the public key to
authorized_keys.
• You can now log in using either your
password or the private key file.
using secure copy: scp
• copy local to remote
scp <source file> user@machine:<path>
• copy remote to local
scp user@machine:<path> <source file>
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
the program mail
• “mail”: useful for sending:
>mail darin@csua
Subject: hello
Cc:
hi there
this is a message
.
other console based options
• elm - quick and simple, easy to use, but
doesn’t handle attachments very well.
• pine - more complete. the “standard”
• mutt - most modern/complex.
accessing mail remotely
• netscape, outlook, eudora, and others can
get at your mail using POP or IMAP.
• POP takes the messages off the server to
your local computer.
• IMAP only reads headers, but leaves mail
how it is on the server. Works well if you
wish to use console based email.
• ALWAYS use SSL (encryption).
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
vi
• is an editor available on all decent Unix
systems. Developed at Berkeley.
• Has two modes: command and insert. In
insert mode you can type normally.
• Press escape to get into command mode. In
command mode each letter is a command.
hjkl ⇔ ←↓↑→
pico - the pine composer
• the simplest visual editor available on most
Unix systems.
• all possible commands displayed at bottom
of screen. (control-somethings)
• no real surprises
emacs
• Always has one major mode running,
potentially several minor modes.
• stands for editing macros - designed by and
for lisp programmers.
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
STD*
• All terminal programs have:
– standard output, which is usually your screen
– standard input, which is usually your keyboard
– standard error, which is also the screen
redirect output to a file with >
• If you type who at the prompt, you will get
a list of who is logged into the system.
• If you type who >f, a file named f will be
created and the standard output of who will
be placed in that file instead of to your
screen.
> vers >>
• By default, who >f will overwrite the file f.
• Use who >>f to append to f rather than
overwriting it.
redirecting input from a file with <
• The program sort will sort its standard
input and then print it on standard out.
• To sort the lines of file1 and display:
sort < file1
• To sort the lines of file1 and save in file2:
sort < file1 > file2
The output of one program can
be the input to another.
who | sort
• The output of who is sorted and shown on
your terminal screen.
grep
• grep shows only those lines containing its
search pattern.
• To see all lines in a file containing ‘bob’:
grep ‘bob’ < file1
The cat command
• the arguments to cat are concatenated together
and displayed on stdout. To view a file:
cat file1
• if no arguments, cat puts on stdout whatever
you type on stdin, so this does the same thing:
cat < file1
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
printers have stupid names
• The printers downstairs are named “lw274”.
• The printer in 330 is called “lw330”.
how to print a .ps file
• syntax:
lp -D<printer> <filename>
• example:
lp -Dlw330 myfile.ps
how to print a .pdf file
• convert it to .ps first!!!
• use the pdf2ps utility program.
pdf2ps input.pdf output.ps
how to print other file types
• Convert them to .ps first!!!
• The program a2ps (anything to .ps) works
most of the time.
How to check the printer’s queue.
• syntax:
lpq -P<printer_name>
• example:
lpq -Plw330
How to cancel your print job.
Type “cancel”.
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
To start a process in the
background, use “&”.
• example:
big_program > output &
• big_program will not have input!
managing jobs
• To suspend the currently active program,
use <control-z>.
• To return to the program you just
suspended, type “fg”
• To put the program you just suspended in
the background, type “bg”
To see a list of your programs
running, type “ps”.
>ps
PID TTY TIME CMD
866 pts/1 00:00:00 tcsh
872 pts/1 00:00:00 ps
use kill to end a process
>ps
PID TTY TIME CMD
866 pts/1 00:00:00 tcsh
874 pts/1 00:00:00 cat
875 pts/1 00:00:00 ps
>kill 874
[1] Terminated cat
kill -9
• If kill <PID> doesn’t end your
process, use kill -9 <PID>
Outline
I. getting help
II. the file system
III. the shell
IV. safe computer sex
V. email options
VI. and lesser editors
VII. input and output redirection
VIII.printing
IX. process management
X. X
cutting and pasting
• Highlight some text in any window.
• Hit the middle mouse button in another
window.
• The highlighted text appears.
• There is no “saving to the clipboard” step as
in Microsoft’s Windows or MacOS.
Changing your fonts.
• <control-leftclick> in xterm
• edit -->preferences --> fonts
in netscape.
Changing your window manager.
• Your ~/.xsession gets run when you
log into X windows, the last line sets which
window manager you are going to use.
• You probably want someone to set up your
X configuration for you the first time.
Using X windows at home on a
MS-Windows machine.
• You need to get a program called a program
called an “Xserver”. Exceed works well
and is free for academic use.
• You must allow X-forwarding through your
ssh client. Putty is good for this.
Unix
Unix
Unix

More Related Content

What's hot

Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Ahmed El-Arabawy
 
Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Ahmed El-Arabawy
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command LineAnuchit Chalothorn
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Ahmed El-Arabawy
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command ShellTushar B Kute
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scriptingVIKAS TIWARI
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsAhmed El-Arabawy
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Ahmed El-Arabawy
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpointbijanshr
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpAhmed El-Arabawy
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Ahmed El-Arabawy
 
Course 102: Lecture 2: Unwrapping Linux
Course 102: Lecture 2: Unwrapping Linux Course 102: Lecture 2: Unwrapping Linux
Course 102: Lecture 2: Unwrapping Linux Ahmed El-Arabawy
 
Linux: Everyting-as-a-service
Linux: Everyting-as-a-serviceLinux: Everyting-as-a-service
Linux: Everyting-as-a-serviceRohit Sansiya
 
Linux week 2
Linux week 2Linux week 2
Linux week 2Vinoth Sn
 

What's hot (20)

Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
 
Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
Linux Fundamentals
Linux FundamentalsLinux Fundamentals
Linux Fundamentals
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
 
Course 102: Lecture 2: Unwrapping Linux
Course 102: Lecture 2: Unwrapping Linux Course 102: Lecture 2: Unwrapping Linux
Course 102: Lecture 2: Unwrapping Linux
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Unix
UnixUnix
Unix
 
Linux: Everyting-as-a-service
Linux: Everyting-as-a-serviceLinux: Everyting-as-a-service
Linux: Everyting-as-a-service
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 

Viewers also liked

Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to UnixSudharsan S
 
0100 welcome
0100 welcome0100 welcome
0100 welcomevkyecc1
 
0103 navigation
0103 navigation0103 navigation
0103 navigationvkyecc1
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating SystemMahakKasliwal
 
Unix linux vmacvwindowspptx2
Unix linux vmacvwindowspptx2Unix linux vmacvwindowspptx2
Unix linux vmacvwindowspptx2Wendy Lile
 
0106 debugging
0106 debugging0106 debugging
0106 debuggingvkyecc1
 
Ait 1-1 Berkely Unix Operating System
Ait 1-1 Berkely Unix Operating SystemAit 1-1 Berkely Unix Operating System
Ait 1-1 Berkely Unix Operating SystemEmman Paolo Nuñez
 
0102 basis
0102 basis0102 basis
0102 basisvkyecc1
 
Unix operating system basics
Unix operating system basicsUnix operating system basics
Unix operating system basicsSankar Suriya
 
0105 abap programming_overview
0105 abap programming_overview0105 abap programming_overview
0105 abap programming_overviewvkyecc1
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix IntroductionAnanthi
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemWongyos Keardsri
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating SystemShivam Pandey
 

Viewers also liked (20)

Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
0100 welcome
0100 welcome0100 welcome
0100 welcome
 
0103 navigation
0103 navigation0103 navigation
0103 navigation
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Wk2 UNIX
Wk2  UNIXWk2  UNIX
Wk2 UNIX
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Unix
UnixUnix
Unix
 
Unix linux vmacvwindowspptx2
Unix linux vmacvwindowspptx2Unix linux vmacvwindowspptx2
Unix linux vmacvwindowspptx2
 
0106 debugging
0106 debugging0106 debugging
0106 debugging
 
Lab2 ppt
Lab2 pptLab2 ppt
Lab2 ppt
 
Ait 1-1 Berkely Unix Operating System
Ait 1-1 Berkely Unix Operating SystemAit 1-1 Berkely Unix Operating System
Ait 1-1 Berkely Unix Operating System
 
0102 basis
0102 basis0102 basis
0102 basis
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
Unix operating system basics
Unix operating system basicsUnix operating system basics
Unix operating system basics
 
0105 abap programming_overview
0105 abap programming_overview0105 abap programming_overview
0105 abap programming_overview
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating System
 
Linux Vs Unix
Linux Vs UnixLinux Vs Unix
Linux Vs Unix
 
Unix - An Introduction
Unix - An IntroductionUnix - An Introduction
Unix - An Introduction
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 

Similar to Unix

Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Chander Pandey
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxRajesh Kumar
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsQUONTRASOLUTIONS
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginnersNitesh Nayal
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O YourHelper1
 
Linux Desktop Operation - Session 1
Linux Desktop Operation - Session 1Linux Desktop Operation - Session 1
Linux Desktop Operation - Session 1Arash Foroughi
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadOnline Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadRavikumar Nandigam
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarGauravRaikar3
 

Similar to Unix (20)

redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Line
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Line
 
Linux
LinuxLinux
Linux
 
Introduction to UNIX
Introduction to UNIXIntroduction to UNIX
Introduction to UNIX
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginners
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linux Basics.pptx
Linux Basics.pptxLinux Basics.pptx
Linux Basics.pptx
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
3. intro
3. intro3. intro
3. intro
 
Linux
LinuxLinux
Linux
 
cisco
ciscocisco
cisco
 
Linux Desktop Operation - Session 1
Linux Desktop Operation - Session 1Linux Desktop Operation - Session 1
Linux Desktop Operation - Session 1
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadOnline Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in Hyderabad
 
3. introduction of centos
3. introduction of centos3. introduction of centos
3. introduction of centos
 
Unix/Linux
Unix/Linux Unix/Linux
Unix/Linux
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
 

More from Sudharsan S (20)

Xml1111
Xml1111Xml1111
Xml1111
 
Xml11
Xml11Xml11
Xml11
 
Xml plymouth
Xml plymouthXml plymouth
Xml plymouth
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
Xml
XmlXml
Xml
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
C Lecture
C LectureC Lecture
C Lecture
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
C Introduction
C IntroductionC Introduction
C Introduction
 
College1
College1College1
College1
 
C Programming
C ProgrammingC Programming
C Programming
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Preface
PrefacePreface
Preface
 
Toc Sg
Toc SgToc Sg
Toc Sg
 
Les08
Les08Les08
Les08
 
Les06
Les06Les06
Les06
 
Les07
Les07Les07
Les07
 
Les04
Les04Les04
Les04
 

Recently uploaded

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 

Recently uploaded (20)

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 

Unix

  • 1. Welcome to Unix Crafted by the CSUA at Berkeley http://csua.berkeley.edu Presented 8/29/2002
  • 2. Redistribution • The authors (nor anyone else) provides no warranty or claim of accuracy of this document. Use at your own risk. • You may use this document in whole or part according to the terms of the GPL. See http://www.gnu.org/copyleft/gpl.html for details.
  • 3. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 4. What is it and where do you get it? • An operating system used on everything from servers to embedded systems. • To you, probably a prompt: ~> type stuff here • You get a temporary account when you take a CS class. Get a (more) permanent account from the OCF or CSUA. Or buy a
  • 5. If you know only one thing, know how to RTFM. ~>man command • gives you help on that command. ~>apropos keyword • tells you all man pages that contain keyword.
  • 6. How to get help. • Come to the CSUA office, 343 Soda. • HKN is next door the CSUA. • Go to the OCF in the MLK Heller Lounge when someone is holding staff hours. • Post your question to a newsgroup (like your class newsgroup). • Hit the man pages/web first !
  • 7. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 8. Files and Directories: Naming something gives you power over it.
  • 10. Addressing relative to your home dir.
  • 11. Addressing relative to your current dir.
  • 12. File system commands • pwd - report your current directory • cd <to where> - change your current directory • ls <directory> -list contents of directory • cp <old file> <new file> - copy • mv <old file> <new file> - move (or rename) • rm <file> -delete a file • mkdir <new directory name> -make a directory • rmdir <directory> -remove an empty directory
  • 13. getting recursive • remove a directory and its contents: rm -r <directory> • copy a directory and its contents: cp -r <directory>
  • 14. File permissions. • There are 3 kinds of people in the world: you (user), your friends (group) and everyone else (other). • Each sort of person may or may not be able to read, write, or execute a file. >ls -l .forward -rw-r--r-- 1 darin csua 23 Jan 23 2002 .forward >ls -l .cshrc.local -rwxr-xr-- 1 darin csua 2988 May 19 00:48 .cshrc.local*
  • 15. executing • “executing” a file means running it as a program. • “executing” a directory means setting your current directory to it using cd.
  • 16. Changing File Permissions • make a file readable to your friends: chmod g+r <filename> • change who owns a file: chown <user> <filename> • change to which group the file belongs: chgrp <group> <filename>
  • 17. touch • look at the full listing again: >ls -l .forward -rw-r--r-- 1 darin csua 23 Jan 23 2002 .forward • Each file has a date stamp of when it was modified. • Use touch to set the timestamp to the current clock. touch <filename> • Touch creates the file if it didn’t exist beforehand.
  • 18. Symbolic Links • use ln -s <old file> <second name> to create a symbolic link to a file. >ls -l .forward* -rw-r--r-- 1 darin csua .forward lrwxr-xr-x 1 darin csua .forward.link@ -> .forward • The first “l” tells you that it’s a symbolic link. • Symbolic links can be used as if it were its target.
  • 19. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 20. what’s a shell? • The shell is the program that runs when you log in. It prints the prompt and reads what you type, invokes programs, etc. • your window to the Unix world. • use “chsh <new shell>” to change your shell
  • 21. File Globbing • some commands can work on many files at once: ~> rm file1 file2 file27 • Use * to match any number of unknown characters ~> rm file* • Use ? to match one unknown character. ~> rm file?
  • 22. (un)aliasing • create shortcuts for yourself ~>alias ll “ls -la” • Use alias with no arguments to discover current aliases ~>alias rm rm -i ll ls -la • Type “unalias rm” to remove alias.
  • 23. shell variables, echo (tcsh) ~>setenv BOB “joe” (tcsh) ~>printenv BOB joe (tcsh) ~>echo $BOB joe
  • 24. PATH: a very important shell variable >echo $PATH / home/d/da/darin/bin:/opt/local/bin:/opt/local/bin/pbmuti ls:/usr/bin:/usr/sbin:/opt/SUNWspro/bin:/usr/ccs/bin:/op t/local/X11/bin:/usr/dt/bin:/usr/openwin/bin:/opt/local/ gnu/bin:/opt/local/games/bin:/usr/ucb:./ • If a program (like ls) is in one directory found in your path, then typing it (~>ls <enter>) will execute it. • Otherwise you can type the full absolute address to
  • 25. finding things in your PATH. • Type “which <command>” to find the location of the program which would be run when you type <command>. • If you don’t remember if it was chgrp or chgroup, type “ch<control-d>” to get a list of commands that starts with ch. • when all else fails, use “find” to find a file.
  • 26. Other useful pre-defined shell variables • HOST what computer you’re logged into • PAGER program used display man pages • PWD current directory • GROUP what group you’re in • USER your login
  • 27. Shell scripts. • If you have a bunch of commands you’d like to automate, you can put them on separate lines of a file. Then type “source <file>” to run the script. • If the first line of your script looks like #!<program name> then you can make the script executable. When it executes, it uses <program name> to interpret the contents of the script.
  • 28. Login scripts • Most people have a script that executes when they log in. It is commonly used to set up one’s PATH and aliases. • Ask someone to help you start your own login script.
  • 29. screen is your friend • You can use the program “screen” to run several shells from one window. • create a new shell by pressing <ctrl-a> c • switch shells by pressing <ctrl-a> <number> • use “<ctrl-a> d” to detach a session and come back
  • 30. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 31. Your Options • Abstinence (switch majors, unplug your computer) • monogamy (use only one computer, do not use network) • protection (also known as encryption)
  • 32. What not to use. • telnet, ftp, rlogin • all your data (including your password) is transmitted plain text over the network. • from library machines you can use the java ssh client from a web browser.
  • 33. using ssh keys • use “ssh-keygen” to generate a public/private set of keys. You keep the private key and append the public key to authorized_keys. • You can now log in using either your password or the private key file.
  • 34. using secure copy: scp • copy local to remote scp <source file> user@machine:<path> • copy remote to local scp user@machine:<path> <source file>
  • 35. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 36. the program mail • “mail”: useful for sending: >mail darin@csua Subject: hello Cc: hi there this is a message .
  • 37. other console based options • elm - quick and simple, easy to use, but doesn’t handle attachments very well. • pine - more complete. the “standard” • mutt - most modern/complex.
  • 38. accessing mail remotely • netscape, outlook, eudora, and others can get at your mail using POP or IMAP. • POP takes the messages off the server to your local computer. • IMAP only reads headers, but leaves mail how it is on the server. Works well if you wish to use console based email. • ALWAYS use SSL (encryption).
  • 39. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 40. vi • is an editor available on all decent Unix systems. Developed at Berkeley. • Has two modes: command and insert. In insert mode you can type normally. • Press escape to get into command mode. In command mode each letter is a command. hjkl ⇔ ←↓↑→
  • 41. pico - the pine composer • the simplest visual editor available on most Unix systems. • all possible commands displayed at bottom of screen. (control-somethings) • no real surprises
  • 42. emacs • Always has one major mode running, potentially several minor modes. • stands for editing macros - designed by and for lisp programmers.
  • 43. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 44. STD* • All terminal programs have: – standard output, which is usually your screen – standard input, which is usually your keyboard – standard error, which is also the screen
  • 45. redirect output to a file with > • If you type who at the prompt, you will get a list of who is logged into the system. • If you type who >f, a file named f will be created and the standard output of who will be placed in that file instead of to your screen.
  • 46. > vers >> • By default, who >f will overwrite the file f. • Use who >>f to append to f rather than overwriting it.
  • 47. redirecting input from a file with < • The program sort will sort its standard input and then print it on standard out. • To sort the lines of file1 and display: sort < file1 • To sort the lines of file1 and save in file2: sort < file1 > file2
  • 48. The output of one program can be the input to another. who | sort • The output of who is sorted and shown on your terminal screen.
  • 49. grep • grep shows only those lines containing its search pattern. • To see all lines in a file containing ‘bob’: grep ‘bob’ < file1
  • 50. The cat command • the arguments to cat are concatenated together and displayed on stdout. To view a file: cat file1 • if no arguments, cat puts on stdout whatever you type on stdin, so this does the same thing: cat < file1
  • 51. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 52. printers have stupid names • The printers downstairs are named “lw274”. • The printer in 330 is called “lw330”.
  • 53. how to print a .ps file • syntax: lp -D<printer> <filename> • example: lp -Dlw330 myfile.ps
  • 54. how to print a .pdf file • convert it to .ps first!!! • use the pdf2ps utility program. pdf2ps input.pdf output.ps
  • 55. how to print other file types • Convert them to .ps first!!! • The program a2ps (anything to .ps) works most of the time.
  • 56. How to check the printer’s queue. • syntax: lpq -P<printer_name> • example: lpq -Plw330
  • 57. How to cancel your print job. Type “cancel”.
  • 58. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 59. To start a process in the background, use “&”. • example: big_program > output & • big_program will not have input!
  • 60. managing jobs • To suspend the currently active program, use <control-z>. • To return to the program you just suspended, type “fg” • To put the program you just suspended in the background, type “bg”
  • 61. To see a list of your programs running, type “ps”. >ps PID TTY TIME CMD 866 pts/1 00:00:00 tcsh 872 pts/1 00:00:00 ps
  • 62. use kill to end a process >ps PID TTY TIME CMD 866 pts/1 00:00:00 tcsh 874 pts/1 00:00:00 cat 875 pts/1 00:00:00 ps >kill 874 [1] Terminated cat
  • 63. kill -9 • If kill <PID> doesn’t end your process, use kill -9 <PID>
  • 64. Outline I. getting help II. the file system III. the shell IV. safe computer sex V. email options VI. and lesser editors VII. input and output redirection VIII.printing IX. process management X. X
  • 65. cutting and pasting • Highlight some text in any window. • Hit the middle mouse button in another window. • The highlighted text appears. • There is no “saving to the clipboard” step as in Microsoft’s Windows or MacOS.
  • 66. Changing your fonts. • <control-leftclick> in xterm • edit -->preferences --> fonts in netscape.
  • 67. Changing your window manager. • Your ~/.xsession gets run when you log into X windows, the last line sets which window manager you are going to use. • You probably want someone to set up your X configuration for you the first time.
  • 68. Using X windows at home on a MS-Windows machine. • You need to get a program called a program called an “Xserver”. Exceed works well and is free for academic use. • You must allow X-forwarding through your ssh client. Putty is good for this.