description: > Tips, and tricks covering builtins, and other common CLIs.
Table of Contents
pushd and popd work according to the LIFO principle
Prepend any command with a space to exclude it from history.
$ sensitive_cmd
We can create SSH keys using ssh-keygen
.
$ ssh-keygen -f ~/.ssh/id_ed25519 -t ed25519 -C "public_email@example.com"
For legacy systems where ed25519
isn't available: (avoid whenever possible!)
$ ssh-keygen -f ~/.ssh/id_rsa -t rsa -b 4096 -o -a 100 -C "public_email@example.com"
If more than one set of keys are needed consider ~/.ssh/id_ed25519_<profile>
as a naming format. Also, add -C "descriptive comment"
.
To copy the new public key to the clipboard:
$ pbcopy < ~/.ssh/id_ed25519.pub
On systems with xclip
rather than pbcopy
we can:
alias pbcopy='xclip -selection clipboard -in'
Use a config
file to ease key management. Also, consider adding custom
git details from .gitconfig
file.
Permission is usually handle by the ch*
family of commands.
On the terminal, ls -l
outputs something like:
drwxr-xr-x 2 pete penguins 4096 Dec 1 11:45 .
where
d
. Directory. If -
, then is a file.r
. Readable. Value 4.w
. Writable. Value 2.x
. Executable. Value 1.-
. Empty ie. permission off.Owner is also known as 'user' to avoid being confused with 'other'.
allow user to exec <file>
$ chmod u+x <file>
disallow group from writing on <file>
$ chmod g-w <file>
allow user, and group to write on <file>
$ chmod ug+w <file>
modify <file>
permission to match code
$ chmod 755 <file>
transfer <file>
ownership to <user2>
$ sudo chown <user2> <file>
set <file>
's owner group
$ sudo chgrp <group2> <file>
set <file>
owners to <user2>
and <group2>
$ sudo chown <user2>:<group2> <file>
This permission sticks files or directories, that is, prevents others from deleting and/or modifying them.
$ sudo chmod +t <dir>
# or
$ sudo chmod 1755 <file>
There are other special bits concerning SUID, and SGID which are mostly use to securely grant special permissions to non-root users in shared environments.