Posix + git Flashcards
What is SSH?
Secure shell (SSH) is a protocol to allow you to remotely log in to another computer. SSH is the client which you run in your machine. The way it works is that the machine you’re trying to connect sends you a challenge which your private key solves and sends the result to the host machine which verifies it via your public key
What is SSHD?
sshd is the server, or daemon in UNIX-speak. It runs in the background on the machine you want to connect to
What port is used by SSH
TCP port 22
What does the command uname -a do?
Prints all information about the current operating system
What command is used to check what user is currently using the computer?
whoami
What command is used to create a new key pair?
ssh-keygen -t ed25519
What do each of the brackets represent? (-)(—)(—)(—)
- File type
- Owner
- Group
- Everyone else
What does the scp command do?
It stands for secure copy and allows you to copy files over SSH
scp syntax is: scp source destination. What form can source/destination take?
[USERNAME@]HOSTNAME:PATH
What is the format of chmod command?
chmod bit_field file_name. I.e. chmod 600 config
How to activate agent forwarding for SSH and what does it do?
- Activate with -A flag
- It allows to reuse same private key in your machine to access machines from a machine other than your own (if you already connected to that machine via SSH)
What is vagrant?
A program to manage VMs through another program like virtualbox.
What does the which command do?
It tells you the location of a given command
What is Busybox
It’s a distribution of the common POSIX commands
What kind of files are usually stored in /etc?
System wide configuration files usually only editable by root
What is musl?
A lightweight implementaiton of the C standard library
What kind of files are stored in /lib?
Dynamic libraries like the C library
What does /sbin or /usr usually contan?
System binaries and readonly data like configuration files but not temp data respectively
What does /tmp store?
Temporary files that may live in RAM
What does /var store?
Files that vary over time like caches or logs
What are /dev, /sys, and /proc used for?
- /dev - interface for devices like hard disks
- /sys - system functions (i.e. changing screen brightness)
- /proc - running processes
What’s a package manager and what is its main benefit? (according to david’s notes)
It allows you to install packages from a repository and it has the advantage of installing dependencies automatically.
What command do you use to figure out what dependencies a package depends on? (alpine linux)
apk info -a [name of package]
What are the two commands that should be run regularly by system administrators?
sudo apk update
sudo apk upgrade
What are 3 ways of turning off pattern matching?
- ””
- ’’
- \
What is good practice when setting and using shell variables?
Set the variable inside “” and use it inside “”. I.e. p = “silly name” , “$p”
What file is processed by bash when it startups up and what you can do with it?
.profile - you can configure the default text editor for instance
What’s the difference between git revert and git reset
Git revert creates a new commit by changing the files to the state at which they were in a previous commit. Git reset moves the HEAD pointer to the commit that you want and leaves the working copy intact unless you specify –hard
How do you show the current user in the prompt?
You have to edit the profile file in /etc/ to include the user in PS1(prompt level 1)
How to check if a user has been added?
- tail /etc/passwd
- tail /etc/group
How to add a user to a specific group?
(from root) sudo adduser [user] [group-name]
What is the setuid used for?
To give normal users the right to execute programs as root. I.e. to execute specific programs in a dir from another user where they wouldn’t normally have w/x rights.
What does the sticky bit do in a directory file?
It allows only the person who creates a file in the dir to be able to edit and rename them. Other people, although they have write permission to dir, cannot edit your file. Usually seen in /tmp
What does it mean to set the SGid on a folder?
That if someone inside that dir creates a file, the file adopts the group for the dir, not of the creator of the file
What’s the purpose of the /etc/sudoers file?
It configures what sudo is allowed to do. I.e deciding who’s allowed to reboot to shutdown the machine
What is mount/unmounting for?
Attaching an external filesystem to your local filesystem (i.e. from a USB or external disk)
What does a rebase do?
It can be used to resolve a conflict by pretending that everything in origin happened before you started your changes.
What command(s) remove duplicate lines in linux?
… sort | uniq …