00-Review of Linux Basics

17

Transcript of 00-Review of Linux Basics

Page 1: 00-Review of Linux Basics
Page 2: 00-Review of Linux Basics

Review of Linux Basics

Page 3: 00-Review of Linux Basics

4

Key Knowledge Area● Linux Directory Structure● File Permissions and Security● Common Linux Commands and Programs● Working with Linux Shells● Bash Shell Scripting

Page 4: 00-Review of Linux Basics

5

Linux Directory Structure

Page 5: 00-Review of Linux Basics

6

Navigating the Linux File System● Change Directory

# cd /home/user# cd ..# pwd/home# cd user/Downloads

# cd /home/user# cd ..# pwd/home# cd user/Downloads

Page 6: 00-Review of Linux Basics

7

File Permissions and Securityدسترسی در سیستم فایل لینوکس در سه سطح اعمال می شود:

) : کاربر مالک فایل یا پوشهuserکاربر (●

) : گروه مالک فایل یا پوشهgroupگروه (●

) : کاربران و گروه ها به غیر مالک فایلotherدیگران (●

$ ls -ldrwxr-xr-x 2 user user 4096 Oct 13 13:19 Desktopdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Documentsdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Downloadsdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Music

$ ls -ldrwxr-xr-x 2 user user 4096 Oct 13 13:19 Desktopdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Documentsdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Downloadsdrwxr-xr-x 2 user user 4096 Oct 13 13:19 Music

# umask0022# umask0022

Page 7: 00-Review of Linux Basics

8

SETUID and SETGID●SETUID

بر روی فایل: در صورتی که این مجوز به فایلی داده شود ، هر کاربری می تواند آن را ●با مجوز صاحب فایل اجرا کند.

بر روی پوشه: این مجوز برای پوشه ها هیچ اثری ندارد.●

●SETGIDبر روی فایل: هر کاربری می تواند فایل را با مجوز گروه اجرا کند.●بر روی پوشه: هر فایل جدید ساخته شده در پوشه در مالکیت گروه مالک خواهد ●

بود و نه گروه سازنده فایل. برای استفاده در پوشه هایی که کاربران به صورت مشترک کار می کنند مناسب است

Page 8: 00-Review of Linux Basics

9

File Security Attributes● lsattr and chattr

a : append onlyc : compressedd : no dumpe : extent formati : immutablej : data journallings : secure deletiont : no tail-mergingu : undeletableA : no atime updatesC : no copy on writeD : synchronous directory updatesS : synchronous updatesT : top of directory hierarchy

a : append onlyc : compressedd : no dumpe : extent formati : immutablej : data journallings : secure deletiont : no tail-mergingu : undeletableA : no atime updatesC : no copy on writeD : synchronous directory updatesS : synchronous updatesT : top of directory hierarchy

# chattr +i /path/to/file# chattr +i /path/to/file

Page 9: 00-Review of Linux Basics

10

Manipulating Files and Directories

Work with file

rm

cp

rmdir

mkdir

mv

File and Dir

cd

ls

Home Dir

Tiled ~

. and ..

Page 10: 00-Review of Linux Basics

11

Viewing and Searching Files

Search

find

locate

grep

head,tail

which

Page 11: 00-Review of Linux Basics

12

Environment and Shell Variables● Shell Variables

● Enviroment Variables

# unset varname# unset varname

# varname=value# varname=value

# export varname=value# export varname=value

# echo $varname# echo $varname

Page 12: 00-Review of Linux Basics

13

Bash Shell Scripting● She Bang

$ vi helloworld.sh#!/bin/bash

var=oracleecho $var

$ vi helloworld.sh#!/bin/bash

var=oracleecho $var

Page 13: 00-Review of Linux Basics

14

Bash Shell Scripting: Conditions● Conditions

test expression[ expression ]help test

test expression[ expression ]help test

if [ expression ] then commandselif [ expression ]then

commandselse commandsfi

if [ expression ] then commandselif [ expression ]then

commandselse commandsfi

Page 14: 00-Review of Linux Basics

15

Bash Shell Scripting: caseانتخاب چندین گزینه●

case $variable in 1 ) echo "You entered one” ;; 2 ) echo "You entered two ;; 3 ) echo "You entered three” ;; * ) echo "You did not enter a number” echo "between 1 and 3”esac

case $variable in 1 ) echo "You entered one” ;; 2 ) echo "You entered two ;; 3 ) echo "You entered three” ;; * ) echo "You did not enter a number” echo "between 1 and 3”esac

Page 15: 00-Review of Linux Basics

16

Bash Shell Scripting: whileتازمانی که شرط درست است●

while [ test ] do commandsdone

while [ test ] do commandsdone

Page 16: 00-Review of Linux Basics

17

Bash Shell Scripting: In-List Syntax of for

for I in listdo commandsdone

for I in listdo commandsdone

for I in /path/to/*do commands to $Idone

for I in /path/to/*do commands to $Idone

Page 17: 00-Review of Linux Basics

18

Bash Shell Scripting: Controlled Loop Syntax of for

for (( c=1; c<=5; c++ ))do commandsdone

for (( c=1; c<=5; c++ ))do commandsdone

for I in {start..end..step}do commandsdone

for I in {start..end..step}do commandsdone