It seems that it consists of a kernel and userland
--You can output the result with >
➜ Desktop cat someoutput | tr a A > newsomeoutput
➜ Desktop cat newsomeoutput
yAmAdA 100
tAnAkA 20
kAndA 60
official
find pathname--name file name
--Head It seems that it can be displayed by specifying the number of lines
➜ Desktop head someoutput
hello
It seems that the contents of the file can also be sorted
➜ Desktop cat someoutput
yamada 100
tanaka 20
kanda 60
➜ Desktop sort someoutput
kanda 60
tanaka 20
yamada 100
➜ Desktop sort -r someoutput #r is reverse
yamada 100
tanaka 20
kanda 60
➜ Desktop sort -n -k 2 someoutput #n is the number k is the line
tanaka 20
kanda 60
yamada 100
--tar command (using | pipe)
➜ Desktop cat someoutput
yamada 100
tanaka 20
kanda 60
➜ Desktop cat someoutput | tr a A
yAmAdA 100
tAnAkA 20
kAndA 60
Output the changed thing to another file
➜ Desktop cat someoutput | tr a A > newsomeoutput
➜ Desktop cat newsomeoutput
yAmAdA 100
tAnAkA 20
kAndA 60
Options are essential. -n (unified)
is a familiar format
➜ Desktop diff -u someoutput newsomeoutput
--- someoutput 2020-01-02 03:02:12.000000000 +0900
+++ newsomeoutput 2020-01-02 03:12:35.000000000 +0900
@@ -1,3 +1,3 @@
-yamada 100
-tanaka 20
-kanda 60
+yAmAdA 100
+tAnAkA 20
+kAndA 60
I'm not so interested here. I wish I could edit and save
--Search /
--Replace
:1s/old/new/g
1 yamada 100
2 tanaka 20
3 kanda 60
:1s/yamada/nkanda/g
1 nkanda 100
2 tanaka 20
3 kanda 60
It has changed.
It seems that there is also conversion by searching the full text of the file.
Full text search
Full-text search with % s
:%s/melon/*MELON*/g
User type
--Group --User Minimum unit authority to use resources such as memory and files
--User created
ʻUseraddUsername * mac seems to be different
-g` group name
--Change user permissions
ʻUsermod` Username
--User deletion
ʻUserdel` username
--Group creation
groudadd
group name
Edit deletion is the same as the user, change only the first letter to group
In ʻetc / passwd`
--group file
The group is stored
etc/group
root
su
--chown user (group) directory --chown user (group) directory
#Changed to nobody
➜ Desktop ls -l user
-rw-r--r-- 1 username staff 0 1 2 03:44 user
➜ Desktop ls -l user
-rw-r--r-- 1 nobody staff 0 1 2 03:44 user
#I try to edit but I can't change it with readonly
➜ Desktop vi user
--chgrp group directory --chgrp group file
--There are three authorities. Read (r read), write (w write), execute (x exec?)
d rwx rwx rwx
From the left, file type, owning user (u), owning group (g), and others (o)
--Change command
chmod mode file
➜ Desktop ls -l user
-rw-r--r-- 1 username staff 0 1 2 03:55 user
#Add w permission to group Addition+
-rw-r--r-- 1 username staff 0 1 2 03:55 user
➜ Desktop chmod g+w user
➜ Desktop ls -l user
-rw-rw-r-- 1 username staff 0 1 2 03:55 user
#Remove w permission for group Add-
➜ Desktop chmod g-w user
➜ Desktop ls -l user
-rw-r--r-- 1 username staff 0 1 2 03:55 user
#Change in octal number This is 664 or something
➜ Desktop ls -l user
-rw-r--r-- 1 username staff 0 1 2 03:55 user
➜ Desktop chmod 664 user
➜ Desktop ls -l user
-rw-rw-r-- 1 username staff 0 1 2 03:55 user
The kernel has the function of operating the hardware in the basic part of the OS. Operate the OS when operating kernel functions. That is the shell
--Create
touch lsdata.sh
#!/bin/bash #Select the shell file to use
ls #The command you want to execute
date
--Execute
➜ Desktop sh lsdate.sh
Screenshot 2020-01-01 11.13.02.png #List
Performance improvement.md
Thursday, January 2, 2020 12:16:37 JST#The date comes out with date
--echo command (command to output the characters given as arguments as standard)
➜ Desktop echo message test
message test
--Variables
Can it be used like this in the terminal?
➜ Desktop abc=123 #Substitution is=Stick together
➜ Desktop echo $abc
123
--export command
export abc=345 #Set environment variables
--Check shell variables and environment variables
Shell variable set
Check environment variables ʻenv`
--Arguments Run-time arguments can be called with $ 1
etc.
➜ Desktop sh lsdate.sh hello yahoo
$1: hello
$2: yahoo
#The contents of the file
➜ Desktop cat lsdate.sh
# !/bin/bash
echo '$1:' $1
echo '$2:' $2
➜ Desktop sh lsdate.sh hello
The characters are the same
➜ Desktop cat lsdate.sh
# !/bin/bash
STR1='hello'
if [ $STR1 = $1 ]; then #When calling a variable$Put on
echo "The characters are the same"
fi
--Repeat, I want to see functions, etc.
It seems that there are many things to do at startup. The configuration may be divided into the main file and the separated function file.
#Constitution
etc/functions/Function file.sh
init.sh
#init.with sh
# !/bin/bash
.etc/functions/* #Read the function carved here
Add a x
option when running
➜ Desktop sh -x lsdate.sh
+ echo '$1:'
$1:
+ echo '$2:'
$2:
IP address and TCP (Transfer Control Protocol)
When sending data, it is delivered to the server by IP address, and the TCP port (22: ssh 80: application) determines where to deliver to the application.
--ping command
➜ Desktop ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
Request timeout for icmp_seq 0
--Route confirmation
➜ Desktop traceroute lpi.jp
traceroute to lpi.jp (3.112.116.66), 64 hops max, 52 byte packets
1 192.168.3.1 (192.168.3.1) 2.046 ms 2.912 ms 2.549 ms
2 * * *
3 softbank32432423432.bbtec.net (221.110.235.201) 43.241 ms 25.163 ms 29.019 ms
--ifconfig command
ʻInet` is the IP address https://www.atmarkit.co.jp/ait/articles/0109/29/news004.html
Recommended Posts