01 Linux Basics
01 Linux Basics
What is Unix?
What is Linux?
Basic Commands
http://www.cs.ucr.edu/~weesan/cs183/
What is Unix?
http://www.cs.ucr.edu/~weesan/cs183/
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/~weesan/cs183/ 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.
PowerPC, IBM S/390,
MIPS, IA-64
PS2, cellphones,
watches, Nokia N810,
NDS, routers, NAS, GPS,
…
http://www.cs.ucr.edu/~weesan/cs183/
Basic Commands
ls which
$ ls -l $ which ls
$ ls -a whereis
$ ls -la $ whereis ls
$ ls -l --sort=time locate
$ ls -l --sort=size -r $ locate stdio.h
cd $ locate iostream
$ cd /usr/bin rpm
pwd $ rpm -q bash
$ pwd $ rpm -qa
~ $ rpm -qa | sort | less
$ cd ~ find
~user $ find / | grep stdio.h
$ cd ~weesan $ find /usr/include | grep stdio.h
What will “cd ~/weesan” do?
http://www.cs.ucr.edu/~weesan/cs183/
Basic Commands (cont)
echo rm
$ echo “Hello World” $ rm foo
$ echo -n “Hello World” $ rm -rf foo
cat $ rm -i foo
$ cat /etc/motd $ rm -- -foo
$ cat /proc/cpuinfo chgrp
cp $ chgrp bar /home/foo
$ cp foo bar chsh
$ cp -a foo bar $ chsh foo
mv chfn
$ mv foo bar
$ chfn foo
mkdir
chown
$ chown -R foo:bar /home/foo
$ mkdir foo
http://www.cs.ucr.edu/~weesan/cs183/
Basic Commands (cont)
tar Pipe
$ tar cvfp lab1.tar lab1 $ cal > foo
gzip $ cat /dev/zero > foo
$ gzip -9 lab1.tar $ cat < /etc/passwd
untar & ungzip $ who | cut -d’ ‘ -f1 | sort |
$ gzip -cd lab1.tar.gz | tar xvf – uniq | wc –l
$ tar xvfz lab1.tar.gz backtick
touch $ echo “The date is `date`”
$ touch foo $ echo `seq 1 10`
$ cat /dev/null > foo Hard, soft (symbolic) link
ln vmlinuz-2.6.24.4 vmlinuz
ln -s firefox-2.0.0.3 firefox
http://www.cs.ucr.edu/~weesan/cs183/
Basic Commands (cont)
Disk usage
$ df -h /
File space usage
$ 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/~weesan/cs183/