Issuu on Google+



Abstraction (1) 1. Hardware 2. Kernel: Internal kernel 3. Proces: User spaces, manage by kernel, not affected

Shell Environment Shell env: huyngo@ip-172-20-200-6:~$ (username@host: path) Standard input:


Standard output:


Standard error:


Basic command (0) - ls huyngo@ip-172-20-200-6:~$ ls -la total 203768 drwxr-xr-x 24 huyngo users drwxr-xr-x 17 root root

4096 Dec 14 21:30 . 4096 Jan 28 2016 ..

-rw-r--r-- 1 huyngo users 233254 Jan 11 2016 -rw-r--r-- 1 huyngo users -rw-r--r-- 1 huyngo users

3480 Jan 6 2016 0 Dec 1 2015 all-chef-databags.log

Practice: list file with capacity human look (MB). List with wildcard

Basic command (1) - cp huyngo@ip-172-20-200-6:~$ cp test1.json test3.json huyngo@ip-172-20-200-6:~$ echo $? 0 Practice: copy with wildcard, copy folder

Basic command (2) - mv huyngo@ip-172-20-200-6:~$ mv test3.json test4.json huyngo@ip-172-20-200-6:~$ echo $? 0 Practice: move folder, wildcard

Basic command (3) - touch huyngo@ip-172-20-200-6:~$ touch file2.txt huyngo@ip-172-20-200-6:~$ ll file2.txt -rw-r--r-- 1 huyngo users 0 Dec 15 13:58 file2.txt

Basic command (4) - rm huyngo@ip-172-20-200-6:~$ rm file2.txt huyngo@ip-172-20-200-6:~$ Practice: rm multiple file, rm wildcard

Navigate Directory huyngo@ip-172-20-200-6:~$ mkdir test huyngo@ip-172-20-200-6:~$ cd test/ huyngo@ip-172-20-200-6:~/test$ cd .. huyngo@ip-172-20-200-6:~$ rmdir test/ huyngo@ip-172-20-200-6:~$ cd test -bash: cd: test: No such file or directory Practice: rm dir not empty,

Wildcard * huyngo@ip-172-20-200-6:~$ echo * all-chef-databags.log backup backup.local.php.erb? ? huyngo@ip-172-20-200-6:~$ echo test?.json test1.json test2.json test4.json [] huyngo@ip-172-20-200-6:~$ echo test[12].json test1.json test2.json Practice: echo file start with test, after that with whatever character and then number 1 or 2. Sample: test@12 or test+12 or test312â&#x20AC;Ś . : any character

Intermediate Command grep -v: exclude -o: correct -R: recursive egrep ( extension or) { "status": "operational", "name": "Email delivery", "created_at": "2016-08-31T21:24:07.594Z", "updated_at": "2016-10-06T20:21:49.891Z", } Practice: print all line, except line contains â&#x20AC;&#x153;created atâ&#x20AC;?

Intermediate Command (1) { "status": "operational", "name": "Email delivery", "created_at": "2016-08-31T21:24:07.594Z", "updated_at": "2016-10-06T20:21:49.891Z", } huyngo@ip-172-20-200-6:~$ curl -sq '' | jq . | egrep -o '[0-9]*-[0-9]*-[0-9]*.[0-9]*:[0-9]*:[0-9]*.*' 2016-12-15T03:30:26 2013-09-26T03:34:27 Practice: print the date match â&#x20AC;&#x153;updated_atâ&#x20AC;?

Less + PWD + DIff

huyngo@ip-172-20-200-6:~$ less test1.json

File File: know what kind of find

Find and locate Find: find from folder and recursive Locate: faster find, but need index

Head and tail Head: get the top line Tail: get the bottom line

Change password Passwd

Practice: Change passwd user test and see the different hash in /etc/shadow before and after

Dot file Dot file: just a hidden file not show default, nothing special

Practice: list all .dot file and current directory

Environment and Shell variable Shell: temporality variable in shell Environment: variable can use in all program (not just shell)

Practice: create simple script and access environment in script


Practice: Try to change the default PATH Important note: be careful with this change, since all default program will be lost

Special character

Process listing and manipulating root@vps-us:~# ps â&#x20AC;&#x201C;aux root@vps-us:~# kill -9 16326

Practice: try to locate a program, than kill that program automatically

Background process & fg pid

Practice: kill all background process

File mode and permission

File mode and permission - : nothing r : read:


w : write: 2 x : execute: 1 4 parts: Type - User â&#x20AC;&#x201C; Group - Other

File mode and permission

File mode and permission Directory: List: if read permission Access: if execute permission Chmod: Chmod 644 test

Practice: try to change permission of a file and access by other user in group, and user in others

Linux lpi 1 day 1