0Pricing
Linux Command Line Mastery · 강의

환경 변수 및 별칭

환경 변수와 명령 별칭을 사용하여 셸 환경을 관리하고 사용자 지정합니다.

환경 변수 및 별칭은(는) CoddyKit의 무료 Linux Command Line Mastery 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Linux Command Line Mastery 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Your Shell's Environment

Welcome! In this lesson, we'll dive into how your Linux shell keeps track of important information. This 'environment' helps your commands run smoothly.

Think of it as your shell's personal workspace, full of settings and shortcuts.

Meet Environment Variables

Environment variables are dynamic named values that store information used by the shell and other programs. They let you customize how your system behaves.

  • They are like temporary storage for your shell.
  • They can hold paths, user settings, and more.
  • Other programs can read these variables to know how to act.

Checking Current Variables

You can see all active environment variables using the printenv command. To view a specific variable, use echo $VARIABLE_NAME.

The dollar sign $ before a variable name tells the shell to show its value.

printenv | head -n 3
echo $HOME

Important System Variables

Two very common and important environment variables are PATH and HOME:

  • PATH: A list of directories where the shell looks for executable commands. When you type ls, the shell checks these directories.
  • HOME: The absolute path to your home directory. This is where your personal files and settings are usually stored.

Setting Temporary Variables

You can create your own environment variables for the current shell session. Just assign a value to a name:

VARIABLE_NAME="value"

Note that there are no spaces around the = sign. These variables are temporary and disappear when you close the terminal.

MY_MESSAGE="Hello CoddyKit"
echo $MY_MESSAGE

# This variable only exists in this shell

Making Variables Global with 'export'

Variables set directly are only available in the current shell. To make them available to any sub-processes (like scripts or other commands you run from your current shell), you need to export them.

export GLOBAL_VAR="I am global"
bash -c 'echo $GLOBAL_VAR'

# Without export, 'bash -c' wouldn't see it.

Introducing Command Aliases

Command aliases are custom shortcuts for longer commands or sequences of commands. They save you typing and can even fix common typos.

  • They personalize your command-line experience.
  • You define a short name that expands to a longer command.
  • Great for frequently used, complex commands.

Creating Quick Shortcuts

To create an alias, use the alias command followed by name='command'. Like variables, these are temporary and last only for the current shell session.

A common example is aliasing ls -alF to ll for a detailed file listing.

alias ll='ls -alF'
ll

# Now 'll' runs 'ls -alF'

Listing and Removing Aliases

To see all aliases currently active in your shell, simply type alias without any arguments. If you want to remove an alias, use the unalias command.

alias
alias c='clear'
alias
unalias c
alias

Check Your Understanding

You've learned about environment variables and aliases. Let's test your knowledge!

Consider the following:

MY_VAR="Test"
export MY_VAR

Which statement is true after running these commands?

Lesson Summary

Great job! You've successfully explored environment variables and aliases.

  • Environment variables store key-value pairs for your shell and programs.
  • Use echo $VAR to see a variable's value and printenv to list them all.
  • export makes variables available to sub-processes.
  • Aliases are custom shortcuts for commands, created with alias name='command'.
  • Both are temporary by default, lasting only for the current shell session.

Next, you'll learn how to make these customizations permanent!

자주 묻는 질문

“환경 변수 및 별칭” 강의는 무료인가요?

네 — “환경 변수 및 별칭” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Linux Command Line Mastery 강의 전체를 잠금 해제할 수 있습니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

“환경 변수 및 별칭”에서 뭘 배우나요?

환경 변수와 명령 별칭을 사용하여 셸 환경을 관리하고 사용자 지정합니다. 브라우저에서 직접 실행하는 실습 코드로 Linux Command Line Mastery을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Linux Command Line Mastery을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Linux Command Line Mastery은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“환경 변수 및 별칭” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Linux Command Line Mastery 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Linux Command Line Mastery 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 명령줄에서 배우는 Git 기초
  2. 환경 변수 및 별칭
  3. 셸 구성: `.bashrc`, `.zshrc`, `.profile`
  4. 명령줄에서 Git으로 브랜치 만들고 병합하기
← Linux Command Line Mastery(으)로 돌아가기