I use Linux Ubuntu, Linux Ubuntu Server, this tutorial is for those technologies, for other Linux distributions the commands may vary slightly, for macOS the commands are similar

You should know that as operating systems you have: Windows (PC), Linux (PC), macOS (MAC) and others

On mobile devices you have Android (a type of Linux), iOS (derived from macOS) and Windows (derived from Windows).

some concepts:

  • OS means operating system
  • hardware is the physical part (machine or part of it)
  • Software is the program, that is, the part that cannot be touched
  • A kernel is the central and fundamental part of any operating system (OS). It acts as the communication bridge and arbitrator between the computer’s hardware and the software the user is running.

Saying Linux is a very broad range, it’s like saying vehicle, there are flying, terrestrial and aquatic, there are airplanes, there are Ferrari cars

MacOS and Windows only have one type, differentiated by their version, almost always a number or name of something (They actually have 2 types: desktop and server versions).

The different types of Linux are called distributions or distros. You don’t just say “I have Linux,” you have to indicate the distribution. A distribution is “Ubuntu” for example, then you say “I have Linux Ubuntu”

There are distributions for PCs as well as for DVD players and also TVs.

Within the Linux distributions for PC you have a user-friendly interface (desktop environment), specialized distributions to know Wi-Fi passwords, specialized distributions for engineers

Generally a Linux distribution with a graphical interface it gives you the choice between different graphical environments (DE) (usually already installed):

  • GNOME
  • KDE
  • XFCE
  • Cinnamon
  • MATE

Images of what GNOME looks like:

logos:

mac (machine or hardware) and macOS (os, software)

windows (os), PC(machine or hardware):

linux (kernel), PC (machine or hardware):

It was written from scratch in 1991 by Linus Torvalds.

It is the core of the operating system. It acts as an intermediary between the computer hardware (CPU, memory, hard drive, peripherals) and the application software. It handles memory management, resource allocation, and low-level communication.

Linux was released under the GPL license, aligning with the GNU philosophy, but is not part of the GNU project.

By itself, the Linux kernel is not enough for a user to interact with or run programs; it requires all the utilities and tools that GNU offers.

It is just a component for an operating system, it is not an operating system

The famous Linux penguin, named Tux, was directly inspired by the creator of the Linux kernel, Linus Torvalds, and a personal anecdote he had with these animals.

A Bite and “Penguinitis”: Torvalds recounted that, during a trip to Australia, he was bitten by a little penguin. He joked that this experience had given him “penguinitis,” an illness that caused him to lie awake at night thinking about penguins and feeling a great love for them.

ubuntu (distribution), gnu/linux (os), PC (hardware or machine)

It is simply called Ubuntu, but the full name is GNU/Linux Ubuntu distribution with the GNOME desktop environment (there are several desktop environments, GNOME is one)

GNU

It was created by Richard Stallman, inspired by UNIX which was created in part by Denis Ritchie, one of the creators of the C programming language and the UNIX operating system.

It is an incomplete operating system and toolset, it lacks a kernel

The goal was to create a completely free, Unix-compatible operating system (OS).

GNU mean GNU is NOT UNIX

It is a massive collection of software (utilities, libraries, compilers, shells, etc.) that make up the operating system itself.

In the early 1990s, the GNU project had almost the entire OS, except for one crucial component: the kernel.

are a set of tools for the GNU/* operating system (* is any kernel, linux is a kernel together they form GNU/linux)

GNU/Linux (are used together)

(GNU/Linux is never mentioned, but it is what we refer to when we talk about Linux)

GNU/Linux refers to the fully functional operating system that people commonly use, such as Ubuntu, Fedora, Debian, etc.

When the Linux kernel was combined with the nearly complete utilities of the GNU project, a free operating system was formed that could rival Unix and Microsoft Windows.

As an operating system, I missed UNIX (on which Linux and macOS are based).

There are Linux distributions without a graphical interface, that is, without a desktop environment, that is, just a console (that communicates with the shell) to write commands.

This is the case of servers (since they do not need monitors) therefore a desktop environment would consume resources unnecessarily.

As an example Linux distribution you have: Ubuntu Server

I was a macos or mac user (has console or terminal that communicates with the shell: iterm, this is kind of hidden)

I was looking for a Linux distribution that is very similar to macOS and that can run most of the commands in a console (that communicates with the shell).

The commands used in Linux or macOS are called bash commands.

macOS is similar to Linux because both operating systems are Unix-like.

UNIX is an operating system that was developed at Bell Labs in the 1970s. It established the philosophy, architecture, and basic commands

  • macOS runs BSD commands (directly derived from the original UNIX)
  • linux ubuntu runs GNU Commands (written to be compatible with UNIX).

I think Ubuntu is very similar to macOS, including the bash commands (for servers I use Linux ubuntu server which is like a Linux Ubuntu console/terminal that communicates with the shell, that is, the same commands).

I feel very familiar with macOS with Linux and Ubuntu (they are very similar).

During a period of my life I have tried several Linux distributions. Maybe someone will say that Linux Ubuntu is for beginners, but I feel very comfortable with it.

Bash is the most common command interpreter on Linux distributions like Ubuntu. When you type a command in the console (that communicates with the shell), Bash interprets and executes it.

I don’t need something more complex, but rather something popular to find solutions.


GNU/Linux withUbuntu with GNOME has a graphical application that functions as a centralized application store, similar to the Play Store or the App Store.

A Windows user would have a hard time getting familiar with this (since they have to search for the program manually, for example using Google). In Linux, Ubuntu, or macOS, if the manufacturer is well-known, you download the program from the store. If it is unknown, you must search for the program and allow it.

The name of this application has changed over time, but it is currently known as App Center or Ubuntu Application Center.

In macOS and iOS it is called AppStore or AppCenter

This application is the easiest way for new users to install and uninstall programs in Ubuntu, offering a graphical user interface (GUI) with categories, descriptions, and screenshots.

names: Ubuntu Software Center (historical), Ubuntu Software or Snap Store (newer versions), App Center (the most recent name, used in versions like Ubuntu 23.10 and later).

As an app store you can use:

  • App Center
    • Graphic (GUI)
    • Easy search, installation and uninstallation
  • apt
    • Console/Terminal/tty (CLI)
    • The underlying package manager that handles .deb packages.
    • It’s used with commands like:
      • sudo apt install [name]

Package Formats They Manage

  • Snap
    • A modern, self-contained packaging format promoted by Canonical (the company behind Ubuntu)
    • The current App Store is very focused on this format.
  • Debian (.deb)
    • The standard package format for Debian-based systems (such as Ubuntu)
    • Represents traditional programs that come from the official Ubuntu repositories

You can install software visually using the App Center or technically using commands in the terminal (mainly apt or snap)


The file browser (visual) where you can view folders/directories and files visually is called:

  • Nautilus (Linux Ubuntu con GNOME)
  • Finder (macOS)

finder images:

an image in Spanish:

Nautilus:


In macOS and Linux, the (.) is usually used to refer to the current directory

and (..) is usually used to refer to the topmost directory (in the hierarchy) (if you are in /a/b .. refers to the /a directory)


In both macOS and Linux Ubuntu, hidden files are written with a (.) before the name, for example .xxxx (not only files, directories too)

If you open the file system, that is, a window, you can hide and show hidden files:

  • CMD + Shift + . (macOS)
  • Crtl + H (Linux + Ubuntu + GNOME)

Something I often use is, if I’m in the terminal in one location, I can open the visual file system in the same location:

  • open . (macOS)
  • nautilus . (linux ubuntu GNOME)

The most useful tool in Linux is the console/terminal, which sends bash commands to the shell

In the console, bash commands are executed in the console and you will see something like this:

linux-username@linux-name:/path/directory$bash_command


A shell is not the same as a console/terminal

In everyday use they are often used as synonyms.

  • Shell (Command Interpreter)
    • It’s the program that processes the commands you type (such as ls, cd, grep). It acts as an interpreter between you and the operating system kernel. Common examples include Bash, Zsh, and Fish
      • analogy: The car engine
  • Terminal (Terminal Emulator)
    • It’s the graphical window or user interface that provides the ability to interact with the shell. It doesn’t process commands; it only provides the input/output environment (keyboard, on-screen text)
      • analogy: The steering wheel and dashboard (the interface)
  • Console (or TTY)
    • Nowadays, it is often used as a synonym for Terminal, but it can refer to virtual terminals.

When you open a terminal window (the interface), you are starting a program that automatically runs a shell (the interpreter, usually Bash) within it

  • You type the commands in the Terminal
  • The Terminal sends them to the Shell
  • The Shell processes them, executes them in the operating system, and sends the result back to the Terminal for you to view

It is very important that you know 2 directories

  • / It is the root directory of the entire system
  • ~ It is the user’s root directory, it is a directory access to the system directory /home/username

There are some important directories you should know:

  • /etc Things that the system uses are stored here
  • /var Here things that vary are stored, such as logs
  • /home Here are the directories of the different users

directory and folder are synonyms


A file name can be xxxx, xxxx.yyyy, the dot only marks the file extension so that it can be processed by a program


A hidden file has a (.) in front of its name like .xxxx


In Windows, you can click on a folder and enter it, but what happens if you don’t have a desktop environment or if you have thousands of files in a directory (this is my case)

example:

I have no interest in those directories and files being ordered.


Below are the console/terminal that communicates with the shell with commands for Linux and Ubuntu:

  • Auto-Completion: Use the Tab key to auto-complete directory names and avoid typing errors.
  • The cd (Change Directory) command, its main function is to change the current working directory in the terminal.
    • cd [directory]
    • examples
      • Absolute Path: Changes to the exact location specified from root (/)
        • cd /home/username/Documents
      • Parent Directory: Goes up one level in the directory hierarchy (goes to the parent folder)
        • cd ..
      • Home: Takes you directly to your home directory (e.g., /home/username on Linux or /Users/username on macOS). This is the fastest way to return to home.
        • cd
        • cd ~
      • Previous Directory: Returns to the directory you were in immediately before executing the last cd
        • cd -
      • Paths with Spaces: If a directory name contains spaces, you must enclose it in quotes or escape the spaces with a backslash.
        • cd "My Files"
        • cd My\ Files

The cat command (short for concatenate) is a standard UNIX/Linux utility that is primarily used to display the contents of text files to standard output (your terminal/console that communicates with the shell).

Although its original name (concatenate) implies joining files, its most common use is simply visualization.

  • visualization:
    • Displays the full contents of the file
      • cat filename.txt
    • Displays the contents of file1.txt and then immediately after that, the contents of file2.txt.
      • cat file1.txt file2.txt
    • You can use cat to create small text files by typing directly into the terminal.
      • cat > new_file.txt
      • write the content you want (can be several lines)
    • Joins the contents of file1.txt and file2.txt and saves it all to a new file called file_joined.txt
      • cat file1.txt file2.txt > united_file.txt
    • Number all output lines
      • cat -n file.txt
    • Number the non-empty lines
      • cat -b file.txt
    • Removes adjacent repeated blank lines (compresses multiple empty lines into one)
      • cat -s file.txt
    • To view the contents of very long files without them scrolling quickly off the screen, it’s best to use the less or more commands
      • cat large_file.log | less

the redirection operator (>)

a > b

sends the contents of exit of “a” command to “b” command, overwrite content


>>

a >> b

send content and append, do not overwrite the previous

example

a >> file.txt

appends the content of “a” to the end of file.txt, it does not replace any previous content


sudo

Before continuing, I want to talk about user privileges/permissions, it’s a concept that Windows doesn’t have.

Imagine a company building, the owner of the company has full access, meaning he can access any room.

An employee can only access some rooms, the employee’s boss can access the same rooms as his employee and will have others unlocked.

The owner is the “root” user, the employee is a “username”, his boss is another “username” with more privileges/permissions

The extent to which access is granted is the privilege/permission

What you can do with a user is ask root for permissions/privileges for a while, it’s like asking for their access card.

borrowing root permissions is done by typing “sudo” before a command, this takes 15 minutes, you will be asked once for the “root” user password, if you do not run another command with sudo within those 15 minutes, when using “sudo” you will be asked again, you can modify the “sudo” time (on this website you can see how to do it)

If there is a file that has one state for the username user and another for the root user, by prepending the reserved word “sudo” you will see the state of the file as if you were the “root” user.

The above is very important since the command “xxxx” can show one thing and “sudo xxxx” can show something else.

the use of “sudo” is like this

sudo command

the file is named “a”, to see the contents of “a”

sudo cat a

switch users

sudo su - [username]

switch to root user

sudo su

You will probably be asked for your password

to log out of the user you are currently on and return to the previous user

exit

The “web” group (or its more common equivalent, www-data)

The “web” group is used to manage permissions on files and directories hosted by a web server (such as Apache, Nginx, or LiteSpeed)

acts as the permissions checkpoint between the web server software and the page files

  • User: www-data (or sometimes apache, nginx, or even web)
  • Group: www-data (or web)

You ensure that only the web server has the necessary access to read, write, or execute those files


chmod and chown are crucial for file management on any UNIX-like system (Linux, macOS) because they control security and access to files and directories

chmod (Change Mode) – Modify Permissions

It is used to change the permissions (access modes) of a file or directory. These permissions define what the owner, group, and other users can do with the item.

Permissions are represented by three letters and apply to three categories of users:

  • r – read – 4
  • w – write (Writing/Modifying) – 2
  • x – execute (Execution/Access) – 1
  • You add the numerical values ​​for each category (Owner, Group, Other) and you get a 3-digit code (octal numeric notation)

examples

  • owner (u) – 7 – Read, Write, Execute (rwx)
  • Group (g) – 5 – Reading and Execution (r-x)
  • Others (o) – 4 – Read Only (r–)

To give the owner all permissions, the group read and execute, and others read only, the code is 754

chmod 754 file.txt

Result: -rwxr-xr–

Use letters to modify specific permissions without affecting others (symbolic notation):

  • u, g, o, a – User, Group, Other, Everyone – + (add permission)
  • – Add – – (remove permission)
  • – Remove – = (assign exact permission)
  • = – Assign

Example: Add execute permission (x) to the owner (u) and group (g) of the file

chmod ug+x script.sh

chown (Change Owner) – Change Owner and Group

It is used to change the owner and/or group of a file or directory.

  • Only the owner changes
    • chown new_owner file
  • Change only the group
    • chown :new_group_file
  • Change owner and group
    • chown new_owner:new_group file

examples

  • Change the owner to ‘admin’
    • chown admin file.pdf
  • Change the group to ‘development’
    • chown :development project.zip
  • Change the owner to ‘root’ and the group to ‘staff’
    • chown root:staff /var/log/app.log

Both chmod and chown are often used with the -R (recursive) option to apply changes to all files and subdirectories within a directory.

Change the owner and group of ‘html’ and all its content to ‘admin:web’

chown -R admin:web /var/www/html

Only the owner of a file or the root user (administrator) can run chmod or chown to modify permissions or ownership.

It is important to clarify that on Linux/UNIX systems, a file only has one owner (user) and one associated group, not multiple owners (b, c, and d) simultaneously.

chown ignores read/write permissions and focuses solely on who owns the file and what group it belongs to. Once the owner is c, user b automatically loses his special status over that file.

  • chown changes who is in the columns of the permissions matrix
  • chmod changes the tags (r/w/x) within those columns

ls (list) Its function is to show the contents (files and directories) of a directory

It’s used to display the contents of a directory. It’s the equivalent of viewing files in Windows File Explorer or Mac Finder, but from the command line.

Displays the contents of a specific route without changing your current location

ls /path/to/folder

Long list format. Displays crucial details: permissions, number of links, owner, group, size in bytes, and last modified date/time.

ls -l

Show all files, including hidden files (those that begin with a dot, such as .bashrc)

ls -a

Human-readable. Used with -l to display file sizes in human-readable units (KB, MB, GB) instead of bytes

ls -lh

Sort by time. Displays the most recent files first, based on when they were last modified

ls -lt

Reverse the order. Use with -t to display the oldest files first, or with normal alphabetical order to list from Z to A

ls -lr

Recursive. Lists the contents of subdirectories continuously.

ls -R

The most practical and frequent combination groups several of the previous options

ls -lha
  • -l: Detailed list (permissions, owners, etc.)
  • -h: File sizes in human-readable format (e.g. 4K, 12M)
  • -a: Also show hidden files (those starting with .)

To view the most recent files, simply add the t

ls -lhat

The mkdir (make directory) command is used to create new directories (folders) in the file system.

mkdir [options] directory_name

Create a folder called projects in your current working directory

mkdir projects

create multiple directories at once:

mkdir dir1 dir2 dir3

Create a directory with an absolute path

mkdir /home/user/Backup/January

The -p (parents) option allows you to create a nested directory structure (folders within folders) in a single line. If any of the intermediate folders don’t exist, mkdir will automatically create them.

mkdir /abc/def

The -v (verbose) option tells the command to print a message for each directory created, confirming that the operation was successful.

mkdir -p directory

you can combine both options

mkdir -pv directory

The pipe symbol (|) in Linux is an operator used to connect the standard output (stdout) of one command to the standard input (stdin) of another.

It acts as a pipe that directs the flow of data from one program to another, allowing complex commands to be chained together.

The pipe allows you to build efficient workflows where information is filtered, transformed and manipulated step by step.

command a | command b | command c

You can combine any command that can read from standard input and write to standard output.


The sed (Stream Editor) command is for filtering and transforming text from files or standard input (stream)

Its main function is to apply text editing operations (such as search, replace, insert or delete)

Replaces the first occurrence of “old” with “new” in each line of the file

sed 's/old/new/' file.txt
sed 's/pattern_to_find/replacement/' file_name

Globally replace (g) and write the changes (w) to a new file called file.txt.out.

sed 's/error/solution/gw' file.txt

The d (delete) command deletes lines that meet a criteria or are in a specific range

Deletes all lines beginning with the # symbol (comments), a common action in configuration files

sed '/^#/d' file.txt

Delete lines 1 through 5

sed '1,5d' file.txt

Delete the last line ($ represents the end of the file)

sed '$d' file.txt

By default, sed displays the modified output in the terminal, but does not modify the original file. To save changes directly to the file, use the -i option

sed -i 's/http/https/g' config.conf

Replace ‘http’ with ‘https’ in the file and save the change

sed supports extended regular expressions (ERE) for more complex searches, which gives it its great power

sed 's/<p>.*<\/p>/[ABC DEF]/' index.html

Replace all content of the file index.html between <p> and </p> with the word [ABC DEF]


The grep (Global Regular Expression Print) command is an essential command-line utility in Linux and macOS that is used to search for lines of text that match a specific pattern within one or more files.

grep [options] 'search_pattern' [file(s)]

example

grep 'error' file.log

This prints all lines in file.log that contain the word “error”

Ignore case. Matches regardless of case

grep -i 'error'

Recursive. Searches for the pattern in all files in the current directory and its subdirectories

grep -r 'admin' /var/www/

Line number. Displays the line number where the match was found

grep -n 'error' file.txt

Count. Only shows the number of lines that match, not the lines themselves

grep -c 'WARNING' server.log

Whole Word. Requires the pattern to match a whole word, not part of a word

grep -w 'log' file.txt

(Will not match “login”)

Extended Regular Expressions (EREX). Allows you to use more advanced regular expression syntax

The true power of grep comes when used with the pipe operator (|), which takes the output of a command and uses it as input to grep

example:

If you want to see a detailed list of all running processes (ps aux) but you are only interested in the web server process (httpd)

ps aux | grep 'httpd'
  • ps aux list all processes
  • | sends that list as input to grep
  • grep ‘httpd’ filters the list and only prints lines that contain “httpd”

In this way, grep acts as an essential filter on the command line.


The date command in Linux is used to display the current system date and time

On modern systems like Ubuntu Server, time management and time synchronization are usually handled automatically through the NTP (Network Time Protocol) service and timedatectl to avoid time skew.

  • %Y
    • Year (4 digits)
  • %m
    • Month (01-12)
  • %d
    • Day of the month (01-31)
  • %H
    • hour (00-23)
  • %M
    • Minute (00-59)
  • %A
    • Full name of the day of the week
  • %B
    • Full name of the month

The real power of date lies in the format option (+), which allows you to specify exactly how you want the information to be displayed using formatting sequences that begin with the percent sign (%)

  • date +%Y-%m-%d
    • 2025-09-28
  • date +"%H:%M"
    • 18:44
  • date +"Today is %A, %d of %B of %Y"
    • Today is Domingo, 28 of Septiembre of 2025
  • date +%s
    • 1730076262
    • Displays the date as the number of seconds since the Epoch (January 1, 1970)

You can also modify the date with “date” but that is not usually done.


The mv (move) command has two main functions

  • Move files and directories from one location to another
  • Rename files and directories

Both functions are, in fact, the same operation: changing the name and/or path of a file or directory in the file system.

to rename, the source and destination files are in the same directory

mv current_name new_name

example

Rename the file reporte_old.txt to reporte_final.txt in the same folder

mv reporte_old.txt reporte_final.txt

To move, the destination path is different from the source path

mv origin destination

examples

Move the project directory (and all its contents) to the /var/www/ directory.

mv project/ /var/www/

Move the report.pdf file from your current directory to the Documents folder

mv report.pdf /home/user/Documents

The cp (copy) command is used to copy files and directories from one location to another.

cp original_file.txt destination_folder/

Copy original_file.txt to the destination_folder/, keeping the same name

Copy original_file.txt to destination_folder/ and simultaneously rename it to copy_file.txt:

cp original_file.txt destination_folder/copy_file.txt

To copy a folder (and all its contents, including files and subfolders), you must use the recursive option (-r or -R)

cp -r Documents/ Backup/

Maintenance of Permits and Property (-p)

The -p (preserve) option is used to keep the original attributes of the copied file, such as its owner, group, and modification date/time

Creates a copy identical to the original, including permissions and date, which is useful for backups:

cp -p report.log backup_report.log

touch is to create an empty file if it doesn’t exist

If the file you specify does not exist, touch creates it instantly with a size of 0 bytes (empty)

touch file_name

hidden file:

touch .file_name

You may need to use the command in conjunction with sudo:

sudo touch file_name

It is very important that you know that you will create a file without content


vi is a console/terminal that communicates with the shell text editor

Just like vi, you have nano and vim

vim is vi improved

vi file_name

You can enter text by touching (i), which is editing mode, or ESC to enter commands

the commands are

  • :w Save changes (write)
  • :q Quit the editor
  • :wq Save and exit. (Equivalent to :x)
  • :q! Force quit, discarding all unsaved changes.

The commands will be seen at the bottom of vi, with ESC you can write them, then press ENTER to apply them


The curl (Client URL) command is a command-line tool for transferring data using URL syntax. It supports a wide range of protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, etc.).

Its most common use is to make requests to web servers, making it essential for developers, system administrators, and for testing APIs.

The most basic use is simply to display the contents of a URL to standard output (the terminal)

curl https://example.com

curl is the preferred tool for sending data via POST, PUT, or DELETE requests, commonly used to interact with REST APIs

curl -X POST -H "Content-Type: application/json" -d '{"user":"test"}' https://api.example.com/data

Upload a File (-F or –form)
Used to submit form data that includes a file:

The @ symbol tells curl that the parameter is a local file and should be loaded

curl -X POST -F 'file=@image.jpg' https://api.example.com/upload

The ping (Packet Internet Groper) command is a fundamental network diagnostic tool used to test connectivity

It sends small packets of data to a specific destination and waits for a response, measuring the time it takes for the round trip

ping [options] destination

example

ping google.com

With ping you can know the IPV4 of a domain (ping4) or IPV6 with ping6


echo is a standard command-line utility in Linux and other operating systems that is used to display a line of text or the value of variables to standard output (the terminal)

echo "hello world"

displays the text: hello world in the terminal/console that communicates with the shell

Display Environment Variables

(variables that store session information, settings, etc.). The dollar sign ($) is used before the variable name

Displays the current shell (e.g. Bash, /bin/bash)

echo $SHELL

Displays the name of the current user

echo $USER

Displays the path to the home directory (/home/username)

echo $HOME

Exit Redirection

  • > (Replaces all existing content in the file with the new text)
    • echo “text” > file.txt
  • Append to End of File (>>): Adds the new text to the end of the existing content
    • echo “second line” >> file.txt

Environment variables are not Linux commands, but system variables.

An environment variable stores an alphanumeric or numeric value

Below I show you how to see its contents with the “echo” command.

The name has the symbol $ before a word

examples

  • $PATH
    • It contains a list of directories where the shell should search for executable commands. This is why you can type ls and the system will find it.
  • $HOME
    • The full path to the current user’s home directory
  • $USER
    • The username’s directory of the current user
  • $SHELL
    • The path to the shell program being used
  • $LANG
    • Defines the system language and encoding (localization) (such as es_AR.UTF-8)

They are named dynamic values ​​that influence how the computer, running programs, and especially the shell (command interpreter) behave.

They are a standardized way of sharing configuration information between processes in an operating system, allowing programs to run without being rigidly coded to a specific location or user.

The export command is what marks a local variable to become an environment variable.

They store critical paths ($PATH), user information ($USER), and software-specific settings ($JAVA_HOME)

They allow you to configure application parameters (such as API keys or database names) outside of the source code, which improves security and makes it easier to change configurations without recompiling the code.

Displays all system environment variables

printenv

Removes an environment variable

unset

example

unset API_KEY

To make an environment variable permanent (so that it is loaded every time you start a new shell), you must add the export line to the end of your personal shell configuration file:

  • ~/.bashrc
    • For Bash users
  • ~/.zshrc
    • For Zsh users

By placing the definition there, the command is automatically executed at every login, ensuring that the variable is always present

The source command is essential for managing environments and variables in the shell

is used to execute commands read from a file in the current shell environment

The most important function of source is to load configuration changes without having to start a new terminal session.

source file_name

If you edit a shell configuration file (such as .bashrc or .zshrc) to add or modify an environment variable

You need to use source so that the changes are applied immediately in your active terminal:

source ~/.bashrc

In development projects, it is common to have files called env.sh or setup.sh that contain all the environment variables ($JAVA_HOME, $PATH, API keys) needed to run the project:

source setup.sh
  • if the variable was never exported, so it remained confined to the parent process. The child process ignores it
  • if the variable was exported, which marked it as an environment variable and allowed the child process to inherit and read it
  • When you run a sh script with ./, you are creating a child process (a subshell)

images with known environment variables:

an idea of ​​what they are used for (they do not appear in the software code, only their key and not their value)

The best way to demonstrate the difference between a shell variable and an environment variable is to create both in a terminal and then run a simple script. This illustrates how only the environment variable is “inherited” by the child process.


The pwd (print working directory) command is one of the fundamental commands in Linux and UNIX-like systems (such as macOS)

Its only function is to print the absolute (full) path of the directory you are currently in in the terminal

When you run pwd, the system returns the path from the root directory (/) to your current location:

pwd

The which command in Linux and UNIX-like systems is used to locate where an executable command is located in the file system

Finding the Location of a Command

example

which ls

Output: /usr/bin/ls

If you have multiple versions of a program installed

which -a python

output:

/usr/bin/python

/usr/local/bin/python


The alias command in Linux and UNIX-like systems is used to create custom shortcuts for longer or more complex commands. It allows you to assign a short name to a command string, including its options or arguments.

alias alias_name='command_to_replace'

Use single quotes (‘) to enclose the command, especially if it contains spaces or operators (such as pipes |)

alias cls='clear'

you can run it:

cls

To view a list of all aliases defined in your current session:

alias

To view the definition of a specific alias:

alias alias_name

To remove an alias you no longer need

unalias alias_name

Like environment variables, aliases created with the alias command only last as long as the terminal session is open.

To make an alias available every time you open a terminal, you must add the alias … line to your shell configuration file.


The shutdown command is used on Linux and macOS systems to safely and controlledly shut down, restart, or halt the system.

Use it instead of simply cutting the power, as it gives the operating system time to end processes, unmount file systems, and save data, preventing data corruption.

sudo shutdown [options] TIME [MESSAGE]

Immediate Shutdown

sudo shutdown now

The alias now is equivalent to +0 (zero minutes from now)

You can schedule the shutdown for a future time, giving users time to save their work

Turn off the system in 15 minutes

sudo shutdown +15

Shut down the system at 11:30 PM today (24-hour format)

sudo shutdown 23:30

Turn off in 5 minutes and notify all connected users with the message

sudo shutdown +5 "The server will be shut down for maintenance"

Reboot the system immediately

sudo shutdown -r now

Cancels a previously scheduled shutdown or restart

sudo shutdown -c

The shutdown command requires administrator permissions, so it should almost always be preceded by sudo. If you forget to use sudo, the system will tell you that you don’t have permission to run it.


The export command is used to mark a variable as an environment variable

  • Shell Variable: Only available in the current shell
  • Environment Variable: Available in the current shell and inherited by any script or program started from that shell

The process is carried out in two steps, although they can be combined (shell variable) (local)

MY_VARIABLE="Secret Content"

Then, you use export to make it an environment variable (environment variable) (exported)

export MY_VARIABLE

The most common way is to define and export it in a single line:

export APP_NAME="My Application"

To see all the variables already exported in your session, you can use export without arguments:

export

You can filter for specific variables (using grep)

export | grep APP_NAME

It’s important to remember that the exported variable only lasts as long as the shell session is active. To have an environment variable loaded automatically each time you start a session, you must add the line export VARIABLE_NAME=”value” to the end of your shell configuration file (such as .bashrc or .zshrc)

By adding the line export VARIABLE_NAME=”value” to one of these files, the command is automatically executed every time a new shell is started, making the variable persistent between sessions.


Script sh

A Bash script (extension .sh) is a text file containing a series of Linux commands, written in the Bash shell programming language, and executed sequentially by the operating system.

They are the most common and essential way to automate tasks on UNIX-based servers and operating systems (such as Linux and macOS).

Every well-formed Bash script has two main components: the shebang and a command sequence.

The Shebang (#!)

!/bin/bash

The first line of almost any Bash script should be the shebang. This is a directive to the operating system that tells it which shell to use to execute the rest of the file.

  • !#: It is the magic sequence that the interpreter indicates
  • /bin/bash: This is the path to the Bash interpreter executable.

Starting with the second line, the script contains the commands you have learned (such as ls, cd, echo, grep, etc.), and may also include programming logic (loops, if/else conditionals, variable handling).

  1. Create the file using a text editor like vi and save it with the .sh extension
  2. Give Execute Permission (chmod)
    • By default, the file is readable and writable only. You need to use chmod to give the owner execution permission
      • chmod +x my_script.sh
      • (The +x adds the execute permission)
  3. There are two common ways to run it
    • Recommended. Tells the shell to execute the file using the interpreter defined in the shebang. (The ./ means “in this directory.”)
      • ./my_script.sh
    • Used for environments. Runs the script in the current shell. Required if the script modifies environment variables (uses export)
      • source my_script.sh

If you run with ./, the script runs in a subprocess, and any environment variables you set are lost upon termination. If you use source, variable changes persist in your current terminal

When you run a sh script with ./, you are creating a child process (a subshell)


apt (Advanced Package Tool)

apt is the most modern and recommended command-line tool for managing packages (software) on Debian/Ubuntu systems.

apt is responsible for searching, downloading, installing, updating, and removing programs from the system, automatically managing all necessary dependencies.

Think of it as the “app store” for the operating system.

You always use sudo before apt because installing software requires administrator privileges:

It downloads the latest software and version information from online repositories, but doesn’t install anything

sudo apt update

Compare the list of installed packages with the updated list and download and install the new versions available

sudo apt upgrade

Find, download, and install the specified package

sudo apt install package_name

Whenever you want to fully update your system, you must run the two-step flow:

  1. Refresh the list of available versions
    • sudo apt update
  2. Install the new versions it found
    • sudo apt upgrade

The commands and concepts seen here were:

  • cd
  • TAB (autocomplete)
  • .
  • ..
  • /
  • ~
  • ls
  • sudo
  • exit
  • mkdir
  • cat
  • sed
  • grep
  • mv
  • cp
  • date
  • chmod
  • chown
  • touch
  • vi
  • curl
  • ping
  • echo
  • alias
  • shutdown
  • pwd
  • which
  • environment variable & shell variable
  • export
  • shell & console/terminal (tty)
  • bash
  • script .sh & ./name
  • .bashrc and source
  • >
  • >>
  • Ubuntu Software Center (GUI) , Ubuntu Software (GUI) or Snap Store(GUI) , App Center (GUI) & apt (CLI)
  • | (pipe)

If you want to learn more about Linux, more specifically Linux Ubuntu Server, you can learn on this website

With these commands I think you can move freely through Linux Ubuntu

You can find information on this website about: ssh, crontabs, hosts, netcat, pipe, scp (to learn more about Linux)