シェルとは
黒い画面。ユーザーに対して、テキストベースのインタフェースを提供するプログラム。コマンドを入力することで、他のプログラムを実行することができる。
シェルにも色々な種類があるが、ここではbashやzshと呼ばれるものを想定する。
プロンプト
infovis:~$infovis: デバイス名~: カレントディレクトリ(homeの縮約形)$: ルートユーザではない(ルートユーザは#)
コマンド入力
infovis:~$ date
Thu Oct 10 07:36:18 JST 2024
infovis:~$infovis:~$ echo hello
helloinfovis:~$ echo "My Files"
My Files環境変数
シェルは、$PATHという環境変数に含まれているディレクトリでプログラムの検索を行う。
infovis:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
infovis:~$ which echo
/bin/echo
infovis:~$ /bin/echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binディレクトリを移動する
infovis:~$ pwd
/home/infovis
infovis:~$ cd /home
infovis:/home$ pwd
/home
infovis:/home$ cd ..
infovis:/$ pwd
/
infovis:/$ cd ./home
infovis:/home$ pwd
/home
infovis:/home$ cd infovis
infovis:~$ pwd
/home/infovis
infovis:~$ cd -
infovis:/home$
infovis:~$ ../../bin/echo hello
helloディレクトリの中身を見る
infovis:~$ ls
infovis:~$ cd ..
infovis:/home$ ls
infovis
infovis:/home$ cd ..
infovis:/$ ls
bin
boot
dev
etc
homeコマンドの使い方を調べる
infovis:~$ ls --helpまたは
infovis:~$ man lsディレクトリの中身を詳しく調べる
ファイルの権限の読み方を調べてみる。
infovis:~$ ls -l /home
drwxr-xr-x 1 infovis users 4096 Jun 15 2019 infovisファイルやディレクトリに対する操作
infovis:~$ mv hello.txt hello2.txt
infovis:~$ cp hello2.txt hello.txt
infovis:~$ rm hello2.txt
infovis:~$ mkdir hola hallo
infovis:~$ rm -r hola
infovis:~$ rmdir halloプログラムをつなげる
infovis:~$ echo hello > hello.txt
infovis:~$ cat hello.txt
hello
infovis:~$ cat < hello.txt
hello
infovis:~$ cat < hello.txt > hello2.txt
infovis:~$ cat hello2.txt
helloinfovis:~$ ls -l / | tail -n1
drwxr-xr-x 1 root root 4096 Jun 20 2019 var
infovis:~$ curl --head --silent google.com | grep --ignore-case content-length | cut -d ' ' -f2
219ファイルやディレクトリを開く
macOS
infovis:~$ open .Windows
infovis:~$ explorer.exe .Linux
infovis:~$ xdg-open .