generated from jobindjohn/obsidian-publish-mkdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Streams, redirection, pipes, jobs - Some parsed circuit notes from ECS 154A
- Loading branch information
Showing
26 changed files
with
337 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected] ls | grep Downloads | ||
``` | ||
|
||
[^1]: https://www.ucl.ac.uk/isd/what-ssh-and-how-do-i-use-it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
Flags are combinational and the order does not matter. | ||
|
||
`-h`: Help | ||
|
||
`-V`: Version | ||
|
||
`-v`, `-vv`, `-vvv`, `--quiet`: Configurable verbosity level | ||
|
||
`-r`: Recursive |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
62 changes: 62 additions & 0 deletions
62
docs/Public/Software/Operating Systems/stream cheat sheet.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.