2-2. Input for becoming a WEB engineer (Linux basics)

Introduction

This is a continuation of this article. 2-1. Input for becoming a WEB engineer (Linux basics) An article on inputs and their outputs to lay the foundation for Linux. Also, since there is a lot of content, the articles will be posted separately.

As mentioned in the previous article, the teaching materials and environment are as follows. ・ Use Udemy for business as teaching materials. [Can be done in 5 days] Introduction to Linux for the first time (LPIC Level 1 compatible) (Lecturer: Hiroki Inoue) -The Linux environment (Ubuntu) utilizes the EC2 instance of AWS. -Region: Asia Pacific (Tokyo) ap-northeast-1  -AMI:Ubuntu Server 20.04 LTS (HVM), SSD Volume Type -Instance type: t2.micro

Linux administration

User group management

Linux is multitasking and multiuser. There is a user account and an account used by the application.

/etc/passwd The format is as follows. ** Username: Password (x): UID: GID: GECOS: Home Directory: Default Shell **

Access control

In addition, permission is the access permission permission setting. You can check the permissions with the [ls -la] command.

Since the access authority setting of r, w, x is expressed by 0,1, it can be expressed as follows.

Access rights Binary number Decimal number
rwx 111 7
rw- 110 6
-w- 010 4
r-x 101 5

chown command

You can change the owner's settings. For example, the command to make the file owner root is

chown command


sudo chown root:root test.txt

chmod command

You can set access permissions. For example, the command to give the user write permission is:

chmod command


sudo chmod o+w test.txt

Debian-based (Ubuntu) package management

There are three ways to introduce the package.

Method Contents
apt-get command Batch execution on the command line
Ubuntu Software Center Batch execution with GUI tool
deb file download & dpkg command Independent download and installation

The options of the dpkg command are as follows

dpkg command


dpkg [option]dpkg package file.deb
option function
-i Installation
-r Uninstall (leave settings)
-P Uninstall (delete settings)
-l View installation packages
-L Display the file list of the installation package
-s Display specified package information
-S Search and display installed files
-E Do not overwrite if it is the same version
-G Do not overwrite if a new version is installed

The options of the apt-get command are as follows

apt-get command


dpkg [option]d package name
option function
-i Installation
-r Uninstall (leave settings)
-P Uninstall (delete settings)
-l View installation packages
-L Display the file list of the installation package
-s Display specified package information
-S Search and display installed files

RedHat (CentOS) package management

There are three ways to introduce the package.

Method Contents
yum command Batch execution on the command line
Package manager Batch execution with GUI tool
rpm file download & rpm command Independent download and installation

The options for the yum command are:

yum command


yum [option]Command package name
command function
install Installation
remove Uninstall
check-update View update target list
update Package update
list List of packages
repolist List of registered repositories
search keyword Keyword package search

You can only download files with the command [yum downloader].

The options of the rpm command are as follows

rpm command


rpm [option]package name.rpm
option function
-i Installation
-U Upgrade (install if not)
-F Upgrade (if installed)
-h View progress
--force Force installation
--nodeps Ignore package dependencies
-e Find and view uninstalled files
-q Inquiry
-l View installation files
-a Display of all information
-p Package specification
-f Display the package of the specified file

Job scheduling

You can execute a specified command at a predetermined time.

Display a list of processes to be executed regularly


crontab -e

The format of crontab is here. [Minute, hour, day, Monday, day of the week, execution job]

File system management

df command

df command


df [option] [file name]
df command option function
-i View inode usage
-h Show M, G
-T Show file system type

du command

du [option] [Directory file]
du command option function
-a Information display of directories and all files
-s Show total only
-h M,Show G

File system management commands

option function
fsck.e2fsck File system check.
debugfs Debug of ext file system
dumpe2fs Information display of ext file system
tune2fs Parameter operation of ext file system

fsck command

fsck command


fsck [option]Device file
option function
-t File system (ext2,ext3 etc.)
-c Investigate bad blocks when creating a file system
-b Recover by specifying a backup superblock
-n Command execution confirmation (does not process)

dumpe2fs command

dumpe2fs command


dumpe2fs [option]Device file
option function
-b Show bad blocks
-h Display only superblock information

The backup location of the superblock is as follows.

Block size Backup superblock location
1024(1kb) 8193
2048(2kb) 16384
4096(4kb) 32768

debugfs command

debugfs command


debugfs [option]Device file
option function
-b Apply block size
-c Open read-only
-R Executes the specified command, not interactively
-n reading

debugfs dedicated command

debugfs command


debugfs [-R command]Device file
command function command function
ls View file list chroot Change root directory
cat Display inode information pwd Current directory display
cd Change current directory close File system closed
-n reading quit Exit debugfs

tune2fs command

tune2fs command


tune2fs [option]Device file
option function
-c times Number of mounts before executing file system check
-i d, m, w File system check interval d, m, w
-j Added ext3 journal (change history)
-I Display of super block information
-L volume name Give the file system a volume name

XFS management tool

XFS management tool


XFS (Journaling File System),~500TB.CentOS7/Standard with RHEL7)
tool function
xfsinfo Display information about the XFS file system
xfs_metadump Save XFS file system metadata to a file
xfs_mdrestore xfs_Restore metadump image

Disk quota management

Quota is the control of the disk space that can be used by the user on linux.

Creating a quota database

quatacheck command (quote initialization)

Quota setting

edquato [optional] file system

Quota activation

quotaon [option] file system quotaoff [option] file system

Check quota status

repquota command | requota [-a] File system | -a option: For all file systems quota {-u, g}: User group quota setting display

at the end

That's the basics of Linux. Next time, I will learn JavaScript

Recommended Posts

2-2. Input for becoming a WEB engineer (Linux basics)
2-1. Input for becoming a WEB engineer (Linux basics)
[Must-see for beginners] Basics of Linux
Linux Basic Education for Front-end Engineer
Linux basics
Linux basics
An introduction to self-made Python web applications for a sluggish third-year web engineer
I searched for the skills needed to become a web engineer in Python
How to create a shortcut command for LINUX
Build a mruby development environment for ESP32 (Linux)
pyenv for linux
Linux command basics
Released a web service for scoring handwriting using DeepLearning
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 7-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 1-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 2-
Create a QR code for the URL on Linux
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 0-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 5-
[Part 2] Let's build a web server on EC2 Linux
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 6-
A brief summary of Linux antivirus software for individuals
How to create a local repository for Linux OS
[Linux] Basics of authority setting by chmod for beginners
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 4-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 3-