0% found this document useful (0 votes)
234 views

01 Linux Basics

This document provides an introduction to Linux basics. It begins with definitions of Unix and Linux, including their histories. It then discusses various Linux distributions and commands used in Linux, such as ls, cd, cp, rm, and vi. The document concludes with references for further reading.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
234 views

01 Linux Basics

This document provides an introduction to Linux basics. It begins with definitions of Unix and Linux, including their histories. It then discusses various Linux distributions and commands used in Linux, such as ls, cd, cp, rm, and vi. The document concludes with references for further reading.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

Linux Basics

WeeSan Lee <[email protected]>

http://www.cs.ucr.edu/~weesan/cs
183/

Roadmap

What is Unix?
What is Linux?
Which Linux Distribution is better?
Fish vs. Fishing
Basic Commands
Vi and Emacs
Q&A
References
http://www.cs.ucr.edu/~we

What is Unix?

A multi-task and multi-user Operating System


Developed in 1969 at AT&Ts Bell Labs by

Ken Thompson (Unix)


Dennis Ritchie (C)
Douglas Mcllroy (Pipes - Do one thing, do it well)

Some other variants: System V, Solaris, SCO


Unix, SunOS, 4.4BSD, FreeBSD, NetBSD,
OpenBSD, BSDI
http://www.cs.ucr.edu/~we

What is Linux?

A clone of Unix
Developed in 1991 by Linus Torvalds, a Finnish
graduate student
Inspired by and replacement of Minix
Linus' Minix became Linux
Consist of

Linux Kernel
GNU (GNU is Not Unix) Software
Software Package management
Others
http://www.cs.ucr.edu/~we

http://www.linuxdevices.com/files/misc/ibm-watchpad.jpg

What is Linux?

Originally developed for


32-bit x86-based PC
Ported to other
architectures, eg.

Alpha, VAX, PowerPC,


IBM S/390, MIPS, IA-64
PS2, TiVo, cellphones,
watches, Nokia N810,
NDS, routers, NAS, GPS,

http://www.cs.ucr.edu/~we

* See references at the end


for the corresponding websites.

Which Linux Distribution is


better?

> 300 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.)

http://www.cs.ucr.edu/~we

Which Linux Distribution is


Ubuntu
better?
Debian
Knoppix

Slackware

Gentoo
CentOS

Redhat

Source:
http://futurist.se/gldt/

http://www.cs.ucr.edu/~we

Which Linux Distribution is


better?

Ask yourself these questions (from LAH)

Is it going to be around in 5 yrs?


Is it giong to stay on top of the latest security
patches?
Is it going to release updated software promptly?
If I have problems, will the vendor talk to me?

Personally, I use Slackware


But, we will use CentOS (possibly along with
Slackware :)
http://www.cs.ucr.edu/~we

Fish vs. Fishing

Manpage

$ man ls
$ man 2 mkdir
$ man man
$ man -k mkdir

1 User-level cmds and


apps

int mkdir(const char *, );

3 Library calls

int printf(const char *, );

man 7 locale

8 System admin. Cmds

2 System calls

/usr/games/fortune

7 Misc. files and docs

/bin/mkdir

/etc/hosts

6 Games and demos

/dev/tty

5 Standard file formats

Manpage sections (LAH


Table 1.2 @ page 12)

4 Device drivers and


network protocols

/sbin/reboot

$ manpath
$ env | grep MANPATH
/etc/man.config

http://www.cs.ucr.edu/~we

Fish vs. Fishing (cont)

Google

linux package management -rpm


linux package management -rpm
linux OR windows
rpm site:redhat.com
linux faq filetype:pdf

Info

Text-base, menu-based help from GNU


?, h, u, t, ^N, ^P, Enter
$ info info
http://www.cs.ucr.edu/~we

Basic Commands

ls

$ cd ~

$ rpm -q bash
$ rpm -qa
$ rpm -qa | sort | less

find

$ cd ~weesan

$ locate stdio.h
$ locate iostream

rpm

$ pwd

$ whereis ls

locate

$ cd /usr/bin

$ which ls

whereis

~user

which

pwd

$ ls -l
$ ls -a
$ ls -la
$ ls -l --sort=time
$ ls -l --sort=size -r

cd

$ find / | grep stdio.h


$ find /usr/include | grep stdio.h

What will cd ~/weesan do?


http://www.cs.ucr.edu/~we

Basic Commands (cont)

echo

$ cp foo bar
$ cp -a foo bar

$ mkdir foo

$ chsh foo

chfn

$ chgrp bar /home/foo

chsh

$ mv foo bar

mkdir

$ rm foo
$ rm -rf foo
$ rm -i foo
$ rm -- -foo

chgrp

mv

$ cat /etc/motd
$ cat /proc/cpuinfo

rm

cp

$ echo Hello World


$ echo -n Hello World

cat

$ chfn foo

chown

$ chown -R foo:bar /home/foo

http://www.cs.ucr.edu/~we

Basic Commands (cont)

tar

$ gzip -9 lab1.tar

$ gzip -cd lab1.tar.gz | tar xvf


$ tar xvfz lab1.tar.gz

touch

Pipe

untar & ungzip

$ tar cvfp lab1.tar lab1

gzip

backtick

$ touch foo
$ cat /dev/null > foo

$ cal > foo


$ cat /dev/zero > foo
$ cat < /etc/passwd
$ who | cut -d -f1 | sort |
uniq | wc l
$ echo The date is `date`
$ echo `seq 1 10`

Hard, soft (symbolic) link

ln vmlinuz-2.6.24.4 vmlinuz
ln -s firefox-2.0.0.3 firefox

http://www.cs.ucr.edu/~we

Basic Commands (cont)

Disk usage

File space usage

$ df -h /
$ du -sxh ~/

Advance stuff

$ ssh eon who


$ ssh eon cd .html ; tar cvfp - cs183 | gzip -9c | tar
xvfpz $ ssh kilo-1 tar cvfp - /extra/weesan | tar xvfp - -C /
http://www.cs.ucr.edu/~we

Vi

2 modes
Input mode

ESC to back to cmd mode

Command mode

Cursor movement

h (left), j (down), k (up), l (right)


^f (page down)
^b (page up)
^ (first char.)
$ (last char.)
G (bottom page)
:1 (goto first line)

Swtch to input mode

Delete

a (append)
i (insert)
o (insert line after
O (insert line before)

Paste

Search

p (paste after)
P (paste before)

Undo

dd (delete a line)
d10d (delete 10 lines)
d$ (delete till end of line)
dG (delete till end of file)
x (current char.)

Save/Quit

http://www.cs.ucr.edu/~we

:w (write)
:q (quit)
:wq (write and quit)
:q! (give up changes)

Emacs

$ emacs
Cursor movement

^f (forward one char.)


^b (backward one char.)
^a (begin of line)
^e (end of line)
^n (next line)
^p (prev. line)
^v (page up)
alt-v (page down)

Deletion

Paste

Undo

^g

Save/Quit

^d (delete one char)


alt-d (delete one word)
^k (delete line)

^x^f

Cancel

^/

Load file

^y (yank)

^x^c (quit w/out saving)


^x^s (save)
^x^w (write to a new file)

http://www.cs.ucr.edu/~we

Q&A

http://www.cs.ucr.edu/~we

References

LAH

Unix history

http://en.wikipedia.org/wiki/Unix
http://upload.wikimedia.org/wikipedia/commons/7/77/Unix_h
istory-simple.svg

Linus Torvalds

Ch 1: Where to Start

http://en.wikipedia.org/wiki/Linus_Torvalds

Linux Kernel

http://www.kernel.org/
http://www.cs.ucr.edu/~we

References

GNU (Gnus Not Unix)

Linux Distribution

http://arrakis.ncsa.uiuc.edu/ps2/cluster.php

Linux Gadgets

http://en.wikipedia.org/wiki/Linux_distribution
http://en.wikipedia.org/wiki/List_of_Linux_distributions

PS2: Computational Cluster

http://www.gnu.org/

http://linuxdevices.com/articles/AT4936596231.html

TiVo

http://dynamic.tivo.com/linux/linux.asp
http://www.cs.ucr.edu/~we

References

Nintendo DS Lite
http://www.nintendo.com/ds/
Nokia N810
http://www.nokia.com/
http://www.engadget.com/2007/10/17/nokia-n810-gets-official/
Linux Distribution
http://en.wikipedia.org/wiki/Linux_distribution
GNU/Linux Distro Timeline: http://futurist.se/gldt/
http://www.distrowatch.com/
http://www.linux.org/dist/
Google Advance Search
http://www.google.com/intl/en/help/refinesearch.html
http://www.cs.ucr.edu/~we

You might also like