00-Review of Linux Basics
-
Upload
behrad-eslamifar -
Category
Documents
-
view
57 -
download
0
Transcript of 00-Review of Linux Basics
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
5
Linux Directory Structure
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
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
8
SETUID and SETGID●SETUID
بر روی فایل: در صورتی که این مجوز به فایلی داده شود ، هر کاربری می تواند آن را ●با مجوز صاحب فایل اجرا کند.
بر روی پوشه: این مجوز برای پوشه ها هیچ اثری ندارد.●
●SETGIDبر روی فایل: هر کاربری می تواند فایل را با مجوز گروه اجرا کند.●بر روی پوشه: هر فایل جدید ساخته شده در پوشه در مالکیت گروه مالک خواهد ●
بود و نه گروه سازنده فایل. برای استفاده در پوشه هایی که کاربران به صورت مشترک کار می کنند مناسب است
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
10
Manipulating Files and Directories
Work with file
rm
cp
rmdir
mkdir
mv
File and Dir
cd
ls
Home Dir
Tiled ~
. and ..
11
Viewing and Searching Files
Search
find
locate
grep
head,tail
which
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
13
Bash Shell Scripting● She Bang
$ vi helloworld.sh#!/bin/bash
var=oracleecho $var
$ vi helloworld.sh#!/bin/bash
var=oracleecho $var
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
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
16
Bash Shell Scripting: whileتازمانی که شرط درست است●
while [ test ] do commandsdone
while [ test ] do commandsdone
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
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