I tried to reintroduce Linux

Introduction

[New Linux Textbook](https://www.amazon.co.jp/%E6%96%B0%E3%81%97%E3%81%84Linux%E3%81%AE%E6%95%99% E7% A7% 91% E6% 9B% B8-% E4% B8% 89% E5% AE% 85-% E8% 8B% B1% E6% 98% 8E / dp / 4797380942 / ref = sr_1_1? __mk_ja_JP =% E3 I read% 82% AB% E3% 82% BF% E3% 82% AB% E3% 83% 8A & dchild = 1 & keywords = Linux & qid = 1584175006 & sr = 8-1) and re-introduced to LINUX.

Terminal

Dedicated hardware used by users to input and output to a computer However, currently, a terminal emulator is used, which is a physical terminal implemented by ** software **.

Various ways of being called

shell

bash

Shell troubleshooting

Ctr + key is represented by ** ^ key ** on the shell

Command history

Ctr + r

(reverse-i-search)`':

Mode to search history every time you enter a character further

command

find

find ./ -type f -name aaa.txt -print

bash

Shell variables

Variables used inside bash. Since it is referenced by bash, there are many shell variables with special meanings that can be customized.

var1="aaaaaa"
echo $val1

Environment variable

** Environment variables can be referenced by external commands ** ** Many shell variables are set as environment variables **

printenv
export shell variable name

bash config file

Login shell loading order

/etc/profile
↓
~/.bash_profile
↓
~/.bashrc

Non-login shell loading order

~/.bashrc

Use properly

** Many settings need to be set every time you start bash, so you can write them in .bashr **

Users, groups and permissions

File permissions


-rw-r--r--.  1 root root      21554 Nov 15  2018 test

Owner: Group: Other users

Directory permissions


drwxr-xr-x   2 root root       4096 Mar 14 17:00 test-test

Directory permissions determine whether files can be deleted If x is set in the directory, cd can move to that directory and read / write files under the directory.

Root user

su

su - //Initialized to the root user environment
su   //Only the user switches while maintaining the current environment such as environment variables and the current directory.

sudo Used to execute commands as another user

sudo cat /etc/shadow

Currently asked for user password You can execute commands if you are allowed

Allow sudo to user

/etc/sudoers Edit with visudo command

All commands can be executed by belonging to the wheel group

<User or%group> <Machine name>=(<Authority>)<command>
%wheel ALL=(ALL) ALL

Minimize operations as root user with sudo

process

View ps command process

TTY means terminal. UNIX option to add hyphen The BSD option does not have a hyphen. The BSD option seems to be the mainstream.

Process running in the current terminal

# ps
  PID TTY          TIME CMD
24021 pts/0    00:00:00 su
24022 pts/0    00:00:00 bash
26512 pts/0    00:00:00 ps

Process running by ** current user ** f also indicates parent and child

# ps xf

View all processes running on your system

# ps ax

The one I use often

# ps auxfwww  //Details with x Do not limit display width with www

UNIX option (with hyphen)

# ps -ef  //e to show all processes f f to parent and child

kill command

Command to send a signal

kill-signal name

The default is TERM

kill -TERM process ID

TERM is finished. Depending on the type of program, the current state is saved or the temporary file is deleted when the TERM signal is received, so it is better to kill it first and then forcibly terminate it.

redirect

Standard error output is a channel for outputting program error messages.

Standard error output redirect

ls aaaaa 2> aaa.txt

Combine standard output (1) and standard error output (2) 2 to 1

ls aaaa > aaaa.txt 2>&1

Standard output to aaaa.txt. Standard error output to the same as 1. & 1 represents standard output

/dev/null

Hide error messages

ls / /xxxxx 2> /dev/null

grep Enclose the regular expression in ``. grep 't[ef]'

If you want to use a regular expression, specify grep -E that can use extended regular expressions.

Extended regular expression

Recommended Posts

I tried to reintroduce Linux
I tried to debug.
I tried to paste
I tried to operate Linux with Discord Bot
I tried to learn PredNet
I tried to implement PCANet
I tried to introduce Pylint
I tried to summarize SparseMatrix
I tried to touch jupyter
I tried to implement StarGAN (1)
I tried adding system calls and scheduler to Linux
I tried to implement Deep VQE
I tried to create Quip API
I tried to touch Python (installation)
I tried to implement adversarial validation
I tried Watson Speech to Text
I tried to touch Tesla's API
I tried to implement hierarchical clustering
I tried to organize about MCMC.
I tried to implement Realness GAN
I tried to move the ball
I tried to estimate the interval.
I tried to create a linebot (implementation)
I tried to create an environment of MkDocs on Amazon Linux
Linux standard textbook (ver3.0.2) I tried Chapter 1
[Linux] I tried to summarize the command of resource confirmation system
I tried to implement Autoencoder with TensorFlow
I tried to summarize the umask command
I tried to implement permutation in Python
I tried to create a linebot (preparation)
I tried to visualize AutoEncoder with TensorFlow
I tried scraping
I tried to recognize the wake word
I tried to get started with Hy
I tried PyQ
I tried to implement PLSA in Python 2
Python3 standard input I tried to summarize
I want to use Linux on mac
I tried to classify text using TensorFlow
I tried to summarize the graphical modeling.
I tried adding post-increment to CPython Implementation
I tried to implement ADALINE in Python
I tried to let optuna solve Sudoku
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
I tried to implement PPO in Python
I tried papermill
I tried to implement CVAE with PyTorch
I tried to make a Web API
I tried to solve TSP with QAOA
[Python] I tried to calculate TF-IDF steadily
I tried to touch Python (basic syntax)
I tried django-slack
I tried Django
I tried spleeter
I tried cgo
I tried my best to return to Lasso
I tried to summarize Ansible modules-Linux edition
I tried to predict Covid-19 using Darts
[Linux] I tried to verify the secure confirmation method of FQDN (CentOS7)
I tried to summarize the Linux commands used by beginner engineers today-Part 1-