Missing Semester - Lecture 5

Job Control Signals can do other things beyond killing a process. For instance, SIGSTOP pauses a process. In the terminal, typing Ctrl-Z will prompt the shell to send a SIGTSTP signal, short for Terminal Stop. We can then continue the paused job in the foreground or in the background using fg or bg. One more thing to know is that the & suffix in a command will run the command in the background, giving you the prompt back. ...

October 17, 2024 · 4 min · KKKZOZ

Missing Semester - Lecture 4

# journalctl run remotely, grep run locally ssh myserver journalctl | grep sshd # both commands run remotely ssh myserver "journalctl | grep sshd" sed sed (Stream Editor) is a powerful command-line tool in Unix/Linux that is used for parsing and transforming text, typically used for finding, replacing, or deleting content in a file or input stream. Common sed Commands: Substitution (s): sed 's/pattern/replacement/' file s: The substitution command. pattern: The string or pattern to search for. replacement: The string to replace the pattern with. Example: ...

October 15, 2024 · 7 min · KKKZOZ

Missing Semester - Lecture 2

Shell Tools and Scripting Shell Scripting To assign variables in bash, use the syntax foo=bar and access the value of the variable with $foo. Note that foo = bar will not work since it is interpreted as calling the foo program with arguments = and bar. bash uses a variety of special variables to refer to arguments, error codes, and other relevant variables: $0 - Name of the script $1 to $9 - Arguments to the script. $1 is the first argument and so on. $@ - All the arguments $# - Number of arguments $? - Return code of the previous command $$ - Process identification number (PID) for the current script !! - Entire last command, including arguments. A common pattern is to execute a command only for it to fail due to missing permissions; you can quickly re-execute the command with sudo by doing sudo !! $_ - Last argument from the last command. If you are in an interactive shell, you can also quickly get this value by typing Esc followed by . or Alt+. Exit codes can be used to conditionally execute commands using && (and operator) and || (or operator). ...

October 11, 2024 · 5 min · KKKZOZ

Missing Semester - Lecture 1

The shell How does the shell know how to find the date or echo programs? The shell is a programming environment, just like Python, and so it has variables, conditionals, loops, and functions. If the shell is asked to execute a command that doesn’t match one of its programming keywords, it consults an environment variable called $PATH that lists which directories the shell should search for programs when it is given a command ...

October 9, 2024 · 2 min · KKKZOZ