0
0
Linux-cliHow-ToBeginner · 3 min read

How to Use Linux Terminal: Basic Commands and Tips

The Linux terminal is a text-based interface where you type commands to control your computer. You use it by typing commands following a simple syntax pattern and pressing Enter to run them. It lets you navigate files, run programs, and automate tasks efficiently.
📐

Syntax

The basic syntax of a Linux terminal command is:

  • command: The program or action you want to run.
  • options: Optional flags that modify the command's behavior, usually starting with a dash (-).
  • arguments: The targets or inputs for the command, like file names or directories.

Example: ls -l /home/user lists files in detailed format in the specified directory.

bash
command [options] [arguments]
💻

Example

This example shows how to list files in your current directory with details and then create a new directory.

bash
ls -l
mkdir new_folder
ls -l
Output
total 4 drwxr-xr-x 2 user user 4096 Apr 27 10:00 existing_folder drwxr-xr-x 2 user user 4096 Apr 27 10:01 new_folder
⚠️

Common Pitfalls

Beginners often forget to check their current directory or misspell commands. Another common mistake is not using sudo when a command needs administrator rights, causing permission errors.

Also, mixing up options or arguments order can cause unexpected results.

bash
mkdir myfolder
cd myfolder
ls

# Wrong: forgetting sudo for system commands
apt-get update

# Right: using sudo
sudo apt-get update
📊

Quick Reference

CommandDescription
lsList files and directories
cdChange directory
pwdShow current directory path
mkdirCreate a new directory
rmRemove files or directories
cpCopy files or directories
mvMove or rename files or directories
sudoRun command with administrator rights
catDisplay file contents
echoPrint text to the terminal

Key Takeaways

Type commands in the format: command, options, then arguments.
Use ls to list files and cd to change directories.
Remember to use sudo for commands needing admin rights.
Check your current directory with pwd before running commands.
Practice simple commands to build confidence in using the terminal.