Pengenalan Linux
Pengenalan Linux
Robert Putnam
Research Computing, IS&T
[email protected]
Introduction to Linux - agenda
What is Linux?
The Bash shell
I/O redirection (pipes, etc.)
Navigating the file system
Processes and job control
Editors
Hello,world in C
What is
Linux?
http://en.wikipedia.org/wiki/Darwin_%28operating_system%29
What is Linux?
Linux is a Unix* clone begun in 1991 and
written from scratch by Linus Torvalds with
assistance from a loosely-knit team of
hackers across the Net.
64% of the world’s servers run some variant
*kernel
What is Linux?
Linux + GNU Utilities = Free Unix
multitasking
tcsh
device grep
cat
access
Hardware file
system
sh
Kernel awk
sort
Shell
Utilities
What is Linux?
“Small programs that do one thing well”
◦ Mac OS X
“Terminal” is already installed
Why? Darwin, the system on which Apple's Mac OS X
is built, is a derivative of 4.4BSD-Lite2 and FreeBSD.
In other words, the Mac is a Unix system!
For X11 (graphics), see XQuartz
(http://xquartz.macosforge.org/landing/)
Connecting to a Linux Host -
Windows Client
MobaXterm
◦ From Windows Desktop
Double-click MobaXterm_Personal_6.5.exe
Double-click saved session scc1.bu.edu [SSH]
Login: <userID>
Password: <password>
Connecting to a Linux Host -
Mac OS X Client
Terminal
◦ Type ssh –X scc1.bu.edu or ssh –Y scc1.bu.edu
Get supplementary files
At the command prompt, type the following:
◦ cd
◦ tar xf /tmp/linux-materials.tar
The Shell
A shell is a computer program that interprets the commands
you type and sends them to the operating system. On Linux
systems (and others, like DOS/Windows), it also provides a
set of built-in commands and programming control
structures, environment variables, etc.
Most Linux systems, including BU’s Shared Computing
Cluster, support at least two shells: TCSH and BASH. The
default shell for your account is BASH. (Which is best?
Caution: flame war potential here!)
“BASH” = “Bourne-again Shell” (GNU version of ~1977 shell written by
Stephen Bourne)
Bash environment variables
Variables are named storage locations. So-called
“environment variables” are conventionally used by
the shell to store information such as where it
should look for commands (i.e., the PATH).
Environment variables are shared with programs
that the shell runs.
To see the current value of PATH, do:
◦ echo $PATH
To see all currently defined environment variables
do:
◦ printenv
Using the Shell
After you connect, type
◦ shazam # bad command
◦ whoami # my login
◦ hostname # name of this computer
◦ echo “Hello, world” # print characters to screen
◦ echo $HOME # print environment variable
◦ echo my login is $(whoami ) # replace $(xx) with program output
◦ date # print current time/date
◦ cal # print this month’s calendar
Commands have three parts; command, options and parameters.
Example: cal –j 3 1999. “cal” is the command, “-j” is an option (or
switch), “3” and “1999” are parameters.
Options have long and short forms. Example:
◦ date –u
◦ date --universal
What is the nature of the prompt?
What was the system’s response to the command?
Command History and Simple
Command Line Editing
Try the history command
Choose from the command history by using the
up ↑ and down ↓ arrows
To redo your last command, try !!
To go further back in the command history try !,
then the number as shown by history (e.g., !132).
Or, !ls, for example, to match the most recent ‘ls’
command.
What do the left ← and right → arrow do on the
command line?
Try the <Del> and <Backspace> keys
Help with Commands
Type
◦ date –-help
◦ man date
◦ info date
[And yes, you can always Google it]
For a list of BASH built-in commands, just
root directory.
Many directories have subdirectories.
Unlike Windows, with multiple drives and
group
owner other
Changing file access permissions
with chmod
We can change a file’s access permissions with
the chmod command. There are a couple of
distinct ways to use chmod. With letters,
u=owner, g=group, o=other, a = all
r=read, w=write, x=execute:
[tuta0@scc1 ~]$ chmod ug+x foo
[tuta0@scc1 ~]$ ls -l foo
-rwxr-xr-- 1 tuta0 tutorial 0 Sep 4 10:03 foo
[tuta0@scc1 ~]$ chmod a-x foo
[tuta0@scc1 ~]$ ls -l foo
-rw-r--r-- 1 tuta0 tutorial 0 Sep 4 10:03 foo
Changing file access permissions
with chmod (cont.)
The chmod command also works with the following
mappings, read=4, write=2, execute=1, which are
combined like so:
[tuta0@scc1 ~]$ ls -l foo
-rw-r--r-- 1 tuta0 tutorial 0 Sep 4 10:20 foo
[tuta0@scc1 ~]$ chmod 660 foo
[tuta0@scc1 ~]$ ls -l foo
-rw-rw---- 1 tuta0 tutorial 0 Sep 4 10:20 foo
(4+2=6)