OS Managment (Linux) Study Guide

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Explain why cleanly mounting and unmounting is important.

- Cleanly mounting and unmounting is crucial for maintaining file system consistency. - It ensures that data is written to storage properly and prevents potential issues like data corruption or incomplete operations. - Proper unmounting releases resources and allows for safe removal of devices without risking data integrity. I.E. a USB drive, unmount when you're done with it

Who is Bill Joy and what were some of his contributions to linux?

- Computer scientist and Co-founder of Sun microsystems, the company that created Java (Sun microsystems was acquired by Oracle in 2010) - Developed VI (Visual Editor), a standardin UNIX systems since the 1970's - Helped with development of BSD UNIX, the distro that macOS was derived from

Explain how storage media works in linux and how it relates to the file system.

- Linux treats storage devices as files; everything is a file, including disks. - The file system organizes data on these devices. - Mounting attaches storage to specific locations in the file hierarchy. - For Example /dev/sda is a disk file, and /mnt/data is a mounted point. How to mount a USB drive in Ubuntu: 1. Locate the USB lsblk 2. Create a mount point sudo mkdir /mnt/usb 3. Mount the USB drive. sudo mount /dev/sdX1 /mnt/usb 4. Unmount the USB drive. sudo umount /mnt/usb # Devices cannot be unmounted while in use *Replace the X in sdX1 with the appropriate letter for your usb drive

What is The PATH in the linux enviornment? Provide an Example use

- PATH is an environment variable listing directories where executable files are located. - It enables the direct execution of programs without specifying their full paths. - If a program "example" is in "/usr/local/bin," adding it to PATH allows running "example" instead of "/usr/local/bin/example." Command: echo $PATH - displays the current PATH directories. Command: export PATH=$PATH:/new/directory - This adds "/new/directory" to the existing PATH, allowing the system to search for executables in this directory. Note: Changes made using export are temporary. For permanent changes, modify startup files like .bashrc or .bash_profile.

Whats the diference between a shell variable and an enviornment variable? Give an example of each

- Shell variables are local to the shell session, They are not available to child processes. # Accessing a shell variable myName="Jeffrey" echo "Hello, $myName" - Environment variables are accessible to child processes. Changes made to environment variables in a shell session affect the behavior of programs started from that session. # Accessing an environment variable export myName="Jeffrey" echo "Hello, $myName"

Explain aliases and provide a use case for one

- Shortcuts or custom names for commands. Example: alias ll='ls -al' - Typing ll now executes ls -al. - Simplifies command usage, creates shortcuts. Note: Aliases are temporary; to make permanent, add to either bashrc or bash_profile

Explain and give some examples of bash_profile and bashrc startup files and how they can be configured

- bash_profile: - Start-up profiles for login shell sessions - File: ~/.bash_profile or ~/.profile - Purpose: Executes commands at login. - Example: Setting environment variables or executing scripts during login. chmod +x myscript.sh vi ~/.bash_profile # Add the script here ./myscript.sh # Add environment variables here export PATH=$PATH:~/bin Note: /etc/profile is a global version of .bash_profile (Will affect all users on a system) - bashrc: - Start-up profiles for non-login shell sessions - File: ~/.bashrc - Purpose: Executes commands for each new shell. - Example: Customizing prompt, setting aliases, or defining functions. vi ~/.bashrc # Add aliases and customize PS1 here alias ll='ls -l' PS1=\u@\h:\w\$ Note: /etc/bash.bashrc is a global version of .bashrc

Give an example of how you would ssh to a server in ubuntu and secure copy something to that server.

1. Connect to a server ssh -i keyfile ip-address # Connects to the server using the specified private key (-i flag), given username and IP address. 2. Set permissions for the private key cd ~/.ssh chmod 400 it_ssh_server_key.pem # Ensure you have the correct permissions on the private key file. 3. Connecting with the modified key ssh -i it_3313_ssh_server_key.pem server@ip-address # Connects to the server using the modified key with proper permissions. 4. Copy a file to the server using SCP scp jeffrey.txt [email protected]:~/. # Copies the local file (jeffrey.txt) to the server (cyberpunks) in the home directory (~/) 5. Edit the SSH config vi ~/.ssh/config # Example configuration... Hostname my-website.com IdentifyFile ~/.ssh/id_rsa # Now we can SSH directly to my-website.com without having to provide full credentials everytime. 6. Generate SSH keys ssh-keygen # generated keys are typically stored in ~/.ssh/

How would you add a directory to the PATH?

A very common example of this is creating a /bin folder in our home directory so we can directly execute commands. We can add custom commands and scripts to this folder 1. Create the directory mkdir ~/bin 2. Add it to the path PATH=$PATH:~/bin 3. Make it stick vi .bashrc # Add the following if statement if [ -d ~/bin ] then PATH=$PATH: ~/bin fi # Tests for the existence of ~/bin before adding it to the path

Explain repositories and how to add custom packages in ubuntu

Centralized servers storing software; essential for software distribution, updates, and security. - Update with... apt update - Install with... apt install apt-get install - Add custom packages with... add-apt-repository Example: sudo add-apt-repository ppa:example/repo

Give me a brief rundown of Ed, Vi, and Vim history

Ed: Year: Developed in the 1960s. Description: Line-oriented text editor, precursor to Vi. Vi (Visual Editor): Year: Created in the 1970s by Bill Joy. Description: Modal text editor with modes like normal, insert, and visual. Vim (Vi Improved): Year: Created in the 1990s by Bram Moolenaar. Description: Further enhancement of Vi, includes additional features and improvements. - Highly extensible, widely used, with modern features for efficient text editing.

Define the following Vi commands and basic operations (insertion, deletion, searching, replacing, saving, quitting)

Insertion: Press i to enter insert mode. Type the text. Press Esc to return to normal mode. Deletion: In normal mode, use x to delete the character under the cursor. Use dd to delete the entire line. Searching: Press / to start a forward search. Type the search pattern and press Enter. Press n to find the next occurrence. Replacing: In normal mode, use :s/old/new/g to replace 'old' with 'new' globally on a line. Use :%s/old/new/g to replace globally in the entire document. Saving: In normal mode, use :w to save changes. Quitting: In normal mode, use :q or :qa to quit if no changes were made. Use :q! to force quit without saving. Use :wq to save and quit.

How do you install and remove software packages?

Install a package: # On Ubuntu use apt or apt-get sudo apt update sudo apt install package_name Remove a package: sudo apt remove package_name Packaging system families: .deb for Debian distros .rpm for Red Hat distros Pacman (.pkg.tar.xz) for Arch distros

Explain the difference between a low level install and high level install in regards to package management

Low-level installs: - Involves direct interaction with package files and lower-level package tools. - Typically requires manual downloading, extracting, and installing of software. - Examples of low-level tools include dpkg in Debian-based systems, which directly handles package installation but doesn't automatically resolve dependencies. # Download the .deb package manually wget http://example.com/package.deb # Install the package using dpkg sudo dpkg -i package.deb High-level install: - Relies on package managers that automate the process of downloading, installing, and managing software and its dependencies. - Higher-level package managers, like apt in Debian-based systems or yum in Red Hat-based systems, provide a more user-friendly interface. - Resolves dependencies automatically, simplifying the installation process for users. # Update package information sudo apt update # Install the package using apt sudo apt install package_name

Linux Networking Basics

Networking in Linux involves communication between devices using protocols like TCP/IP. Key aspects include... IP Addressing: - Devices are assigned IP addresses for identification on the network. Routing: - Determines the paths data takes between devices. DNS: - Translates human-readable domain names to IP addresses. Firewall: - Manages incoming and outgoing network traffic based on predefined security rules. A Few Commands... - ping for checking connectivity - traceroute for tracing the route to a host - ssh for secure remote access

How do you go about customizing the prompt? (basic stuff only)

PS1 Variable: - PS1 is the primary variable controlling the prompt. - It defines the appearance and content of the shell prompt. PS1 Components: - PS1 can be customized using escape codes for dynamic information. Example: PS1="\u@\h:\w$ " sets the prompt to "user@hostname:current_directory$ " Escape Codes: \u: Username \h: Hostname \w: Current working directory $: Indicates the end of the prompt. Example PS1 Customization: PS1="\u@\h:\w$ " sets a basic prompt with user, hostname, and current directory. View Current Prompt: To view the current PS1 value: echo $PS1. Editing PS1 in Shell: Temporarily customize the prompt using PS1="new_prompt_here". Changes are effective until the session ends. Permanent Customization: Edit ~/.bashrc or ~/.bash_profile to set PS1 permanently. Example: export PS1="\u@\h:\w$ ". Use source ~/.bashrc to apply changes without restarting.

Explain the concept of Package managers in linux and why we need them

Package managers are tools that simplify software installation, removal, and management on Linux systems. For example we can install Emacs with the following commands in Ubuntu... sudo apt update sudo apt install emacs - Debian-based (e.g., Ubuntu): APT (Advanced Package Tool) - Red Hat-based (e.g., Fedora): DNF (Dandified Yum), YUM (Yellowdog Updater Modified) Efficient Software Management: - Package managers streamline the process of installing, updating, and removing software. Dependency Resolution: - They manage dependencies, ensuring required libraries or components are installed. Centralized Repositories: - Package managers access repositories with precompiled, verified software. Version Control: - They handle multiple software versions, allowing users to choose. Easy Updates: - Simplify updating installed software with a single command. sudo apt update && sudo apt upgrade Faster Installation: - Precompiled packages save time compared to compiling from source. - Package managers ensure a consistent environment across systems. Dependency Tracking: - Prevents conflicts by managing software dependencies. Rollback Features: - Some package managers support rollback to previous software versions. - Assuming you have apt version history enabled, you can use the following command to list available versions and rollback to a more stable one if need be... sudo apt list -a <package-name> sudo apt install <package-name>=<version-number> - Package managers enhance system stability, security, and user experience by providing a standardized and organized approach to software management.

What are Partitions? Why would we use multiple partitions?

Partitions in Linux are distinct sections on a storage device, each treated as an independent unit. Using multiple partitions offers several benefits, including: Isolation: - Different partitions can isolate system files, user data, and other content, enhancing organization and security. System Stability: - Partitioning allows for separate areas for the operating system and user data, reducing the risk of system-related issues affecting user data. Backup and Restore: - Individual partitions can be backed up and restored independently, simplifying backup processes. Multi-Boot Systems: - Multiple partitions support the installation of multiple operating systems on a single device, facilitating dual or multi-boot configurations. Performance: - Strategic partitioning can optimize performance by placing frequently accessed data on specific partitions.

Explain the concepts and differences between Sourcing vs. Shell

Sourcing (source or .): - Executes commands in the current shell session. Example: source script.sh - Modifies the current environment, such as setting variables. - When running a script, it runs in a Subshell. Changes to environment variables don't persist in the parent shell unless you source the script. Subshell (New Shell): - Executes commands in a new shell environment. Example: bash script.sh - Changes are confined to the subshell; no impact on the parent shell. Note: Sourcing is often used for configuration files to apply changes directly to the current shell session.

What is the Linux Environment? Define the following Environment variables (env, printenv, set export, alias).

The Linux environment is the system's configuration and state, comprising variables, settings, and configurations that influence how processes and commands behave. env - Command to display or modify environment variables env PATH=/bin:/usr/bin ls # Proves that ls exists in /bin and /usr/bin printenv - Command to print environment variables. printenv PATH # Shows the different locations that will be searched for environment variables set - Command to display shell variables and functions. set | grep USER # Displays environment variables containing "USER" export - Command to set an environment variable. export MY_VAR="value" printenv MY_VAR # Creates an environment variable named MY_VAR (Available to child processes) alias - Command to create a shortcut for a command or a sequence of commands. alias ll='ls -l' # The alias 'll' itself isnt stored in the path, however the command 'ls -l' is. This is why we are able to call aliases by there name

What is fstab and What is the fstab file location format?

The `fstab` file is a system configuration file in Linux that contains information about disk drives and partitions, specifying how they should be mounted into the file system. The fstab file is located at /etc/fstab.

Describe the types of text editors in linux and give an example of each.

There are text based editors, modal based text editors and graphical editors Text based editors like nano are lightweight and come standard with most linux installs VIM is a modal based text editor with different features like Normal mode, Command mode, Insert mode, Visual mode, etc. Graphical based editors like gedit have interactive interfaces with features like menu's and toolbars

Explain the following Storage related commands (mount/umount, fsck, fdisk, mkfs, dd, md5sum)

mount/umount: Mounts/Unmounts filesystems to/from directories. fsck: Checks and repairs filesystem consistency. fdisk: Partitions disks. mkfs: Creates a filesystem on a device. dd: Copies and converts files/block-level copying. md5sum: Calculates and verifies MD5 checksums for files. How to use fdisk: 1. List avaliable disks. Find which disk you want to partition fdisk -l 2. Run fdsik sudo fdisk /dev/sdX 3. Commands in fdisk program - Press n to create a new partition. - Choose the partition type (usually p for primary). - Specify the partition number (you probably want to use the next available) - Specify the filesystem type (ext4) - Press w to write changes How to create a new ext4 Filesystem for new partition: sudo mkfs.ext4 /dev/sdX1 # /dev/sdX1 being the partition we want to create the filesystem in Note: BE CAREFUL when partitioning drives and creating filesystems on partitions. You will LOSE all your data on that drive and/or partition!

Explain the following Net based commands (ping, tracepath, ip, netstat, ftp, wget)

ping: Tests network connectivity by sending ICMP echo requests. - ping destination # See if you can connect to a destination IP tracepath: Traces the route to a destination, similar to traceroute. - tracepath destination # View the hops along the path to troubleshoot connection errors ip: Manages network interfaces, addresses, routes, and more. - ip addr # Displays ip addressing info netstat: Displays network statistics and connections. - netstat -l # Displays listening sockets ftp: Command-line FTP client for file transfer. - ftp ftp.example.com # Connect to an FTP Server wget: Downloads files from the internet via HTTP, HTTPS, or FTP. wget https://example.com/file.zip # Download a zip file from a webserver

Explain the following Secure network commands (ssh, sftp, ssh-keygen, ssh-copy-id)

ssh: Secure Shell for remote command-line access. sftp: Secure File Transfer Protocol for secure file operations. ssh-keygen: Generates SSH key pairs for authentication. ssh-copy-id: Copies SSH keys to a remote server for passwordless login.

Give the basics of writing a simple shell script. How do you make a script executable?

vi myscript.sh #!/bin/bash echo "Hello, world!" Save and Exit. To make the script executable... Change Permissions: - Use the chmod command to add execute permissions to the script. chmod +x myscript.sh Run the Script: - Execute the script using ./ followed by the script name. ./myscript.sh Ensure the script starts with a shebang (#!/bin/bash) to specify the shell to use. This makes the script self-executable. Note: When you run a script, it runs in a subshell, and changes to environment variables don't persist in the parent shell unless you source the script.


संबंधित स्टडी सेट्स

MGMT 201 Chapter 1: The Management Process Today

View Set

Chapter 4: Introduction to Psychology

View Set

Outsiders Chapter 7-9 quiz review

View Set

PEDS: Chapter 48 Nursing Care of a Family when a child has an Endocrine or a Metabolic Disorder Prep-U

View Set

Biology 1013 Launchpad Ch.5 Quiz

View Set

ATI Mental Health Nursing Review

View Set

Level H Unit 15 Vocabulary Completing the Sentence

View Set

Chapter 7 Oceanography- Ocean Circulation

View Set

Psychosocial Pathology - Case Studies

View Set

Macroeconomics Professor Knight Exam 2: Pearson Quiz Questions

View Set