> if문
#!/bin/bash
typeset -i b=30
if [ $b -eq 30 ];
then
echo "\$b = $b "
fi
root@il7:~# . a.sh
$b = 30
> if ~ else문
#!/bin/bash
typeset -i b=30
if [ $b -eq 30 ];
then
echo "\$b = $b"
else
echo "\$b = $c"
fi
$b = 30
> 다중 if 문
#!/bin/bash
typeset -i b=30
if [ $b -ge 90 ];
then
echo "\$b = $b A"
elif [ $b -ge 80 ];
then
echo "\$b = $b B"
elif [ $b -ge 70 ];
then
echo "\$b = $b C"
elif [ $b -ge 60 ];
then
echo "\$b = $b D"
else
echo "\$b = $b F"
fi
$b = 30 F
> for 문
#!/bin/bash
for a in aa bb cc dd
do
echo " a = $a"
done
a = aa
a = bb
a = cc
a = dd
> while 문
1 #!/bin/bash
2 n = 1
3 while [ $n -le 10 ]
4 do
5 sum=`expr $sum + $n`
6 echo " n = $n, sum = $sum "
7 n='expr $n + 1'
8 done
~
n = 1 , sum = 1
n = 2 , sum = 3
n = 3 , sum = 6
n = 4 , sum = 10
n = 5 , sum = 15
n = 6 , sum = 21
n = 7 , sum = 28
n = 8 , sum = 36
n = 9 , sum = 45
n = 10 , sum = 55
> until문
#!/bin/bash
n=1
until [ $n -gt 10]
do
sum=`expr $sum + $n `
echo " n=$n, sum = $sum "
n=`expr $n + 1 `
done
n = 1 , 1
n = 2 , 2
n = 3 , 3
n = 4 , 4
n = 5 , 5
n = 6 , 6
n = 7 , 7
n = 8 , 8
n = 9 , 9
n = 10 , 10
> case문
#!/bin/bash
var=1
case $var in
1)
echo "Apple"
;;
2)
echo "Grape"
;;
3)
echo "kiwi"
;;
esac
Apple
> continue,break문
#!/bin/bash
echi "== countinue"
for ((i=0; i<10;i++))
do
if (( i ==5 ))
then
countinue;
fi
echo " \$i ==> $i ";
done
echo " == break "
for ((i=0; i<10;i++))
do
if (( i ==5 ))
then
break;
fi
echo " \$i ==> $i ";
done
== continue
$i ==> 0
$i ==> 1
$i ==> 2
$i ==> 3
$i ==> 4
$i ==> 6
$i ==> 7
$i ==> 8
$i ==> 9
== break
$i ==> 0
$i ==> 1
$i ==> 2
$i ==> 3
$i ==> 4
> select문
#!/bin/bash
PS3="Select : "
select p in 'ls -f' pwd date who exit
do
$p
done
1) ls -f
2) pwd
3) date
4) who
5) exit
Select : 1
a1 h k2 4000 kk u2
ifelse.sh u3 continuebreak.sh .func1.sh.swp k1 u
hh.sh case.sh for.sh b.sh aa .
a1.c .. select.sh if.sh k3
func1.sh until.sh shift.sh while.sh multiif.sh
Select : 2
/root/d80
Select : 3
Wed May 3 09:52:49 PM KST 2023
Select : 4
j tty1 2023-05-03 10:46
j pts/0 2023-05-03 10:46
j pts/1 2023-05-03 10:47 (10.0.2.2)
j pts/2 2023-05-03 10:47 (10.0.2.2)
j pts/3 2023-05-03 11:54 (10.0.2.2)
j pts/4 2023-05-03 11:54 (10.0.2.2)
j pts/5 2023-05-03 12:08 (10.0.2.2)
j pts/6 2023-05-03 12:08 (10.0.2.2)
j pts/7 2023-05-03 15:06 (10.0.2.2)
j pts/8 2023-05-03 15:09 (10.0.2.2)
j pts/9 2023-05-03 17:55 (10.0.2.2)
j pts/13 2023-05-03 16:20 (10.0.2.2)
j pts/14 2023-05-03 16:20 (10.0.2.2)
j pts/15 2023-05-03 17:14 (10.0.2.2)
j pts/16 2023-05-03 17:14 (10.0.2.2)
Select : 5
> shift문
#!/bin/bash
echo $*
shift
echo $*
shift
echo $*
shift
echo $*
shift
echo $*
echo $*
echo "shift 3 "
shift 3
echo $*
C언어 자료구조 UNIX 오라클
자료구조 UNIX 오라클
UNIX 오라클
오라클
C언어 자료구조 UNIX 오라클
shift 3
오라클
> 함수 - 1
#!/bin/bash
function sub
{
echo " sub 함수입니다 "
}
function sub2
{
echo " 함수에서 인수받기 "
echo " \$1 = $1, \$2 = $2 "
}
sub2 "한국인" "중국인"
function sub3
{
echo " 함수에서 리턴하기 "
return 20 25
}
sub3
n=$?
echo " return value = $n "
sub 함수입니다
함수에서 인수 받기
$1 = 한국인, $2 = 중국인
함수에서 리턴하기
return value = 20
> 함수 - 2
#!/bin/bash
sum
{
res=$(($1+$2))
return $res
}
a=3
b=5
sum $a $b
retval=$?
echo "$a + $b = $retval"
3 + 5 = 8
NC 서버 설정하기
먼저 repo 변경하고 시작하세요.
>> repo 변경하기
vi /etc/apt/sources.list
:% s/kr.archive.ubuntu.com/mirror.kakao.com/g
cat > ~/.bash_aliases << A
alias h='history'
alias l='ls -AlF'
alias c='clear'
alias cp='cp -i'
alias mv='mv -i'
alias df='df -h'
alias du='du -sh'
alias li='ls -Ali'
alias lh='ls -Alh'
##root only
alias ai='apt -y install'
alias aq='apt list --installed | grep '
alias ac='apt list --installed | wc -l'
alias pq='ps -ef | grep'
alias sss='systemctl start '
alias ses='systemctl restart'
alias uq='tail -7 /etc/passwd && ls /home'
A
. ~/.profile
cat > ~/.vimrc << A
se nu ai ci si ts=4 sw=4 ruler title showmatch
syntax on
hi comment ctermfg=red
A
. ~/.vimrc
echo "PATH=$PATH:." >> ~/.profile
chmod +x my_init.sh
mount -o remount / - 클라우드는 home이 없기에
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'jj';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> create user ilil@localhost identified with mysql_native_password by 'jj';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on ilDB.* to ilil@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
apt-get -y install php php-curl php-gd php-intl php-mbstring php-soap php-xml
ai php-xmlrpc php-zip php-mysql
cd /var/www/html
/var/www/html# cat > il.php
"); phpinfo(); ?>chmod 755 ~
w3m localhost/il.php
wget https://ko.wordpress.org/latest-ko_KR.tar.gz
tar xf latest-ko_KR.tar.gz
il.php index.html latest-ko_KR.tar.gz wordpress
mv wordpress/ wp
w3m localohost/wp
chmod 755 wp
w3m localhost/wp
systemctl restart tomcat9
http://127.0.0.1:8080
vi /etc/fstab
9 UUID=8d992262-a389-4a90-b69a-8c010594a44a / ext4 errors=rem ount-ro,usrquota 0 1
mount -o remount /
quotaoff -avug
quotacheck -avugm
repquota -a
quotaon -avug
edquota -u
edquota -p <source - user>
bind설정, 확인
vi named.conf.options
21 dnssec-validation no;
22 recursion yes;
23 allow-query { any; };
24 listen-on-v6 { any; };
31 zone "il.co.kr" {
32 type master;
33 file "/etc/bind/il.zone";
34 };
35
36 zone "30.200.100.in-addr.arpa" {
37 type master;
38 file "/etc/bind/il.rev";
39 };
vi il.rev
1 $TTL 604800
2 @ IN SOA ns.il.co.kr. master.il.co.kr. (
3 2 ; Serial
4 604800 ; Refresh
5 86400 ; Retry
6 2419200 ; Expire
7 604800 ) ; Negative Cache TTL
8 ;
9 @ IN NS ns.il.co.kr.
10 IN A 100.200.30.10
11 10 IN PTR ns.il.co.kr.
12 20 IN PTR www.il.co.kr.
13 20 IN PTR king.il.co.kr.
14 30 IN PTR ftp.il.co.kr.
15 40 IN PTR mail.il.co.kr.
vi il.zone
1 $TTL 604800
2 @ IN SOA ns.il.co.kr. master.il.co.kr. (
3 2 ; Serial
4 604800 ; Refresh
5 86400 ; Retry
6 2419200 ; Expire
7 604800 ) ; Negative Cache TTL
8 ;
9 @ IN NS ns.il.co.kr.
10 IN A 100.200.30.10
11 ns IN A 100.200.30.10
12 www IN A 100.200.30.20
13 ftp IN A 100.200.30.30
14 mail IN A 100.200.30.40
15 king IN CNAME www
systemctl restart bind9
ai sendmail
ai mailutil
mail 1234@abcd.123