CHAPTER FIFTEEN: LINUX & MACOS Flashcards
(34 cards)
What is Linux and Why Do People Use It?
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).
What’s Under the Hood: Kernels, Shells, and Terminals
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.
What is a Shell, Terminal, and Console?
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.
shell
Interactive shell = You type commands live.
Non-interactive shell = Linux runs a list of commands from a file (a script).
What is a Desktop Environment?
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).
Console Switching
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.
Linux Command Structure
When you type a command, Linux expects it in this format:
- Command — the thing you want to do.
Example: ls means “list files”. - Options/Switches — change how the command works.
Short: -l
Long: –help - Arguments — what you want to do the command to.
Example: ls -l /home means “list in detail the files in /home”.
Redirecting Output
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.
Case Sensitivity
Linux is picky about upper/lowercase.
File.txt ≠ file.txt
LS ≠ ls — capital letters mean something totally different (or nothing at all!).
File Editors in Linux
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
Navigating the Linux File System
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).
Navigation Commands
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)
ls Command
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.”
cat Command
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»_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.”
find Command
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.).
grep Command
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”.
Metacharacters and Escaping
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
File Management Commands
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.
Disk Space Commands
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).
User Account Management
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.
su Command
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!).
sudo Command
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.
User Management Commands
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.
Group Management Commands
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