Professional Documents
Culture Documents
Linux
Linux
LINUX
2014
Linux
Linux
RAM, CPU.
.1
.2
.3
.4
.5
.6
.7
.8
.9
Linux Ubuntu
Linux .
.
.
.Linux
.)permissions( Linux
(.)process control
.
Linux .
.Linux
Linux
.
1969 c
Linux Unix
1975
PSD .
.
Linux
.1975
Linux workstations super computers
Linux
.
Linux
.1
.2
.3
.4
:Kernel
kernel :
....
:System Library
Linux
.
:System Utility
.Linux
:User Interfaces CLI
( )Terminal ( GUI
mouse keuboard
).
Linux :
Linux
Linux Linux
Linux
Red Hat, Ubuntu,
...Mint, Debian
Linux
VMware Workstation .
File New Virtual Machine
.iso
.Easy install
Linux
.
Command Line Interface
kernel Graphical User
Interface .
:Linux
]Command [options] [arguments
:Command .
:Options command
.
:Arguments commands .
:
mkdir m 654 test
argument test
option m
option .
. .Ubuntu Linux
Terminal terminal .
:
date .
cal .
uname .
uname a .
uname m architecture.
clear .
.1 manual
Linux
8
:
shell command .
System calls functions
.kernel
Libraries functions .
/div
.
.
.
.
man
man whois .
man cat
.
q man pages .
man passwd passwd
man 5 passwd passwd
man pages man man
:
apropos man pages
:
apropos passwd = man k passwd
:
whatis cat
whatis passwd
man f passwd
whereis cat
whereis ls
whereis passwd
whereis tar
options --h
cat --h
netstat --h
--h :
info cat
.man pages
.Linux
Linux
pwd
print working directory
.
cd Desktop/
pwd .
cd change directory
.
cd /etc
cd ~ home directory
Cd .home directory
parent directory cd ..
root directory cd ..
Linux .
cd
.
:
Absolute path root /
Relative path /
.current working directory
home directory desktop :
Cd /home/ismail/Desktop/ .absolute path
cd Desktop/ .relative path
Linux tab completion Tab
Tab .
directory
list ls
ls a
().
Ls l
.
Ls lh
:
Ls document/ document .
mkdir :rmdir
mkdir course course directory .
rmdir
rm r
Linux
Linux
File1 file1
.
directory Linux
Linux disks
.
:
touch
.
file
Linux
Linux
.doc .
Magic File
:
file :
file1 :
/proc /dev
option :
rm
.
cp
2 arguments
.
file1
.
mv
.
Linux
:
Head
11 .
Tail .
log
.
Cat
.
cat /etc/passwd
Tac
LinuxVI editor
.VIM
Linux
.
VI
.
:VI
:
vi file1
:
vi R file1
view file1
vi editor :
Command mode
.
Insert mode .
:
vi file1
command mode
i insert mode command mode
ESC ESC .
:VI
Action
Inputs
:q
!:q
:w
:wq
:w New_file
i
I
a
A
o
O
x
X
dd
D
Mode
Insert
mode
Command
mode
.
:
regular expressions .
grep & egrep .
fgrep
.
grep
/grep options pattern filename/
-i patterns
-l pattern
pattern .
-n pattern
-v
-c pattern
-w pattern pattern
.
grep root /etc/passwd
grep n root /etc/passwd
grep n bash /etc/passwd
grep v bash /etc/passwd
grep vc bash /etc/passwd
grep c bash /etc/passwd
grep i BAsh /etc/passwd
grep BAsh /etc/passwd
grep i BAsh /etc/passwd
grep i Bash /etc/passwd /etc/group
grep iw Bash /etc/passwd /etc/group
:
options grep :
^ .
$ .
no...y 6 no y
] [a-d .
*] [a-d a ab .... abc
] [^a-z .
grep ^no /etc/passwd
grep -n ^no /etc/passwd
grep -vn ^no /etc/passwd
grep -vc ^no /etc/passwd
grep -vn bash$ /etc/passwd
grep bash$ /etc/passwd
grep r... /etc/passwd
egrep
w :
+
*
| )(or
egrep -n [a-d]+ /etc/passwd
egrep -n [x-z]+ /etc/passwd
egrep -n (root|nobody) /etc/passwd
egrep -n (root|nobody|tech) /etc/passwd
fgrep
regular expressions
/fgrep options string filenames/
Grep [a-b]* /etc/passwd
Fgrep [a-b]* /etc/passwd
*] [a-b .
.find
...
.
/Find pathname expressions actions/
Pathname .
Expressions .
Actions .
:
11
.Block = 512 Byte
find Desktop/ -name
find Desktop/ -size +10
find Desktop/ -size -10
find Desktop/ -size 10
11:
find Desktop/ -atime +10
find Desktop/ -atime -10
find Desktop/ -atime 10
:
find Desktop/ -mtime +10
find Desktop/ -mtime -10
find Desktop/ -mtime 10
find Desktop/ -user User_name
:
find Desktop/ -type f
:
find Desktop/ -type d
find Desktop/ atime -5 user user_name
:
find Desktop/ atime -5 user user_name print
find Desktop/ atime -5 user user_name ls
find Desktop/ atime -5 user user_name ok rm {} \;
rm
}{
-ok
;\ }{
find Desktop/ atime -5 user user_name -exec rm {} \;
.
:
cd Desktop/
pwd
ls
find lecture04 name file*
find lecture04 name *file
find lecture04 name *file*
find lecture04 name *.txt
find lecture04 atime +2 ls
find ~ -size +1
find ~ -size +1 exec wc {} \;
find ~ -size +1 exec cat {} \;
.
tar Linux
/tar functions archivefile filenames/
Archivefile .
Filenames .
functions :
tar help
c .
t .
x .
f .
v .
j z
.
cd Desktop/
tar cf etc.tar /etc
root files
:
sudo tar cf etc.tar /etc
ls ltrh
sudo tar cvf etc.tar /etc
ls ltrh
:
sudo tar cvfj etc_bzip2.tar /etc
ls ltrh
sudo .root user
.
.
zip
:
:
zip -r lecture04.zip lecture04
zip r etc.zip /etc
sudo zip r etc.zip /etc
:
sudo zip -0 r etc_1.zip /etc
sudo zip -1 r etc_2.zip /etc
sudo zip -9 r etc_3.zip /etc
:
cd Desktop/lecture04
zip p 123456 file_with_pass.zip new_copy
.history
zip e file_with_pass1.zip new_copy
Then we inter the password after this command.
.
:
mkdir compress
cp *.zip compress/
cd compress/
unzip file.zip
unzip file_with_pass.zip
:
unzip l etc.zip
:
unzip v etc.zip
:
unzip t file.zip
zip .
gzip
:
cd Desktop/lecture04
gzip new_copy
new_copy.gz
:
gzip -c file111
:
gzip c file111 > file111.gz
ls ltrh
gzip :
gzip r compress/
cd compress
ls ltrh
cd ..
.
:
gunzip new_copy.gz
gunzip c file111.gz > unzipped.txt
gzip cd file111.gz > un_zipped.txt
:
tar zcf compress.tar.gz compress/
ls ltrh
bzip2
.
bzip2 c file111.gz > all.gz
ls ltrh
.
Uname
:
uname
uname a
uname i
uname n
uname r
uname s
uname rs
uname rsn
man uname
Cal
cal 12 2010 :
cal -1
:
cal -3
:
:2115 1 2114 12 11
cal -3 12 2014
man cal
Date
:
sudo date --set=31 October 2114 23:11:11
changing date and time
sudo date s 31 October 2114 23:11:11
changing time and date
sudo date +%T s 23:11:11
changing time
sudo +%Y%m%d s 21141131
changing year, month, and day
sudo date +%hh s 23
changing hours
sudo date +%mm s 11
changing minutes
sudo date +%ss s 11
changing seconds
wc
:
cd Desktop/lecture04
ls
wc file6.txt
wc new_copy
wc new_copy unzipped.txt
wc l new_copy
wc c new_copy
wc w new_copy
wc m new_copy
wc L new_copy
line counts
byte counts
word counts
character counts
max line length
History
ls f*
ls *f
ls *.zip
ls f*.zip
ls file?
ls [a-d]*
ls [abc]*
cd ~
pipe
. :
*ls fil
:
ls fil* |wc l
.
ls fil* |wc m
.
history | grep date
history | gerp date s
history | gerp date | wc l
Linux
.
Linux
.
:
ls l
.
Permission sets
3 3
.
read/no read r/write/no write w/execute/denied x/-
:
cat /etc/group
mkdir lecture12
cd lecture12
touch file1 file2
ls l
.
mkdir subdir
ls l
cat /etc/group
:
chgrp adm subdir/
ls l
mkdir sub
cd sub
touch fil2
touch fil1
touch fil3
cd ..
ls l
chgrp adm sub
ls l
cd sub
ls l
:
cd ..
chgrp R adm sub
cd sub
ls l
owner
:
cat /etc/passwd
userID, groupID :
chown root fil1
sudo chown root fil1
ls l
owner group :
chown root:adm fil2
sudo chown root:adm fil2
~ cd
:
Directory/folder
Ls
Modification
Cd, ls -l
File
Cat
Vi
Execute
r
w
x
Linux
etc/passwd
hash
.
userID
.
:
cd Desktop/lecture04
ls ltrh
cd lecture12/
ls l
touch file12
1. symbolic mode:
chmod [u/g/o/a] [+/-/=] [rwx]
u=owner; g=group; o=others; a=all;
+ add permission; - delete permission; = chang permission;
chmod u+x file12
chmod g+w file12
chmod g-w file12
chmod o-r file12
2. octal mode: each permission is presented by number, r=4; w=2; x=1
let say that octal value = 7 then 7 = 111 = rwx
6 = 110 = rw5 = 101 = r-x
4 = 100 = r-3 = 011 = -wx
2 = 010 = -w1 = 001 = --x
0 = 000 = --632 = rw--wx-w751 = rwxr-x--x
777 = rwxrwxrwx
775 = rwxrwxr-x
chmod 44 file1 = chmod 044 file1
chmod 7 file1 = chmod 007 file1
chmod 600 file12
ls l
touch file4
ls ltrh
default permissions = rw-r--r-- which is defined by umask = 022
umask 666
755 644
.777
processes.
Linux
.
process
process
PID processID 5 process
process
.
process UID : GID
UID userID GID groupID
.process
process processes process
parent process .child process
parent process child process child process
child process child process
PPID .parent process ID
init process process
1 kernel parent process daemon process
zombie process
.
:processes
Ps
processes .
ps e
PID, TTY, Time, CMD
ps f
UID, PPID, PID, Time, TTY
ps ef
ps ef | more
:
UID .
PID .process
PPID parent peocess .process
C CPU .process
STIME .
TIME .process
CMD command .process
ps :
cd Desktop/lecture04
vi new_copy
ps ef | grep vi
.
ps ef | grep vi new_copy
.
pgrep vi
process
pgrep x vi
process vi .
pgrep n vi
process .
pgrep U 1000
1111
:
pgrep l U 1000
:
ptree vi
Signals
processes signals
process
:
sigkill 9 process .
sigterm 15 process .
: process
kill PID
kill SIGTERM 3771
kill -15 3771
:
Kill SIGKILL 3771
:
pkill vi
Linux
.
data centers
.
.
telnet
1969 unix
ports
.get, delete
plain text
.
telnet
telnet server
telnet client
putty 23
Linux
ubuntu, debian :
sudo s
apt-get update
apt-get install telnetd
telnet :
cd /etc/init.d/
inetd restart
exit
client IP
telnet:
Ifconfig
client :
telnet 192.168.1.55
telnet ( telnet
)server telnet
server telnet .exit
ssh
22 server digital
certificate client .
openSSH
:
sudo s
apt-get update
apt-get install openssh-server openssh-client
client :
ssh 192.168.1.55
key client .
server client FTP
SFTP SSH scp linux servers
.ssh
file1 client client :
cd Desktop/
dcp file1 ismail@192.168.1.55:/home/ismail/Desktop/lecture14
client .server
scp_folder client :server
scp r scp_folder ismail@192.168.1.55:/home/ismail/Desktop/
Linux .
passwd
root :
root :
su
passwd
passwd ismail
who
.
who H
who am i
whoami
cmp
.
cd Desktop/lecture04
cmp file6.txt file7.txt
cmp file11 file21
man cmp
sort
:
vi sort_file
ESC :wq
sort sort_file
:
vi sort_file1
:
sort sort_file sort_file1
.
:
:
:
sort u sort_file
sort n sort_file1
sort r sort_file
sort rn sort_file1
:
sort t , k1,1 sort_t
sort_t ,
.
:
simple link hard link
.Linux
windows shortcut
shortcut
shortcut
.
linux unix shortcut symbolic link
hard link .
Symbolic link
hard link .
Hard Disk
File1
File2
hard link
symbolic
link
Linux
inode
ls i inode
.
cd Desktop/lecture
ls i
touch f1 f2
.
ln
symbolic link hard link :
ln :hard link
ln s :symbolic link
Ln s /home/ismail/Desktop/lecture04/f1 /home/ismail/Desktop/f1_l
ls ltrh f1_l link
symbolic hard inode
inode link symbolic link .hard link
link :
rm f1_l
:hard link
ln /home/ismail/Desktop/lecture04/f1 /home/ismail/Desktop/
cd ..
ls ltrh
.
:
ls ltrh
:
D
L link
1 1
hard link .
Linux .
.
.
root super user
.
su
init 0
.level 0
init 6
shutdown r +2
To cancel commands
shutdown c
:
shutdown r +2 system will reboot within 2 minutes
:
shutdown h +10
: .
Linux
INSTANT LINUX
BASICS
COMMAND LINE
2014