0
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 3 years have passed since last update.

Linuxコマンド一覧

Last updated at Posted at 2022-03-29

find

$ find /test | xargs grep "AAA"
$ find /test -name "index.html"

・/testは階層
・xargs→中の文字列検索

ping

ping 142.250.196.99

・142.250.196.99はwww.google.co.jpに対応している。

tail

$ cd /var/log/apache2
$ tail -f access_log
$ tail -f error_log
$ tail -n 10 access_log // 10行分出力

ユーザー関連

$ id username
$ cat /etc/passwd
$ cut -d: -f1 /etc/passwd
$ sudo su - username // ユーザーの切り替え

UMASK

・/etc/login.defsに記載されており、デフォルトの禁止事項を設定できる。
・ファイルはデフォルトで666, ディレクトリはデフォルトで777になっている。
・例えばディレクトリのUMASK値が022ならば、777 - 022 = 755 がデフォルトの権限となる。

SSH接続

・鍵作成

ssh-keygen -t rsa -b 4096 -f authorized_keys

・authorized_keysは変えてOK
・-t RSAは暗号手段の名称
・-b バイト数
・-f 鍵の名前

$ sudo apt update
$ sudo apt install openssh-server
$ sudo systemctl status ssh

・3行目は確認コマンド

参考URL
https://codechacha.com/ja/ubuntu-install-openssh/

パスワードを自動生成する

$ sudo apt install pwgen
$ pwgen --help
$ pwgen -y -s 10 3

・3行目は例。
・-y 最低でも1つの記号を入れる(helpオプションで確認できる)
・-s 偏りを一切つくらない(helpオプションで確認できる)
・10文字/3通り →このくらいの長さならそれなりに頑丈。
・鍵認証できるならどうでも良い?→結論はNG。秘密鍵を紛失したり、サーバー会社の仕様変更などにより鍵認証ができなくなった場合などの際には、一生ログインができず泣き寝入りとなる。必ず設定しておくこと。

Ubuntuのパスワード再設定

$ sudo su -
# passwd ubuntu

・上の自動生成したものを設定するとよい

フォルダごと削除

$ rm -rf [DirectoryName]

ディレクトリ構造のみコピーする

$ ./src -type d -print0  | xargs -0 tar zcf src.tar.gz --no-recursion

tar


0
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
0
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?