Opensuse11.4

Pertemuan 2 Praktikum


Catatan dari teman gw namanya Kenzu Pangestu.

Harap maklum minta catatan dari teman soalnya pertemuan ini gw kebanyakan gagal dalam kerjain soal ini hehehe.

Thank you my firend atas catatannya hehehe😀

du untuk menampilakan size.

1.Use du to display all size, files/folders, and total size below the current directory (up to 1 subdirectory)!

Answer :

prk@BN62905:~> du -c –max-depth=1

prk@BN62905:~> du -hc –max-depth=1

-h untuk menampilakan size dengan keterangan B,KB(K),MB(M), Dll.

df untuk menampilakan drive yang ada dan keterangannya.

-a untuk menampilkan semuanya.

clear untuk membersihkan konsole mirip cls

2. Use df to display free disk space, then:

a. Display Information of all the File Systems

Answer :

df -a

b. Display a grand total of every column

Answer :

df –total 

3. Use touch to create new file with name “Meeting2”.

Run command ls -l.

Then, change the permission of file “Meeting2” to rwxrw-r—

Answer :

// rwx rwx rwx

1       2    3

1 = untuk user

2 = untuk grup

3 – untuk other

read = 4

write = 2

execute (x) = 1

// total 777

touch Meeting2

ls -l

chmod 764 Meeting2

atau

chmod u=rw,g=r,o=rwx Meeting2

langsung isi tanpa hitung

chmod  totalrwx nama untuk mengubah permission.

4. Run this command:

ls > file1

ls >> file2

Then, use command cat to show the contents of file1 and file2.

Run the both command once more, then show the content of file1 and file2. Is there anything different?

Give conclusion for redirection > and >> based on your observation!

Answer :

prk@BN62905:~> ls > file1

prk@BN62905:~> ls >> file2

> = redirection  , override

>> = append

prk@BN62905:~> ls > file1 maksudnya output dari ls akan dipindahkan ke file 1 kalau ada isi di override.

prk@BN62905:~> ls >> file2 maksudnya output dari ls akan dipindahkan ke file 2 kalau ada isi di append.

5. From home directory, use command vi to create and write into “Meeting2’s Commands” file with the following contents:

variable=“Some of Meeting2’s command”

echo $variable

echo “use cat to Concatenate and print (display) the content of files”

Echo “use grep to Search file(s) for lines that match a given pattern”

echo “use df to Display free disk space”

echo “use du to Estimate file space usage”

Then, use command grep to search all lines that contains word “dIspLaY” on that file (non-case sensitive)!

Answer :

prk@BN62905:~> vi “Meeting2’s Commands”

tekan I

copas ke konsole :

variable=“Some of Meeting2’s command”

echo $variable

echo “use cat to Concatenate and print (display) the content of files”

Echo “use grep to Search file(s) for lines that match a given pattern”

echo “use df to Display free disk space”

echo “use du to Estimate file space usage”

tekan esc

:wq // save and quit

prk@BN62905:~> grep “display” “Meeting2’s Commands”

mencari dan mendisplay semua baris yang mengandung kata display dari file editor dan case-sensitive

prk@BN62905:~> grep -i “dIsPlaY” “Meeting2’s Commands”

mencari dan mendisplay semua baris yang mengandung kata display dari file editor dan tidak case-sensitive

-i untuk tidak case-sensitive / igmored case

kalau ada kata yang kepisah pakai tanda “ ”

6. Change permission “Meeting2’s Commands” file to rwxrwxrwx with command chmod, then:

a. Execute that file with command ./”Meeting2’s Commands”.

b. Run command ./” Meeting2’s Commands” 1>True.txt 2>Error.txt. Is there anything different? What is the purpose of the redirection?

Answer :

chmod  777 “Meeting2’s Commands”

./”Meeting2’s Commands”

./nama untuk menjalankan program / file tersebut

./”Meeting2’s Commands” 1>True.txt 2>Error.txt

// 1 untuk penampung hasil output

//2 untuk penampung hasil error

cat True.txt

cat Error.txt

cat nama untuk buka file

7. Use command grep, head, tail to display all line from file “Meeting2’s Commands” that does not

contain word “display”, show line 3 and line 4 only!

 Answer :

grep -vi “display” “Meeting2’s Commands” mencari line yang tidak mengandung display

-v = inverse

head = mengambil beberapa baris di awal

tail = mengambil beberapa baris di akhir

| | = pipe untuk memberikan output dari A ke B. 

prk@BN62905:~> grep -vi “display” “Meeting2’s Commands” | head -4 | tail -2 

8. Use symbol pipe to combine command ls and sort to display output form command ls -l in the order based on line 7!

Answer :

ls -l | sort -k 7

sort = diatur / diurut

-k angka = kolom ke angka

9. Use symbol pipe, commands cat, tr, and symbol redirect to display contents of file “Cool Commands” and every lowercase letters are translated to uppercase. Save the result of translate into file “result.txt”!

 Answer :

cat “Meeting2’s Commands” | tr [:lower:] [:upper:] > result.txt

cat result.txt

tr = translate

10. Use command awk to display odd rows and line 7 and 8 only from the result of ls-l!

Answer :

ls -l | awk ‘{if(NR%2==1)print $7,$8}’

awk = bahasa interpreter / interpreter language

$ = kolom

NR = number rows = baris.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s