CHAPTER FIFTEEN: LINUX & MACOS Flashcards

(34 cards)

1
Q

What is Linux and Why Do People Use It?

A

Linux is an operating system—like Windows or macOS—that runs on desktops and servers. People love it because it’s:

Very reliable (it doesn’t crash easily).
Very secure (harder for viruses or hackers to mess with it).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s Under the Hood: Kernels, Shells, and Terminals

A

The kernel is the core of Linux. Think of it like the brain of the operating system. It:
- Talks to the hardware (like your keyboard, screen, and hard drive).
- Lets software (like a web browser or file manager) ask the hardware to do stuff.

A Linux distribution (or distro) is:
- The kernel plus a bunch of other tools (apps, utilities, etc.).
- It comes with a package manager (a tool that installs software).
- Examples: Ubuntu, Fedora, Debian, etc.
- Some are free and run by communities; others are commercial and come with paid support.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Shell, Terminal, and Console?

A

Shell = The text-based command center where you type commands.
It’s the thing that listens to your commands and talks to the OS.
Popular shells: Bash, zsh, ksh.

Terminal = The program that shows you the shell.
It’s the window or interface you use to type shell commands.

Console = Kind of like the terminal, but tied to the system’s actual screen and keyboard.

Linux connects these using a tty (teletype) device. Think of it like:

stdin (0): What you type (keyboard input).
stdout (1): What you see (output text).
stderr (2): Error messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

shell

A

Interactive shell = You type commands live.

Non-interactive shell = Linux runs a list of commands from a file (a script).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Desktop Environment?

A

Some Linux systems boot to a pretty graphical interface (just like Windows).

That’s called a desktop environment (DE), and some examples are:
Gnome, KDE, Cinnamon, Xfce.
These graphical environments are built using something called Xorg or the X Window System.

Inside them, you can still open a terminal emulator — it’s like a terminal in a window.
This connects to the shell using a pseudoterminal (pty/pts).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Console Switching

A

Linux has multiple virtual terminals (like tabbed desktops).

You can switch between them using Ctrl + Alt + F1 to F6.
One may show your desktop.
Another might show a login screen or command line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Linux Command Structure

A

When you type a command, Linux expects it in this format:

  1. Command — the thing you want to do.
    Example: ls means “list files”.
  2. Options/Switches — change how the command works.
    Short: -l
    Long: –help
  3. Arguments — what you want to do the command to.
    Example: ls -l /home means “list in detail the files in /home”.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Redirecting Output

A

Use pipes (|) to send the output of one command into another.

ls | more — shows one screen of files at a time.

Use ; to run multiple commands on one line.

cd /home; ls — change to /home, then list the files there.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Case Sensitivity

A

Linux is picky about upper/lowercase.

File.txt ≠ file.txt

LS ≠ ls — capital letters mean something totally different (or nothing at all!).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

File Editors in Linux

A

Nano is a simple text editor. Great for beginners.

nano file.txt to open or create a file.
Use CTRL+O to save and CTRL+X to quit.

Vi or Vim is a more powerful (but harder) editor.

It has 2 modes:
Insert mode = for typing text (press i, a, o, etc. to get in).
Command mode = for saving, quitting, etc.

:w = write (save)

:wq = write and quit

:q! = quit without saving

:set number = show line numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Navigating the Linux File System

A

Linux treats everything like a file, even hardware (like hard drives).

/dev/sda = your first hard drive
/dev/sdb = second drive (like a USB stick)

No drive letters like Windows (C:, D:).
Everything starts at / (root).

Important folders:
/home = personal files
/etc = system configuration files

When Linux boots:

Loads the kernel into RAM.
Loads the file system from the disk (like the operating system).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Navigation Commands

A

pwd = print working directory (tells you where you are in the file system)

cd = change directory

cd /etc = go to etc folder (absolute path from root)

cd documents = go into “documents” folder in your current directory

cd .. = go up one level (to the parent folder)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ls Command

A

Think of ls as the “show me what’s here” command. It’s like looking into a folder to see what files or subfolders are inside.

When you type ls, it lists the contents of your current folder.

ls -l gives a long list, meaning it gives more details like size, who owns the file, and when it was last changed.

ls -a shows all files—even the hidden ones (files starting with a dot like .hiddenfile).

ls -la /etc means: “Show me everything (even hidden stuff) in the /etc folder, with all the juicy details.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

cat Command

A

cat stands for “concatenate,” but just think of it as a way to read the contents of a file. It shows what’s inside.

cat filename.txt will show you what’s in that file.

cat -n filename.txt does the same thing but adds line numbers.

You can redirect this output:

cat > file.txt means “take what I type next and overwrite file.txt with it.”

cat&raquo_space; file.txt means “take what I type and add it to the end of file.txt.”

You can also combine cat with a pager:

cat longfile.txt | more means “read the file, but pause so I can read it page by page.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

find Command

A

find is used to look for files or folders.

The basic form:
find where_to_look what_to_look_for

Example:
find /home -name myfile.txt means “Search in /home for a file named myfile.txt.”

You can search based on:

-name (the name of the file)
-user (who owns the file)
-size (how big it is)
-type (what kind of file: normal file, folder, link, etc.)

Windows files are identified by their file extensions like .jpg, .doc, but in Linux, the type refers more to what kind of object the file is (folder, link, socket, etc.).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

grep Command

A

grep is like a super-powered search tool for text inside files.

If you want to find a specific word in a file, you use grep.

Example:

grep -i “uid=1003” /var/log/messages
This looks inside the system log file and shows you any line that mentions uid=1003, ignoring case sensitivity (it doesn’t care if it’s uppercase or lowercase).

You can also use grep with ls like this:

ls -l | grep audit
It lists files whose names contain the word “audit”.

17
Q

Metacharacters and Escaping

A

Some characters have special powers in Linux—called metacharacters. For example:

  • means “match anything.”

ls *.txt lists all files that end in .txt.

But what if your file is literally called *star.txt?

You need to escape the metacharacter so Linux doesn’t treat it as special.

To escape it, you use a backslash \, like: *

Spaces are also tricky:

If you want to search for “My File.txt”, use quotes or escape the space:
“My File.txt” or My\ File.txt

18
Q

File Management Commands

A

cp Command
Stands for copy.
It copies a file from one place to another.
cp file1.txt file2.txt makes a copy named file2.txt.
cp file.txt /folder/ moves a copy of the file into a different folder.

mv Command
Stands for move, but it also renames files.
mv file1.txt /folder/ moves it.
mv oldname.txt newname.txt changes the name.

rm Command
Stands for remove, and it deletes files.
rm file.txt deletes a file.
rm -r folder deletes a folder and everything inside it.

19
Q

Disk Space Commands

A

df Command
Stands for disk free.
Shows you how much space is left on your hard drives.

du Command
Stands for disk usage.
Tells you how big a folder or file is.
du -h folder/ gives you a human-readable size (like MB or GB).

20
Q

User Account Management

A

Root User (Superuser)
The root user is the all-powerful “admin” of the Linux system.

Be careful—this account can do anything, including deleting the whole system!

Normally, you should use a regular user account for daily tasks.

21
Q

su Command

A

su stands for switch user.

su username switches to another user account.

If you type just su, it tries to switch to the root account.

su - switches to root and loads the root user’s environment (better practice!).

22
Q

sudo Command

A

sudo stands for superuser do.

It lets a regular user temporarily do something with admin privileges—if they’re allowed to in the /etc/sudoers file.

Example: sudo apt update lets you run the update command as an admin.

You might be asked to enter your own password for confirmation.

23
Q

User Management Commands

A

User settings are stored in special files:

/etc/passwd: contains basic user info.

/etc/group: shows which groups users belong to.

/etc/shadow: contains passwords (stored securely as hashes).

useradd: Adds a new user.

usermod: Changes user info (like their group or home folder).

userdel: Deletes a user.

passwd: Changes the password of a user.

24
Q

Group Management Commands

A

In Linux, you can organize users into groups, kind of like putting people into teams.

Groups help control what users can do with files — who can read them, change them, or run them.

There are three main commands:

groupadd – makes a new group.

groupmod – changes a group.

groupdel – deletes a group.

A user can belong to many groups, but they can only use one main group at a time — this is called their effective group ID.

This main group is listed in a file called /etc/passwd.

If a user wants to switch their main group (just temporarily), they can use the newgrp command

25
File Permissions Commands
Every file or folder has rules that say who can do what with it. These are called permissions. There are three types of permissions: 1. Read (r) – lets someone see or open the file. 2. Write (w) – lets someone change or delete the file. 3. Execute (x) – lets someone run the file if it’s a program or script. For folders, it lets you enter the folder. These permissions apply to three kinds of users: The owner of the file. The group the file belongs to. Other people (everyone else). Permissions are shown using symbols: r means read allowed. w means write allowed. x means execute allowed. - means the permission is not allowed.
26
Package Management Commands
In Linux, software can come in two forms: Source code – like the raw ingredients. You need to “cook” it using a compiler. Pre-compiled – like ready-to-eat food. You just install it.
27
APT (Advanced Packaging Tool)
used by Debian-based systems like Ubuntu. It installs .deb files.
28
YUM (Yellowdog Updater, Modified)
used by Red Hat-based systems like CentOS. It installs .rpm files.
29
Distributions and Repositories
A Linux distribution (or distro) is a version of Linux, like Ubuntu or Fedora. Each distro comes with a bunch of pre-selected software packages. These packages are stored online in places called repositories (repos). There can be different kinds of repos: Stable (official, safe to use) Beta (testing, might have bugs) Unsupported (use at your own risk) The package manager (APT or YUM) needs to know where these repos are (the web address). When you install or update software, it grabs it from these repos. During system setup, your package manager is usually automatically configured with the right repos.
30
apt-get and yum Commands
For APT (used on Ubuntu/Debian): apt-get update – refreshes your list of available software. apt-get upgrade – updates all installed software to the newest version. apt-get install – installs new software. For YUM (used on Red Hat/CentOS): yum check-update – checks for updates. yum update – installs all updates. yum install – installs new software.
31
Process Monitoring Commands
Every running program is a process. Each process has a unique number called a PID (Process ID). The very first process on a Linux system is called init and always has PID 1. Every new thing you run gets its own PID.
32
ps Command
The ps command shows a list of running processes. Run ps by itself, and it shows what’s running in your current terminal. You can add options to ps to get more details or see other users' processes.
33
Network Management Commands
On Linux, network devices (like your wired or wireless card) are called interfaces. They used to be named eth0, eth1, etc. Some newer systems use names like enp3s0. There are two kinds of network settings: 1. Running configuration – what your network is doing right now. 2. Persistent configuration – what your network will do after a reboot. Newer systems use tools like: 1. NetworkManager (with a GUI or nmcli command) 2. systemd-networkd (more for advanced users)
34