W1: Linux Introduction Flashcards

1
Q
  1. Research: Computing Machines
A

a machine that can recieve an input, and automatically process it into an ouptput. Like the turing machine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Research: Turing Machine
A

‘the blueprint of modern computing’. Initially just a theoretical idea of a device that, when given a tape of whatever needed length of 1s and 0s, reads the tape and changes the 1s and 0s in accordance with its instructions. the tape of 1s and 0s starts as a question, and when the turing machine is finished with it, becomes the answer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Research: Von-Neumann Architechture
A

computer model designed by John Von-Neumann in 1945.

Input -> Memory -> Output
V> Processor (Control Unit <->Arithmetic Logic Unit)

Input is stored as command in Memory,
Processor fetches the commend from Memory,
Control Unit manages commands and input/output,
ALU handles the actual calculations,
CU stores complete commands in memory,
then output is displayed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Research: Operating System
A

program that allows a user to interact with the computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. Research: History of Linux
A

developed by Linus Torvalds.

started in 1991 as a pet project,

became community open source project

Linux 1.0.0 launched in 1994

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. Research: What is Linux?
A

open source Operating System. Actually even Android is based in Linux

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

The component of a computer system that controls the interpretation and execution of instructions. The CPU of a PC consists of a single microprocessor, while the CPU of a more powerful mainframe consists of multiple processing devices, and in some cases, hundreds of them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. CPU cache
A

Store temporary files, using hardware and software components. An example of a hardware cache is a CPU cache. This is a small chunk of memory on the computer’s processor used to store basic computer instructions that were recently used or are frequently used.; that’s why it is faster.

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

Form of computer memory that can be read and changed in any order, typically used to store working data and machine code.

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

EPROM

A

Read-only memory is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device.

EPROM can be erased when exposed to certian ultraviolets.

Eraseable Programmable, read only memory.

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

a set of computer instructions in firmware which control input and output operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Bus (address, data, control)
A

Bus: Circuits on the motherboard that connects the CPU to other components.

Address: single-directional, transports address signals from CPU to main memory
Data: Bi-directional, transports data between components.
Control: bi-directional, sends control signals (clock timings, interrupt requests) between components.

(CPU sends addresses to memory and I/O controller, but memory and I/O controller only respond with data and control signals)

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

Data storage device using to read and write data onto a rotating disk coated with magnetic material.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. I/O device
A

secondary storage, keyboard, mouse, monitors, printers, any external device that could send input or recieve output.

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

The way in which files are named and placed logically for storage and retrieval.

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

A (passive) set of code and instructions meant to complete a task.

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

a running (active) instance of a program.

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

Universal Serial Bus

technology used to connect computers with peripheral devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
  1. Serial Port
A

a connector by which a device that sends data one bit at a time may be connected to a computer. (monitor port)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
  1. Parallel port
A

a connector for a device that sends or receives several bits of data simultaneously by using more than one wire.

looks like the wider RS-232

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
  1. RS-232
A

Form of Serial Data transmission, or ‘Serial Connection’. (USB is also serial)

the type of connection.

delivers data as voltage signals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
  1. (U)EFI
A

UEFI is a set of specifications written by the UEFI Forum. They define the architecture of the platform firmware used for booting and its interface for interaction with the operating system. uses C, BIOS didn’t have C.

actively replacing BIOS

can be improved with the C support. has the option to increase home much disk space it uses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
  1. Boot Loader
A

a program that loads an operating system when a computer is turned on.

computer program responsible for booting a computer. When computer turns off, its software‍—operating systems, application code, and data‍—‌remains stored on non-volatile memory.

UEFI and BIOS are boot loaders, sorta.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q
  1. GRUB/LILO
A

GRUB: new boot loader with multi-OS device management. supports Windows, Linux, UNIX, macOS, BSD, and Solaris.

LILO: older boot loader with single OS device management. Only supports Linux.

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

Advanced Technology Attatchment Packet Interface

ATA Packet Interface is a protocol that has been added to Parallel ATA and Serial ATA so that a greater variety of devices can be connected to a computer than with the ATA command set alone. It carries SCSI commands and responses through the ATA interface.

connection protocol, for wider variety of device connection, including SATA

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

Serial Advanced Technology Attachment

refers to a type of connector cable that is used to attach components, like hard drives, to a motherboard. A solid-state drive (SSD) is a type of storage drive that allows for very fast read and write speeds. Comparing the drive type with a type of connector cable does not really make sense.
connection protocol for storage devices and others

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q
  1. Master boot record
A

The Master Boot Record (MBR) is the information in the first sector of a hard disk or a removable drive.

Identifies how and where the system’s operating system (OS) is located in order to be booted (loaded) into the computer’s main storage or random access memory (RAM).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
  1. Binary / octal / hex
A

…really?

the 1s and 0s, or rather numerical representation of data written in base 2, to be interpretted as true/falses as machine language.

octal is the base 8 representation of binary, or otherwise just base 8 numerology.

hex is the same but at base 16.

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

Mean time between failures (MTBF)

The average time between system breakdowns. Crucial maintenance metric to measure performance, safety, and equipment design, especially for critical or complex assets like generators or airplanes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q
  1. Swap file
A

What is a swap file (swap space or page file)? A swap file is a system file that creates temporary storage space on a solid-state drive or hard disk when the system runs low on memory. The file swaps a section of RAM storage from an idle program and frees up memory for other programs.

A swap file allows Linux to simulate the disk space as RAM. When your system starts running out of RAM, it uses the swap space to and swaps some content of the RAM on to the disk space. This frees up the RAM to serve more important processes. When the RAM is free again, it swaps back the data from the disk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q
  1. Virtual memory
A

Common technique used in a computer’s operating system. Uses both hardware and software to enable a computer to compensate for physical memory shortages, temporarily transferring data from random access memory (RAM) to disk storage.

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

file data structure that stores information about any Linux file except its name and data.

keep track of all the files on a Linux system. Except for the file name and the actual content of the file, inodes save everything else.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q
  1. ASCII table
A

ASCII, in full American Standard Code for Information Interchange, a standard data-encoding format for electronic communication between computers. ASCII assigns standard numeric values to letters, numerals, punctuation marks, and other characters used in computers.
limited to 128

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

Worldwide character encoding standard.

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

wchar_t: 16-bit wide character used to store Unicode encoded as UTF-16LE. native character type on windows operating systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q
  1. UTF-7/8
A

both types of Unicode Transformation Format, the standard used to encode 16-bit Unicode characters such as international letters and special symbols in a format that can be transmitted through 7-bit or 8-bit systems.

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

What is POSIX in computer?
POSIX (Portable Operating System Interface) is a set of standard operating system interfaces based on the Unix operating system.

family of standards specified by IEEE for maintaining compatibility among operating systems. Therefore, any software that conforms to POSIX standards should be compatible with other operating systems that adhere to the POSIX standards.

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

GNU’s Not Unix

GNU is a Unix-like operating system. That means it is a collection of many programs: applications, libraries, developer tools, even games. The development of GNU, started in January 1984, is known as the GNU Project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q
  1. IP / TCP / UDP
A

TCP/IP is a stream-oriented protocol, while UDP is a packet-oriented protocol. This means that TCP/IP is considered to be a long stream of data that is transmitted from one end of the connection to the other end, and another long stream of data flowing in the opposite direction.

TCP: fast, but potential packet losses.
IP is safer, slower, but certian to reach the destination.

UDP can be used for every type of application that TCP can, as long as you also implement a proper retransmission mechanism. s

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

The kernel, or system core, ensures the smooth running of the operating system within a computer and is the interface between the software and the hardware. It is used in all devices with an operating system, for example, computers, laptops, smartphones, smartwatches, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q
  1. System call
A

A system call is a routine that allows a user application to request actions that require special privileges. Adding system calls is one of several ways to extend the functions provided by the kernel.

create, delete, open, close, read, write,

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

The waterfall model is a breakdown of project activities into linear sequential phases, meaning they are passed down onto each other

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

Scrum is a framework for project management that emphasizes teamwork, accountability and iterative progress toward a well-defined goal. The framework begins with a simple premise: Start with what can be seen or known. After that, track the progress and tweak, as necessary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q
  1. Agile development
A

Agile is an iterative approach to project management and software development that helps teams deliver value to their customers faster and with fewer headaches. Instead of betting everything on a “big bang” launch, an agile team delivers work in small, but consumable, increments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q
  1. File system: NTFS
A

New Technology File System:

Process that the Windows NT operating system uses for storing, organizing, and finding files on a hard disk efficiently. NTFS was first introduced in 1993, as apart of the Windows NT 3.1 release.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q
  1. File system: NFS
A

The Network File System (NFS) is a mechanism for storing files on a network. It is a distributed file system that allows users to access files and directories located on remote computers and treat those files and directories as if they were local.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q
  1. File System: FAT-16/32
A

The FAT32 file system cannot store individual files larger than 4 GB, while the NTFS file system can. Compared to FAT32, the NTFS file system has higher disk utilization and can manage disk space more effectively. The read and write speeds of NTFS are also faster than that of FAT32.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q
  1. File System: JFS
A

Journaled File System (JFS) is a 64-bit journaling file system created by IBM.

The “journaled” aspect of JFS means that the file system keeps tracks of changes to files and folders in a log file (or journal). This log can be used to backtrack certain changes in case of an unexpected power failure or system crash, which may prevent data corruption

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q
  1. File System: ext4
A

Fourth extended file system, is a journaling file system for Linux. ext4’s most common use case is formatting volumes, hard drives, and other computing storage solutions. ext4 is the default file system for DigitalOcean Volumes Block Storage due to its stability and backwards compatibility.

Ext4 has better journaling capabilities and a higher maximum supported size of 1 exbibyte, while ExFAT is compatible with both Windows and MacOSX operating systems up to 16 exbibytes in size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q
  1. Disk Partition: Primary
A

Primary partition is a bootable partition and it contains the operating system/s of the computer, while logical partition is a partition that is not bootable. Multiple logical partitions allow storing data in an organized manner

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q
  1. Disk Partition: Extended
A

A partition that can be divided into additional logical drives.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q
  1. Disk Partition: Logical
A

A logical partition can be formatted and assigned a drive letter. A logical partition must be created inside an extended partition.

If an extended partition does not already exist on the disk or the specified size of the logical drive exceeds the extended partition, no partition is created

gets past the 4 bootable drives limit. can help divide the disk into different file systems for logical organization.

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

1 apt-get update

A

checks for Ubuntu updates and installs them

54
Q
  1. install SSH, Valgrind, htop, Ubuntu-restricted-extras, and Parcellite
A

sudo apt install openssh-client
sudo apt-get install openssh-client

apt search valgrind
sudo apt install valgrind

sudo apt install htop

sudo apt install ubuntu-restricted-extras

sudo apt-get install parcellite

55
Q
  1. What are the sections of the manual? List and describe them.
A

1 General commands: commands used in the terminal
2 System calls: functions provided by the kernel
3 Library Functions: Functions in program libraries
4 Special files: usually devices in /dev and related drivers
5 file formats and conventions: file formats like etc/passwd
6 games: descriptions of commands that display database quotes
7: Miscellaneous: macro packages and conventions, boot parameters, and other things
8: System administation commands: commands mostly reserved for root
9: Kernel Routines: information about internal kernel operations

NAME - command name
SYNOPSIS - command structure
DESCRIPTION - comman’s description
OPTIONS - available command options
AUTHOR - command’s author
REPORTING BUGS - instructions on how to report bugs to developer
COPYRIGHT - command’s license info
SEE ALSO - points to related commands and full documentation
CONFIGURATION - configuration details for command/device
EXIT STATUS - possible exit status values

56
Q
  1. Which sections of the manual contain a command write?
A

man -f write //searches for the page/section where the command is

outputs: write (1), and write(2)

57
Q
  1. Create a C program that prints hello world and the main() function’s argv and envp arguments. Place it under your home directory.
A
58
Q
  1. deleted?
A

mv a.out

…something

59
Q
  1. when there is more than one date in the file system, how do you know which will run
A

mv something.out date

whichever is located in the local file from which the terminal is running.
whichever appears first on the PATH

60
Q
  1. when would you use which and type
A

which: finds excecutable in your PATH
type determines of command is alias, function, build-in-command, cached excecuteable, etc.

type is a shell built-in, wouldn’t be found by which
preferable to use type, al

61
Q
  1. Name three bash config files. when does each of them run?
A

/etc/profile : system wide initialisation, executed during login

/etc/bashrc : another system wide init file. executed every time bash shell is opened by a user.

~/.bash_profile : if exists, executed after /etc/profile during login

~/.bash_login : executed instead of ~/.bash_profile otherwise.

~/.profile : executed if either bash_profile nor bash_login exist during login.

~./bashrc : contains specific configs. read at login and each time a new Bash sehll is started. put aliases here.

~/.bash_logout : executed during logout
~/.inputrc : used to customize key bindings/key strokes

62
Q
  1. Edit the environment variable PATH to run executables which are located in the current directory.

It would be a good idea to add the current directory to the end of the PATH. why?

in which file would you put this change?

A

echo $PATH
pwd //checks current directory //let’s say /home/daniel
export PATH=/home/daniel:$PATH

adding directories to the PATH makes it easier to call files within them from any other directory, without having to list out the directory path individually.

making a permanent cheange: affects the ~/.bashrc file
nano ~/.bashrc
export PATH=$PATH:the/file/path

63
Q
  1. What happens to SHLVL when you run a shell within a shell? What happens when you exit the shell? Hint: look at ps – forest and ps -l.
A

the shell level gets ‘higher’, or rather deeper as we cause subshells within subshells

64
Q
  1. write an alias to remove files ending with ~ from the current directory
A

alias rt~=’rm -r *~’

you can delete a file… but not the items within it

./*~

65
Q
  1. In which file would you place an alias so that you have it when you start a new bash?
A

in ~/.bashrc

66
Q
  1. Create a shell function that checks if a file exists. if it does, then copy it to /tmp
A

!/bin/sh

FILE=1

echo “please enter file name.”
read FILE
if test -f “$FILE”; then
cp “$FILE” tmp/”$FILE”
fi

67
Q
  1. Add if/else, do/while and for constructs to the shell script for more functionality, including the ability to copy multiple files at once
A

!/bin/sh

FILE=”lol”
while [[ “$FILE” != “finish” ]]
do
echo “please enter file name. Enter ‘finish’ if you wish to abort”
read FILE
if test -f “$FILE”; then
cp “$FILE” /tmp/”$FILE”;
fi
done

68
Q
  1. What happens to the files and directories in /tmp when you reboot?
A

oops they get deleted,

otherwise deleted after 10 days.(?)

69
Q
  1. What is ulimit used for? Why would you use it for a core file?
A

ulimit is a program that lets you define file size limits for the shell and its sub-processes.

affects how many resources are spent on maintaining core files/errors. (imagine crashing 100 times)

core files help understand why programs terminate unexpectidly, which means they assist in big fixing. increasing core file ulimit helps get a bigger picture of a problem.

can set ulimit to 0 and then just not know why everything is on fire.

70
Q

18 what happens when you cat a text file into /dev/tty? When you cat /dev/tty? (You may find ^C and ^D useful)

A

dev tty just replicates inputs;

tty= terminal type. it’s responsible for terminal typing all-the-same.

71
Q
  1. what does set do?
A

displays and sets the names and values of shell and linux environment variables

72
Q
  1. From your terminal, login to another computer and run gedit on a file in /tmp. ensure that the window that opens is on your computer, and not the remote computer
A

sudo apt-get install openssh-server ii.
^install openssh_server

ssh localhost

sh your_username@host_ip_address / sh daniel@host_ip_address
^ connect to

-X

73
Q
  1. Who is currently logged into your system?
A

who
who -b

74
Q
  1. when was the last time the machine was rebooted?
A

last reboot

75
Q
  1. what is the IP address of your computer?
A

can run ip addr
ip a
fconfig

76
Q
  1. How can you see the usage of the computer’s resources?
A

top
top -i //hides idle resources

77
Q
  1. compare the output of top and htop. What is the correlation, if any, between them?
A

htop is more interactive, colorful, slightly better ui.

78
Q
  1. How do you set the clock on your computer? why would you not do this?
A

sudo timedatectl set-time hh:mm:ss

several programs and websites will refuse to function if your machine clock is innacurate.

79
Q
  1. Write a shell script that records the current time to a file in /tmp
A

!/bin/sh

touch “/tmp/date.txt”;
echo $(date)&raquo_space; “/tmp/date.txt”;

80
Q
  1. How long does it take to list all the files in the file system?
A

time -ls -m

81
Q
  1. What options are there for editing and re-running previous commands in the shell?
A

you use the up and down arrows to cycle through previous commands,

!! // repeats the last command,

fc - s

CTRL+P

82
Q
  1. What is the difference between crontab, at and batch
A

at: deliberately notices PATH and environment variables and sets them in place when the command runs.

cron: has its own seperate environment. cron sets the PATH to PATH=:/bin/usr/bin:/usr/lbin

Batch just calls “at” with the following flags:
at -q b -m now

Batch: non-urgent missions,

83
Q
  1. Use at to remind yourself in 5 minutes that it ight be time to go to the bathroom.
A

sudo apt install update
sudo apt install at

echo “commit to bathroom” | at now +5 minutes

echo doesn’t work, it it feels like it should.

at now +5 minutes
> notify-send “commit to bathroom”
> CTRL+d

84
Q
  1. Come back from the bathroom quicly. We have lots of work to do.
A

just 5 more minutes.

85
Q
  1. Run sleep 100 & several times. use jobs, bg, fg, ^Z, and kill to manipulate the jobs.
A

jobs lists current jobs,
bg sends a job to the background,
fg sends to to the foreground,
^Z ends the current job
kill kills all current hobs

86
Q
  1. What processes are running on your machine?
A

ps aux

87
Q
  1. What is the PID
A

echo $$

88
Q
  1. what happens when you run kill -9 with the PID of your shell as a parameter?
A

the shell commits un-alive

89
Q
  1. nice is nice. Read about it.
A

lets you run a command at a priority lower than the command’s normal priority. default drop is 10, unless parameter is provided.

90
Q
  1. Run xeyes on a remote computer. Ensure that it continues to run after you log out.
A

yes

91
Q
  1. How would you stop the xeyes that some idiot is running on your computer?
A

ps aux,
locate the xeyes PID,
kill -9 PID

92
Q
  1. Which directory are you in? go to $HOME
A

pwd,

cd $HOME

93
Q
  1. Display hidden files in your home directory
A

ls -a

94
Q
  1. cp the entire contents of your home directory to /tmp (including hidden files)
A

cp * -a $HOME /tmp

95
Q
  1. Move what you just copied to /tmp/stupidity
A

mv * /tmp /tmp/stupidity

96
Q
  1. What is the difference between ln and ln-s
A

ln creates a hard link, ln -s creates a soft link

soft link is “more powerful”.

soft link functions like a shortcut,

hard link is like a constantly updated copy.

97
Q
  1. Instead of using cd all the time, try pushd and popd
A

pushd [OPTIONS] [DIRECTORY]
pushd /home // push the current directory to the top of the directory stack and change to /home

popd will pop the top directory from the stack and move ‘down’ the stack.

98
Q
  1. Do the commands cp, mv, and rm each have the flags -i, -r and -f?
    -what are these flags good for?
    b. why does mv not have the -r flag?
A

cp has -i, -r and -f,
mv has -i and -f,
rm has -i, -r and -f

-i : interactive, prompts overwrite (prompts ‘are you sure’ before deleting somethigns sensitive)
-r: recursive, copies directories recursively. (includes all subfiles/subdirectories within the file)
-f: force, if the file cannot be opened, remove it and try again

mv doesn’t have the -r flag, it moves all files and contents already. meaning it already has the recursive property.

99
Q
  1. What file systems are mounted? What type are they?
A

‘mount’.

findmnt

(ext4, sysfr, etc.)

“any external device is called a block device”

100
Q
  1. How much disk space are you using? How much is still free?
A

df

though I’m preferring df -h.

used 11G, 7.2G available (/dev/nvme0n1p8)

101
Q
  1. Create a text file with your deepest and darkest secrets.
A

touch weeb.txt
gedit weeb.txt
secret

102
Q
  1. Update the permissions so only you can read and modifiy it.
A

chmod +rwx weeb.txt //adds read/write/excecute permissions
chmod -rwx

chmod ugo-rwx weeb.txt //remove rwx permissions from users, groups and others.
chmod 700 weeb.txt //adds rwx permissions to only the owner of the file

103
Q
  1. Create a “friend” account for playing with permissions
A

useradd [OPTIONS] USERNAME
sudo useradd bob
sudo passwd bob [12345]

104
Q
  1. Create a group for your friend and add the user “friend” to this group
A

groupadd bobsgroup
sudo usermod -a -G bobsgroup bob

105
Q
  1. Set the permissions so that only you and your friends can read your secrets.
A

sudo chgrp g-rwx weeb.txt
chmod g+r weeb.txt

106
Q
  1. Update the permissions so that only you can modify the file.
A

chmod g-wx weeb.txt

107
Q
  1. It would be a good idea to erase the file.
A

agreed.

108
Q
  1. Create a directory that others can browse but not modify.
A

mkdir -m go-wx directory

109
Q
  1. What does execute permission on a directory signify?
A

execute permission defines whether a user can ‘enter’ the directory (make it their current directory)

110
Q
  1. Find the Linux dictionary file.
A

gedit usr/share/dict/words

sudo find -name dict

111
Q
  1. Count the number of words that start with a and end with z (use grep | wc) and print the number to a file in /tmp
A

grep ^a.*z$ /usr/share/dict/words | wc -w

^a has to start with a

z$ has to end with z

  • could be anything in between
112
Q
  1. Display the words containing qui respelled with kwi. You should learn to spell.
A

grep -E ‘qui’ /usr/share/dict/words

grep -E ‘qui’ /usr/share/dict/words > /tmp/kwi.txt
sed -i ‘s/qui/kwi/g’ /tmp/kwi.txt
cat /tmp/kwi.txt

113
Q
  1. Record all your commands for the next few minutes to a file in /tmp
A

script /tmp/testScript.txt
exit | at now +5 minutes

114
Q
  1. what are the last 20 words in the dictionary?
A

tail -20 /usr/share/dict/words
tail -n20 /usr/share/dict/words

115
Q
  1. There are “magic” numbers at the beginning of many executeables. What are their values? (Usually the first size_t bytes for something written in C).
A

“Magic Numbers” are the first few bytes of each file, unique to the file type.

xxd boop.sh | head

the first few bytes of each file. roughly the first 16 bytes.

xxd date.sh | head: magic number is 23 21 2f 62 69 6e 2f 73

116
Q
  1. What are possible orderings of the following elements: fileName, cmd, <, >, 2 in a single statement?
A

cmd <fileName> 2
cmd fileName <2>
cmd filename filename</fileName>

117
Q
  1. Make tea and read about tee.
A

named after and functions like a T-pipe.
wc -l text1.txt|tee -a text2.txt

outputs the bit count of text1.txt to console, but also appends it to text2.txt (-a flag appends. removing the -a flag will overwrite the contents of text2.txt)

118
Q
  1. Create a file named .myuncs that will contain all the commands and usefal aliases. Save this file on the disk-on-key (/media/student_name/MIZI (you need to first change the disk-on-key label to MIZI).
A

mount //find ‘on /media/disk (/dev/sda1)
sudo apt install mtools

umount /media/daniel/’UBUNTU 22_0’
sudo mlabel -i /dev/sda1 :: MIZI

sudo touch /media/daniel/MIZI/.myunsc
compgen -c -a|tee /media/daniel/MIZI/.myunsc

119
Q
  1. Find 2 ways to bypass a locked computer (if you don’t know the password).
A

enter ubuntu recovery mode and open root shell prompt,
mount -rw -o remount/ (remount root with write access)
ls /home (list available users)
psswrd username (resets user’s password)

reboot the computer, press E to prompt grub edit screen,
find the line starting with linux, append init=/bin/bash to the end of that line
CTRL+x to save changes. this will boot into linux kernel with read and write permissions/ passwordless root shell.

ls /home, passwrd username. set a new password and shut down.

120
Q
  1. Create a .tar file of your home directory. Compress it. Restore it in /tmp/derpy.
    -We don’t use full paths with .tar! (Only relative.) Why?
A

sudo tar cf home.tar home
mkdir /tmp/derpy
sudo tar -xf home.tar.gz -C /tmp/derpy

sudo tar -cf home.tar /home
sudo tar -xf home.tar -C /tmp/derpy

-c : create
-x : extract
-z : compress?

121
Q
  1. cat the .tar file into /dev/null.
A

cat home.tar.gz > /dev/null

and into the void it goes

122
Q
  1. Create a new file in your home directory, and create a new .tar file.
A

sudo touch newFile
sudo tar -f new.tar newFile

123
Q
  1. Compare the old and new .tar file contents. At which line do they differ?
A

The head lines, effectively
cmp file1 file2

124
Q
  1. time to sleep.
A

sleep NUMBER[suffix]
sleep 2m // 2 minutes
sleep 10s // 10 seconds
sleep 1d // sleep 1 day
sleep 5 // 5 seconds

125
Q
  1. What is sync good for?
A

synchronizes cache data to permanent system memory.

prevents data loss.

syncs all cache data by default, otherwise

sync [OPTIONS] [file]

126
Q
  1. When would you use swapon and swapoff?
A

activate and deactivate partitions ins specific devices.

127
Q
  1. What is the difference between a swap file and a swap partition?
A

swap file handling is more flexible, but slower. (can’t enlarge a swap partition without disk management tools)

Swap partitions are straight up faster, and more common.

128
Q
  1. Learn how to use GDB
A

GNU Project Debugger. helps poke into C programs while they are executing and see what exactly makes programs crash. operates on exe files (binary files produced by compilation process.)

already installed:: type into console:
gdb
(exit with q)
can run:
gdb ./a.out/

https://www.geeksforgeeks.org/gdb-step-by-step-introduction/

129
Q
  1. Create a Core fle anc check it out using GDB
A

gcc -std=c99 -g -o test breakme.c
gdb ./test

break main
run
gcore

gdb ./test core.83282

130
Q
  1. Use Valgrind to check your program for any memory allocation leaks.
A

sudo apt install valgrind
valgrind EXECUTEABLE