[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.
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
Ctr + key is represented by ** ^ key ** on the shell
Ctr + r
Mode to search history every time you enter a character further
Ctr + rto move to the previous search result
Ctr + gto print the result and return to the prompt.
Ctr + sto go back one, but it is assigned to the screen lock, so you need to unlock it.
find ./ -type f -name aaa.txt -print
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 variables can be referenced by external commands ** ** Many shell variables are set as environment variables **
printenv export shell variable name
Login shell loading order
/etc/profile ↓ ~/.bash_profile ↓ ~/.bashrc
Non-login shell loading order
/etc/profile -** Setting items common to all users **
~/.bash_profile -** Items that need to be set only once at login **
~/.bashrc -** Items that need to be set every time you start bash **
** Many settings need to be set every time you start bash, so you can write them in .bashr **
-rw-r--r--. 1 root root 21554 Nov 15 2018 test
Owner: Group: Other users
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.
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
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
Command to send a signal
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.
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
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.