[read] cat*, grep, head/tail, tee, (shuf, short, uniq, wc)
*: more, less
[write] echo/printf, seq, yes. cut, tr, awk, sed, tac
File types4
Within the file system, each file is marked with a type, indicating what kind of file it is. One of these file types denotes ordinary data files, which are usually called regular or plain files to distinguish them from other file types. These other file types include devices, pipes, sockets, directories, and symbolic links. The term file is commonly used to denote a file of any type, not just a regular file.
Directories and links4
A directory is a special file whose contents take the form of a table of filenames coupled with references to the corresponding files. This filename-plus-reference association is called a link, and files may have multiple links, and thus multiple names, in the same or in different directories. Directories may contain links both to files and to other directories. The links between directories establish the directory hierarchy. Every directory contains at least two entries: . (dot), which is a link to the directory itself, and .. (dot-dot), which is a link to its parent directory, the directory above it in the hierarchy. Every directory, except the root directory, has a parent. For the root directory, the dot-dot entry is a link to the root directory itself (thus, /.. equates to /).
permissions5, encoding, binaries.
Programs4
Programs normally exist in two forms. The first form is source code, human-readable text consisting of a series of statements written in a programming language such as C. To be executed, source code must be converted to the second form: binary machine-language instructions that the computer can understand. (This contrasts with a script, which is a text file containing commands to be directly processed by a program such as a shell or other command interpreter.) The two meanings of the term program are normally considered synonymous, since the step of compiling and linking converts source code into semantically equivalent binary machine code.
[read] dir, {colors}, ls, pwd/basename, find, file. cksum, {md5,sha1,sha256}sum. xdd, strings
[write] mkdir, ch{mod,own,..} (cp, mv, rm, ln, link, touch), (vi, ed), (mkfifo, mktemp). dd
filesystems, "all is a file", users/groups, processes, signals.
Process4
Put most simply, a process is an instance of an executing program. When a program is executed, the kernel loads the code of the program into virtual memory, allocates space for program variables, and sets up kernel bookkeeping data structures to record various information (such as process ID, termination status, user IDs, and group IDs) about the process.
Shell4
A shell is a special-purpose program designed to read commands typed by a user and execute appropriate programs in response to those commands. Such a program is sometimes known as a command interpreter. Whereas on some operating systems the command interpreter is an integral part of the kernel, on UNIX systems, the shell is a user process. The shells are designed not merely for interactive use, but also for the interpretation of shell scripts, which are text files containing shell commands. For this purpose, each of the shells has the facilities typically associated with programming languages: variables, loop and conditional statements, I/O commands, and functions.
Signal4
Process termination and termination status4
A process can terminate in one of two ways: by requesting its own termination using the
_exit()
system call (or the relatedexit()
library function), or by being killed by the delivery of a signal. In either case, the process yields a termination status, a small nonnegative integer value that is available for inspection by the parent process using thewait()
system call. In the case of a call to_exit(),
the process explicitly specifies its own termination status. If a process is killed by a signal, the termination status is set according to the type of signal that caused the death of the process. (Sometimes, we’ll refer to the argument passed to_exit()
as the exit status of the process, as distinct from the termination status, which is either the value passed to_exit()
or an indication of the signal that killed the process.) By convention, a termination status of 0 indicates that the process succeeded, and a nonzero status indicates that some error occurred. Most shells make the termination status of the last executed program available via a shell variable named$?
.Process user and group identifiers (credentials)4
Privileged processes
[read] df, du. date, host{id,name}, uptime, (nproc, uname). groups, users, whoami. printenv ps, lsof, netstat, top, mem, ...
[write] sleep, nice, kill, nohup, timeout. env, wall. su, sudo, who. paralell. tar
ip, ifconfig, route curl, dig, ssh, nmap, telnet, nc, ping, traceroute, tcpdump
bat. tree. screen, tmux, asciinema. htop. watch, viddy. column, jq, csvkit, csvlens
date: 2024-12-02 source: "Bite Size Linux" (Julia Evans)
lsof
(list open files) will show you a process's open files.python
f = open("file.txt")
f.readlines()
mkfifo my_pipe
): this lets two unrelated processes communicate through a pipe.date: 2024-12-15 source: "Bite Size Linux" (Julia Evans)
man 2 read
means "get me the man page for read from section 2".man 1 read
gives you a different man page from man 2 read
.If you dont' specify a section, man will look through all the sections and show the first one it finds.
programs:
man grep
man ls
man sendfile
man ptrace
man printf
man fopen
man null # for /dev/null docs
man sudoers # for /etc/sudoers
man proc # files in /proc
# not super useful
man sl
# explains concepts!
man 7 pipe
man 7 symlink
man apt
man chroot
date: 2024-12-16" source: "Bite Size Linux" (Julia Evans)
execute
ls -l file.txt
shows you permissions. Here's how to interpret the output:
bash
rw- rw- r-- bork staff
bork (user) can staff (group) can anyone can
read & write read & write read
txt
user group all
000 110 110 100
^setuid
^setgid
txt
r = can read
w = can write
x = can execute
txt
r = can list files
w = can create files
x = can `cd` into and access files
txt
rw- r-- r-- = 110 100 100 = 6 4 4
chmod 644 file.txt
means "change the permissions to rw- r-- r--
".
setuid
affects executables:bash
$ ls -l /bin/ping
rws r-x r-x root root
^this means ping always runs as root
setgid
does 3 different unrelated things for executables, directories and regular files.2025-08-05 choose puzzles from Advent of Code to put in practice 0.md and 1.md