Shell / Bash
Resources¶
Shells:
POSIX:
Documentation¶
Cheatsheets¶
Tutorials¶
Introductions
- TBD
Games
Introduction¶
Shell¶
-
-
An operating system shell is a computer program that provides relatively broad and direct access to the system on which it runs.
-
Most operating system shells are not direct interfaces to the underlying kernel... Shells are special applications that use the kernel API in just the same way as it is used by other application programs.
- Related: Kernel โข Operating system โข Unix shell
-
-
Command-line interface - Wikipedia
- Related: Graphical user interface
-
- Related: Scripting language
Different shells¶
Using Bash¶
If you're using zsh, run:
Command line interface¶
Customization¶
Language¶
Syntax¶
Variables¶
TBD
Quoting¶
In most cases, you should quote variables to prevent word-splitting and globbing issues.
Comments¶
TBD
Pipelines¶
TBD
Compound commands¶
Looping constructs¶
Conditional constructs¶
Utilities¶
TBD
Working with files and directories¶
ls¶
ls lists the contents of a directory. ls -l produces outputs like the one below:
-rw-r--r-- 1 user staff 1234 Aug 27 21:10 notes.txt
drwxr-xr-x 5 user staff 160 Aug 27 20:59 my_folder
- File type and permissions (
-rw-r--r--,drwxr-xr-x)- First character: file type
-= regular filed= directoryl= symbolic link
- Next 9 characters: permissions in 3 groups (owner, group, others).
r= read,w= write,x= execute (or directory access).- Example:
rw-means read/write allowed, no execute.
- First character: file type
- Link count (
1,5)- Number of hard links to the file (for directories, this counts subdirectories, including
.and..).
- Number of hard links to the file (for directories, this counts subdirectories, including
- Owner (
user)- The username of the file owner.
- Group (
staff)- The group that owns the file.
- File size (
1234,160)- Size in bytes (though for directories this is metadata size, not the total contents).
- Last modified date/time (
Aug 27 21:10)- When the file was last changed (content or metadata).
- File/directory name (
notes.txt,my_folder)- The actual name of the file or directory.