9. BY: AM.NA.SA - 8 -
Service management
ls /etc/init.d ﻋ
ﺮ
ض
أ
ﺳ
ﻤ
ﺎ
ء
ا
ل
services
ا
ﻟ
ﻤ
ﻮ
ﺟ
ﻮ
د
ە
k
l
3
ا
ل
system
sudo service /etc/init.d jobname
status
ﻋ
ﺮ
ض
ﺣ
ﺎ
ﻟ
ﻪ
job
ﻣ
ﻌ
ﻴ
ﻨ
ﻪ
ا
ذ
ا
8
ﺎ
ﻧ
ﺖ
)
wait – running -
stop
(
sudo service /etc/init.d jobname
stop
و
ﻗ
ﻒ
job
ﻣ
ﻌ
ﻴ
ﻨ
ﻪ
ا
ذ
ا
8
ﺎ
ﻧ
ﺖ
k
l
3
ﺣ
ﺎ
ﻟ
ﻪ
ﺗ
ﻨ
ﻔ
#
ﺬ
sudo service /etc/init.d jobname
start
Ö
ﺸ
ﻐ
#
ﻞ
job
ﻣ
ﻌ
ﻴ
ﻨ
ﻪ
ا
ذ
ا
8
ﺎ
ﻧ
ﺖ
ﻣ
ﺘ
ﻮ
ﻗ
ﻔ
ﻪ
sudo service --status-all ﻋ
ﺮ
ض
ﺣ
ﺎ
ﻟ
ﻪ
8
ﻞ
jobs
ا
ل
ا
ذ
ا
8
ﺎ
ﻧ
ﻮ
ا
)
wait – running -
stop
(
File Manipulation
grep “Word” fileName
EX: grep “foo” file1
ﻟ
ﻠ
5
ﺤ
ﺚ
ﻋ
ﻦ
8
ﻠ
ﻤ
ﺔ
د
ا
ﺧ
ﻞ
ا
ﻟ
ﻤ
ﻠ
ﻒ
و
I
ﻌ
ﺮ
ض
ا
ﻟ
ﺴ
ﻄ
ﺮ
ا
ﻟ
2
3
ﻟ
Ù
£
ﻓ
#
ﻪ
ا
ﻟ
z
ﻠ
ﻤ
ﺔ
ﻋ
2
ا
ﻟ
ﺸ
ﺎ
ﺷ
ﺔ
tr “oldChar” “newChar”<filename
EX: tr “a” “b” < C
ﺑ
#
ﻌ
ﻤ
ﻞ
Replacement
ﻟ
ﻠ
ﺤ
ﺮ
و
ف
ﻳ
5
ﺤ
ﺚ
ﻋ
ﻦ
ا
ﻟ
ﺤ
ﺮ
و
ف
k
l
3
ا
ﻟ
ﻤ
ﻠ
ﻒ
و
œ
ﻈ
ﻬ
ﺮ
ا
ﻟ
ﻨ
†
#
ﺠ
ﺔ
ﻋ
2
ا
ﻟ
ﺸ
ﺎ
ﺷ
ﺔ
sed -i 's/old/new/' fileName
EX: sed -i 's/foo/bar/' myfile.txt
sed -i 's/old/new/g' fileName
EX: sed -i 's/false/true/g'
myfile.txt
EX: cat this is false | sed
's/false/true/g'
Replace the first occurrence of word “foo”
with word “bar”
Replace all the occurrences of word “foo”
with word “bar”
Commands:
echo HELLO > f1.txt
echo GOODBYE > f2.txt
diff f1.txt f2.txt
diff compares two files line by line, outputs
differences to stdout (screen)
– No differences à no output
10. BY: AM.NA.SA - 9 -
output:
1c1
< HELLO ---
> GOODBYE
diff -y f1.txt f2.txt
– output all differences
cut –f numberOfColumn fileName
Ex: cut –f 2 myfile
ا
F
3
k
l
3
ا
ﻟ
ﻌ
ﻤ
ﻮ
د
ا
ﻟ
ﺘ
ﺎ
ã
l
3
ﻣ
ﻦ
8
ﻞ
ﺳ
ﻄ
ﺮ data ﺑ
#
ﻌ
ﺮ
ض
8
ﻞ
ا
ل
ا
ﻟ
z
ﻠ
ﻤ
ﺎ
ت
k
l
3
ا
ﻟ
ﺴ
ﻄ
ﺮ
ﺗ
ﻜ
ﻮ
ن
ﻣ
ﻔ
ﺼ
ﻮ
ﻟ
ﻪ
ب
tab
cut –c indexFrom-To fileName
Ex: cut –c 2-5 myfile
ﺑ
#
ﻌ
ﺮ
ض
8
ﻞ
ا
ل
Index5 ل Index2 ا
ﻟ
2
3
k
l
3
8
ﻞ
ﺳ
ﻄ
ﺮ
ﻣ
ﻦ data
sort fileName ASCII Code ا
u
ﺠ
ﺪ
œ
ﺔ
u
ﺎ
ل Data ﺑ
[
ﺗ
ﺐ
ا
ل
wc fileName و
ا
ﻟ
z
ﻠ
ﻤ
ﺎ
ت Character ﺑ
#
ﻌ
ﺮ
ض
ﻋ
ﺪ
د
ا
ﻟ
ﺴ
ﻄ
ﻮ
ر
و
ا
ل
wc –c fileName k
l
3
ا
ﻟ
ﻤ
ﻠ
ﻒ Character ﺑ
#
ﻌ
ﺮ
ض
ﻣ
ﺠ
ﻤ
H
ع
ا
ل
wc –l fileName ﺑ
#
ﻌ
ﺮ
ض
ﻣ
ﺠ
ﻤ
H
ع
ا
ﻟ
ﺴ
ﻄ
ﻮ
ر
wc –w fileName ﺑ
#
ﻌ
ﺮ
ض
ﻣ
ﺠ
ﻤ
H
ع
ا
ﻟ
z
ﻠ
ﻤ
ﺎ
ت
Package source update/install
cd /etc/apt
sudo apt-get update ا
ﻻ
ﻣ
ﺮ
د
ە
ﺑ
#
ﻘ
ﻮ
ل
ﻫ
ﻞ
k
l
3
ﺗ
ﺤ
ﺪ
ﻳ
ﺜ
ﺎ
ت
ﻟ
ﻠ
[è
ا
ﻣ
ﺞ
و
ﻻ
ﻷ
و
ﻟ
ë
ﻨ
ﻪ
ﻻ
œ
ﻘ
ﻮ
م
u
ﺎ
ﻟ
ﺘ
ﺤ
ﺪ
œ
ﺚ
sudo apt-get upgrade Install ﻋ
ﻠ
ﺸ
ﺎ
ن
ا
ﻋ
ﻤ
ﻞ
ﺗ
ﺤ
ﺪ
œ
ﺚ
ﻟ
ﻠ
[è
ا
ﻣ
ﺞ
ا
F
3
ﻋ
ﻤ
ﻠ
ﺘ
ﻠ
ﻬ
ﺎ
Used to install the newest versions of
all packages currently installed on the
system
sudo apt-get -u upgrade ﻟ
ﻌ
ﻤ
ﻞ
ﺗ
ﺤ
ﺪ
œ
ﺚ
ﻟ
ﻠ
[è
ا
ﻣ
ﺞ
و
ﻋ
ﺮ
ض
ا
ﻟ
[è
ا
ﻣ
ﺞ
ا
F
3
ﺣ
ﺼ
ﻠ
ﻬ
ﺎ
Upgrade
11. BY: AM.NA.SA - 10 -
sudo apt-get dist-upgrade ﻋ
ﻠ
ﺸ
ﺎ
ن
ا
ﻋ
ﻤ
ﻞ
ﺗ
ﺤ
ﺪ
œ
ﺚ
ﻟ
ﻠ
[è
ا
ﻣ
ﺞ
،
و
ﺗ
ﺤ
ﺪ
œ
ﺚ
ا
ﻟ
[è
ا
ﻣ
ﺞ
ا
ﻟ
ﻤ
ﻌ
ﺘ
ﻤ
ﺪ
ە
ﻋ
ﻠ
ﻴ
ﻬ
ﺎ
.
ﺗ
ﺤ
ﺪ
œ
ﺚ
ﻻ
ﺧ
ﺮ
ﻧ
ﻈ
ﺎ
م
u
ﺎ
ﻟ
z
ﺎ
ﻣ
ﻞ
In addition to performing the function
of upgrade, this option also
intelligently handles changing
dependencies with new versions of
packages
sudo apt-get install
programName
EX: sudo apt-get install mplayer
ﻻ
ي
ﺑ
ﺮ
ﻧ
ﺎ
ﻣ
ﺞ Install ﻟ
ﻌ
ﻤ
ﻞ
sudo apt-get remove
programName
EX: sudo apt-get remove mplayer
ﻟ
ﻤ
ﺴ
ﺢ
ا
ي
ﺑ
ﺮ
ﻧ
ﺎ
ﻣ
ﺞ
sudo apt-get remove –s
programName
EX:sudo apt-get remove –s
mplayer
ﻋ
ﻠ
ﺸ
ﺎ
ن
ا
ﻋ
ﻤ
ﻞ
ﻣ
ﺴ
ﺢ
ﻟ
ﻠ
[è
ﻧ
ﺎ
ﻣ
ﺞ
و
I
ﻌ
ﺮ
ض
ﻟ
ﻮ
ﻓ
#
ﻪ
ا
ي
ﺣ
ﺎ
ﺟ
ﺔ
م
ﻋ
ﺘ
ﻤ
ﺪ
ة
ﻋ
ﻠ
#
ﻪ
ﻫ
ﺘ
†
ﺸ
ﺎ
ل
ﻣ
ﻌ
ﺎ
ە
Package search
cd /etc/apt
apt-cache pkgnames Prints the name of each package in the
system.
apt-cache search item
EX: apt-cache search vsftpd
Search for particular item in all
packages
apt-cache pkgnames Name
EX: apt-cache pkgnames vsftpd
Show details of a package
apt-cache showpkg Name Show information details and
dependencies of a package
12. BY: AM.NA.SA - 11 -
Logging and log management
cd /etc/rsyslog.d/
ls
Display entries in system log
vi rsyslog.conf Display content of logging configuration
file and allow to edit it
Process management
ps • Report a snapshot of current processes
• show the processes associated with the
current terminal session.
ps a gives more information about processes
associated with the current terminal
session like process state
ps ef list all processes of all users (full list)
ps aux
EX:
ps aux|grep firefox
gives more and more details about every
process in the system such as state (user
oriented )
search process named firefox from all the
listed set of process in the system and
display its details
top - displays a continuously updating display
of the processes
- Viewing Processes Dynamically
Kill processID
Killall ProcessName
Terminate a process
Ls proc List currently working processes
Ls dev list set of devices in the system