Linux Security Basics-Fall24
Linux Security Basics-Fall24
By Nayla Greige
Outline
• Basic Commands
• Users and groups
• Permissions and access control
• Running commands with privilege
• Authentication
Introduction to Linux
• What is Linux?
• Definition: Linux is an open-source operating system
kernel created by Linus Torvalds in 1991. It serves as the
foundation for many operating systems known as Linux
distributions.
• Open Source: The source code of Linux is freely available,
allowing users to view, modify, and distribute it.
• Examples: Ubuntu, CentOS, Fedora, Debian, Arch Linux,
and Mint.
Linux File System Hierarchy
• Root Directory (/): The top-level directory in the Linux file system hierarchy.
• Home Directory (/home): Contains user-specific files and directories.
• Binary Directory (/bin): Contains essential command binaries such as ls, cp, mv.
• System Configuration (/etc): Contains configuration files for system-wide settings.
• Library Directory (/lib): Contains essential libraries needed for system binaries.
• Temporary Files (/tmp):Used for temporary file storage by applications.
• Device Files (/dev): Contains device files that represent hardware devices.
• Mount Points (/mnt, /media): Used for mounting external storage devices.
Basic Commands
• File Operations:
ls: List directory contents.
cp: Copy files or directories.
mv: Move or rename files or directories.
rm: Remove files or directories.
touch: Create an empty file or update the timestamp of an existing file.
• Directory Operations:
cd: Change directory.
pwd: Print the current working directory.
mkdir: Create a new directory.
rmdir: Remove an empty directory.
Basic Commands
• File Viewing:
cat: Concatenate and display file contents.
more, less: View file contents page by page.
head, tail: Display the beginning or end of a file.
• Permissions:
chmod: Change file permissions.
chown: Change file ownership.
chgrp: Change file group ownership.
USER AND GROUP
Users
• User and Group Files:
/etc/passwd: Stores user account information.
/etc/group: Stores group account information.
• File Permissions:
Types: Read (r), Write (w), Execute (x).
Ownership: Each file has an owner, a group, and permission settings for user, group, and
others.
Users
• In Linux, each user is assigned a unique user ID
• User ID is stored in /etc/password
• Find user ID
Add Users & Switch to Other Users
• Add users
• Directly add to /etc/password
• Use “adduser” command
• Full System Access: The root shell grants unrestricted access to all
files and system resources, including the ability to modify system
configurations, install or remove software, and manage user
accounts.
• Privileges: Commands executed in a root shell can change system
settings, install updates, and access all files, regardless of the file
permissions set for other users.
How to access a root shell?
1. Using su (Substitute User)
2. Start a Root Shell:
sudo -i
Common Methods to Grant
Superuser Privileges
• sudo
• Set-uid programs (covered in a separate chapter)
• POSIX capabilities
Using sudo
• sudo: Super-user Do
• Allows permitted users to execute commands as a superuser
• A user must be authorized (/etc/sudoers)
• Here is how the seed user is allowed to run sudo
Running Command Using Another
User
su (substitute user): Allows switching to another user, typically the root
user. You need to provide the root password.
POSIX Capabilities
• Divide the root privilege into smaller privilege units
• Known as capabilities
• Use “man capabilities” to find all the capabilities
• Examples
Setting File Capabilities (1)
• Before