2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

良く使うUNIXコマンド: 中級編

Last updated at Posted at 2019-05-22

はじめに

良く使うけど少し難しいUNIXコマンドについてまとめました
これだけできれば「CUI操作の利点が活かせる!!」と言えると思います.

良く使うUNIXコマンド: 初級編
良く使うUNIXコマンド: 中級編 now
##目次

  1. wc (word count)
  2. grep (global regular expression print)
  3. find
  4. wget
  5. alias
  6. man (manual)
  7. export
  8. which
  9. chmod (change mode)
  10. chown (change owner)

###wc (word count)
行数, 文字数, バイト数を表示

$ wc tmp #tmpファイルの行数, 文字数, バイト数を表示
$ wc -l tmp #tmpファイルの行数だけ表示

###grep (global regular expression print)
ファイル中の文字列を検索
(ファイル内検索)
grep 検索正規表現 ファイル名
で使う


$ grep tmp* ./hoge.txt #hoge.txt中の正規表現であるtmp*を検索
$ grep tmp* ./* #カレントディレクトリのファイルからtmp*を検索
$ grep -r tmp* ./* #カレントディレクトリ以下のファイルからtmp*を検索

###find
ファイルを検索
(ファイルを!!検索)

$ find . -name  "*.cpp" #カレントディレクトリ以下の*.cppファイルを検索

###wget
WWW上のファイルのダウンロード
wget URL
で使う

$ wget https://camo.qiitausercontent.com/021d5415399a7c79ec82e7ad6755d409a1c81563/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3335333634362f39336530653437372d653034322d303837352d636531352d3464613736653036373665362e6a706567 -O momo.png#-Oオプションで保存ファイル名指定
$ wget --http-user="ユーザーネーム" --http-password="パスワード" (URL)#ログイン付きURLでもダウンロードできる

###alias
コマンドの別名を登録

$ alias ls="ls -al" #lsを実行するとls -alが実行される
$ alias tmp="ls" #tmpを実行すると lsが実行される

###man (manual)
コマンドのマニュアルを表示
マニュアルを閉じたい場合 q を押すと閉じれる


$ man ls #ls のマニュアルを表示
$ man cd #cd のマニュアルを表示

###export
パスを通すことができる
$HOME はホームまでのパス

export PATH=$HOME/tmp/:$PATH #tmpまでのパスを通す

###which
実行コマンドのパスを表示


$ which find # findコマンドがどこで呼ばれているか表示

###chmod (change mode)
権限の変更 (ls -l で権限が見れる)
chmod (権限) ファイル名
で権限の変更ができる


$ chmod +x tmp.sh #tmp.shに実行権限を付与
$ chmod -x tmp.sh #tmp.shの実行権限を消す

###chown (change owner)
ユーザー所有権, グループ所有権の変更


$ chown root tmp #tmpのユーザー所有権をrootに変更
$ chown root:root tmp #ユーザー所有権とグループ所有権をrootに変更

参考文献

【Linux】コマンドまとめ 〜コマンド名の由来を添えて〜

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?