インターネット技術特論
コマンドライン,shell
B:コマンドライン, shell
山口 実靖
http://www.ns.kogakuin.ac.jp/~ct13140/inet/
インターネット技術特論B-1
login shellを tcsh に変更
インターネット技術特論B-2
コマンドラインログイン方法
https://user.ccs.kogakuin.ac.jp/icassist/
にアクセス.
• PuTTY によるコマンドラインログイン
– ユーザ名(学籍番号)とパスワード を入力 → OK
↓
– 登録情報
↓
– ログインシェルを"/usr/local/bin/tcsh"に変
更して,"更新"
– 入手
http://www.chiark.greenend.org.uk/~sgtatham/putty/
"Download PuTTY!" → "putty.exe"
インターネット技術特論-3
コマンドラインログイン方法
• PuTTY によるコマンドラインログイン
– 実行
インターネット技術特論-4
コマンドラインログイン方法
学籍番号
パスワード
green.ns.kogakuin.ac.jp
22
初回接続時の
質問は"Yes"を選択
インターネット技術特論-5
PuTTY における copy & paste
• マウスでドラッグ → コピー
• マウスを右クリック → ペースト
インターネット技術特論-8
コマンドライン操作
• ls : 存在するファイルのリストを表示
• pwd : 現在地(カレントディレクトリ)の表示
• cd : 移動. 現在地の変更.
• cp : ファイルのコピー
• mv : ファイルの移動,名前変更
• rm : ファイルの削除
• mkdir : ディレクトリの作成
• rmdir : ディレクトリの削除
インターネット技術特論-9
インターネット技術特論-10
ls
ct13140@green[101]:ls
Documents and Settings/
News/
a/
public_html/
ct13140@green[102]:
ls -alF
ct13140@green[132]:ls -alF
total 3368
drwxr-xr-x 14 ct13140 user
drwxr-xr-x 10254 root
root
-rw------1 ct13140 user
-rw------1 ct13140 user
-rw------1 ct13140 user
-rw-r--r-1 ct13140 user
-rw-r--r-1 ct13140 user
-rw------1 ct13140 user
-rw------1 ct13140 user
-rw------1 ct13140 user
drwx-----2 ct13140 user
-rw-r--r-1 ct13140 user
drwx-----6 ct13140 user
drwx-----4 ct13140 user
drwx-----2 ct13140 user
drwxr-xr-x 15 ct13140 user
drwxr-xr-x
2 ct13140 user
Mail/
WindowsApplication1/
a.txt
temp/
現在地(カレントディレクトリ)にあるファイルのリストが表示された.
ls は list コマンド.
4096 Sep 15 01:07 ./
954368 Sep 10 09:42 ../
204 Sep 9 22:55 .Xauthority
10 Sep 15 01:07 .bash_history
91 Sep 11 2008 .cshrc
21 Apr 12 2007 .exrc
32 Oct 4 2007 .forward
687 Sep 15 00:35 .history
46 Apr 3 2006 .login
75 Apr 3 2006 .mh_profile
4096 Nov 5 2008 .ssh/
77 Sep 11 2008 .tcshrc
4096 Jul 5 2007 Documents and Settings/
4096 Sep 11 2007 Mail/
4096 Apr 3 2006 News/
4096 Sep 10 17:58 public_html/
4096 May 1 2006 temp/
現在地(カレントディレクトリ)にあるファイルのリストが
詳細な情報とともに表示された.
インターネット技術特論-11
cd, pwd (相対パス)
ct13140@green[101]:ls
Documents and Settings/
News/
a/
public_html/
ct13140@green[102]:pwd
/home/ct13140
ct13140@green[103]:ls
Documents and Settings/
News/
a/
public_html/
ct13140@green[104]:cd a
/home/ct13140/a
ct13140@green[105]:pwd
/home/ct13140/a
ct13140@green[106]:ls
x/ y/ z/
ct13140@green[107]:cd x
/home/ct13140/a/x
ct13140@green[108]:pwd
/home/ct13140/a/x
ct13140@green[109]:ls
x0.txt
x1.txt
x2.txt
ct13140@green[110]:cd ..
/home/ct13140/a
ct13140@green[111]:pwd
/home/ct13140/a
cd, pwd (相対パス)
/
Mail/
WindowsApplication1/
a.txt
temp/
home
Mail/
WindowsApplication1/
a.txt
temp/
ct13140
a
Mail
public_html
x
y
インターネット技術特論-12
z
ct13140@green[111]:pwd
/home/ct13140/a
ct13140@green[112]:ls
x/ y/ z/
ct13140@green[113]:cd y
/home/ct13140/a/y
ct13140@green[114]:pwd
/home/ct13140/a/y
ct13140@green[115]:ls
y.txt
yy.txt
ct13140@green[116]:cd ..
/home/ct13140/a
ct13140@green[117]:pwd
/home/ct13140/a
ct13140@green[118]:ls
x/ y/ z/
ct13140@green[119]:cd z
/home/ct13140/a/z
ct13140@green[120]:pwd
/home/ct13140/a/z
ct13140@green[121]:ls
000.ppt
001.ppt
002.ppt
ct13140@green[122]:cd ../..
/home/ct13140
ct13140@green[123]:pwd
/home/ct13140
ct13140@green[124]:cd ..
/home
ct13140@green[125]:pwd
/home
/
home
ct13140
a
Mail
public_html
x
y
インターネット技術特論-13
cd, pwd (相対パス)
ct13140@green[125]:pwd
/home
ct13140@green[126]:cd ..
/
ct13140@green[127]:pwd
/
ct13140@green[128]:ls
NR_etc/
Settings/
and/
core
dev/
devices/
fj/
home/
kernel/
mnt/
net/
opt/
rsc/
sbin/
snap/
var/
vol/
xfn/
ct13140@green[129]:cd usr
/usr
ct13140@green[130]:cd local/
/usr/local
ct13140@green[131]:cd var/
/usr/local/var
ct13140@green[132]:cd games/
/usr/local/var/games
ct13140@green[133]:cd emacs/
/usr/local/var/games/emacs
ct13140@green[134]:ls
snake-scores
tetris-scores
cdrom/
export/
lost+found/
proc/
usr/
home
インターネット技術特論-14
cd, pwd (絶対パス)
/
bin@
etc/
lib@
platform/
tmp/
z
usr
local
var
ct13140@green[101]:pwd
/home/ct13140
ct13140@green[102]:cd /usr/local/var/games/emacs/
/usr/local/var/games/emacs
ct13140@green[103]:pwd
/usr/local/var/games/emacs
ct13140@green[104]:cd /tmp
/tmp
ct13140@green[105]:pwd
/tmp
ct13140@green[106]:cd /usr/share/doc/
/usr/share/doc
ct13140@green[107]:pwd
/usr/share/doc
ct13140@green[108]:cd
/home/ct13140
ct13140@green[109]:pwd
/home/ct13140
games
emacs
インターネット技術特論-15
インターネット技術特論-16
ファイルの属性
cd, pwd
• 特殊な相対パス
.
カレントディレクトリを意味する
.. アッパーディレクトリを意味する
• 特殊な絶対パス
/
ルートディレクトリ(トップディレクトリ)
-rw-------
1 ct13140
user
91 Sep 11
2001 .cshrc
↑ファイルのパーミッションが"-rw-------"であることを示す.
詳細は後述.
-rw-------
1 ct13140
user
91 Sep 11
2001 .cshrc
↑ファイルのownerが"ct13140"であることを示す.
-rw-------
1 ct13140
user
91 Sep 11
2001 .cshrc
↑ファイルのgroupが"user"であることを示す.
-rw-------
1 ct13140
user
91 Sep 11
2001 .cshrc
↑ファイルのサイズが"91"であることを示す.
-rw-------
1 ct13140
user
91 Sep 11
2001 .cshrc
↑ファイルの更新日時が"Sep 11 2001"であることを示す.
インターネット技術特論-17
インターネット技術特論-18
ファイルのパーミッション
ファイルのパーミッション
最初の1文字は,ディレクトリか否か.
drwxr-xr-x
"d"はディレクトリであることを示す.
-rw-r--r-次の3文字は"ファイルのオーナー"に対する
パーミッション.
-rw-r--r-次の3文字は"グループのメンバー"に対する
パーミッション.
-rw-r--r-"-"はディレクトリでなくファイルであるこ
とを示す.
-rw-r--r-次の3文字は"それ以外のユーザ"に対する
パーミッション.
インターネット技術特論-19
ファイルのパーミッション
インターネット技術特論-20
ファイルのパーミッション
rwxは,Read,Write,eXecuteの権限
-rw-r--r—
ファイルのオーナーに対して,
read,write許可,実行不許可.
• ディレクトリのx(実行権限)は,"ディレクトリに
入る権限"
• 他にも,"setuid","setgid","sticky
bit"があるが,割愛.
-rw-r--r-グループのメンバーに対して,
read許可,write,実行不許可.
-rw-r--r-その他のユーザに対して,
read許可,write,実行不許可.
インターネット技術特論-21
ファイルのパーミッションの変更
• rwx は 許可,不許可 の1bit.2進数で表現可能.
• 例
rwx
r-x
-wx
--x
:
:
:
:
111
101
011
001
→
→
→
→
7
5
3
1
rwr--w---
:
:
:
:
110
100
010
000
→
→
→
→
6
4
2
0
インターネット技術特論-22
ファイルのパーミッションの変更
ct13140@green[101]:ls -l a.b
-rw-r----- 1 ct13140 (略) a.b
ct13140@green[102]:chmod 705 a.b
ct13140@green[103]:ls -l a.b
-rwx---r-x 1 ct13140 (略) a.b*
"chmod 705 a.b" は,
"オーナー向けパーミッション" を
"グループ向けパーミッション" を
"その他向けパーミッション" を
7(111=rwx) にして,
0(000=---) にして,
5(101=r-x) にする.
インターネット技術特論-23
サーバでのC言語の使用
インターネット技術特論-24
サーバでのC言語の使用
• 右記のファイルをWebサーバに転送.
• コンパイル
cc hoge.c –o abc
"hoge.c" をコンパイルして,"abc"という実行
ファイルを作成する.
• 実行
./abc
hello.c
#include <stdio.h>
void main(){
printf("Hello¥n");
}
– カレントディレクトリの"abc"を実行する.
インターネット技術特論-25
インターネット技術特論-26
サーバでのC言語の使用
ct13140@green[100]:ls
Documents and Settings/ Mail/
News/
WindowsApplication1/
a/
a.txt
hello.c
hello.c
public_html/
temp/
#include <stdio.h>
ct13140@green[101]:cat hello.c
void main(){
#include <stdio.h>
printf("Hello¥n");
void main(){
}
printf("Hello¥n");
}
ct13140@green[102]:cc hello.c -o hello
ct13140@green[103]:ls
Documents and Settings/ Mail/
News/
WindowsApplication1/
a/
a.txt
hello*
hello.c
public_html/
temp/
ct13140@green[104]:./hello
Hello
ct13140@green[105]:
インターネット技術特論-27
© Copyright 2026 Paperzz