[Linux/LPIC] Memorandum

Overview

--Memo the content you were interested in as a memorandum ――Please note that the description is not exhaustive.

Super

Summary of package management command differences

--- --- ---
rpm -e(--erase) Uninstall a package
-l (--list) View files contained in the specified package
-a (--all) View all installed packages
Other remove Uninstall a package
list Search and view installed packages
dpkg -s(--status) Detailed package information
apt-cache show Detailed package information
Other info Detailed package information
dpkg -S (--search) Shows from which package the specified file was installed
Other (apt is apt-Become a cache) search Search for packages with the specified keyword
--- --- ---
yum chack-update View updatable packages
zypper list-updates(lu) View updatable packages
--- --- ---
yum Do not omit options -Do not use
apt Do not omit options -Do not use
zypper Omit options to 2 characters -Do not use

Device mounting procedure

--Create partition - fdisk - parted --File system implementation - ext2~4 --ext2 does not support journals --Commands: mkfs, mke2fs --Parameter setting command: tune2fs - XFS --Command; mkfs.xfs --Mount --Description in fstab, etc.

GRUB configuration files and updates

dmesg and systemd-journald

system Overview command
dmesg A command to display the message output by the Linux kernel at boot time dmesg
systemd-journald Standard log collection and storage service journalctl

Creating a file system

--Ext2 is selected by default (all of the following use ext2 for type)

--- ---
mkfs /dev/hda1 mkfs -t ext2 /dev/hda1
mke2fs /dev/hda1 mke2fs -t ext2 /dev/hda1

Runlevel target on systemd operation

--- ---
rescue.target runlevel1.target

ln default

--- b t (number the lines excluding blank lines) is the default

A command that can display the UUID of the device

A command that can list all the set environment variables

Exception usage of init (telinit)

--Usually change the runlevel using numbers - telinit 5 - init 5 --As an exception, if you want to reload "/ etc/inittab" without restarting the system, do the following: --telinit q or telinit Q --init q or init Q

High

Package management tool

Distribution Package management Dependency management
Red Hat rpm yum (There is also dnf as a successor to yum)
Fedora rpm dnf (Also the successor to yum)(Became the default management tool from Fedora 22)
Debian dpkg apt
openSUSE rpm zypper

rpm command

Only --f takes a file name as an argument. Only --p takes a package file name as an argument.

option Overview
-q(--query)package name Check if the specified package is installed
-V(--verify)package name Package inspection
The following combined options Overview
-a (--all) View all installed packages
-l (--list) View files contained in the specified package
-i (--info) Detailed information on the specified package
-f (--file)file name Shows from which package the specified file was installed
-p (--package)Package file name Referral target is a package file
--changelog Display change history of specified package
-c (--configfiles) Display configuration file
--nomd5 Do not inspect file tampering with MD5
-R (--require) View files that the specified package depends on
option Overview
-i(--install)Package file name Package installation
-U(--upgrade)Package file name Package upgrade (install if not)
-F(--freshen)Package file name Package upgrade (do not install without)
-e(--erase)package name Uninstall a package
The following combined options Overview
-v Display detailed information
-h (--hash) Show progress with "#"
--test Do not run, run test
-nodeps Ignore dependencies

dpkg command

option Overview
dpkg-reconfigure Reconfigure as you did when you installed the installed packages
-E If the same version is already installed, do not install
-G Do not install if the new version is already installed
-R Specify the directory name, recursively search the package files stored in the specified directory, and install the packages together.
The following actions Overview
-i (--install) Package installation
-r (--remove) Uninstall the package leaving the settings fal
-P (--purge) Uninstall including setting fal
-l (--list) Search and view installed packages
-L (--listfiles) List files installed from the specified package
-s (--status) View detailed information about installed packages
-S (--search) Shows from which package the specified file was installed
-C (--audit) View packages that have not been installed (incomplete)

yum subcommand / zypper subcommand

--yum configuration file - /etc/yum.conf --/etc/yum.repos.d = Package acquisition source (repository) is set in the file in the directory --zypper config file =

yum subcommand Overview zypper subcommand
install package name Installation install (in)
update Package name (If executed without specifying a package, all updatable packages will be updated) update update(up)
remove package name Uninstall remove(rm)
info Package name Display detailed information info
list package name List display / version and whether it is installed or not None
search keyword Search for packages with the specified keyword search(se)
check-update package name View updatable packages list-updates(lu)
grouplist List of package groups None
groupinstall group Group installation of packages None
None List repositories repos(lr)
None Repository update refresh

apt-get subcommand (significantly different from yum and zypper)

Subcommand Overview
install package name Installation
update Updated package database to the latest version
upgrade Upgrade all installed packages
info Package name Display detailed information
dist-upgrade Upgrade your distribution to the latest version
clean Delete the package file acquired in the past

apt-cache subcommand

Screen Shot 2020-12-20 at 15.37.41.png

ldd --Command to search library --You can use ldd/etc/ls to search for the library used by the command. --Command to update the cache file "/etc/ld.so.cache" of the shared library - ldconfig

Boot loader

function

--Called after booting the BIOS to boot the OS and kernel

Install command

MBR (Master Boot Record)

--Saved in 446 bytes of storage --The rest is the route table 16 bytes * 4 and 2 bytes boot signature

init program

name Feature
SysVinit Manage system state by runlevel
Upstart Manage system state by runlevel
systemd Manage system state by target

--systemd subcommand collection --systemd command is systemctl --systemctl subcommand [Unit name]

Screen Shot 2020-12-16 at 10.39.12.png

Boot-related target directory

Screen Shot 2020-12-16 at 11.08.45.png

Shell variables / environment variables

name Feature
Shell variables Valid only on the shell
Environment variable Can be called by any action of an application command executed in the shell

--Major premise --The value of the environment variable cannot be retained permanently with the export command, so it must be described in the configuration file. (.Zshrc for zsh, .bash_profile for bash) --Environment variable (path) --Search and execute from the directory set in the environment variable PATH (the so-called path is in the path) --export PATH = $ PATH: directory --If the command is in a directory that is in the path, you can execute it only by the command name without specifying the path where the command is stored. --Environment variables are provided for each user. For example, the environment variables used by user1 and user2 can have different values. --Environment variables (other than paths) --Some are set by default (USER, HOME, etc.) --Set with export environment variable name = "value"

--Change shell variables to environment variables --Set by export shell variable name (after all, with export environment variable name = "value")

tar (archive function)

--tar [option] [directory name] [file name] --When creating hoge.tar that archives aa, bb, cc, the description is as follows (The archive name is described first)

% tar cf hoge.tar aa bb cc

--- c (Create new archive) --- x (extract from archive) --- t (Display archive information) --It is not compressed, and if you keep the information before putting it together, it may be larger than the original file procedure.

cpio (Archive function)

--cpio [option] --- o (create a new archive) --- i (extract from archive) -- Accept only from standard input

% cpio -i <file name.cpio

grep command (search function)

--Search for various things from the process to the contents of the file --By default, the line corresponding to the search target is displayed.

name Feature Example
grep Search using regular expressions grep search regular expression filename
grep -E Search using both extended regular expressions and regular expressions grep -E Extended regular expression file name
egrep Search using both extended regular expressions and regular expressions egrep search regular expression or extended regular expression filename
fgrep Search for the entered character string as it is egrep "String"file name
grep -F Search for the entered character string as it is grep -F "String"file name
pgrep In a running processFind the process ID using patterns that represent process names, users, groups, terminal names, etc. pgrep [option] [Patterns such as process names]

tee (Standard input output destination is bifurcated)

% dmesg | tee -a log.txt

--Receive the standard output of dmesg as a standard input with a pipe, and add both the standard output (1) and log.txt. If you do not specify the option -a (probably an abbreviation for add), it will be overwritten (>).

ln (create link)

--ln [option] Link source Link destination --Create hard link without options --Hard link --A link that directly refers to the actual file --Director hard links cannot be created (to prevent the creation of circular directories) --Cannot be created on different partitions (because inodes are managed separately and may be duplicated) --Create symbolic link with option -s --Symbolic link --A link pointing to the location of the original file (like a shortcut in Windows)

File management on Linux

--Files (including directories) are managed using "file entity (data body)" and "inode" --inode is like a label --Files are deleted when inode (hard link) reaches 0

mv (move and rename files)

--Move the "test1.txt" file to the "dir1" directory in the current directory and rename the file to "test2.txt"

% mv test1.txt dir1/test2.txt

kill signal system

command Feature
kill Specify PID
killall Specify the target by process name
pkill Specify the target process name with a regular expression

--kill [-signal name or-signal number] [process ID] --killall [-signal name or-signal number] --killall -s [-signal name or-signal number] --pkill [-signal name or-signal number] process name (command name) --pkill --signal [-signal name or-signal number] process name (command name) -* 15 (TERM) is selected if no signal is specified for killall and pkill.

Screen Shot 2020-12-16 at 11.59.20.png

Process monitoring

option Overview
top The command to update and display the process operation status at regular intervals is top
ps A command that displays the currently running process, but does not update the displayed content at regular intervals.
uptime Show current system load average
free Display memory and swap area usage

--ps [option] --There are BSD options without "-" and UNIX options starting with "-".

Screen Shot 2020-12-16 at 12.42.47.png

Docker

Main commands

Screen Shot 2020-12-16 at 12.20.36.png

File display system basic commands

command Overview
cat Show all file contents
tail Display by specifying the end of the file
nl View files with line numbers
head Show top of file
sort Sort the contents of the file by line
paste Combine multiple files line by line
fmt Format text by specifying the maximum number of characters per line
wc Check the number of characters and lines in the file
uniq Show consecutive duplicate lines in a sorted file on one line
cut Extracts and displays the specified field from each line of the text file
split Split the file by the specified number of lines

Low

Virtual terminal control program

A means of using multiple terminals on one terminal by operating a program that controls virtual terminals instead of using a large number of terminal programs.

VM virsh --A shell for working with libvirt (a library for open source virtualization management) --Various operations such as virtual machine resource management and virtual network management are possible --Command collection

Screen Shot 2020-12-16 at 11.46.15.png

chown, chgrp (belonging group)

--You can change the owned group --chown [-R]: group name file or directory --chgrp [-R] group name file or directory --Use the "-R" option to recursively change the owning user or group of the specified directory and the files under it. --If there is no "-R" option, change the owning group for directories only

chmod (permission)

--Three digits represent the status of users (U), groups (G), and others (O) --The situation is the total value of the following numbers --If it is 753, [Full authority (4 + 2 + 1)] [Read / execute (4 + 1)] [Write / execute (2 + 1)]

Authority symbol Numerical value
reading r 4
Writing w 2
Run x 1

find

--Command to search files and directories under the specified directory --find [search starting directory] [search expression] [action]

Difference between snapshot and backup

Feature the difference
snap shot Updated data Updated dataのみ更新
backup All storage contents Save all of the storage area

Regular expression

Screen Shot 2020-12-22 at 14.14.31.png

Vi editor

Screen Shot 2020-12-22 at 14.58.47.png Screen Shot 2020-12-22 at 15.06.16.png

--To execute Linux commands without exiting the vi editor, execute the following vi command in command mode. -:![Command] --Example:! Ls The left indicates that the ls command was executed in the current directory.

tail command

name Feature
-n lines or-Number of lines 指定したNumber of linesをファイルの末尾から表示
-c bytes Display the specified number of bytes from the end of the file
-f Keep displaying lines added to the end of the file

tr and sed

--Sed seems to be considered as upward compatible with tr

command Feature important
tr Can be replaced and deleted Standard input and standard outputIs used, so if you want to process the file, use the "cat" command etc.
sed In addition to the tr function, you can add Specified fileIs processed according to the command and output to standard output.

nice and nice

--Nice values ​​(priority) are both -20 to 19 (-20 is the highest priority and 19 is the lowest priority) --The default nice value if nothing is specified is 10 --The default reason value when nothing is specified is 0 --Nice value description method is different for each --In nice, -(hyphen) is accompanied, so -10 becomes --10. --In renice, -(hyphen) is not accompanied, so -10 becomes 10.

command Feature Example
nice Execute the command by specifying the run-time priority nice -10 Command name, or nice-n 10 command name
renice Change the priority of running processes renice 10 (-p)Process ID, Or renice-n 10 (-p)Process ID

Editor type

Screen Shot 2020-12-23 at 12.35.52.png

du and df

command Feature
du (abbreviation for disk usage) Directory usage
df (abbreviation for disk free) Directory availability

Symbolic links and hard links

command Feature Example
Symbolic link Record the path
Hard link Link to the actual situation based on the inode number

fdisk, parted and mkfs

command Feature Example
fdisk MBR format partition operation command
parted MBR and gpt format partition operation commands
mkfs Create a file system

fstab and mtab

--mount is a mounting operation that embeds a disk device in a Linux directory and makes it usable.

command Feature Example
fstab(filesystem table) Describes the devices that are mounted by default at boot time
mtab(mounted filesystem table) Describes the device currently cloaked,Automount is not set at startup, and what is mounted after startup is described in the file

tune2fs --Perform existing file system management operations --Different from mkfs in that it creates a file system

command Feature Example
tune2fs ext2, ext3, ext4 file system parameters changed

File system type

Screen Shot 2020-12-24 at 15.45.08.png

telinit --Try to change the runlevel.

UUID --UUID (Universally Unique Identifier) ​​is an identifier that uniquely identifies an object on software.

Block device

--Device files that transfer data in block units instead of character units when accessed --Commands that can display the UUID of the device

command
lsblk
blkid

Recommended Posts

[Linux/LPIC] Memorandum
Matplotlib memorandum
linux memorandum
jinja2 memorandum
Python memorandum
Django memorandum
Command memorandum
plotly memorandum
multiprocessing memorandum
ShellScript memorandum
pip memorandum
Python memorandum
pydoc memorandum
python memorandum
Pandas memorandum
python memorandum
DjangoGirls memorandum
Command memorandum
Python memorandum
pandas memorandum
python memorandum
Python memorandum
Python basics memorandum
RAID type memorandum
Python pathlib memorandum
Knapsack problem memorandum
Memorandum of sed
Python memorandum (algorithm)
Linux memorandum [links]
nc command memorandum
numpy memorandum 1 / np.pad
Revit API memorandum
Memorandum conda command
Pandas operation memorandum
setuptools command memorandum
Python memorandum [links]
tslearn trial memorandum
Django's basic memorandum
Memorandum about validation