LoginSignup
0
0

More than 3 years have passed since last update.

Linux コマンドを打った自分のログを取得していく方法

Last updated at Posted at 2019-12-03

Linuxのログを取得する方法はいくつかあると思いますが自分がいつも実施する方法を記載します。

1 .bash_profileファイル編集

「.bash_profileにscriptコマンドを実行するよう設定する」ことにより
自動で作業ログを保存することができます。

nano .bash_profile viかnanoなどで編集してください。
.bash_profileに下記を追加します。

scriptコマンドはデフォルトファイル出力非同期のため
-fオプションをつけリアルタイムで出力しましょう。

nano .bash_profile

以下が出てきたら最終行に1行打ち込みましょう

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

打ち込む内容は以下です。

script -q -f -a ../../etc/xxx/yyy.log

2 ディレクトリ作成

一応丁寧に書いてます

まずpwdを

pwd

続いてホームから2階層上に移動します。

cd ../..

etcへ移動しましょう。

cd etc

3 ディレクトリxxx と ファイルyyyを作成

mkdir xxx ディレクトリ名

ディレクトリを作成したらファイルも作成しましょう

touch yyy.log

4 logファイルの権限変更

以上です。

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