<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>プロファイル | OI-systems</title>
	<atom:link href="https://oi-systems.net/archives/tag/%E3%83%97%E3%83%AD%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB/feed" rel="self" type="application/rss+xml" />
	<link>https://oi-systems.net</link>
	<description>手軽に始められる『ブログ・自作アプリetc...』の情報を発信します。</description>
	<lastBuildDate>Sat, 21 Dec 2024 11:32:57 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://oi-systems.net/wp-content/uploads/2024/11/cropped-212808e1a8384082b9b8a240ba1f4e63-32x32.png</url>
	<title>プロファイル | OI-systems</title>
	<link>https://oi-systems.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【プロファイル設定】LINUXのプロファイル設定の基本と応用</title>
		<link>https://oi-systems.net/archives/1298</link>
					<comments>https://oi-systems.net/archives/1298#respond</comments>
		
		<dc:creator><![CDATA[よしのぶ]]></dc:creator>
		<pubDate>Sun, 15 Dec 2024 08:00:21 +0000</pubDate>
				<category><![CDATA[サーバーを作ろう]]></category>
		<category><![CDATA[AlmaLinux]]></category>
		<category><![CDATA[LINUX]]></category>
		<category><![CDATA[プロファイル]]></category>
		<guid isPermaLink="false">https://oi-systems.net/?p=1298</guid>

					<description><![CDATA[プロファイル設定とは、Linuxシステムでのユーザー環境やシステム全体の動作を設定するためのファイル群のことを指します。主に、シェル環境をカスタマイズするために利用されます。ユーザーごとに異なる設定を行うことができるため [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>プロファイル設定とは、Linuxシステムでのユーザー環境やシステム全体の動作を設定するためのファイル群のことを指します。主に、シェル環境をカスタマイズするために利用されます。ユーザーごとに異なる設定を行うことができるため、効率的な管理が可能です。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">AlmaLinux8におけるプロファイル設定の基本</a><ol><li><a href="#toc2" tabindex="0">/etc/profileの設定方法</a><ol><li><a href="#toc3" tabindex="0">「teraterm作業ログを取得」する設定</a></li></ol></li></ol></li><li><a href="#toc4" tabindex="0">まとめ</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">AlmaLinux8におけるプロファイル設定の基本</span></h2>



<p>AlmaLinux8では、主に以下の2つの設定ファイルがプロファイル設定に使用されます。</p>



<div class="wp-block-cocoon-blocks-sticky-box blank-box block-box sticky">
<ul class="wp-block-list">
<li><code>/etc/profile</code>: システム全体に適用される設定。</li>



<li><code>~/.bash_profile</code>: ユーザー固有の設定。</li>
</ul>
</div>



<p>これらの設定を理解することで、ユーザー環境を細かくカスタマイズすることができます。</p>



<h3 class="wp-block-heading"><span id="toc2">/etc/profileの設定方法</span></h3>



<p><code>/etc/profile</code>は、システム全体に適用される設定を記述するファイルです。このファイルには、システム全体で必要な環境変数やパスの設定を行います。例えば、全ユーザーが利用するソフトウェアのパス設定をここに記述します。</p>



<h4 class="wp-block-heading"><span id="toc3">「teraterm作業ログを取得」する設定</span></h4>



<p>今回「teraterm作業ログを取得」する設定を追加します。</p>



<p>１．次のコマンドを入力して<em>root</em>ユーザーに変更します。</p>



<pre class="wp-block-code plaintext"><code>$ sudo su -</code></pre>



<p>２．次のコマンドを入力して<em>root</em>ユーザーに変更されたことを確認します。</p>



<pre class="wp-block-code plaintext"><code># whoami
root</code></pre>



<p>３．「<code>/etc/profile</code>」編集前に事前バックアップを取得します。※$(date +%Y%m%d)の部分は作業当日の日付となります。ご自身で作業する場合は本ブログの表示と異なりますのでご注意ください。</p>



<pre class="wp-block-code plaintext"><code># ls -ld /etc/profile
-rw-r--r-- 1 root root 2325  9月 10  2023 /etc/profile

# cp -p /etc/profile /etc/profile_$(date +%Y%m%d)

# ls -ld /etc/profile_$(date +%Y%m%d)
-rw-r--r-- 1 root root 2325  9月 10  2023 /etc/profile_20241215</code></pre>



<p>４．次のコマンドを入力し、「<code>/etc/profile</code>」を編集します。</p>



<pre class="wp-block-code plaintext"><code># vi /etc/profile</code></pre>



<p>5．最終行に以下の内容（赤字部分）を追記します。</p>



<div class="scrollable-table"><table style="width: 96.0393%; height: 172px;">
<tbody>
<tr style="height: 43px;">
<td style="width: 50%; height: 43px;">コマンド名</td>
<td style="width: 50%; height: 43px;">説明</td>
</tr>
<tr style="height: 43px;">
<td style="width: 50%; height: 43px;">G</td>
<td style="width: 50%; height: 43px;">ファイルの最終行にジャンプ</td>
</tr>
<tr style="height: 43px;">
<td style="width: 50%; height: 43px;">o</td>
<td style="width: 50%; height: 43px;">カーソルがある下の行にテキストを挿入</td>
</tr>
<tr style="height: 43px;">
<td style="width: 50%; height: 43px;">:wq</td>
<td style="width: 50%; height: 43px;">変更を保存して <kbd>vi</kbd> を終了</td>
</tr>
</tbody>
</table></div>



<pre class="wp-block-code plaintext"><code># /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

（～中略～）

<span class="red"># output operation log
P_PROC=`ps aux | grep $PPID | grep sshd | awk '{ print $11 }'`
if &#91; "$P_PROC" = sshd: ]; then
  script -afq /var/log/scripts/opelog/$(date +%Y%m%d_%H%M%S)_$(whoami).log
exit
fi</span></code></pre>



<p>６．差分を比較して編集が変更内容を確認します。</p>



<pre class="wp-block-code plaintext"><code># diff /etc/profile /etc/profile_20241215 -y --suppress-common-lines
                                                              &gt; # output operation log
                                                              &gt; P_PROC=`ps aux | grep $PPID | grep sshd | awk '{ print $11 }'
                                                              &gt; if &#91; "$P_PROC" = sshd: ]; then
                                                              &gt;   script -afq /var/log/scripts/opelog/$(date +%Y%m%d_%H%M%S)_
                                                              &gt; exit
                                                              &gt; fi</code></pre>



<p>７．TeraTermタブ「ファイル」⇒「セッションの複製」よりTeraTermにログインする。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="245" height="522" src="https://oi-systems.net/wp-content/uploads/2024/12/image-10-wpp1734249323690.png" alt="" class="wp-image-1304" srcset="https://oi-systems.net/wp-content/uploads/2024/12/image-10-wpp1734249323690.png 245w, https://oi-systems.net/wp-content/uploads/2024/12/image-10-wpp1734249323690-141x300.png 141w" sizes="(max-width: 245px) 100vw, 245px" /></figure>



<p>８．次のコマンドを入力して「teraterm作業ログが取得」されていることを確認します。</p>



<pre class="wp-block-code plaintext"><code># ll /var/log/scripts/opelog/
合計 *****
-rw-rw-r-- 1 ***** *****     277 12月 15 16:51 20241215_165126_*****.log</code></pre>



<h2 class="wp-block-heading"><span id="toc4">まとめ</span></h2>



<p>「AlmaLinux8のプロファイル設定の基本と応用」はいかがでしたか？</p>



<p><code>profile</code>設定を使ってシステム全体の設定を管理しつつ、ユーザーごとの個別設定を行うためには、適切にユーザーごとの設定ファイルを使用することが重要です。</p>



<p>以上、最後までお読みいただきありがとうございました。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://oi-systems.net/archives/1298/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
