or at least the ones i am not too tired to note down. i'm lazy and forgetful. this is not the full list.
-
- password
- ssh keys
- generate:
ssh-keygen -t ed25519 -C [meaningful comment]
- connect:
ssh -i [path/to/key] user@host
- generate:
-
- UNIX an operating system of old
- has philosophy regarding how computer systems should function
- various branches based on UNIX follow some or all of the philosophy
-
- everything is a file
- make every program do one thing; and do it well
- UNIX an operating system of old
-
- indication of where a file or directory is on the filesystem
- use command
pwd
to find path of current directory (aka working directory) - filesystem is tree-like hierarchy starting
/
- root - each level is separated by
/
- i.e
/home/avengers
= root » home » avengers
- i.e
-
/home/<your username>
= your home directory; holds personal files~
in a path is often synonymous to your home directory
-
-
- start at
/
- working dir doesn't matter while using paths of this type
- start at
-
- start at working directory
.
means working directory; optional..
means parent of.
- working dir matters while using paths of this type
- start at working directory
-
-
hidden files and directories
- have names starting with
.
(not to be confused with working dir) ./.secrets
path to hidden file in.
- have names starting with
-
- hold applications; some common ones are
- ~/.local/bin
- ~/.bin
- /usr/bin/
- /usr/local/bin
- hold applications; some common ones are
-
- hold source package of apps installed from source; some options are
- ~/.local/src
- /usr/local/src
- hold source package of apps installed from source; some options are
-
- special file that shows text output
-
- special file that shows text errors
-
- special file that makes everything written to it disappear
-
- bash is common and has good features
-
- treats everything as space-separated words
- aka word-splitting
- prevent using
"
or'
around the entire phrase
echo "hello world"
- or escape () the spaces
echo hello\ world
- words with special meaning (variables, command substitution) in shell work inside
"..."
but not'...'
- is mostly case-sensitive
- date ≠ Date
- supports variables
- accessible using
$var_name
- set using
var_name=value
echo $var_name
to view; empty/unset var prints blank line- has special ones
$0
- current application$_
- last arg of previous command$?
- exit code or previous command$USER
- username$HOME
- path to home directory of user$1
-$9
- positional args of current command
(useful in scripting using bash)$PATH
- list of paths to directories holding executable files expected as commands. each path is separated by:
- accessible using
- expects valid command names
- a command is
- an executable file in
$PATH
- absolute or relative path to an exectuable file
- something built into the shell
- an executable file in
- a command is
- substitutes commands wrapped in
``
with output- e.g.
echo today's date is : `date`
`date`
will be subtituted by its output and passed as argument toecho
- e.g.
- redirects stdout and stderr using
>
- lhs of
>
is source1
is stdout and2
is stderr of the current command- no space between source and
>
- i.e one unsplit unit
1>
; not1 >
- i.e one unsplit unit
- lack of source implies
1
- BASH only
&>
indicates both1
and2
- rhs of
>
is the destination- usually path to a file
- can also be
&1
or&2
to refer to stdout and stderr respectively- thus shell way of writing to stderr is
echo hello world 1>&2
- thus shell way of writing to stderr is
- behaviour
>
overwrites destination>>
appends to destination
- NB shell sees
>
in any part of command as redirection, not as command argument, unless escaped with one of" ' \
- lhs of
- uses patterns
*
can be used to match anything in a pathls /home/user/D*
= list items in ~ starting with capital D
- executes login scripts
~/.profile
- set variables (incl PATH) for current user
- (for bash)
~/.bashrc
- configure other bash options for current user
/etc/profile
- set variables (incl PATH) for all users
- treats everything as space-separated words
-
-
- compiled
- are transformed to binary that can be executed directly
- interpreted (scripts)
- interpreted apps need to be called with the interpreter -
python /path/to/script.py
- instead the!#/path/to/interpreter
shebang is used at the start of the script file
- interpreted apps need to be called with the interpreter -
- compiled
- should have permission to execute
- granted using
chmod +x </path/to/app>
- granted using
- need to be in
$PATH
dirs to be executed directly from the shell - can also be executed using absolute or relative path
-
-
pwd
cd [path]
ls [path]
ls -1
- show in one columnls -a
- incl. hidden filesls -l
- show more info
echo
mkdir [path]
mkdir -p
- create required non-existent directory along the way
touch [path]
- `cp [src paths...] [dest path]
cp -r
- copy a directory
mv [src paths...] [dest path]
chmod [options] [path]
- change permissionchmod +x path
- make executable
file
- show filetypedate
man [name of command]
- manual for commandnano
- text editorgit
git init
- make.
a git repogit clone [url]
git clone [url] [path]
- clone to directory named[path]
(should be empty)
git add [paths]
- stage files; prepare for commitgit commit -m "[meaningful message]"
- commit staged changesgit remote add [remote name] [remote url]
- remote name is usually origingit fetch
git pull
git pull --set-upstream origin main
- first time pull
git push
git push --set-upstream origin branch
- first time push
git branch [name]
- create branch[name]
based on last commit- `git checkout [branch name] - switch to branch
-
finger
- show logged in usersfinger [username]
- info on user
chsh
- change login shellbash
sh
gcc [C source file]
- compile C codegcc -o [name]
- output name for compiled file (default:a.out
)
Wow