· FabLab Westharima Team · Documentation  · 5 min read

Terminal Launch, Usage, and Basic Commands [Beginner]

Explaining basic usage of terminal necessary for programming and version control. Clearly summarizing from command basics to safe usage for beginners.

目次

When programming or performing version control, you may work with terminals and command-line tools installed in OS and development environments like VS Code. I’ve summarized the usage simply as a memo.

What is a Terminal?

A terminal is like a “command center” for operating computers in text-based manner. Unlike GUI (Graphical User Interface) that operates with mouse and icons, it gives instructions to computer by directly entering command statements called commands. It’s an essential tool in various fields including programming, web development, and server management, enabling efficient performance of advanced work and automation. It may seem a bit difficult at first, but by learning basic usage, your computer skills will improve dramatically.

Launching Terminal

Launching terminal differs depending on operating system you’re using.

Below explains how to open terminal (mac, Linux) or command prompt (windows) in common operating systems. Depending on operating system and version you’re using, procedures may differ slightly.

Windows:

  • Use third-party software like Git Bash

  • Windows Subsystem for Linux (WSL): Click Start menu, enter WSL distribution name (e.g., “Ubuntu”) in search box and select it.

Linux (Ubuntu etc.):

  • Use shortcut: Press Ctrl + Alt + T keys simultaneously.

  • Open from application menu: Open application menu and search/select “Terminal”.

macOS:

  • Use Spotlight: Press Command + Space keys simultaneously to open Spotlight, type “Terminal” and select from search results.

  • Open from Applications folder: Select Applications > Utilities > Terminal.

【Example】macOS:    Open Applications > Utilities > Terminal app

After launching, following terminal appears.

Basic Terminal Usage

Basic Command Input:

When terminal launches, prompt is displayed. This is state where system is waiting for user command input. Enter command here and press Enter key to execute command. 【Example】

ls

Command Options and Arguments:

  • Most commands can specify options and arguments.

  • Options are usually strings starting with - or , which can modify command behavior.

  • Arguments usually specify target (e.g., file or directory) that command acts upon. 【Example】

ls -l

Using Command History:

  • key: Displays previously entered command.

  • key: Displays next command (if exists).

  • history command: Displays list of recently executed commands.

Tab Completion:

While entering command or file name, pressing Tab key makes terminal automatically complete the name. This is very convenient especially when entering long file or directory names.

【Example】

cd Doc[Tab]

When you type this, if there’s directory named Documents, it will be completed to that.

Canceling Command

Ctrl + C: Cancels running command.

Command Cheat Sheet (Bare Minimum)

Here we introduce carefully selected basic commands frequently used in terminal operations. Just by learning these commands, you can browse files, move around, and perform simple operations.

Note:

  • Can reflect (execute) commands only in current location.
  • These commands are common in many Unix-like systems and Linux distributions, but note that they may differ depending on specific system or configuration you use.

Directory Operations:

pwdDisplay path to current directory
cdMove to other directory (e.g., cd directory_name)
cd ..Move to one level up directory
mkdirCreate new directory. Execute with “mkdir new_directory_name”. (e.g., mkdir sample)
rmdirDelete directory. (only if empty) ※Files deleted with this command don’t go to trash and no warnings are issued, so execute with sufficient caution. If you accidentally delete important files, computer may not boot.

File Operations:

lsList contents of current directory 【Options】: ls -l (detailed display), ls -a (including hidden files)
cpCopy file or directory, cp [source] [destination]
mvMove file or directory, or rename mv [source] [destination]
rmDelete file ⚠︎ Caution: Files deleted once cannot basically be restored. Execute carefully. 【Options】: rm -r (delete directory and contents), rm -f (force delete), rm -i (confirm on delete)
findSearch for files and directories
catDisplay file contents

Other Operations:

manOpen command manual (e.g., man ls)
clearErase all command output results (displayed text)

How to Express Directories:

.Current directory (directory where you are now)
..Parent directory (one level up directory)
~Home directory (directory you’re in right after login)
../../Parent directory’s parent directory (two levels up directory)

Directory is like a “folder” for organizing files.

Precautions and Dangerous Commands When Using Terminal

Terminal is very powerful tool, but because of that, incorrect usage can cause serious damage to system.

  • Pre-execution confirmation: For commands that affect system like rm or sudo, always double-check content and target.

  • Administrator privilege operations (sudo): Before executing commands that affect system (especially when using sudo), it’s important to fully understand what that command does. Wrong commands can cause data loss or system corruption. It’s important to think twice before using.

  • Data backup: Before working with important files or data, always make backups. rm and other data modification commands cannot be undone once executed.

  • Error messages: Terminal provides error messages explaining why command failed. Error messages on command failure are hints for problem solving. Understand content and search web if necessary.

  • Check latest information: Command and tool usage methods may change due to OS version upgrades etc. Always try to check latest information.

  • Self-learning: Users interact with system through terminal and can effectively execute various tasks. Terminal is powerful tool but depends on knowledge and experience of user using it. New commands and techniques always exist, and it’s important to use community forums and educational resources to expand knowledge.

Frequently Asked Questions (FAQ) and Troubleshooting

QuestionAnswer
Q1. Why doesn’t terminal respond when I enter command?Did you press Enter key after entering command? Also, check if there’s no spelling mistake in command and it’s entered in half-width characters.
Q2. I deleted file with rm command, can I restore it?Files deleted with rm command basically don’t go to trash and restoration is very difficult. Make sure to backup important files beforehand.
Q3. Japanese input garbled in terminal, what should I do?Terminal’s character encoding setting may be cause. In many cases, changing setting to “UTF-8” solves it. Check settings screen of terminal you’re using.
Q4. Can’t move directory with cd command. What’s the cause?Specified directory may not exist, directory name spelling mistake, or case distinction may be wrong. Try checking correct directory name with ls command.
Q5. Can I customize terminal background color and text color?Yes, most terminal applications can freely customize background color, text color, font, etc. from settings. Change to your preferred settings to build more comfortable working environment.
Back to Blog

Related Posts

View All Posts →
FFmpeg Installation, Usage, Options, and Commands

FFmpeg Installation, Usage, Options, and Commands

Explaining usage of FFmpeg, a powerful tool that can execute video/audio conversion, compression, extraction, and concatenation via command line. Basic command structure and practical recipes without confusion even for beginners.

ImageMagick v7 Installation, Commands, and Options List

ImageMagick v7 Installation, Commands, and Options List

Explaining usage of ImageMagick, a powerful tool that can batch process image conversion, compression, resize, composition, etc. via command line. Comprehensively summarizing from installation methods to practical command examples for beginners.