Emphasis is placed on building simple, short, clear, modular, and extensible code that can be easily maintained and repurposed by developers other than the original creators. The Unix Philosophy favors composability. Maxims include:
The kernel is the heart of the operating system. It interacts with the hardware and most of the tasks like memory management, task scheduling and file management.
The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
Overwrite:
>
- output<
- inputAppend:
>>
- output<<
- inputMerge:
&>
output<&
inputecho
- write arguments to the standard outputwc
- word, line, character, and byte countdiff
- compare files line by linexargs
- construct argument list(s) and executessh
- OpenSSH remote login clientscp
- OpenSSH secure file copyls
- list directory contentscd
- change directorypwd
- return working directorymkdir
- make directoriesrmdir
- remove directoriestouch
- change file access and modification timescp
- copy filesrm
- remove directory entriesmv
- move filesfind
- walk a file hierarchylocate
- find filenames quicklygrep
- file pattern searchertree
list contents of directories in a tree-like format. Requires installation via a package manager such as homebrew.cat
- concatenate and print filesless
- opposite of more
head
- display first lines of a filetail
- display the last part of a filesort
- sort or merge lines of text and binary filessed
- stream editorawk
- pattern-directed scanning and processing languageps
- process statustop
- display sorted information about processeskill
- terminate or signal a processPrograms can output to other programs:
program_a | program_b
Each file in Unix has an associated permission level. This allows the user to prevent others from reading/writing/executing their files or directories. Use ls -l filename
to find the permission level of that file
Permission levels:
r
means “read only” permissionw
means “write” permissionx
means “execute” permission-rwxrwxrwx
[1][2][3]
1. user
2. group
3. world
Interrupting a job while it is executing can be done using UNIX communication mechanisms called signals which provide software interrupts. For example, ^c
is a keybinding to SINGINT
.
You can also pause a job with ^z
, check to see it’s in the background by running jobs
, and resume the job in the foreground with fg %<job-number>
or in the background with bg %<job-number>
.
signal
- simplified software signal facilitieskill
- terminate or signal a processnohup
- invoke a utility immune to hangupsA list of commands to be executed sequentially can be combined into a single file called a script. Syntax can be specific to bash, zsh, or any number of command-line interpreter scripting languages.
Run a shell script with the sh
command followed by the file path.
Adding a shebang to the beginning of a script and making it an executable by running chmod +x <file_name>
allows the file to be called without the sh
command. chmod -x
reverts the executable to a plain file.