finals Flashcards
what does a package manager do?
makes it easy for users to manage software on their system. Allows you to do stuff like install, remove, update software
What is an advantage of package manager?
generally handle dependencies. If a package needs additional software to run, the package manager will install it too
What is one of the few tools that makes one Linux distro different from another?
the package manager. And diff distros will have different packages in their package repositories
What’s the package manager for Arch Linux?
pacman
What’s the package manager for Ubuntu?
apt
What’s the package manager for Nix?
nix
What is one of the reasons Arch Linux is so popular?
it has a lot of packages and those packages are generally up-to-date
Which distro has the largest package repository? By how much?
Nix. By ~30% more
pacman command to refresh local package repository?
pacman -Sy
pacman command to upgrade isntalled packages
pacman -Syu
pacman command to install one or more packages and any dependencies
pacman -S <packages>
pacman command to search for a packages
pacman -Ss <search term>
pacman command to remove a package, configuration files, and package dependencies
packman -Rns <packages>
pacman command to display remote information about a package. To display extensive info about a given package??
pacman -Si <package>
what is getopts? What arguments does it take?
it’s a shell builtin that can be used to handle options in shells scripts.
it takes 3 arguments:
- valid options that will be handled
- a variable populated with option arguments (ie “${opt}” )
- a list of options and arguments to be processed $@
what is optarg?
when a flag is set to expect an argument, the argument for that flag is held in the OPTARG variable (eg. my_script -n “ted” <– the OPTARG for -n is the string “ted”)
how to tell getopts to run in silent error checking mode?
Put a colon in the options string
eg. “:a:b:”
the first : tells it to run in silent error checking mode
what does “shift” do?
Shift positional parameters n characters to the LEFT (default is 1 character).
Cannot undo it (no “unshift”).
Shifts are cumulative
how to shift positional parameters to remove any options handled by getopts
shift $(($OPTIND -1))
do the flags and flag options come first or the positional arguments?
flags and flag options should be provided before positional arguments
how to check if there are positional parameters
shift $(($OPTIND -1))
if [[ $# -lt 1 ]]; then
echo “….”
exit 1
fi
What’s FTP?
File Transfer Protocol
Popular method of transferring files to and from remote servers
Why was FTP deprecated?
Lack of security features
What’s SFTP?
Secure(or SSH) File Transfer Protocol
provides functionality similar to FTP, but uses SSH for security
How to get the help menu for sftp?
?
or
help
What’s the sftp command to make a local directory? To make a remote directory?
local directory:
lmkdir dir-name
remote directory:
mkdir dir-name
how to download a file from remote server?
Connect via sftp. Then:
get file-path
How to upload a file via sftp?
put file-path
file will be uploaded to the users home directory
Vim: what does gg do?
go to beginning of file
Vim: what does =G do?
indent and go to file end
Vim: how do you move to the first instance of a character in a line?
f <character>
eg. f g
will move to the first instance of the letter g on the current line
What can pacman do?
can install, update, remove packages
What’s a package and what does it contain?
A package is an archive.
It contains:
o All of the compiled files of an application
o Metadata about the app (eg. app name, version, dependencies, etc)
o Installation files and directives for pacman
o (optionally) extra files to make your life easier (eg. a start/stop script)
benefits of using packages instead of compiling and installing programs yourself
o Easily updatable
o Dependency checks
o Clean removal
why should you use “pacman -Syu package_nam” instead of “pacman -Sy package_name”
in practice, do not run “pacman -Sy package_name” cuz it can lead to dependency issues
How to install single package or list of packages?
pacman -S package_name1 package_name2
What’s a virtual package?
Special package that does not exist by itself but is provided by 1 or more other packages. Virtual packages cannot be installed by their name; they’re installed when you have installed a package providing the virtual package
To remove a single package but leave its dependencies installed
pacman -R package_name
To remove package and its dependencies not required by other packages
pacman -Rs package_name
To remove package that’s required by another packages without removing the dependent package
pacman -Rdd package_name
To search for already installed package
pacman -Qs string1 string2
To list all packages no longer required as dependencies (orphans)
pacman -Qdt
Pacman stores downloaded packages where?
/var/cache/pacman/pkg/
Does pacman remove old or uninstalled versions automatically? Yes or no, and what are the advantages?
No.
o Allows downgrade without having to retrieve previous version through other means
o Package that has been uninstalled can easily be reinstalled directly from cahce directory without new download from the repository
How to delete all cached versions of installed and uninstalled packages except for the most recent 3
paccache -r
To remove all cached packages not currently installed and unused sync databases
pacman -Sc
How to download package without installing it
pacman -Sw package_name
What is a “unit”?
any resource/object that systemd knows how to manage
What is a unit file?
Where are systemd unit files found?
unit file is a plain text ini-style file that encodes information about a service, socket, device,… controlled and supervised by systemd
/usr/lib/systemd/system
/run/systemd/system
/etc/systemd/system
Where are the system’s copy of unit files? The systemd unit files distributed with installed RPM
/usr/lib/systemd/system
Where are dynamically created unit files created at runtime
/run/systemd/system
What should you do if you need to modify the system’s copy of a unit file?
create a unit file here: /etc/systemd/system
Order of precedence for unit files?
- /etc/systemd/system
- /run/systemd/system
- /usr/lib/systemd/system
How can you override specific directives from the system’s unit file?
Create subdirectory named after the unit file with .d appended to the end
eg. for unit called example.service, create a subdir called example.service.d and in this directory a file ending with .conf will override or extend the attributes of the system’s unit file
What are the types of unit files?
.service
.socket
.device
.mount
.automount
.swap
.target
.path
.timer
.snapshot
.slice
.scope
what do service files do?
Manages services/applications (start/stop, auto-start conditions, dependencies, ordering info for related software).