You are on page 1of 15

Coding In Linux

Masuk ke root linux(openSuse)


Masuk ke root linux.
dip5a@linux-lne0:~> whoami
Ni adalah
root dir

dip5a
dip5a@linux-lne0:~> su
Password:

Kembali kepada dir home ada


simbol (~)

linux-lne0:/home/dip5a # su dip5a
balik ke home user.
linux-lne0:/home/dip5a # su dip5a
dip5a@linux-lne0:~>

buat mkdir
dip5a@linux-lne0:~> mkdir Aman

Buat mkdir dan senarai dir yg di


cipta

ls
dip5a@linux-lne0:~> ls
Aman Desktop

Download Pictures public_html Videos

bin Documents Music

Public

Templates

masuk ke Aman dir


dip5a@linux-lne0:~> cd Aman

buat dir kat dalam aman


dip5a@linux-lne0:~/Aman> mkdir oren
dip5a@linux-lne0:~/Aman> ls
oren

Coding In Linux
buat dir sekali gus
dip5a@linux-lne0:~> mkdir Aman/puo
dip5a@linux-lne0:~> cd Aman
dip5a@linux-lne0:~/Aman> ls
oren puo

padam dir guna rmdir


dip5a@linux-lne0:~/Aman> rmdir puo
dip5a@linux-lne0:~/Aman> ls
oren

kembali ke dir dip5a


dip5a@linux-lne0:~/Aman> cd..
dip5a@linux-lne0:~>

padam dir aman dan dir oren sekali gus


dip5a@linux-lne0:~> rm -r Aman
dip5a@linux-lne0:~> ls
bin

Documents Music

Public

Templates

Desktop Download Pictures public_html Videos

Buat fail

Coding In Linux
dip5a@linux-lne0:~> touch f1
dip5a@linux-lne0:~> ls
bin

Documents f1

Pictures public_html Videos

Desktop Download Music Public

Templates

Buat fail dan tulis data fail


dip5a@linux-lne0:~> cat > f2
nama saya aman.
^C

Symbol ni tekan :

dip5a@linux-lne0:~> ls
bin

Documents

f1 Music

Public

Templates

Desktop Download f2 Pictures public_html Videos

Fail tercipta
Papar data dalam fail f2
dip5a@linux-lne0:~> cat f2
nama saya aman.

Edit fail semula f2


dip5a@linux-lne0:~> cat >> f2

Coding In Linux
nama saya aman.
saya pelajar puo.
^C
dip5a@linux-lne0:~> cat f2
nama saya aman.
nama saya aman.
saya pelajar puo.

guna

vi

Coding In Linux

tekan i INSERT (masukkan data dalam fail)

Nak save fail vi


W nak save.

Gunakan : Esc+Shift+:
Masukkan huruf :W

f3

f3 nama fail.

nak save.
5

Coding In Linux

Dan tekan : Enter.

Fail ber jaya disimpan.

Keluar dari

vi

Gunakan : Esc + Shift +:

Coding In Linux

Masukkan huruf

:q

nak save.

Kembali ke :

Tercipta fail :
f3

dip5a@linux-lne0:~> vi
dip5a@linux-lne0:~> ls
bin

Documents

f1 f3

Pictures public_html Videos

Desktop Download f2 Music Public

Templates

dip5a@linux-lne0:~>

cipta fail
dip5a@linux-lne0:~> cat >f4

Cipta satu fail

^C
dip5a@linux-lne0:~> ls
bin

Documents f1 f3 Music

Public

Templates

Desktop Download f2 f4 Pictures public_html Videos


Fail tercipta.
7

Coding In Linux

Padam fail
dip5a@linux-lne0:~> rm f4
dip5a@linux-lne0:~> ls
bin

Documents f1 f3

Pictures public_html Videos

Desktop Download f2 Music Public

Templates

Fail f4 telah di padam.

Untuk lihat semua fail


Di desktop klik pada :

Buat compress fail gzip


dip5a@linux-lne0:~> ls
bin

Documents

f1 Music

Public

Templates

Desktop Download f2 Pictures public_html Videos


dip5a@linux-lne0:~> tar czvf

Aman.gz

f1 f2

Buat compress fail bzip


dip5a@linux-lne0:~> tar cjvf

Aman.bz2

f1 f2

Coding In Linux
Buat compress fail bzip
dip5a@linux-lne0:~> tar cf

Aman.tar

f1 f2

Nak Extract compress fail


dip5a@linux-lne0:~> tar xvf

Aman.tar

masuk Ke Root Untuk Tambah User


dip5a@linux-lne0:~> su
Password:
linux-lne0:/home/dip5a # useradd

-m aman

linux-lne0:/home/dip5a # passwd aman


linux-lne0:/home/dip5a # useradd

-m oren

linux-lne0:/home/dip5a # passwd oren

Coding In Linux
DI Root Untuk buat group
linux-lne0:/home/dip5a # groupadd

dip

linux-lne0:/home/dip5a # groupadd

dip5a

DI Root Untuk buat primary group


linux-lne0:/home/dip5a # usermod

dip5a

dip

aman

DI Root Untuk buat secondary group


linux-lne0:/home/dip5a # usermod

Untuk Change Permission


Fail
dip5a@linux-lne0:~> chmod

744 f1

user
linux-lne0:/home/dip5a # chmod

704 aman

group
linux-lne0:/home/dip5a # chmod

704 dip5a

10

aman

Coding In Linux
Buat compress Di Ubuntu 11.10
dip5a@ubuntu:/$ sudo

apt-get

install

zip

Reading pakage lists Done


Building dependency tree
Reading state information Done
Zip is already the newest version.
0 upgraded, 0 newly installed,
dip5a@ubuntu:/$

Aman.zip

adding:

f1

(stored 0%)

adding:

f3

(stored 0%)

dip5a@ubuntu:/$
bin

zip

0 to remove and 107 not upgraded.


f1

f2

ls

Documents f1 f3 Music

Desktop Download Aman.zip

Public

Templates

Pictures public_html Videos

11

Coding In Linux
Task 3
a.

Installing Samba. Open terminal and execute sudo apt-get install samba .

b.

To create password as PA$$woRd, open terminal and execute sudo smbpasswd -a


nina command. Then, enter PA$$woRd. Example:

12

Coding In Linux
c.
Open terminal and execute mkdir Desktop/SHARED to create a directory name
SHARED
in desktop. To share the files using samba, add some command line at smb.conf
file in directory /etc/samba/. To do this, Open terminal and execute the command sudo pico
/etc/samba/smb.conf . Then insert the following words in bottom page of smb.conf :
[SHARED]
comment = Share directory /nina/Desktop/SHARED
path = /nina/Desktop/SHARED
guest ok = Yes
locking = No
Example:

13

Coding In Linux
d.

To restart Samba, execute sudo restart smbd.


Example:

14

Coding In Linux
e.

To check syntax errors, execute sudo testparm .


Example:

If presses enter, it will show;

15

You might also like