1
2

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 1 year has passed since last update.

【メモ】よく忘れるコマンド集

1
Last updated at Posted at 2019-08-21

よく忘れるコマンド集

"pattern" の検索

grep -rnw 'directory' -e "pattern"

重複ファイルの検索

sudo apt install fdupes #fdupes が無い場合
fdupes -r ./ > duplications.txt
cat duplications.txt
他に
rdfind path-to-treat

ファイル名の空白をアンダースコアに変換

ファイル/ディレクトリ名に空白が入っているファイル/ディレクトリの空白を下線_に置換するワンライナーから転載

find . -name "* *" | rename 's/ /_/g'

各ディレクトリのファイル数を数える/ファイル数の多いディレクトリの抽出

for d in `find hogehoge -type d`; do echo $d,`ls "$d" | wc -l`; done | cat > files.txt
awk 'BEGIN{FS=","}{i=NF; if ($i > 500) print $0}' files.txt > so_many_files.txt

gfortran で fftw3 を使ってコンパイルするよ

gfortran hoge.f90 hoge1.f90 -I/usr/include -lfftw3 -ohoge.x

rsync 関係

rsync 関係

Linuxで「特定の文字列を含むファイルを全て検索する」ためのコマンド

http://qiita.com/kenju/items/9bebc75df1e0b3c3ee9bからの転載

##########################
# grep
#   -r : 再帰的にgrepコマンドを実行する
#   -n : 行番号を出力する
#   -w : 文字列全体にマッチする場合
#   -l : (option)これをつければファイル名だけを出力(マッチした部分は省く)
#
# Usage
#   # 現在いるディレクトリ配下から「httpd」という文字列を含むファイルすべてを抽出する
#   $ grep -rnw . -e "httpd"
##########################
$ grep -rnw 'directory' -e "pattern"

ディレクトリの使用量を確認する

du -h --max-depth=1

(辿る階層は任意。上の例では、カレントディレクトリに存在する子ディレクトリの容量を表示する。)

UUIDの確認

blkid
lsblk -f

Linuxバージョンの確認(Ubuntu)

uname -a
cat /etc/issue
cat /etc/lsb-release
cat /proc/version

Linuxステータス関係ツール

free
top
# 3rd party
htop
vtop
gtop
slurm
screenfetch

ハードウェア情報など

cat /proc/cpuinfo # CPU
cat /proc/meminfo # Memory
# /proc には様々なハードウェア情報がある
df -h             # HDD
fdisk -l
sudo dmidecode    # マザーボード情報

停電対応

> sudo at -t 201612100000

入力待ちになるので、

> shutdown -h now
> ([CTRL] + [D]) #キーコンビネーション

と打てば、

job 4 at Sat Dec 10 00:00:00 2016

のように返ってくるはず。

Dropboxの再起動

> dropbox stop
> dropbox start

Dropboxが停止している場合、

Dropbox isn't running!

と言われる。'dropbox start' で起動時にも

Starting Dropbox...Dropbox isn't running!
Done!

と言われるが、同期は再開するようである。

と出る場合は、やっぱりダメかも。リモートから X forwarding している場合、
しばらくすると、

connect localhost port 6000: Connection refused

というエラーが出て同期しない。Xなしでログインしていれば、問題無く以下のようなコメントを吐いて同期を開始する。

Starting Dropbox...Done!

トンネルを掘る

ssh -N -f -L10022:xx.xx.xx.xx:22 -L10080:xx.xx.xx.xx:80 user@host

ポート番号指定+暗号鍵

ssh -p[port no.] -i ~/.ssh/rsa_key user@host

Mac OS Catalina で SIP disable の後

コマンドそのものというより、やり忘れることが多い...

sudo mount -uw /
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?