diff --git a/docs/Public/Media/FullAdder.png b/docs/Public/Media/FullAdder.png new file mode 100644 index 000000000..36edacd3e Binary files /dev/null and b/docs/Public/Media/FullAdder.png differ diff --git a/docs/Public/Media/FullAdderLessHardware.png b/docs/Public/Media/FullAdderLessHardware.png new file mode 100644 index 000000000..81b3e03fa Binary files /dev/null and b/docs/Public/Media/FullAdderLessHardware.png differ diff --git a/docs/Public/Media/HalfAdder.png b/docs/Public/Media/HalfAdder.png new file mode 100644 index 000000000..0dd804fd3 Binary files /dev/null and b/docs/Public/Media/HalfAdder.png differ diff --git a/docs/Public/Media/Multiplication.PNG b/docs/Public/Media/Multiplication.PNG new file mode 100644 index 000000000..0614b23ad Binary files /dev/null and b/docs/Public/Media/Multiplication.PNG differ diff --git a/docs/Public/Media/Mux.png b/docs/Public/Media/Mux.png new file mode 100644 index 000000000..5703a9b31 Binary files /dev/null and b/docs/Public/Media/Mux.png differ diff --git a/docs/Public/Media/Screen Shot 2023-10-06 at 1.29.12 PM.png b/docs/Public/Media/Screen Shot 2023-10-06 at 1.29.12 PM.png new file mode 100644 index 000000000..6cbeece6f Binary files /dev/null and b/docs/Public/Media/Screen Shot 2023-10-06 at 1.29.12 PM.png differ diff --git a/docs/Public/Software/Computer Architecture/gate.md b/docs/Public/Software/Computer Architecture/gate.md new file mode 100644 index 000000000..8f8b39cf6 --- /dev/null +++ b/docs/Public/Software/Computer Architecture/gate.md @@ -0,0 +1,5 @@ +A *gate* is the building block of a computer, performing basic logical functions. [^1] + +They have multiple inputs, and produce one output. + +[^1]: https://www.techtarget.com/whatis/definition/logic-gate-AND-OR-XOR-NOT-NAND-NOR-and-XNOR#:~:text=A%20logic%20gate%20is%20a,of%20logic%20gates%20in%20them. \ No newline at end of file diff --git a/docs/Public/Software/Computer Architecture/multiplexer.md b/docs/Public/Software/Computer Architecture/multiplexer.md new file mode 100644 index 000000000..c9c1fd8df --- /dev/null +++ b/docs/Public/Software/Computer Architecture/multiplexer.md @@ -0,0 +1,7 @@ +A *multiplexer* selects one of its [[data]] ports to forward to the output based on the selection signal. + +It behaves like a switch statement in programming. + +![[Mux.png]] + +In general, a *multiplexer* has $2^n$ data inputs and requires $n$ select bits to choose which one will be the output. Larger *multiplexers* can be constructed with [[gate]] and [[tree]] of other *multiplexers*. \ No newline at end of file diff --git a/docs/Public/Software/Networks/SSH.md b/docs/Public/Software/Networks/SSH.md index 9a66ebc01..ccc44f279 100644 --- a/docs/Public/Software/Networks/SSH.md +++ b/docs/Public/Software/Networks/SSH.md @@ -2,4 +2,9 @@ *SSH* is often used to "login" and perform operations on remote computers, but can also be used for transferring data. [^1] +You can run a [[command]] on remote machines and [[pipe]] the result: +```bash +ssh noah@pc17.cs.ucdavis.edu ls | grep Downloads +``` + [^1]: https://www.ucl.ac.uk/isd/what-ssh-and-how-do-i-use-it \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/Bash cheat sheet.md b/docs/Public/Software/Operating Systems/Bash cheat sheet.md index bcd385446..f21224769 100644 --- a/docs/Public/Software/Operating Systems/Bash cheat sheet.md +++ b/docs/Public/Software/Operating Systems/Bash cheat sheet.md @@ -34,4 +34,54 @@ cp rm ``` - Remove each specified file permanently - - Does not remove directories by default \ No newline at end of file + - Does not remove directories by default +```bash +alias ='' +``` +- Substitutes the alias name with the command to be run + - Create shortcuts for tedious commands + - Extend the default behavior of commands +```bash +alias rm='rm -i' # confirm to delete file +alias rm='mv -t -/.tash' # move file to a trash directory +alias cp='cp -b' # make backup of destinationFile +alias mv='mv -u' # move only if sourceFile is newer +alias hello="echo 'cow power'" +``` + +```bash +cat +less +``` +- Print contents of file to screen; concatenate + - `less` outputs a page at a time, to scroll through + - Can search through file using the `/` +```bash +head +``` +- Shows the first 10 lines of a file + - Use `-n ` to print certain number of lines from file +```bash +tail +``` +- Shows the last 10 lines of a file +```bash +nano +``` +- Opens simple [[CLI]] text editor +```bash +vim +``` +- Another text editor +```bash +man +man mkdir +man stdio +``` +- System reference manuals +- Contains details of all command behavior and flags +- Documentation of c libraries +```bash +tldr +``` +- Lists the typical uses of a command diff --git a/docs/Public/Software/Operating Systems/Bash.md b/docs/Public/Software/Operating Systems/Bash.md index f4f11b23c..29bbef4f1 100644 --- a/docs/Public/Software/Operating Systems/Bash.md +++ b/docs/Public/Software/Operating Systems/Bash.md @@ -1,4 +1,4 @@ -*See:* [Advanced Bash-Scripting Guide](https://tldp.org/LDP/abs/html/) +*See:* [Advanced Bash-Scripting Guide](https://tldp.org/LDP/abs/html/), [[Bash cheat sheet]] *Bash* is a [[shell]] that is widely used in [[Linux]] and [[MacOS]] as the default shell. [^1] diff --git a/docs/Public/Software/Operating Systems/command.md b/docs/Public/Software/Operating Systems/command.md index f78834413..6f1d1425e 100644 --- a/docs/Public/Software/Operating Systems/command.md +++ b/docs/Public/Software/Operating Systems/command.md @@ -1,3 +1,29 @@ A *command* is a request to perform an operation or run a program. -You can add a [[flag]] which affect how a *command* can work. \ No newline at end of file +You can add a [[flag]] which affect how a *command* can work. + +`;`: +- Execute *commands* in series +```bash +echo -n "hello " ; echo "world" +hello world +``` + +`&&`: +- Conditionally on success +```bash +cat / && echo "world" +cat: /: Is a directory +cd ~/slides/ && du -sh Makefile +4.0K Makefile +``` + +`||`: +- Conditionally on failure +```bash +cat / || echo "Cat failed" +cat /: Is a directory +Cat failed +echo -n "hello" || echo "world" +hello +``` \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/exit.md b/docs/Public/Software/Operating Systems/exit.md new file mode 100644 index 000000000..f74e503ab --- /dev/null +++ b/docs/Public/Software/Operating Systems/exit.md @@ -0,0 +1,14 @@ +An *exit* occurs when the command finishes. + +A `0` indicates success. Any other value indicates error. + +```bash +echo "Hello" > /dev/null +echo $? +0 + +cat missing.txt +cat: missing.txt: No such file or directory +echo $? +1 +``` \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/file system.md b/docs/Public/Software/Operating Systems/file system.md index 9749d6095..a0fb35e0c 100644 --- a/docs/Public/Software/Operating Systems/file system.md +++ b/docs/Public/Software/Operating Systems/file system.md @@ -1 +1 @@ -A *file system* of an [[operating system]] generally has a [[tree]] data structure for [[file]] which branches from the [[root]] to different directories. \ No newline at end of file +A *file system* of an [[operating system]] generally has a [[tree]] data structure for [[file]] which branches from the [[[knowledge-base/docs/Public/Software/Theory/root|root]] to different directories. \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/flag.md b/docs/Public/Software/Operating Systems/flag.md index c625a4ab1..80b09cd04 100644 --- a/docs/Public/Software/Operating Systems/flag.md +++ b/docs/Public/Software/Operating Systems/flag.md @@ -1,3 +1,11 @@ A *flag* can be added to a command to affect how it works. -Flags are combinational and the order does not matter. \ No newline at end of file +Flags are combinational and the order does not matter. + +`-h`: Help + +`-V`: Version + +`-v`, `-vv`, `-vvv`, `--quiet`: Configurable verbosity level + +`-r`: Recursive \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/job.md b/docs/Public/Software/Operating Systems/job.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/Public/Software/Operating Systems/kernel.md b/docs/Public/Software/Operating Systems/kernel.md index d05457e72..9a8a460c1 100644 --- a/docs/Public/Software/Operating Systems/kernel.md +++ b/docs/Public/Software/Operating Systems/kernel.md @@ -2,4 +2,17 @@ The *kernel* is a computer program that is at the core of a computer's [[operati The *kernel* interacts with the [[shell]] and other programs, as well as the computer's [[hardware]], including the [[processor]], [[memory]], and disk drives. [^1] +Kernel parameters can be accessed through a pseudo [[file system]] `/sys` +```bash +cat /sys/class/input/mouse0/device/name +Logitech USB Optical Mouse +cat /sys/class/hwmon/hwmon3/temp1_crit +120000 +cat /sys/class/leds/input2::scrolllock/brightness +0 +``` +- Some system variables can be changed on the fly +```bash +sudo bash -c "echo 1 > /sys/class/leds/input2::scrollock/brightness" +``` [^1]: https://www.linfo.org/kernel.html \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/path.md b/docs/Public/Software/Operating Systems/path.md new file mode 100644 index 000000000..60b7f7722 --- /dev/null +++ b/docs/Public/Software/Operating Systems/path.md @@ -0,0 +1,27 @@ +A *path* is a special variable used to find the executable of a program. The [[shell]] searches `$PATH` when you enter a [[command]]. + +```bash +which ls +/usr/bin/ls +echo $PATH +/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda-10.1/bin:/usr/lib/jvm/default/bin ... +echo $PATH | sed 's/:/\n/g' +/usr/local/sbin +/usr/local/bin +/usr/bin +/opt/cuda-10.1/bin +/usr/lib/jvm/default/bin +``` +- You can run a program without searching for its path +```bash +./hello +Hello World! +``` + +```bash +hello +bash: hello: command not found +sudo mv hello/usr/local/bin +hello +Hello World! +``` \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/pipe.md b/docs/Public/Software/Operating Systems/pipe.md new file mode 100644 index 000000000..8bfdbcf64 --- /dev/null +++ b/docs/Public/Software/Operating Systems/pipe.md @@ -0,0 +1,10 @@ +A *pipe* is used to combine two or more commands. It will take the output of a [[command]] and use that as the input for the next command. [^1] + +Using the *pipe* '|' character: +```bash +ls -l / | tail -n3 +``` + +You can chain *pipes* together. + +[^1]: https://www.redhat.com/sysadmin/pipes-command-line-linux \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/process.md b/docs/Public/Software/Operating Systems/process.md index 7f82777a8..2b11b0a89 100644 --- a/docs/Public/Software/Operating Systems/process.md +++ b/docs/Public/Software/Operating Systems/process.md @@ -2,4 +2,68 @@ A *process* is a program or [[command]] that is actually running on the computer The [[operating system]] can run many different processes at the same time. [^1] +*Process* commands on the [[CLI]]: + +`Ctrl+C`: +- Stops a process +```bash +sleep 60 +^C +``` + +`Ctrl+Z`: +- Pause a process +```bash +sleep 5 +^Z +[1]+ Stopped sleep 5 +echo "Hello" +Hello +``` + +`fg`, `bg`: +- Resume in either foreground or background +```bash +fg +sleep 5 +``` + +```bash +bg +[1]+ sleep 5 & +echo "What now?" +What now? +[1]+ Done sleep 5 +``` + +`&`: +- Start a process in the background +```bash +cat /dev/random > /dev/null & +``` + +`jobs`: +- Lists all jobs (processes) +```bash +jobs +[1]- Stopped cat /dev/random > /dev/null +[2]+ Stopped sleep 10 +``` + +`kill`: +- Terminate jobs (processes) +```bash +kill %1 +[1]+ Terminated cat /dev/random > /dev/null +``` + +- Jobs are tied to the [[terminal]] session + - Exiting terminal kills stopped and backgrounded jobs + +- Protect background job from terminal exit: +```bash +nohup sleep 10 & // "no hang up" for a new job +disown %1 // For a job already running +``` + [^1]: https://www.ibm.com/docs/pt-br/aix/7.1?topic=administration-commands-processes \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/redirection.md b/docs/Public/Software/Operating Systems/redirection.md new file mode 100644 index 000000000..d8b3a6d58 --- /dev/null +++ b/docs/Public/Software/Operating Systems/redirection.md @@ -0,0 +1,21 @@ +*See: * [[stream]] + +A *redirection* is a way to change the standard input / output of the [[CLI]] to point to and from files. [^1] +You can redirect `stdout` to a file like this: +```bash +echo "Hello World!" > hello.txt +cat hello.txt +``` + +Redirect `stdin`: +```bash +cat < hello.txt +``` + +Append `stdout` to a file: +```bash +cat < hello.text >> hello_copy.txt +``` + + +[^1]: https://www.guru99.com/linux-redirection.html \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/root.md b/docs/Public/Software/Operating Systems/root.md new file mode 100644 index 000000000..5af2ed828 --- /dev/null +++ b/docs/Public/Software/Operating Systems/root.md @@ -0,0 +1,9 @@ +*Root* is a user account for administrative purposes, and typically has the highest access rights on the system. [^1] + +You can use `sudo` to perform actions as *root*. +- Short for "super user do" +- Actions run as root can damage your system + +Some things do require *root* privileges, if they change any files in the *root*. + +[^1]: https://www.ssh.com/academy/pam/root-user-account#:~:text=Root%20is%20the%20superuser%20account,account%2C%20regardless%20of%20the%20name. \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/stream cheat sheet.md b/docs/Public/Software/Operating Systems/stream cheat sheet.md new file mode 100644 index 000000000..e34717247 --- /dev/null +++ b/docs/Public/Software/Operating Systems/stream cheat sheet.md @@ -0,0 +1,62 @@ +*See:* [[stream]] +`head`: +- Sends the first `n` lines of its input to its output +```bash +head -n3 +``` + +`tail`: +- Sends the last `n` lines of its input to its output +```bash +tail -n3 +``` + +```bash +ls -l / > temp.txt +tail -n3 < temp.txt +``` + +`grep`: +- Searches the input stream for a string +- Outputs every line that contains the string +```bash +history | grep tail +``` + +`cut`: +- Removes sections from each line of the input +- Useful when filtering columns from input +```bash +cat foo.txt +A,B,C,D +A,B,C,D +B,B,C,D +D,C,B,A +cat foo.txt | cut -d "," -f1,4 +A,D +B,D +D,A +``` + +`sort`: +- Sorts the input and sends it to `stdout` +- Defaults to alphanumeric sort, but it has many sorting options + +`uniq`: +- Outputs the unique lines in the input +- Only detects repeated lines if they are adjacent + - Input needs to be sorted first +```bash +sort foo.txt | uniq // Display each line once +sort foo.txt | uniq -u // Display only unique lines +sort foo.txt | uniq -d // Display only duplicated lines +sort foo.txt | uniq -c // Display frequency of each line +``` + +`tee`: +- Read from standard input and write to standard output and files +```bash +echo 1 | sudo tee /sys/class/leds/input2::scrolllock/brightness +``` + + diff --git a/docs/Public/Software/Operating Systems/stream.md b/docs/Public/Software/Operating Systems/stream.md new file mode 100644 index 000000000..f929fb18f --- /dev/null +++ b/docs/Public/Software/Operating Systems/stream.md @@ -0,0 +1,7 @@ +*See:* [[stream cheat sheet]] + +A *stream* refers to a collection of text. + +There are generally two *streams* in the command line: +- `stdin` for user input (default is keyboard) +- `stdout` for user output (default is display) \ No newline at end of file diff --git a/docs/Public/Software/Operating Systems/text editor.md b/docs/Public/Software/Operating Systems/text editor.md new file mode 100644 index 000000000..54d865262 --- /dev/null +++ b/docs/Public/Software/Operating Systems/text editor.md @@ -0,0 +1,3 @@ +A *text editor* is a program that edits plain text. They are sometimes known as "notepad" software. [^1] + +[^1]: https://en.wikipedia.org/wiki/Text_editor \ No newline at end of file diff --git a/docs/Public/Software/Theory/tree.md b/docs/Public/Software/Theory/tree.md index 1e739f206..8f3cc0239 100644 --- a/docs/Public/Software/Theory/tree.md +++ b/docs/Public/Software/Theory/tree.md @@ -1,4 +1,4 @@ -A *tree* is a type of [[graph]] [[data structure]] that has a hierarchical "tree" structure. A [[root]] [[node]] "branches" off to its connected children nodes, and those nodes act as a parent node to other children nodes. You can traverse through the *tree* from the root to any node in a unique path in one direction. +A *tree* is a type of [[graph]] [[data structure]] that has a hierarchical "tree" structure. A [[knowledge-base/docs/Public/Software/Theory/root]] [[node]] "branches" off to its connected children nodes, and those nodes act as a parent node to other children nodes. You can traverse through the *tree* from the root to any node in a unique path in one direction. *Trees* can be used to store data that has an inherent hierarchical structure i.e. directories, files, and folders in file management systems. [^1]