空飛ぶロボットのつくりかた

ロボットをつくるために必要な技術をまとめます。ロボットの未来についても考えたりします。

Linuxのお勉強

プロンプト

[robonchu@localhost~]$

ユーザ名 ホスト名

コマンドラインの編集

コマンド 内容
Ctrl+b 1back
Ctrl+f 1go
Ctrl+a text first
Ctrl+e text end
Ctrl+h 1back delete
Ctrl+k cut from text first to end
Ctrl+u cut from text end to first
Ctrl+y yank

コマンド履歴

コマンド 内容
Ctrl+p 1back command
Ctrl+n 1go command
Ctrl+r search back command
Ctrl+r ↑search back command next
Enter ↑search back command execute
Ctrl+g ↑search back command end

文字コード変更

iconv -f EUC-JP -t UTF-8

ファイルとディレクト

コマンド 内容
pwd current directory display
ls -l detail
ls -a all
ls -F file type
mkdir [dir name] make dir
mkdir -p [dir name] / [dir name] / [dir name] ↑search back command end
touch [file name] create file
rm [file name] delete file
rm -r [dir name] delete dir
rm -i [file name] check delete
cat [file name] display file
cat -n [file name] display file with num
less [file name] display file & can scroll
space ↑ down scroll
b ↑ up scroll
q ↑ exit
\ [word] ↑ search down
? [word] ↑ search up
n ↑↑ next
N ↑↑ pre
cp [file name] [file name] copy file
cp -r [dir name] [dir name] copy dir
mv [file name] [file name] file name change
mv [file name] [dir name] file location change
ln -s [file name] [file or dir name] symbolic link

探す

コマンド 内容
find [start dir] [search type] [action] find location (ex: find . -name test.txt a -type f -print)
updatedb & locate [file name] find location
locate -b [file name] find file name only location

調べる

コマンド 内容
[command] –help display how to use command
man [command] mannual display
man -k [key word] find man including keyword (ex: man -k copy)
which [command] find command path

bashの設定

コマンド 内容
alias [new command name]=‘[command name]’ new name touch
type [command] check origin or alias

シェル変数と環境変数

コマンド 内容
printenv display env
env display env
export [env name]=[setting name] set env

パーミッション

ls -l [dir]
-rrrwwwxxx. ~

-:通常ファイル , d:ディレクトリ , l:シンボリックリンク

rrr(read): オーナー

www(write): グループ

xxx(execute): その他

に対するパーミッション

qiita.com

コマンド 内容
chmod [ex: u+x] or [ex: 777] file mode chane
su - [user name] init env & user switch
su [user name] keep env & user switch
sudo -u [user name] [command] execute command on user name

プロセスとジョブ

コマンド 内容
ps aux display process detail
Ctrl + z stop job
jobs -l display jobs with PID
fg %[job num] to for ground
bg %[job num] to back ground
kill %[job num] kill job
kill [PID] kill process
kill -KILL [PID] kill process

フィルタ

コマンド 内容
head -n [num] display file top
tail -n [num] display file end
grep [pattern] [file name] pick up word
ws output line num

テキスト処理

コマンド 内容
diff [origin file] [file] display diff
diff -u [origin file] [file] display diff on unified format
diff -ur [origin dir] [dir] display diff on unified format

アーカイブと圧縮

コマンド 内容
tar czf [file name].tar.gz [file name] tar + gz make
tar xzf [file name].tar.gz tar + gz open

パッケージ

コマンド 内容
sudo apt-get install [pkg name] install pkg
sudo apt-get remove [pkg name] remove pkg
sudo apt-get purge [pkg name] remove pkg with setting
sudo apt-cache search (–name-only) [key word] search pkg
sudo apt-cache policy [pkg name] display version

リモート

コマンド 内容
ssh [username]@[IP or name] remote login

ダウンロード

コマンド 内容
wget [URL] download file

その他のコマンド

コマンド 内容
du [file or dir] display file size

参考:

シェルにおけるシングルクォート、ダブルクォート、バッククォートで囲った場合の挙動の違い

`apt-get install`するまえに`apt-cache` でバージョンを調べる方法 - Qiita