Cd_(UNIX)
[Wikipedia|▼Menu]

.mw-parser-output .monospaced{font-family:monospace,monospace}cd(シーディー、change directory)は、シェル等の(プロセスの)現在のワーキングディレクトリ(カレントディレクトリ)を変更するコマンドである。UNIX系(UNIXやLinuxなど)のターミナルで入力して使う。
概要

原理的に外部コマンドとして実装することが不可能であり、かならずシェル等の内部コマンド(ビルトインコマンド、en:Shell builtin)として実装される。

ディレクトリファイルシステム中の論理的な区分であり、ファイルを保持するために使われる。ディレクトリは他のディレクトリをも含めることができる。cdコマンドはサブディレクトリ(子ディレクトリ)に移動したり、親ディレクトリに移動したり、ルートディレクトリ(すべてのディレクトリの根にあたるディレクトリ)に一気に移動したり、ある与えられたディレクトリに移動したりすることができる。

次の図は何らかのファイルシステムの一部分を示している。1つのファイル ("text.txt")と3つのサブディレクトリを含むユーザのホームディレクトリ(~で表している[1])が示されている。

もしカレントディレクトリがホームディレクトリ(~)であれば、「cd games」というコマンドを実行した後で「ls」と実行すると、例えば次のような結果が得られる。me@host:~$ lsworkreports games encyclopedia text.txtme@host:~$ cd gamesme@host:games$

ユーザはこの時点で"games"ディレクトリにいる。
引数

引数なし、あるいは cd ~ 
シェル変数 $HOME に設定されたディレクトリ(※
[注釈 1])に移動する。

cd ~ユーザ名
ユーザ名のホームディレクトリに移動

cd ディレクトリ名
サブディレクトリに移動。たとえば今カレントディレクトリが /user の状態で「cd bin」と入力しenterキーを押すと /user/bin に移動する。一方、「cd /bin」と入力しenterキーを押すと /bin に移動する。

cd ..
ひとつ上のディレクトリに移動。たとえばいま仮に /user/bin/temp にいる状態で「cd ..」と入力しenterキーを押すと、/user/binに移動する。

cd ../..
ふたつ上のディレクトリに移動。たとえばいま仮に /user/bin/temp にいる状態で「cd ../..」と入力しenterキーを押すと /user に移動する。

cd -
直前にいたディレクトリに移動。たとえばある時 /user/bin にいて、次に「cd /etc」と入力しenterキーを押し /etcに移動した状態で元の /user/binに戻りたかったら「cd -」と入力してenterキーを押せばよい。そこで何か作業をしてまた /etc に戻りたかったら「cd -」と入力すれば良い。つまり「cd - 」を使えば、ユーザは2つのディレクトリに交互に移動して作業する場合に毎回ディレクトリ名を入力する手間が省ける。
^ '~' をユーザのホームディレクトリが設定されている変数 $HOME として解釈するか否かはシェルの実装に依存する。
^ 通常はユーザのホームディレクトリがログイン時に環境変数として設定されている。

外部リンク

cd(1)
man page(SunOS リファレンスマニュアル 1 : ユーザーコマンド) - オラクル
.mw-parser-output .asbox{position:relative;overflow:hidden}.mw-parser-output .asbox table{background:transparent}.mw-parser-output .asbox p{margin:0}.mw-parser-output .asbox p+p{margin-top:0.25em}.mw-parser-output .asbox{font-size:90%}.mw-parser-output .asbox-note{font-size:90%}.mw-parser-output .asbox .navbar{position:absolute;top:-0.90em;right:1em;display:none}

この項目は、コンピュータに関連した書きかけの項目です。この項目を加筆・訂正などしてくださる協力者を求めていますPJ:コンピュータ/P:コンピュータ)。
.mw-parser-output .hlist ul,.mw-parser-output .hlist ol{padding-left:0}.mw-parser-output .hlist li,.mw-parser-output .hlist dd,.mw-parser-output .hlist dt{margin-right:0;display:inline-block;white-space:nowrap}.mw-parser-output .hlist dt:after,.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{white-space:normal}.mw-parser-output .hlist li:after,.mw-parser-output .hlist dd:after{content:" ・\a0 ";font-weight:bold}.mw-parser-output .hlist dt:after{content:": "}.mw-parser-output .hlist-pipe dd:after,.mw-parser-output .hlist-pipe li:after{content:" |\a0 ";font-weight:normal}.mw-parser-output .hlist-hyphen dd:after,.mw-parser-output .hlist-hyphen li:after{content:" -\a0 ";font-weight:normal}.mw-parser-output .hlist-comma dd:after,.mw-parser-output .hlist-comma li:after{content:"、";font-weight:normal}.mw-parser-output .hlist-slash dd:after,.mw-parser-output .hlist-slash li:after{content:" /\a0 ";font-weight:normal}.mw-parser-output .hlist dd:last-child:after,.mw-parser-output .hlist dt:last-child:after,.mw-parser-output .hlist li:last-child:after{content:none}.mw-parser-output .hlist dd dd:first-child:before,.mw-parser-output .hlist dd dt:first-child:before,.mw-parser-output .hlist dd li:first-child:before,.mw-parser-output .hlist dt dd:first-child:before,.mw-parser-output .hlist dt dt:first-child:before,.mw-parser-output .hlist dt li:first-child:before,.mw-parser-output .hlist li dd:first-child:before,.mw-parser-output .hlist li dt:first-child:before,.mw-parser-output .hlist li li:first-child:before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child:after,.mw-parser-output .hlist dd dt:last-child:after,.mw-parser-output .hlist dd li:last-child:after,.mw-parser-output .hlist dt dd:last-child:after,.mw-parser-output .hlist dt dt:last-child:after,.mw-parser-output .hlist dt li:last-child:after,.mw-parser-output .hlist li dd:last-child:after,.mw-parser-output .hlist li dt:last-child:after,.mw-parser-output .hlist li li:last-child:after{content:")\a0 ";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)" ";white-space:nowrap}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)" "}.mw-parser-output .navbar{display:inline;font-size:75%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:88%}.mw-parser-output .navbox .navbar{display:block;font-size:88%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}

表示

編集










Unixコマンド
ファイルとファイルシステム管理

cat

chattr(英語版)

chmod

chown

chgrp

cksum

cmp

cp

dd

du

df(英語版)

file

fsck

fuser(英語版)

ln

ls

lsof

mkdir

mount

mv

pax

pwd

rm

rmdir

size

split

tee

touch

type(英語版)

umask(英語版)

プロセス管理

at

bg

chroot

cron

fg

kill

killall

nice

pgrep

pidof

pkill

ps

pstree(英語版)

reboot

shutdown

time

top

ユーザ管理/環境

clear

env

exit

finger

history(英語版)

id

logname(英語版)

mesg

passwd

su

sudo

uptime

talk

tput(英語版)

uname

w

wall

who

whoami

write

テキスト処理

awk

banner

basename

comm(英語版)

csplit(英語版)

cut

diff

dirname

ed

ex(英語版)

fmt

fold(英語版)


次ページ
記事の検索
おまかせリスト
▼オプションを表示
ブックマーク登録
mixiチェック!
Twitterに投稿
オプション/リンク一覧
話題のニュース
列車運行情報
暇つぶしWikipedia

Size:16 KB
出典: フリー百科事典『ウィキペディア(Wikipedia)
担当:undef