프로그램 실행
* GUI 환경이 아닌 곳에서
시스템
프로세스
- 모니터링
foreground(전면에서 실행)
/ background(후면에서 실행)
ps
ps -ef | grep 찾고자 하는 프로세스명
ps aux | grep 찾고자 하는 프로세스명
top
pstree
kill -9 프로세스아이디(pid)
* gedit 실행 -> pid -> kill
프로그램
스레드
* gedit 실행 -> pid -> kill 해보자
[master@localhost ~]$ ps -ef | grep gedit
master 3347 1 28 09:57 ? 00:00:00 /usr/bin/gedit --gapplication-service
master 3357 3177 0 09:57 pts/0 00:00:00 grep --color=auto gedit
[master@localhost ~]$ kill -9 3347
텍스트 편집기 종료됨
텍스트 편집기 들어가서 작성하다가 잠시 백그라운드로 전환하고자 하면 : sh를 한다
exit를 명령어로 치면 다시 텍스트 편집기로 들어간다
작업예약을 해보자
윈도우에서는 위와 같이 할 수 있다.
[master@localhost ~]$ at -l
[master@localhost ~]$ at 10:18 am today
at> ls -l ~master
at> <EOT>
job 1 at Thu Aug 16 10:18:00 2018
[master@localhost ~]$ at -l
1 Thu Aug 16 10:18:00 2018 a master
1부터 10까지 순차적으로 숫자를 세는 counter를 만들어준다.
public class counter {
public static void main(String[] args) {
for(int i=1; i<=10; i++) {
System.out.println("i = " + i);
}
}
}
[master@localhost ~]$
You have new mail in /var/spool/mail/master
[master@localhost ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/master": 1 message 1 new
>N 1 master Thu Aug 16 10:18 28/1347 "Output from your job "
&
Message 1:
From master@localhost.localdomain Thu Aug 16 10:18:01 2018
Return-Path: <master@localhost.localdomain>
X-Original-To: master
Delivered-To: master@localhost.localdomain
Subject: Output from your job 1
To: master@localhost.localdomain
Date: Thu, 16 Aug 2018 10:18:01 +0900 (KST)
From: master@localhost.localdomain (master)
Status: R
합계 8
-rw-rw-r--. 1 master master 425 8월 13 17:20 HelloWorld.class
-rw-rw-r--. 1 master master 114 8월 13 17:19 HelloWorld.java
drwxrwxr-x. 2 master master 6 8월 14 12:30 sub1
-rwxrw-r--. 1 master master 0 8월 14 12:30 test.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:19 test1.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:21 test2.txt
drwxr-xr-x. 2 master master 6 8월 13 20:18 공개
drwxr-xr-x. 2 master master 6 8월 13 20:18 다운로드
drwxr-xr-x. 2 master master 6 8월 13 20:18 문서
drwxr-xr-x. 2 master master 6 8월 13 20:18 바탕화면
drwxr-xr-x. 2 master master 6 8월 13 20:18 비디오
drwxr-xr-x. 2 master master 6 8월 13 20:18 사진
drwxr-xr-x. 2 master master 6 8월 13 20:18 서식
--More--
[master@localhost ~]$ at 1:12 pm today
at> java counter ~master
at> <EOT>
job 8 at Thu Aug 16 13:12:00 2018
You have mail in /var/spool/mail/master
[master@localhost ~]$ at -l
8 Thu Aug 16 13:12:00 2018 a master
[master@localhost ~]$
[master@localhost ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/master": 8 messages 1 new
1 master Thu Aug 16 10:18 29/1358 "Output from your job "
2 master Thu Aug 16 10:55 31/1484 "Output from your job "
3 master Thu Aug 16 10:55 24/586 "Output from your job "
4 master Thu Aug 16 13:05 15/576 "Output from your job "
5 master Thu Aug 16 13:07 15/576 "Output from your job "
6 master Thu Aug 16 13:10 15/576 "Output from your job "
7 master Thu Aug 16 13:11 15/571 "Output from your job "
>N 8 master Thu Aug 16 13:12 23/575 "Output from your job "
& 8
Message 8:
From master@localhost.localdomain Thu Aug 16 13:12:01 2018
Return-Path: <master@localhost.localdomain>
X-Original-To: master
Delivered-To: master@localhost.localdomain
Subject: Output from your job 8
To: master@localhost.localdomain
Date: Thu, 16 Aug 2018 13:12:01 +0900 (KST)
From: master@localhost.localdomain (master)
Status: R
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
i = 10
&
At EOF
& q
Held 8 messages in /var/spool/mail/master
You have mail in /var/spool/mail/master
root로 예정된 작업을 확인해보자
[root@localhost ~]# ls -l /var/spool/at/
합계 8
-rwx------. 1 master master 4470 8월 16 13:17 a0000901863764
drwx------. 2 root root 6 8월 16 13:12 spool
[root@localhost ~]# atq
9 Thu Aug 16 13:20:00 2018 a master
예정된 작업을 지워보자
[root@localhost ~]# at -d 9
[root@localhost ~]# atq
[root@localhost ~]# atrm8
정해진 시간에 반복 실행
[master@localhost ~]$ crontab -l
no crontab for master
[master@localhost ~]$ ls /var/spool/cron/
ls: cannot open directory /var/spool/cron/: 허가 거부
[master@localhost ~]$ crontab -e
no crontab for master - using an empty one
crontab: installing new crontab
[master@localhost ~]$ crontab -l
10 11 * * * ls -l ~master > ~master/crontab.out
[master@localhost ~]$ ls -l ~master
합계 12
-rw-rw-r--. 1 master master 425 8월 13 17:20 HelloWorld.class
-rw-rw-r--. 1 master master 114 8월 13 17:19 HelloWorld.java
-rw-rw-r--. 1 master master 138 8월 16 10:52 counter.java
drwxrwxr-x. 2 master master 6 8월 14 12:30 sub1
-rwxrw-r--. 1 master master 0 8월 14 12:30 test.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:19 test1.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:21 test2.txt
drwxr-xr-x. 2 master master 6 8월 13 20:18 공개
drwxr-xr-x. 2 master master 6 8월 13 20:18 다운로드
drwxr-xr-x. 2 master master 6 8월 13 20:18 문서
drwxr-xr-x. 2 master master 6 8월 13 20:18 바탕화면
drwxr-xr-x. 2 master master 6 8월 13 20:18 비디오
drwxr-xr-x. 2 master master 6 8월 13 20:18 사진
drwxr-xr-x. 2 master master 6 8월 13 20:18 서식
drwxr-xr-x. 2 master master 6 8월 13 20:18 음악
[master@localhost ~]$ ls -l ~master > test.txt
[master@localhost ~]$ cat test.txt
합계 12
-rw-rw-r--. 1 master master 425 8월 13 17:20 HelloWorld.class
-rw-rw-r--. 1 master master 114 8월 13 17:19 HelloWorld.java
-rw-rw-r--. 1 master master 138 8월 16 10:52 counter.java
drwxrwxr-x. 2 master master 6 8월 14 12:30 sub1
-rwxrw-r--. 1 master master 0 8월 16 11:09 test.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:19 test1.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:21 test2.txt
drwxr-xr-x. 2 master master 6 8월 13 20:18 공개
drwxr-xr-x. 2 master master 6 8월 13 20:18 다운로드
drwxr-xr-x. 2 master master 6 8월 13 20:18 문서
drwxr-xr-x. 2 master master 6 8월 13 20:18 바탕화면
drwxr-xr-x. 2 master master 6 8월 13 20:18 비디오
drwxr-xr-x. 2 master master 6 8월 13 20:18 사진
drwxr-xr-x. 2 master master 6 8월 13 20:18 서식
drwxr-xr-x. 2 master master 6 8월 13 20:18 음악
>는 출력방향을 바꾼다는 redirection이다. 위에서는 출력을 text.txt에 출력해버린 것이고 그 결과는 cat test.txt를 통해 알아보면 제대로 동작함을 알 수 있다.
[master@localhost ~]$ crontab -l
10 11 * * * ls -l ~master > ~master/crontab.out
[master@localhost ~]$ ls
HelloWorld.class crontab.out test1.txt 다운로드 비디오 음악
HelloWorld.java sub1 test2.txt 문서 사진
counter.java test.txt 공개 바탕화면 서식
[master@localhost ~]$ cat crontab.out
합계 16
-rw-rw-r--. 1 master master 425 8월 13 17:20 HelloWorld.class
-rw-rw-r--. 1 master master 114 8월 13 17:19 HelloWorld.java
-rw-rw-r--. 1 master master 138 8월 16 10:52 counter.java
-rw-r--r--. 1 master master 0 8월 16 11:10 crontab.out
drwxrwxr-x. 2 master master 6 8월 14 12:30 sub1
-rwxrw-r--. 1 master master 896 8월 16 11:09 test.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:19 test1.txt
-rw-rw-r--. 1 tester1 tester1 0 8월 14 12:21 test2.txt
drwxr-xr-x. 2 master master 6 8월 13 20:18 공개
drwxr-xr-x. 2 master master 6 8월 13 20:18 다운로드
drwxr-xr-x. 2 master master 6 8월 13 20:18 문서
drwxr-xr-x. 2 master master 6 8월 13 20:18 바탕화면
drwxr-xr-x. 2 master master 6 8월 13 20:18 비디오
drwxr-xr-x. 2 master master 6 8월 13 20:18 사진
drwxr-xr-x. 2 master master 6 8월 13 20:18 서식
drwxr-xr-x. 2 master master 6 8월 13 20:18 음악
매일 11시 10분에 crontab을 만들라고 한것을 확인해 보면 위와 같이 잘 만들어졋음을 알 수 있다.
네이버 실시간 검색어를 긁어와 보자
[master@localhost ~]$ ping 192.168.0.16
PING 192.168.0.16 (192.168.0.16) 56(84) bytes of data.
64 bytes from 192.168.0.16: icmp_seq=1 ttl=128 time=0.553 ms
64 bytes from 192.168.0.16: icmp_seq=2 ttl=128 time=0.482 ms
64 bytes from 192.168.0.16: icmp_seq=3 ttl=128 time=0.441 ms
64 bytes from 192.168.0.16: icmp_seq=4 ttl=128 time=0.501 ms
64 bytes from 192.168.0.16: icmp_seq=5 ttl=128 time=0.519 ms
64 bytes from 192.168.0.16: icmp_seq=6 ttl=128 time=0.587 ms
64 bytes from 192.168.0.16: icmp_seq=7 ttl=128 time=0.434 ms
64 bytes from 192.168.0.16: icmp_seq=8 ttl=128 time=0.502 ms
^C
--- 192.168.0.16 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 6999ms
rtt min/avg/max/mdev = 0.434/0.502/0.587/0.052 ms
리눅스에서 Filezilla를 다운 받는다
filezilla 설치하기
[root@localhost ~]# yum -y install filezilla
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.kaist.ac.kr
* updates: ftp.kaist.ac.kr
No package filezilla available.
Error: Nothing to do
No Package filezilla available이라 적히면 eple repository를 설치해야 한다
[root@localhost ~]# yum -y install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.kaist.ac.kr
* updates: ftp.kaist.ac.kr
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1
Installed:
epel-release.noarch 0:7-11
Complete!
이제 filezilla를 깔자
[root@localhost ~]# yum -y install filezilla
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.9 kB 00:00
* base: ftp.kaist.ac.kr
* epel: mirror.premi.st
* extras: ftp.kaist.ac.kr
* updates: ftp.kaist.ac.kr
epel | 3.2 kB 00:00
(1/3): epel/x86_64/group_gz | 88 kB 00:00
epel/x86_64/updateinfo FAILED
http://mirror.dmmlabs.jp/linux/fedora/epel/7/x86_64/repodata/3133880428a75ac08f85f7d3cde4bf4168f81d8afd9b62b7cc230192ddcac35b-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
(2/3): epel/x86_64/updateinfo | 934 kB 00:00
epel/x86_64/primary FAILED
http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/7/x86_64/repodata/38fcc834a9c1a2bff6785b64f431c21efb8a0283d4fe7535a4877f6407e851a7-primary.xml.gz: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(3/3): epel/x86_64/primary | 3.6 MB 00:00
epel 12657/12657
Resolving Dependencies
--> Running transaction check
---> Package filezilla.x86_64 0:3.7.4.1-1.el7 will be installed
--> Processing Dependency: libwx_gtk2u_xrc-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_core-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_aui-2.8.so.0(WXU_2.8.5)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_aui-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_adv-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_baseu_net-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_baseu-2.8.so.0(WXU_2.8)(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_xrc-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_core-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_aui-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_gtk2u_adv-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_baseu_xml-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_baseu_net-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Processing Dependency: libwx_baseu-2.8.so.0()(64bit) for package: filezilla-3.7.4.1-1.el7.x86_64
--> Running transaction check
---> Package wxBase.x86_64 0:2.8.12-20.el7 will be installed
---> Package wxGTK.x86_64 0:2.8.12-20.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
filezilla x86_64 3.7.4.1-1.el7 epel 3.1 M
Installing for dependencies:
w64.rpm | 2.9 MB 00:00
--------------------------------------------------------------------------------
Total 3.7 MB/s | 6.6 MB 00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-11.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wxBase-2.8.12-20.el7.x86_64 1/3
Installing : wxGTK-2.8.12-20.el7.x86_64 2/3
Installing : filezilla-3.7.4.1-1.el7.x86_64 3/3
Verifying : wxGTK-2.8.12-20.el7.x86_64 1/3
Verifying : wxBase-2.8.12-20.el7.x86_64 2/3
Verifying : filezilla-3.7.4.1-1.el7.x86_64 3/3
Installed:
filezilla.x86_64 0:3.7.4.1-1.el7
Dependency Installed:
wxBase.x86_64 0:2.8.12-20.el7 wxGTK.x86_64 0:2.8.12-20.el7
Complete!
Java로 작성하여 Dept를 불러와보자
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class tableloader {
public static void main(String[] args) {
String url = "jdbc:oracle:thin:@192.168.0.16:1521:orcl";
String user = "scott";
String password = "tiger";
Statement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, user, password);
String sql = "select * from dept";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.printf("%s\t%s\t%s\n",
rs.getString("deptno"),
rs.getString("dname"),
rs.getString("loc"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if(rs != null) try {rs.close();} catch(SQLException e) {};
if(stmt != null) try {stmt.close();} catch(SQLException e) {};
if(conn != null) try {conn.close();} catch(SQLException e) {};
}
}
}
위에 것을 vi tableloader.java에 작성한다
[master@localhost ~]$ javac tableloader.java
[master@localhost ~]$ java -classpath .:/home/master/ojdbc7.jar tableloader
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
CLASSPATH 환경변수에 ojdbc7.jar를 추가하기 위해서 아래와 같이 한다
[master@localhost ~]$ vi .bash_profile
[master@localhost ~]$ source .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export CLASSPATH=.:/home/master/ojdbc7.jar
[master@localhost ~]$ vi .bash_profile
[master@localhost ~]$ java tableloader
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
환경변수에 추가해줬기 때문에 classpath로 안하고 그냥 java tableloader로 해도 됨
리눅스에 이클립스를 설치해보자
www.eclipse.org에서 eclipse photon linux 64bit를 다운받고 터미널을 켜서 아래와 같이 한다
[master@localhost ~]$ ls 다운로드/
FileZilla3
FileZilla_3.35.2_x86_64-linux-gnu.tar.bz2
eclipse
eclipse-jee-photon-R-linux-gtk-x86_64.tar.gz
[master@localhost ~]$ mv ./다운로드/eclipse .
[master@localhost ~]$ ls
HelloWorld.class crontab.out tableloader.class test2.txt 바탕화면 음악
HelloWorld.java eclipse tableloader.java 공개 비디오
counter.class ojdbc7.jar test.txt 다운로드 사진
counter.java sub1 test1.txt 문서 서식
[master@localhost ~]$ cd ./eclipse/
[master@localhost eclipse]$ ls
artifacts.xml dropins eclipse.ini icon.xpm plugins
configuration eclipse features p2 readme
[master@localhost eclipse]$ ./eclipse
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCEx01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
String url = "jdbc:oracle:thin:@192.168.0.16:1521:orcl";
String user = "scott";
String password = "tiger";
Statement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, user, password);
String sql = "select * from dept";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.printf("%s\t%s\t%s\n",
rs.getString("deptno"),
rs.getString("dname"),
rs.getString("loc"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if(rs != null) try {rs.close();} catch(SQLException e) {};
if(stmt != null) try {stmt.close();} catch(SQLException e) {};
if(conn != null) try {conn.close();} catch(SQLException e) {};
}
}
}
'Web & Mobile > Linux' 카테고리의 다른 글
Lecture 67 - Linux(5) 네트워크, 원격관리 (0) | 2019.06.21 |
---|---|
Lecture 66 - Linux(4) RPM 패키지, YUM 패키지, 톰캣 설치법, putty 사용법, vsftp 설치법 (0) | 2019.06.20 |
Lecture 64 - Linux(2) 사용자 계정 관리, 로그인 관리 (0) | 2019.06.18 |
Lecture 63 - Linux(1) 리눅스의 기초 (0) | 2019.06.17 |
VMware을 이용한 Linux CentOS 설치 방법 (0) | 2019.06.17 |
댓글