/etc/login.defs
passwd
chage

at
atq
atrm

at

systemd
systemd-journald

mail

ip

ping
traceroutetracepath

sudo

.
source/etc/bash.bashrc/etc/profile
env
exportset
unset~/.bash_profile~/.bash_login~/.profile

~/.bashrc~/.bash_logoutfunctionalias

/bin/bash--login<スクリプト>cat script.sh | ssh <ユーザー名>@<サーバー名>

tty

Ctrl
Ctrl

Alt

pty

Alt

F1

Ctrl

Alt

F6

F7

tty
pts
man

tty

man

pts

bash
bash

bash
bash
bash -lbash --login

bash -ibash --noprofile/etc/profile~/.bash_profile~/.bash_login~/.profile

bash --norc/etc/bash.bashrc~/.bashrc
bash --rcfile <file>/etc/bash.bashrc~/.bashrc<file>

su

sudo

su
root

su

-

user2

su user2

su

-l

user2

su

--login

user2

user2

user2

su - rootsu -su root

su

root
root

su

user2

root

sudo

sudoerssudo
wheel

sudoers

user2

sudo

root@debian:~# usermod -aG sudo user2

su

sudo

sudo

su

-

user2

sudo su user2
sudo -u user2 -s
sudo

su

-

root

sudo

su

-l

user2

sudo

user2
user2
sudo

su

-

root

su

--login

user2

user2

sudo -i

root

sudo

-i

<some_command>

sudo

su

root

sudo

-s

su

sudo

sudo

-u

root

su

root

root

-s

root

sudo

su
-c
-i

sudo
-s

su

sudo

su

echo $0

-bash

bash

/bin/bash<スクリプト名>

bash

ps

aux

|

grep

user2@debian:~$ ps aux | grep bash
user2

5270

0.1

0.1

25532

5664 pts/0

Ss

23:03

0:00 bash

user2

5411

0.3

0.1

25608

5268 tty1

S+

23:03

0:00 -bash

bash

user2

5452

0.0

0.0

16760

940 pts/0

S+

23:04

0:00 grep--color=auto bash

ps

TTY
TTY

COMMAND

pts

user2
TTY

Ctrl

Alt

tty1

user2

F1

grep

bash

TTY

bash

pts/0

user2

Ctrl

Alt

ps aux | grep bash

起動ファイル

/etc/
~
less

/etc/profile
sh

bash
if

PATH

PS1
/etc/profile/etc/bashrc/etc/profile.d/etc/profile.d/*/etc/profileF7

~/.bash_profile~/.bash_profile~/.profile~/.bash_login~/bash_profile~/.profile
PATH
~/bin

PATH
~/.bashrc~/.bash_logout
起動ファイル
終了ファイル/etc/profile/home/user2/.profile

root@debian:~# echo 'echo Hello from /etc/profile' >> /etc/profile
root@debian:~# echo 'echo Hello from ~/.profile' >> ~/.profile

>>

echo
ssh

user2

user2@debian:~$ ssh user2@192.168.1.6
user2@192.168.1.6's password:
Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Nov 27 19:57:19 2018 from 192.168.1.10
Hello from /etc/profile
Hello from /home/user2/.profile~/.profile~/.bash_profile~/.bash_login~/home/user2/.profile/etc/bash.bashrc
bash

bash
LINES

COLUMNS~/.bashrc
bash/etc/bash.bashrc~/.bash_aliases

/etc/bash.bashrc/home/user2/.bashrc

root@debian:~# echo 'echo Hello from /etc/bash.bashrc' >> /etc/bash.bashrc
root@debian:~# echo 'echo Hello from ~/.bashrc' >> ~/.bashrc

user2

user2@debian:~$ bash
Hello from /etc/bash.bashrc
Hello from /home/user2/.bashrc

bash

-l

--login/bin/bash#!
test.shecho'Hello from a script'

user2@debian:~$ echo "echo 'Hello from a script'" > test.shuser2@debian:~$ chmod +x ./test.sh

-l

bash

user2@debian:~$ bash -l ./test.sh

test.shHello from /etc/profile
Hello from /home/user2/.profile
Hello from a script/etc/profile~/.profile

echo

ssh

user2@debian:~$ echo "Hello-from-a-noninteractive-login-shell" | sshuser2@192.168.1.6
Pseudo-terminal will not be allocated because stdin is not a terminal.
user2@192.168.1.6's password:
Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Hello from /etc/profile
Hello from /home/user2/.profile-bash: line 1: Hello-from-a-noninteractive-login-shell: command not found/etc/profile~/.profile-bash

BASH_ENV/etc/profile/etc/bash.bashrc~/.bashrc~/.profileroot@debian:~# su - user2
Hello from /etc/bash.bashrc
Hello from /etc/profile
Hello from /home/user2/.bashrc
Hello from /home/user2/.profile

su

-

user2

Hello

from

/etc/bash.bashrc

Hello from /etc/profile

su

from

/home/user2/.bashrc

Hello

from

/home/user2/.profile<username>
su

su

-l

<username><username>/etc/bash.bashrc/etc/profile

Hello

-

/etc/profile~/.profile~/.bashrc~/.profilesu--login/etc/bash.bashrc<username>~/.bashrc.
.

.profile# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then. "$HOME/.bashrc"

fi

if

$HOME/.bashrc-f. "$HOME/.bashrc"

$HOME

.
~/.bashrc

user2@debian:~$ echo "alias hi='echo We salute you.'" >> ~/.bashrc>>>~/.bashrc

user2@debian:~$ tail -n 1 !$tail -n 1 ~/.bashrc
alias hi='echo We salute you.'!$~/.bashrc

user2@debian:~$ . ~/.bashrc

user2@debian:~$ hi
We salute you.

sourcesource.

~/.bashrc

user2@debian:~$ source ~/.bashrc

SKEL
skel

skel
/etc/adduser.conf

adduser
SKEL

user2@debian:~$ grep SKEL /etc/adduser.conf# The SKEL variable specifies the directory containing "skeletal" user
SKEL=/etc/skel# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching thisSKEL_IGNORE_REGEX="dpkg-(old|new|dist|save)"

SKEL/etc/skel/etc/skel

user2@debian:~$ ls -a /etc/skel/.

..

.bash_logout.bashrc.profile.
ls -amy_personal_scripts

root/etc/skel/etc/skel

root@debian:~# cd /etc/skel/

root@debian:/etc/skel#

root@debian:/etc/skel# ls -a.

..

.bash_logout.bashrc.profileroot@debian:/etc/skel# mkdir my_personal_scripts
root@debian:/etc/skel# ls -a.

..

.bash_logout

user2.bashrc

my_personal_scripts.profile

home

root@debian:~# deluser --remove-home user2
Looking for files to backup/remove ...
Removing files ...
Removing user `user2' ...
Warning: group `user2' has no more members.
Done.

user2

root@debian:~# adduser user2
Adding user `user2' ...
Adding new group `user2' (1001) ...
Adding new user `user2' (1001) with group `user2' ...
Creating home directory `/home/user2' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for user2
Enter the new value, or press ENTER for the default
Full Name []:Room Number []:Work Phone []:Home Phone []:Other []:

Is the information correct? [Y/n] yuser2/home/user2

root@debian:~# su - user2
user2@debian:~$ pwd/home/user2
user2@debian:~$ ls -a.

..

.bash_history

my_personal_scripts.bash_logout.bashrc

my_personal_scripts.profileecho $0
ssh user2@machine2
Ctrl

Alt

F2

su - user2

echo $0
test.sh

su

user2
su
sudo
root
su
sudo
root
su
sudo
user2
su
sudo

sudo

/etc/profile
user2

root

root

user2

/etc/bash.bashrc ~/.profile~/.bashrc

Helloworld!

function hello() {echo "Hello world!"
}

user2

root

Hello_world!

#!/bin/bash#hello_world: a simple bash script to discuss interaction in scripts.
echo "Hello world!"~/.bashrc

tty.bash_login~/.bash_login

bash

su

Alt

sudo
F1

Ctrl
F6

tty

echo $0~/.bash_profile~/.profile~/.bash_login~/.bashrc~/.bash_logout/etc/profile/etc/bash.bashrc

>
skel

bash

su

sudo

usermodecho>>/etc/profile.d/*

ps

less

ssh

chmod

grep

ls

cd

mkdir

deluseradduser.

sourcetailecho $0
ssh user2@machine2
Ctrl

Alt

-bash
-bash

F2

su - user2

-su
bash
/bin/bash./test.shecho $0
test.sh

su

sudo

user2
su
su - user2

su -l user2 su --login user2

sudo
sudo su - user2

sudo su -l user2

rootsusu - root

su -

sudo
sudo su - root

sudo su -root
su
su rootsusudo -isudo su --login user2

sudo
sudo su root

sudo susudo -ssudo -u root -s

user2
su
su user2
sudo
sudo su user2

sudo -u user2 -s/etc/profile
user2

root

root

user2

/etc/bash.bashrc ~/.profile~/.bashrc

Helloworld!

function hello() {echo "Hello world!"
}

user2

/home/user2/.bashrc

root/root/.bashrc

Hello_world!

#!/bin/bash#hello_world: a simple bash script to discuss interaction in scripts.
echo "Hello world!"

~/.bashrc$ source .bashrc$ . .bashrc

tty
Ctrl

Alt

F1

Ctrl

Alt

F6

/etc/profile/home/john/.profile.bash_login~/.bash_login/etc/skel.bash_login

<変数名>=<値>

$ distro=zorinos

distrozorinoszorinos

distro$ distro =zorinos-bash: distro: command not found$ distro= zorinos-bash: zorinos: command not found

distrozorinos$$ echo $distro
zorinosa-z$ distro=zorinos$ echo $distro
zorinos$ DISTRO=zorinos$ echo $DISTRO
zorinos$ distro_1=zorinos$ echo $distro_1
zorinos$ _distro=zorinos$ echo $_distro

A-Z

0-9

_

echo

zorinos$ 1distro=zorinos-bash: 1distro=zorinos: command not found$ "my distro"=zorinos-bash: my: command not found$ my_distro=zorinos$ echo $my_distro
zorinos

a-z

A-Z

0-9

?

!

$ distro=zorin12.4?
$ echo $distro
zorin12.4?

$ distro=zorin 12.4
-bash: 12.4: command not found$ distro="zorin 12.4"$ echo $distro
zorin 12.4
$ distro='zorin 12.4'$ echo $distro
zorin 12.4

<

>

|

*

.

/

zori
n

$ distro=>zorin$ echo $distro$ ls zorin
zorin$ distro=">zorin"$ echo $distro>zorin$ lizard=uromastyx$ animal='My $lizard'$ echo $animal
My $lizard$ animal="My $lizard"$ echo $animal
My uromastyx

echo$ lizard="

genus

|

uromastyx"$ echo $lizard
genus | uromastyx$ echo "$lizard"
genus

|

uromastyx

history

$ distro=zorin.?/!os-bash: !os: event not found$ distro=zorin.?/!
$ echo $distro
zorin.?/!

$ distro=zorinos\>$ distro=zorinos\\$ echo $distro
zorinos\$ reptile=tortoiseecho$ echo $reptile
tortoisereadonly

$ readonly reptile=tortoise$ reptile=tortoise$ readonly reptile

reptile$ reptile=lizard-bash: distro: readonly variablereadonly

readonly -p
set

set
less

$ set | less
BASH=/bin/bash
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:fo
rce_fignore:histappend:interactive_comments:login_shell:progcomp:promptvars:sourcep
ath
BASH_ALIASES=()BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="1" [4]="release" [5]="x86_64-pc-linuxgnu")
BASH_VERSION='4.4.12(1)-release'(...)

reptile$ set | grep reptile
reptile=tortoise

reptile$ bash$ set | grep reptile$$ echo $reptile
$

bash

unset

$ echo $reptile
tortoise$ unset reptile$ echo $reptile
$

unset

$ echo $SHELL/bin/bash$

$ my_shell=$SHELL$ echo $my_shell/bin/bash$ your_shell=$my_shell$ echo $your_shell/bin/bash$ our_shell=$your_shell$ echo $our_shell/bin/bash

export$ export reptile

exportreptile$ bash$ echo $reptile
tortoiseexport$ export amphibian=frog$ bash$ echo $amphibian
frog

export-n<環境変数名>export-p$ export
declare -x HOME="/home/user2"
declare -x LANG="en_GB.UTF-8"
declare -x LOGNAME="user2"(...)
declare -x PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
declare -x PWD="/home/user2"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"declare -x SSH_CLIENT="192.168.1.10 49330 22"
declare -x SSH_CONNECTION="192.168.1.10 49330 192.168.1.7 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="xterm-256color"declare -x USER="user2"
declare -x XDG_RUNTIME_DIR="/run/user/1001"
declare -x XDG_SESSION_ID="8"declare -x reptile="tortoise"

declare -x

exportenv

printenv$ env
SSH_CONNECTION=192.168.1.10 48678 192.168.1.7 22
LANG=en_GB.UTF-8
XDG_SESSION_ID=3
USER=user2
PWD=/home/user2
HOME=/home/user2
SSH_CLIENT=192.168.1.10 48678 22
SSH_TTY=/dev/pts/0
MAIL=/var/mail/user2
TERM=xterm-256color
SHELL=/bin/bash
SHLVL=1
LOGNAME=user2
XDG_RUNTIME_DIR=/run/user/1001
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games_=/usr/bin/env

printenv

env

echo

$ echo $PWD
/home/user2$ printenv PWD/home/user2

printenv

$
PWD

env

-i

env

$ env -i bash

$ echo $USER$$ env
LS_COLORS=PWD=/home/user2
SHLVL=1_=/usr/bin/printenv

env

BASH_ENV.startup_script

CROCODILIAN=caiman

test_env.sh#!/bin/bash
echo $CROCODILIAN

test_env.sh$ chmod +x test_env.sh

env

BASH_ENV.startup_script

test_env.sh$ env BASH_ENV=/home/user2/.startup_script ./test_env.sh
caiman

env

env
env

-i

env

$ BASH_ENV=/home/user2/.startup_script ./test_env.sh
caimantest_env.sh#!/bin/bash./some_script

chmod

+x

DISPLAY

localhost0$ printenv DISPLAY:0

my.xserver:0:1

HISTCONTROLHISTFILE

ignorespace

ignoredups

ignoreboth$ echo $HISTCONTROL
ignoreboth

HISTSIZE$ echo $HISTSIZE

1000

HISTFILESIZEHISTFILE$ echo $HISTFILESIZE
2000

HISTFILE~/.bash_history$ echo $HISTFILE/home/user2/.bash_history

HISTFILE

historyhistory3

history
HOME~/.profile# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then. "$HOME/.bashrc"
fi

if

~

$HOME

$ echo ~; echo $HOME/home/carol"$HOME/.bashrc"

/home/carol;if$ if [ ~ == "$HOME" ]; then echo "true"; else echo "false"; fi
true=

HOSTNAME$ echo $HOSTNAME
debianHOSTTYPE$ echo $HOSTTYPE
x86_64LANG$ echo $LANG
en_UK.UTF-8

LD_LIBRARY_PATH$ echo $LD_LIBRARY_PATH/usr/local/lib

==

MAIL

$ echo $MAIL/var/mail/carol/var/spool/mail/$USER
MAILCHECK$ echo $MAILCHECK
60

PATH

/etc/profile

if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"fiexport PATH

if

root
PATH

PATH

export

PATH

PATH

(...)
else

/usr/local/sbinPATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sb
in"fi
export PATH

# su - carol$ echo $PATH/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin

PATH/usr/local/sbin
PATH=/usr/local/sbin:$PATH

PATH=$PATH:/usr/local/sbin/usr/local/sbin

PS1/etc/profile

if
root

#

$

if [ "`id -u`" -eq 0 ]; then
PS1='# 'else
PS1='$ '
fi

root

id

0

root

id

-u

PS2
>

PS3
select

PS4
+
SHELL

$ echo $SHELL/bin/bash

USER$ echo $USER
carol

debian=motherubuntu=deb-based
mint=ubuntu-based; export
mint
export suse=rpm-based
zorin=ubuntu-basedecho $HISTCONTROL

ignorebothecho ~/home/carolecho $DISPLAY

reptilium:0:2

echo $MAILCHECK

60

echo $HISTFILE/home/carol/.bash_history

lizard =chameleon
cool
lizard=chameleon
lizard=cha|me|leon
lizard=/** chameleon**/
win_path=C:\path\to\dir\es_ES.UTF-8

ssh/home/carol/scripts
PATH
my_pathPATH

my_pathPATH

mammalgnu

ver_sub

mammal$var_sub

The

value

of

echo

mammalisgnu

mammal

set

grep

env

penguinmammalgrep

mammalBIRD

yellow-eyeduser2

penguin

NEW_BIRDbin

~/bin

bash

PATH

PATH

~/.profile

if

let
let
your_val
10

your_val

my_val5

music_info

music_info(){latest_music=`ls -t ~/Music | head -n 5`
echo -e "Your latest 5 music files:\n$latest_music"
}

ls
echo

-t

~/Music

|

head

-n

5

latest_musiclatest_music=`ls -t ~/Music | head -n 5`

latest_music=$(ls -t ~/Music| head -n 5)

latest_music="(ls -t ~/Music| head -n 5)"

latest_musicMusiclatest_music=((ls -t ~/Music| head -n 5))

ローカル

グローバル

環境

exportDISPLAY
HOSTNAME

HOSTTYPE

LANG

SHELL
~
if

echo

ls

readonly

set

grep

bash

HISTCONTROL

LD_LIBRARY_PATHUSER

HISTSIZEMAIL

HISTFILESIZE

MAILCHECKPATHHISTFILE
PS1

HOME

unsetexportenv

printenv

chmod

historysu

iddebian=motherubuntu=deb-based
mint=ubuntu-based; export
mint
export suse=rpm-based
zorin=ubuntu-basedecho $HISTCONTROL

ignoreboth
historyecho ~/home/carol

carol

HOME

/home/carolecho $DISPLAY

reptilium:0:2

echo $MAILCHECK

60

echo $HISTFILE/home/carol/.bash_history

reptilium

history/home/carol/.bash_history

lizard =chameleon

lizard=chameleon

echo $lizard

cool

cool_lizard=chameleo echo $cool_lizard

lizard=chameleonnchameleon
chameleon

lizard=cha|me|leon

lizard="cha|me|leon" echo $lizard

cha|me|leon

lizard='cha|me|leon'
lizard=/** chameleon lizard="/**

echo "$lizard"/** chamelon **/win_path=C:\path\to\ win_path=C:\\path\\t echo $win_path

C:\path\to\dir\**/chameleon **/"
lizard='/**
chameleon **/'

dir\o\\dir\\

LANG=es_ES.UTF-8
es_ES.UTF-8
echo $PWD

pwd

echo $SSH_CONNECTION

ssh

PATH=$PATH:/home/carol/scripts/home/carol/scripts
PATH
my_pathPATH

my_path=PATH

my_pathPATH

my_path=$PATH

mammalgnu

mammal=gnu

ver_sub$var_submammalThe

value

var_sub="The value of mammal is $mammal"

mammalexport mammalofmammal

echo
is

gnu

set

grep

mammalset | grep mammal

env

grep

mammalenv | grep mammal

penguin

BIRD*BIRD=penguin; export BIRD*

yellow-eyed

penguin

NEW_BIRD

export NEW_BIRD="yellow-eyed penguin"export NEW_BIRD='yellow-eyed penguin'user2

mkdir ~/binmkdir /home/user2/bin

mkdir $HOME/binbin

~/binbash

PATH

PATH="$HOME/bin:$PATH"

PATH=~/bin:$PATH

PATH=/home/user2/bin:$PATH

PATH

if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"fi~/.profile

if

let
let
your_val
10

let "my_val = 5 + 5"

let 'my_val = 5 + 5'

your_val

my_val5

let "your_val = $my_val / 2"

let 'your_val = $my_val / 2'music_info

music_info(){latest_music=`ls -t ~/Music | head -n 5`
echo -e "Your latest 5 music files:\n$latest_music"
}

ls
echo

-t

~/Music

|

head

-n

6

latest_musiclatest_music=`ls -t ~/Music | head -n 5`

latest_musicMusiclatest_music=$(ls -t ~/Music| head -n 5)aliasalias alias_name=command(s)$ alias oldshell=sholdshellsh$ oldshell$$ alias ls='ls --color=auto'ls

dir_colors(5);dircolors(1)git$ alias git_info='which git;git --version'$ git_info/usr/bin/git
git version 2.7.4

alias$ aliasalias git-info='which git;git --version'
alias ls='ls --color=auto'
alias oldshell='sh'unaliasunaliasgit_info

$ unalias git-info$ aliasalias ls='ls --color=auto'
alias oldshell='sh'alias

hi='echoWe

saluteyou.'$ alias greet='echo Hello world!'$ greetHello world!

$ alias ll='ls -al'

ll

-a

-l
'

$ reptile=uromastyx$ alias greet='echo Hello $reptile!'$ greetHello uromastyx!

$ alias greet='reptile=tortoise; echo Hello $reptile!'$ greetHello tortoise!

\$ alias where?='echo $PWD'$ where?
/home/user2

$ \where?
-bash: where?: command not found$ where?
/home/user2$ alias my_home=where?
$ my_home/home/user2$ alias where?='echo $PWD'$ where?
/home/user2$ cd Music$ where?
/home/user2/Music$ alias where?="echo $PWD"$ where?
/home/user2$ cd Music$ where?
/home/user2

~/.bashrc#$ grep alias .bashrc# enable color support of ls and also add handy aliases
alias ls='ls --color=auto'#alias dir='dir --color=#alias vdir='vdir --color=#alias grep='grep --color=#alias fgrep='fgrep --color'#alias egrep='egrep --color=# some more ls aliases#ll='ls -al'#alias la='ls -A'#alias l='ls -CF'
# ~/.bash_aliases, instead of adding them here directly.
if [ -f ~/.bash_aliases ]; then. ~/.bash_aliasesfi~/.bash_aliases.bashrc############ .bash_aliases:# a file to be populated by the user's personal aliases (and sourced by ~/.bashrc).
###########
alias git_info='which git;git --version'
alias greet='echo Hello world!'
alias ll='ls -al'alias where?='echo $PWD'

functionfunctionfunction function_name {command #1
command #2
command #3.
.
.
command #n}()function{}function_name() {command #1
command #2
command #3.
.
.
command #n}

PS2$ greet() {> greeting="Hello world!"> echo $greeting> }>$ greet() { greeting="Hello world!"; echo $greeting; }bash$ greetHello world!

/etc/bash.bashrc~/.bashrc.

source$?
0$ ps aux | grep bash
user2

420

0.0

0.4

21156

5012 pts/0

Ss

17:10

0:00 -bash

user2

640

0.0

0.0

12784

936 pts/0

S+

18:04

0:00 grep bash

$ echo $?
00

user1@debian:~$ ps aux |rep bash
-bash: rep: command not founduser1@debian:~$ echo $?

127

$$

$ ps aux | grep bash
user2

420

0.0

0.4

21156

5012 pts/0

Ss

17:10

0:00 -bash

user2

640

0.0

0.0

12784

936 pts/0

S+

18:04

0:00 grep bash

$ echo $$420$!

$ ps aux | grep bash &[1] 663$ user2
user2

420
663

0.0
0.0

0.4
0.0

21156
12784

5012 pts/0

Ss+

972 pts/0

S

17:10
18:08

0:00 -bash
0:00 grep bash

^C
[1]+

Done

ps aux | grep bash

$ echo $!
663

&
$0

$9
$0

PS2

$ special_vars() {> echo $0> echo $1> echo $2> echo $3}

debianubuntuzorin

special_vars>

$ special_vars debian ubuntu zorin-bash
debianubuntuzorin$ alias great_editor='echo $1 is a great text editor'$ great_editor emacs
is a great text editor emacs

$#

$@

$*

$_
man

funed

editors() {editor=emacs
echo "My editor is: $editor. $editor is a fun text editor."}bash

$ . funed$ editors
My editor is emacs. emacs is a fun text editor.

editors

editor$ echo $editor
emacs

editors() {editor=emacs
echo "The text editor of $USER is: $editor."}
editors

editors$ . funed
The text editor of user2 is: emacs.

editors
tortoiseeditors() {editor=emacs
echo "The text editor of $USER is: $editor."echo "Bash is not a $1 shell."}
editors tortoise$ . funed
The text editor of user2 is: emacs.
Bash is not a tortoise shell.

editors() {editor=emacs
echo "The text editor of $USER is: $editor."echo "Bash is not a $1 shell."}$ . funed

tortoise$1$ editors tortoise
The text editor of user2 is: emacs.
Bash is not a tortoise shell.

funed

funed.sh#!/bin/bash
editors() {editor=emacs
echo "The text editor of $USER is: $editor."echo "Bash is not a $1 shell."}
editors tortoise

シバン

シェバン
bash

#!/bin/bash$ chmod +x funed.sh$ ./funed.sh
The text editor of user2 is: emacs.
Bash is not a tortoise shell.

$ alias great_editor='gr8_ed() { echo $1 is a great text editor; unset -f gr8_ed;}; gr8_ed'

gr8_ed()

{

echo

$1

is

a

great

text

editor;unset

gr8_ed; }
unset

-f

gr8_edbash

gr8_edgr8_ed$ great_editor emacs
emacs is a great text editor

unset

-f

gr8_edunset

unset -v

unset -f

unset

user2

user2

$HOME/Video

Matroska/home/user2/.bashrc
check_vids.mkv

check_vids() {ls -1 ~/Video/*.mkv > /dev/null 2>&1
if [ "$?" = "0" ];thenecho -e "Remember, you must not keep more than 5 video files in your Video
folder.\nThanks."

-f

else
echo -e "You do not have any videos in the Video folder. You can keep up to
5.\nThanks."fi}check_vids~/Videomkv/dev/null

editors

editors() {editor=emacs
echo "Hi, $USER!"
echo "$editor is more than a text editor!"check_vids}
editors

editors

check_vids

editorsuser2# su - user2
Hi, user2!
emacs is more than a text editor!
Remember, you must not keep more than 5 video files in your Video folder.
Thanks.

\~/Music

ogg

logg

logg

logg

b

bash

bash_info

which bash

echo"$BASH_VERSION"
kernel_info

uname -rgreet

echo Hi, $USER!

computerpc=slimbook

echo My

computer is a $pc
root/etc/bash.bashrc

user2

special_vars$ special_vars2() {> echo $#> echo $_> echo $1> echo $4> echo $6> echo $7> echo $_> echo $@> echo $?
> }my_fun$ special_vars2 crying cockles and mussels alive alive ohecho $#
echo $_
echo $1
echo $4
echo $6
echo $7
echo $_
echo $@
echo $?
関数内の関数check_vids
check_music~/Music
ogg
7
music

my_fun
PS1

PS1
fyi

<user>@<host-date>

;

$?
$_

bash

alias

unaliascd

grep

function

$$

$!

$0

$9

$#

$@

$*

.

source

ps

echo

chmod

unset

su

\

alias

~/Musicogg

alias logg='ls -1 ~/Music/*ogg'

logg

alias logg='echo $USER:; ls -1 ~/Music/*ogg'

logg

logg

aliasunalias logg

b

bash

bash_info

which bash

kernel_info

alias b=bash
echoalias bash_info='which"$BASH_VERSION"

bash; echo "$BASH_VERSION"'

uname -ralias kernel_info='uname
-r'

greet

echo Hi, $USER!

alias greet='echo Hi,$USER'

computerpc=slimbook

echo My

computer is a $pc

root/etc/bash.bashrc

my_fun() {echo Hello, $USER!
echo Your path is: $PATH}
my_funfunction my_fun {echo Hello, $USER!
echo Your path is: $PATH}

my_funalias
computer='pc=slimbook; echo
My computer is a $pc'

my_funuser2

su - user2

my_fun() { echo "Hello, $USER!"; echo "Your path is: $PATH"; }function my_fun { echo "Hello, $USER!"; echo "Your path is: $PATH"; }my_fununset -f my_fun

special_vars$ special_vars2() {> echo $#> echo $_> echo $1> echo $4> echo $6> echo $7> echo $_> echo $@> echo $?
> }$ special_vars2 crying cockles and mussels alive alive ohecho $#

7echo $_

7echo $1

cryingecho $4

musselsecho $6

alive

echo $7ohecho $_ohecho $@

crying cockles and mussels alive alive ohecho $?

0関数内の関数check_vids
check_music~/Music
ogg
7
music

check_music() {ls -1 ~/$1/*.$2 > ~/.mkv.log 2>&1
if [ "$?" = "0" ];thenecho -e "Remember, you must not keep more than $3 $4 files in your
$1 folder.\nThanks."elseecho -e "You do not have any $4 files in the $1 folder. You cankeep up to $3.\nThanks."fi}check_music Music ogg 7 musicmy_funreadonly -f my_fun

PS1

readonly -f
PS1

fyi

<user>@<host-date>fyi() {
echo -e "For your Information:\nUsername: $USER
Home directory: $HOME
Host: $HOSTNAME
Operating System: $OSTYPE
Path for executable files: $PATH
Your mail directory is $MAIL and is searched every $MAILCHECK seconds.
The current level of your shell is: $SHLVL"
PS1="\u@\h-\d "
}
fyi

for
while
test
if
read
seq
exec

||
&&

#!
#!/bin/bash/bin/bash##!/bin/bash# A very simple script
echo "Cheers from the script file! Current time is: "date +%H:%M/bin/bash
echo

date
script.sh$ bash script.sh
Cheers from the script file! Current time is:
10:57

echo

-n
echo

-n

$ bash script.sh
Cheers from the script file! Current time is: 10:57.sh#!
#!/usr/bin/python#!/usr/bin/perl#!/usr/bin/awk

chmodo+r

script.shbash
script.shchmod$ chmod +x script.sh

script.sh./script.shPATHecho "Cheers from the script file! Current time is:" ; date +%H:%M

sourcescript.sh.

script.sh$?
exec

SOLUTION=42

SOLUTION

42

0

*

?

$*

$@
"$@"

$#

$0

$!

$$

$?
0

0

$1
$2
${10}

read

${11}

echo "Do you want to continue (y/n)?"read ANSWERANSWERREPLY

readecho "Type your first name and last name:"read NAME SURNAMENAMESURNAME
read

-p
echo

read -p "Type your first name and last name:" NAME SURNAME$ OS=`uname -o`uname$ OS=$(uname -o)#$ OS=$(uname -o)$ echo $OS
GNU/Linux$ echo ${#OS}
9

-o

OS

$()

declare
SIZES$ declare -a SIZES$ SIZES=( 1048576 1073741824 )SIZES${SIZES[0]}${SIZES[1]}$ echo ${SIZES[0]}1048576$ echo ${SIZES[1]}1073741824

SIZES[0]=1048576
SIZES${#SIZES[0]}@*$ echo ${#SIZES[@]}2$ echo ${#SIZES[*]}2$ FS=( $(cut -f 2 < /proc/filesystems) )

cut

-f

2

<

/proc/filesystems
FS/proc/filesystems

$IFS
IFS=$'\n'

expr
$VAL1

$VAL2

$ SUM=`expr $VAL1 + $VAL2`

$SUM

expr
SUM=$((

$VAL1

+

$VAL2

$(())

))
SIZES=(

10485761073741824)

SIZES=( $((1024**2)) $((1024**3)) )/proc/meminfo$ FREE=$(( 1000 * `sed -nre '2s/[^[:digit:]]//gp' < /proc/meminfo` ))sed/proc/meminfo/proc/meminfo

&&
0

&&

COMMAND A && COMMAND B && COMMAND C

||
||

if
test
if

test

/bin/bash
Confirmed:/bin/bashisexecutable.

if test -x /bin/bash ; thenecho "Confirmed: /bin/bash is executable."
fi

test

-x
test
]

[

[
test

if [ -x /bin/bash ] ; thenecho "Confirmed: /bin/bash is executable."
fi

else

if

if [ -x /bin/bash ] ; thenecho "Confirmed: /bin/bash is executable."elseecho "No, /bin/bash is not executable."
fi

if

fi

echo
-e

#!/bin/bash# Get the operating system's generic name
OS=$(uname -o)# Get the amount of free memory in bytes
FREE=$(( 1000 * `sed -nre '2s/[^[:digit:]]//gp' < /proc/meminfo` ))echo -e "Operating system:\t$OS"
echo -e "Unallocated RAM:\t$(( $FREE / 1024**2 )) MB"

echo

-e
echo
\t

Operating system:

GNU/Linux

Unallocated RAM:

1491 MB\nechoecho -e "Operating system:\t$OS\nUnallocated RAM:\t$(( $FREE / 1024**2 )) MB"

echo
printfprintfprintf

printf "Operating system:\t%s\nUnallocated RAM:\t%d MB\n" $OS $(( $FREE / 1024**2
))

%s

$OS

%d
printf\n

printfprintfman printf

printf

MSG='Operating system:\t%s\nUnallocated RAM:\t%d MB\n'printf "$MSG" $OS $(( $FREE / 1024**2 ))

read

-s
read
PASSWORD

whoamiwhoami

apt-getWHO

dist-upgrade

apt-getdist-upgrade

systemctl
systemctl

rebootrebootbash: ./script.sh: Permission denied./script.sh

do.sh

undo.shdo.shundo.shmail -s "Maintenance Error" root <<<"Scheduled task error"

mail

||
echo
chmod
exec
read
declaretest
ifprintf

&&

read

-s
read
PASSWORD

read -s PASSWORD
whoamiwhoamiWHO=`whoami`
apt-getWHO=$(whoami)

dist-upgrade

apt-get&&WHO

dist-upgrade

systemctl
systemctl

rebootapt-get dist-upgrade && systemctl reboot

rebootbash: ./script.sh: Permission denied./script.sh./script.sh
do.sh

undo.shdo.shundo.sh$0

mail -s "Maintenance Error" root <<<"Scheduled task error"

mail
if [ "$?" -ne 0 ]; then mail -s "Maintenance Error" root <<<"Scheduled task error";
fi

test

test

test

test
/etc
test

-d

/etc

[

-d

/etc

]

[

]

$ test -d /etc
$ echo $?
0$ [ -d /etc ]$ echo $?
0

$?
/etc
$VAR
test
-a "$VAR"
VAR-e-b "$VAR"
VAR-c "$VAR"
VAR-d "$VAR"
VAR-e "$VAR"
VAR-a-f "$VAR"
VAR-g "$VAR"
VAR-h "$VAR"
VAR-L

-L "$VAR"
VAR-h-k "$VAR"
VAR-p "$VAR"
VAR-r "$VAR"
VAR-s "$VAR"
VAR-S "$VAR"
VAR-t "$VAR"
VAR-u "$VAR"
VAR-w "$VAR"
VAR-x "$VAR"
VAR-O "$VAR"
VAR-G "$VAR"
VAR-N "$VAR"
VAR"$VAR1" -nt "$VAR2"
VAR1

VAR2

"$VAR1" -ot "$VAR2"
VAR1

VAR2

"$VAR1" -ef "$VAR2"
VAR1

VAR2

-z "$TXT"
TXT-n "$TXT"

test "$TXT"

TXT"$TXT1" = "$TXT2"
TXT1"$TXT1" == "$TXT2"TXT2"$TXT1" != "$TXT2"
TXT1

TXT2

"$TXT1" < "$TXT2"
TXT1

TXT2

"$TXT1" > "$TXT2"
TXT1

TXT2

LANG

C

LANG=C$NUM1 -lt $NUM2
NUM1

NUM2

lt

$NUM1 -gt $NUM2
NUM1

NUM2

gt

$NUM1 -le $NUM2
NUM1

NUM2

le

$NUM1 -ge $NUM2
NUM1

NUM2

ge

$NUM1 -eq $NUM2
NUM1

NUM2

$NUM1 -ne $NUM2
NUM1

NUM2

! EXPR
EXPR
EXPR1 -a EXPR2
EXPR1

EXPR2

EXPR1 -o EXPR2

if

case

case
case

case

#!/bin/bash
DISTRO=$1
echo -n "Distribution $DISTRO uses "case "$DISTRO" indebian | ubuntu | mint)echo -n "the DEB";;
centos | fedora | opensuse )echo -n "the RPM";;*)
echo -n "an unknown"

)

|

;;
esac
echo " package format."

;;

:&

::&

*
case

esac

script.shcaseopensuse$ ./script.sh opensuse
Distribution opensuse uses the RPM package format.

case

test
nocasematch
shopt

-s

shopt

-u

shopt
case

-s

nocasematch

shopt

for

for

for

for VARNAME in LIST
do
COMMANDS
done

VARNAME

LIST
LIST

IFS
do

done
NUM

#!/bin/bash
for NUM in 1 1 2 3 5 8 13
doecho -n "$NUM is "if [ $(( $NUM % 2 )) -ne 0 ]thenecho "odd."
else
echo "even."
fi
done

if

NUM
script.sh$ ./script.sh
1 is odd.

until

while

1 is odd.
2 is even.
3 is odd.
5 is odd.
8 is even.
13 is odd.

for#!/bin/bash
SEQ=( 1 1 2 3 5 8 13 )for (( IDX = 0; IDX < ${#SEQ[*]}; IDX++ ))doecho -n "${SEQ[$IDX]} is "if [ $(( ${SEQ[$IDX]} % 2 )) -ne 0 ]thenecho "odd."
else
echo "even."
fi
done

NUM

IDX
IDX

IDX

=

0

IDX++

until

IDX

<

${#SEQ[*]}

test
until

#!/bin/bash
SEQ=( 1 1 2 3 5 8 13 )IDX=0
until [ $IDX -eq ${#SEQ[*]} ]doecho -n "${SEQ[$IDX]} is "if [ $(( ${SEQ[$IDX]} % 2 )) -ne 0 ]thenecho "odd."
else
echo "even."fi
IDX=$(( $IDX + 1 ))
done

until

for

while
until

until
[

$IDX

-eq

test

${#SEQ[*]}

IDX

]

while

while

[

$IDX

-lt

${#SEQ[*]}

SEQ~/.sync.list$ cat ~/.sync.list
Documents
To do
Work
Family Album.config.ssh.bash_profile.vimrc]mapfile
sync.sh#!/bin/bash
set -ef# List of items to sync
FILE=~/.sync.list# Origin directory
FROM=$1# Destination directory
TO=$2# Check if both directories are valid
if [ ! -d "$FROM" -o ! -d "$TO" ]thenecho Usage:
echo "$0 <SOURCEDIR> <DESTDIR>"
exit 1fi# Create array from filemapfile -t LIST < $FILE# Sync itemsfor (( IDX = 0; IDX < ${#LIST[*]}; IDX++ ))doecho -e "$FROM/${LIST[$IDX]} \u2192 $TO/${LIST[$IDX]}";rsync -qa --delete "$FROM/${LIST[$IDX]}" "$TO";
done

set
-e
-f
-ef

FILE
~/.sync.list

FROM

TO
[ ! -d "$FROM" -o ! -d "$TO" ]mapfile

-t

LIST

<

$FILE

-t
$FILE

for

IDX

LIST
echo

\u2192

-e

rsync
-q
-a
--deletecarol.rsync.list/media/carol/backup$ sync.sh /home/carol /media/carol/backup/home/carol/Documents → /media/carol/backup/Documents/home/carol/"To do" → /media/carol/backup/"To do"/home/carol/Work → /media/carol/backup/Work/home/carol/"Family Album" → /media/carol/backup/"Family Album"/home/carol/.config → /media/carol/backup/.config/home/carol/.ssh → /media/carol/backup/.ssh/home/carol/.bash_profile → /media/carol/backup/.bash_profile

/home/carol/.vimrc → /media/carol/backup/.vimrc.sync.list
carol
script.shPATH/usr/local/bin

test

FROM

#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]doecho $COUNTER
done

carol
Dave
emma
Frank
Grace
henry

Dave
Frank
Grace
carol
emma
henry

TO

test 1 > 2

test
if

if

case

case
for

test

if

case

for

until

while

until

while

test

FROM

test

"$FROM"

-nt

TO

"$TO"

FROM

TO

#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]doecho $COUNTER
done

COUNTER
))

done

carol
Dave
emma
Frank
Grace
henry

Dave
Frank
Grace
carol
emma
henry

COUNTER=$(( $COUNTER + 1

LANG

C

PARAMS=($*)

PARAMS=("$@")

PARAMS

test 1 > 2>
test

OLDIFS=$IFS>

OLDIFSIFS

IFS=$'\n'IFS=$OLDIFS

IFS/etc/X11/xorg.conf/etc/X11/xorg.conf.d/~/.xsession-errors
xhost
xauth
DISPLAYX

libXrandr

libXcursor

libX11hostname:displaynumber.screennumber

hostname

displaynumber0
displaynumber
screennumber

0

DISPLAY$ echo $DISPLAY:0libxkbfile

0

:0
:0.0
:0.1

DISPLAY$ DISPLAY=:0.1 firefox &gtk-options(7)--screen--display

/etc/X11/xorg.conf
xorg.conf
xorg.conf
SectionSectionEndSection

xorg.conf
InputDevice

InputClass/etc/X11/xorg.conf.d/

InputClass/etc/X11/xorg.conf.d/00-keyboard.conf

Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"Option "XkbLayout" "us"Option "XkbModel" "pc105"
EndSection

XkbLayout
XkbModelxkeyboard-config(7)/usr/share/X11/xkb

Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"Option "XkbLayout" "gr(polytonic)"
Option "XkbModel" "chromebook"
EndSection

setxkbmap

$ setxkbmap -model chromebook -layout "gr(polytonic)"/etc/X11/xorg.conf.d/00-keyboard.conf

setxkbmap

systemd

localectl/etc/X11/xorg.conf.d/00-keyboard.conf
localectl$ localectl --no-convert set-x11-keymap "gr(polytonic)" chromebook

localectl--no-convert
MonitorMonitorSection "Monitor"
Identifier"DP2"

Option"Primary" "true"

EndSection

DeviceDeviceSection "Device"Identifier"Device0"

Driver"i915"

BusID"PCI:0:2:0"

EndSection

ScreenScreenMonitorDeviceScreenSection "Screen"
Identifier "Screen0"
Device"Device0"

Monitor"DP2"

EndSection

ServerLayout
ServerLayout

Section "ServerLayout"
Identifier"Layout-1"

Screen"Screen0" 0 0

InputDevice"mouse1"

InputDevice"system-keyboard""CorePointer""CoreKeyboard"

EndSection/etc/X11/xorg.conf.d//usr/share/X11/xorg.conf.d//etc/X11/xorg.conf.d//etc/X11/xorg.conf

xdpyinfo$ xdpyinfo
name of display::0

version number:

11.0

vendor string:

The X.Org Foundation

vendor release number:

12004000

X.Org version: 1.20.4
maximum request size:

16777212 bytes

motion buffer size:

256

bitmap unit, bit order, padding:image byte order:

32, LSBFirst, 32

LSBFirst

number of supported pixmap formats:7

supported pixmap formats:
depth 1, bits_per_pixel 1, scanline_pad 32
depth 4, bits_per_pixel 8, scanline_pad 32
depth 8, bits_per_pixel 8, scanline_pad 32
depth 15, bits_per_pixel 16, scanline_pad 32
depth 16, bits_per_pixel 16, scanline_pad 32
depth 24, bits_per_pixel 32, scanline_pad 32
depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:
focus:

minimum 8, maximum 255

Nonenumber of extensions:25

BIG-REQUESTS
Composite
DAMAGEDOUBLE-BUFFER
DRI3
GLX
Generic Event Extension
MIT-SCREEN-SAVER
MIT-SHM
Present
RANDR
RECORDRENDER
SECURITY
SHAPE
SYNC
X-Resource
XC-MISCXFIXES
XFree86-VidModeExtension
XINERAMA
XInputExtension
XKEYBOARD
XTEST
XVideodefault screen number:0number of screens:1

screen #0:
dimensions:

3840x1080 pixels (1016x286 millimeters)

resolution:

96x96 dots per inch

depths (7):24, 1, 4, 8, 15, 16, 32

root window id:

0x39e

depth of root window:

24 planes

number of colormaps:

minimum 1, maximum 1

default colormap:

0x25

default number of colormap cells:
preallocated pixels:
options:256

black 0, white 16777215

backing-store WHEN MAPPED, save-unders NO

largest cursor:

3840x1080

current input event mask:

0xda0033

KeyPressMask

KeyReleaseMask

EnterWindowMask

LeaveWindowMask

StructureNotifyMask

SubstructureNotifyMask

SubstructureRedirectMask PropertyChangeMask
number of visuals:

ColormapChangeMask

270

...

DISPLAY

xorg.conf/etc/X11/xorg.conf$ sudo Xorg -configure

DISPLAY$ sudo Xorg :1 -configureX
Xorg
xorg.conf.new

X

Xorg

/etc/X11/
xorg.conf$ sudo mv xorg.conf.new /etc/X11/xorg.conf

xorg.conf(5)Xserver(1)X(1)

DISPLAY
WAYLAND_DISPLAY$ echo $WAYLAND_DISPLAY
wayland-0

Xorg(1)

xorg.confXlab01DISPLAY

Ctrl

Alt

F1

F6

/etc/X11/xorg.conf.d/10-kiosk.conf
ServerFlags
xorg(1)DISPLAY

setxkbmap/etc/X11/xorg.conf

localectl

Xorg/etc/X11/xorg.conf/usr/share/X11/xorg.conf.d/
xdpyinfo/etc/X11/xorg.conf.d/

$ xdpyinfo/etc/X11/xorg.conf.d/
InputDevice

xorg.conf-configure

X

Xorg

X

lab01DISPLAY$ echo $DISPLAY
lab01:0.2$ localectl

Ctrl

Alt

F1

F6

/etc/X11/xorg.conf.d/10-kiosk.conf
ServerFlags
xorg(1)

Section "ServerFlags"
OptionEndSection"DontVTSwitch""True"

Alt
Ctrl

Tab

c

.desktopssh~/.vnc/xstartup

Ctrl
Ctrl

v

Alt

F2

c

Ctrl
Ctrl

v

Ctrl

c

Alt

konsoleF2cCtrl

C

Ctrl
C
Alt

Ctrl

Shift

2
4

7

5

xkbset

Alt

Alt

Tab

AltTab

Shift

/etc/passwd/etc/shadow/etc/group/etc/skel/
chage
getentgroupaddgroupdelgroupmodpasswduseradd

userdelusermoduseradd
michael# useradd michael

useradd

passwd
id

groups# passwd michael
Changing password for user michael.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# id michael
uid=1000(michael) gid=100(michael) groups=100(michael)# groups michaelmichael : michaelidgroupspasswduseradd
-c

-d

-e

-f

-g

-G

-k
-m

-m

-M

-s

-u

useradd

usermod# usermod -s /bin/tcsh michael# usermod -c "Michael User Account" michael

useradd

usermodmichael--create-homeusermod
-c

-d
-m

-e
YYYY-MM-DD
-f

-g

-G

-a

-l

-L
/etc/shadow

-s

-u

-U
/etc/shadow

usermod-luserdel-r# userdel -r michael

useraddgroupadd

usermodgroupmodgroupdel# groupadd -g 1090 developer-gdeveloperdeveloper

web-developer# groupmod -n web-developer -g 1050 developer-g

web-developer# groupdel web-developer-m/etc/skells-al/etc/login.defs/etc/login.defs

UID_MINUID_MAXGID_MIN

GID_MAX

CREATE_HOME

USERGROUPS_ENAB

MAIL_DIRPASS_MAX_DAYS

PASS_MIN_DAYS

PASS_MIN_LEN

PASS_WARN_AGE

passwd

passwds# ls -l /usr/bin/passwd-rwsr-xr-x 1 root root 42096 mag 172015 /usr/bin/passwd

passwd

-d

-e

-i

-l
/etc/shadow

-n

-S

-u
/etc/shadow

-x

-w

gpasswd
newgrpgpasswd

chage

chage

-l

chage
-d

-E
YYYY-MM-DD

-I

-m

-M

-W

usermod -L
passwd -u
chage -E
groupdeluseradd -sgroupadd -g
userdel -r
usermod -lgroupmod -n
useradd -m
passwdpasswd -n
passwd -x
passwd -w
passwd -i
passwd -S

chage

groupadd

administratorsdevelopers

useradd-Gadministrators,developers kevin/etc/login.defs

CREATE_HOME

USERGROUPS_ENAB

designers

yes

web-designers
kevin
kevin

kevin

developers

kevin

chage

kevin

emma
administrators

emma

emma
designers

developers

web-designers/bin/shkevinadministratorsdevelopersweb-useradd

usermod

userdelgroupaddgroupmodgroupdelpasswdchage/etc/skel

/etc/login.defs

usermod -L
passwd -u
chage -E

groupdeluseradd -sgroupadd -g

userdel -r

usermod -lgroupmod -n
useradd -m

passwdchage

passwd -nchage -mpasswd -x

chage -M

passwd -w

chage -W

passwd -ichage -I

passwd -S

chage -lpasswd

-n

chage

-m

passwd

-x

chage

-M

passwd

-w

chage

-W

passwd-i

chage
passwd

-S

-I
chage

-l

usermod--unlockpasswd -u-Lusermod--lockpasswdusermod-U-lusermodgroupadd

administratorsdevelopers# groupadd administrators# groupadd developers

useraddadministrators,developers kevin/etc/login.defs

CREATE_HOME

USERGROUPS_ENAB

yes

kevin
CREATE_HOME
kevin
USERGROUPS_ENAB
kevin

designers

web-designers
kevin

kevin

# groupadd designers# groupmod -n web-designers designers# usermod -a -G web-designers kevin# id kevin
uid=1010(kevin) gid=1030(kevin)groups=1030(kevin),1028(administrators),1029(developers),1031(web-designers)

kevindevelopers# usermod -G administrators,web-designers kevin# id kevin
uid=1010(kevin) gid=1030(kevin)groups=1030(kevin),1028(administrators),1031(web-designers)

usermod-Gkevin# passwd kevin
Changing password for user kevin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

chage# chage -l kevin | grep "Account expires"
Account expires: never# chage -E 2022-12-31 kevin# chage -l kevin | grep "Account expires"
Account expires

usermod: dec 31, 2022-echage -E

emma
administratorsdevelopers

web-designers# useradd -u 1050 -g administrators -G developers,web-designers emma
# id emma
uid=1050(emma) gid=1028(administrators)
groups=1028(administrators),1029(developers),1031(web-designers)

emma/bin/sh# usermod -s /bin/sh emma

emma

chsh

chsh

kevin

administrators

designers# userdel -r emma

developersweb-# userdel -r kevin# groupdel administrators# groupdel developers# groupdel web-designers

/etc//etc/passwd/etc/group/etc/shadow

/etc/gshadow

usermodx/bin/bash

x!

newgrp!
newgrpgpasswd

grep
cat

grep

# grep emma /etc/passwd
emma:x:1020:1020:User Emma:/home/emma:/bin/bash# cat /etc/group | grep db-admin
db-admin:x:1050:grace,frankgetent# getent passwd emma
emma:x:1020:1020:User Emma:/home/emma:/bin/bash# getent group db-admin
db-admin:x:1050:grace,frankgetentgetent/etc/nsswitch.conf

# cat /etc/passwd | grep '\(root\|mail\|catherine\|kevin\)'root:x:0:0:root:/root:/bin/bash
mail:x:8:8:mail:/var/spool/mail:/sbin/nologin
catherine:x:1030:1025:User Chaterine:/home/catherine:/bin/bash
kevin:x:1040:1015:User Kevin:/home/kevin:/bin/bash# cat /etc/group | grep '\(root\|mail\|db-admin\|app-developer\)'root:x:0:
mail:x:8:
db-admin:x:1015:emma,grace
app-developer:x:1016:catherine,dave,christian# cat /etc/shadow | grep '\(root\|mail\|catherine\|kevin\)'root:$6$1u36Ipok$ljt8ooPMLewAhkQPf.lYgGopAB.jClTO6ljsdczxvkLPkpi/amgp.zyfAN680z
rLLp2avvpdKA0llpssdfcPppOp:18015:0:99999:7:::
mail:*:18015:0:99999:7:::
catherine:$6$ABCD25jlld14hpPthEFGnnssEWw1234yioMpliABCdef1f3478kAfhhAfgbAMjY1/B
AeeAsl/FeEdddKd12345g6kPACcik:18015:20:90:5:::
kevin:$6$DEFGabc123WrLp223fsvp0ddx3dbA7pPPc4LMaa123u6Lp02Lpvm123456pyphhh5ps012
vbArL245.PR1345kkA3Gas12P:18015:0:60:7:2::# cat /etc/gshadow | grep '\(root\|mail\|db-admin\|app-developer\)'root:*::
mail:*::
db-admin:!:emma:emma,grace
app-developer:!::catherine,dave,christianroot

catherine

kevin

mail

app-developercatherine

kevinuseradd-mchristianchristiangetentchristianchristianeditor
emma

ls

-l

dave

/etc/passwd

frank/etc/group/etc/shadow/etc/gshadow

/etc/passwd/etc/group/etc/shadow/etc/gshadow

getent# cat /etc/passwd | grep '\(root\|mail\|catherine\|kevin\)'root:x:0:0:root:/root:/bin/bash
mail:x:8:8:mail:/var/spool/mail:/sbin/nologin
catherine:x:1030:1025:User Chaterine:/home/catherine:/bin/bash
kevin:x:1040:1015:User Kevin:/home/kevin:/bin/bash# cat /etc/group | grep '\(root\|mail\|db-admin\|app-developer\)'root:x:0:
mail:x:8:
db-admin:x:1015:emma,grace
app-developer:x:1016:catherine,dave,christian# cat /etc/shadow | grep '\(root\|mail\|catherine\|kevin\)'root:$6$1u36Ipok$ljt8ooPMLewAhkQPf.lYgGopAB.jClTO6ljsdczxvkLPkpi/amgp.zyfAN680z
rLLp2avvpdKA0llpssdfcPppOp:18015:0:99999:7:::
mail:*:18015:0:99999:7:::
catherine:$6$ABCD25jlld14hpPthEFGnnssEWw1234yioMpliABCdef1f3478kAfhhAfgbAMjY1/B
AeeAsl/FeEdddKd12345g6kPACcik:18015:20:90:5:::
kevin:$6$DEFGabc123WrLp223fsvp0ddx3dbA7pPPc4LMaa123u6Lp02Lpvm123456pyphhh5ps012
vbArL245.PR1345kkA3Gas12P:18015:0:60:7:2::# cat /etc/gshadow | grep '\(root\|mail\|db-admin\|app-developer\)'root:*::
mail:*::
db-admin:!:emma:emma,grace
app-developer:!::catherine,dave,christianroot

catherinerootcatherine

kevindb-admin

emma

grace

mail
mail

/sbin/nologin
mail

ftp

/sbin/nologin

news

daemon/bin/false

app-developer

catherinedavechristiancatherine

kevin
kevin

root

/etc/login.defs

UID_MINUID_MAX/etc/shadow/etc/passwdx/etc/shadowuseradd-mchristian# useradd -m christian# cat /etc/passwd | grep christianchristian:x:1050:1060::/home/christian:/bin/bash

christian/etc/

passwd/bin/bash/etc/passwd

christian# cat /etc/group | grep 1060
christian:x:1060:

christianchristian/etc/login.defs

getentUSERGROUPS_ENAB/etc/group
useradd

christian# getent shadow christianchristian:!:18015:0:99999:7:::

christian/etc/shadow/etc/shadow/etc/shadow/etc/shadow/etc/shadow
christianemma

editordave

frank# cat /etc/group | grep editor
editor:x:1100:emma,dave,frank# usermod -a -G editor christian# cat /etc/group | grep editor
editor:x:1100:emma,dave,frank,christian# cat /etc/gshadow | grep editor
editor:!::emma,dave,frank,christian/etc/ghadow
editoremma
ls-l/etc/passwd

dave/etc/groupfrank

christian/etc/shadow/etc/gshadow# ls -l /etc/passwd /etc/group /etc/shadow /etc/gshadow-rw-r--r-- 1 root root

853 mag

1 08:00 /etc/group-rw-r----- 1 root shadow 1203 mag

1 08:00 /etc/gshadow-rw-r--r-- 1 root root

1354 mag

1 08:00 /etc/passwd-rw-r----- 1 root shadow 1563 mag

1 08:00 /etc/shadow/etc/passwd/etc/groupx
shadow/etc/shadow/etc/gshadow

/etc/cron.{d,daily,hourly,monthly,weekly}//etc/at.deny/etc/at.allow/etc/crontab/etc/cron.allow/etc/cron.deny/var/spool/cron/crontabatatq
atrm
systemctl

systemd-run

cron

cron

crontabcronanacronanacronanacronユーザーcrontabs/var/spool/cron*
30 12 * * 0,
0,30 * * * *0 9-17 * * 1-6/*/5 * * * */etc/crontabs/etc/crontab

SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# Example of job definition:# .---------------- minute (0 - 59)# |.------------- hour (0 - 23)# ||.---------- day of month (1 - 31)

# |

|

|

.------- month (1 - 12) OR jan,feb,mar,apr ...

# |

|

|

|

.---- day of week (0 - 6) (Sunday=0 or 7) OR

sun,mon,tue,wed,thu,fri,sat
# |

|

|

|

|

# *

*

*

*

* user-name command to be executed/etc/crontab/etc/cron.hourly/etc/cron.weekly/etc/cron.d/etc/cron.daily/etc/cron.monthly/etc/cron.daily/etc/cron.d/hourly/etc/cron.d/daily

*

,

-

/etc/cron.d/weekly//etc/cron.d/monthly

@reboot@hourly@daily@midnight@weekly@monthly@yearly

HOME
cron

MAILTO

PATH@annually

SHELL/bin/shcrontabcrontab-e$ crontab -e
no crontab for frank - using an empty one
Select an editor.

To change later, run 'select-editor'.

1. /bin/ed
2. /bin/nano< ‑‑‑‑ easiest

3. /usr/bin/emacs24
4. /usr/bin/vim.tiny
Choose 1-4 [2]:crontabVISUALEDITOR

crontabfoo.sh0 10 * * * /home/frank/foo.sh

0,15,30,45 08 * * 2 /home/frank/bar.sh
30 20 1-15 1,6 1-5 /home/frank/foobar.shbar.shfoobar.sh

crontabcrontab-ecrontab

-l

-r

-u

/etc/crontab/root/etc/cron.dbarfoo.sh/etc/crontab

30 01 * * * root /root/barfoo.sh >>/root/output.log 2>>/root/error.log/root/output.log/root/error.log

MAILTO/dev/null

crontab

/etc/cron.allow/etc/cron.denycrontab/etc/cron.allow
crontab/etc/cron.allow/etc/cron.denycrontab/etc/cron.deny/etc/cron.allow

crontab/etc/cron.denycron.timertimer[Timer]
OnCalendar=
OnCalendar=

DayOfWeek Year-Month-Day Hour:Minute:Second

DayOfWeek

*

/

,
..

/etc/systemd/system/foobar.service/etc/systemd/system/foobar.timer[Unit]
Description=Run the foobar service

[Timer]
OnCalendar=Mon *-*-1..7 05:30:00
Persistent=true[Install]WantedBy=timers.target# systemctl enable foobar.timer# systemctl start foobar.timer

OnCalendar
systemctl daemon-reload

systemctl

list-timers--alljournalctl
systemctl

OnCalender=

hourlydaily

weeklymonthlyjournalctl--useryearlysystemd.timer(7)crontabcrontab@hourly@daily@weekly@monthly@annually
OnCalendar

hourlydaily
weeklymonthly
yearlycrontab30 13 * * 1-500 09-18 * * *30 08 1 1 *0,20,40 11 * * Sun
00 09 10-20 1-3 **/20 * * * *OnCalendar*-*-* 08:30:00
Sat,Sun *-*-* 05:00:00*-*-01 13:15,30,45:00
Fri *-09..12-* 16:20:00
Mon,Tue *-*-1,15 08:30:00*-*-* *:00/05:00

cron

date

foobar.sh
output.log

crontab./foobar.sh

crontab

emma

ls

-l

/usr/bin/crontab

cron

cron

crontabcrontab/etc/cron.allow
crontab/etc/crontab/etc/cron.dsystemctl/etc/cron.denycrontab@hourly

0 * * * *@daily0 0 * * *@weekly

0 0 * * 0@monthly

0 0 1 * *@annually0 0 1 1 *OnCalendar

hourly*-*-* *:00:00

daily*-*-* 00:00:00

weeklyMon *-*-* 00:00:00

monthly*-*-01 00:00:00

yearly*-01-01 00:00:00

crontab30 13 * * 1-500 09-18 * * *30 08 1 1 *0,20,40 11 * * Sun

00 09 10-20 1-3 **/20 * * * *OnCalendar*-*-* 08:30:00
Sat,Sun *-*-* 05:00:00*-*-01 13:15,30,45:00

Fri *-09..12-* 16:20:00

Mon,Tue *-*-1,15 08:30:00*-*-* *:00/05:00

cron

dave@hostname ~ $ crontab -e
no crontab for dave - using an empty one
Select an editor.

To change later, run 'select-editor'.

1. /bin/ed
2. /bin/nano< ---- easiest

3. /usr/bin/emacs24
4. /usr/bin/vim.tiny
Choose 1-4 [2]:date

00 13 * * 5 datemailfoobar.sh
output.log*/1 * * * * ./foobar.sh >> output.log

crontabHOME

cron./foobar.sh

crontab#00 13 * * 5 date*/1 * * * * ./foobar.sh

crontabemma

crontab

MAILTO

MAILTO="emma"cron

MAILTO

MAILTO=""$ ls -l /usr/bin/crontab-rwxr-sr-x 1 root crontab 25104 feb 102015 /usr/bin/crontab

crontabs

crontabcrontabcrontabcrontabcrontab

at
at
at
at

at
Ctrl

D

$ at now +5 minutes
warning: commands will be executed using /bin/shat> date
at> Ctrl+D
job 12 at Sat Sep 14 09:15:00 2019

at

date

cron
at

atd
at

batch

batch

at
-c

-d
atrm
-f

-l
atq
-m

-q
a
at

a

batch

z

A

Z

b
batch

-v

atq
at

foo.shbar.sh$ at 09:30 AM
warning: commands will be executed using /bin/shat> ./foo.shat> Ctrl+D
job 13 at Sat Sep 14 09:30:00 2019
$ at now +2 hours

warning: commands will be executed using /bin/shat> ./bar.shat> Ctrl+D
job 14 at Sat Sep 14 11:10:00 2019

atq

$ atq
14

Sat Sep

14 11:10:00 2019 a frank

13

Sat Sep

14 09:30:00 2019 a frank

12

Sat Sep

14 09:15:00 2019 a frank

at -l

atq
atq

atrm
at

atrm

$ atrm 14

atrm

at
atrm
atrm

/etc/at.allow/etc/at.denyat/etc/at.allowat/etc/at.allow/etc/at.denyat/etc/at.deny
at

-d

at

HH:MM
月

月

日付

年

MMDDYY

MM/DD/YY

DD.MM.YY

日付

YYYY-MM-DD

midnight

noon

now

teatime+today

tomorrow
at

07:15

AM

Jan

01

at

now

+5

minutes/usr/share/doc/at

timespec

atsystemd-run

date# systemd-run --on-calendar='2019-10-06 11:30' datefoo.sh# systemd-run --on-active="2m" ./foo.shsystemd-run

systemd-run(1)journalctl
systemd-run

journalctl--userat
at 08:30 AM next weekat midday
at 01-01-2020 07:30 PM
at 21:50 01.01.20
at now +4 days
at 10:15 PM 31/03/2021
at tomorrow 08:30 AM
at

at

at

foo.shatbar.shatfoobar.sh
at

atq
at

at

at
at
at
at

systemd-run

at

atq
at
at
atrm
at
/etc/at.allow/etc/at.denyatsystemd-run
timer

at
at 08:30 AM next weekat midday
at 01-01-2020 07:30 PM
at 21:50 01.01.20
at now +4 days
at 10:15 PM 31/03/2021
at tomorrow 08:30 AM monotonic
at
at

-c

at

at

-l
at

at

at
-l

atq

systemd-run

at

-d

-d

atrm

foo.shat$ at 10:30 AM October 31
warning: commands will be executed using /bin/shat> ./foo.shat> Ctrl+D
job 50 at Thu Oct 31 10:30:00 2019

bar.shat$ at 10:00 AM tomorrow
warning: commands will be executed using /bin/shat> ./bar.shat> Ctrl+D
job 51 at Sun Oct 6 10:00:00 2019foobar.shat$ at now +30 minutes
warning: commands will be executed using /bin/shat> ./foobar.shat> Ctrl+D
job 52 at Sat Oct 5 10:19:00 2019

atq
at

# atq
52

Sat Oct

5 10:19:00 2019 a dave

50

Thu Oct 31 10:30:00 2019 a frank51

Sun Oct

6 10:00:00 2019 a emma

atq

at
at

at

# atrm 50 51 52# ls -l /usr/bin/at-rwsr-sr-x 1 daemon daemon 43762 Dec

12015 /usr/bin/at

atss
daemonat

/etc/timezone/etc/localtime/usr/share/zoneinfo/
LC_*
LC_ALLLANG
TZ/usr/bin/locale
tzselect
timedatectl
date
iconv
UTF-8

ISO-8859

date$ dateMon Oct 21 10:45:21 -03 2019-03

timedatectl

$ timedatectl
Local time: Sat 2019-10-19 17:53:18 -03
Universal time: Sat 2019-10-19 20:53:18 UTC
RTC time: Sat 2019-10-19 20:53:18
Time zone: America/Sao_Paulo (-03, -0300)
System clock synchronized: yessystemd-timesyncd.service active: yes
RTC in local TZ: no

Time

zone

America/Sao_Paulo/etc/timezone
Etc
Etc/GMT+3$ cat /etc/timezone
Etc/GMT+3

tzselecttzselecttzselecttzselect$ tzselectPlease identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa2) Americas
3) Antarctica
4) Asia5) Atlantic Ocean
6) Australia
7) Europe8) Indian Ocean
9) Pacific Ocean10) coord - I want to use geographical coordinates.

11) TZ - I want to specify the time zone using the Posix TZ format.
#? 2

2
10

12

Please select a country whose clocks agree with yours.
1) Anguilla

19) Dominican Republic37) Peru

2) Antigua & Barbuda

20) Ecuador38) Puerto Rico

3) Argentina21) El Salvador

39) St Barthelemy4) Aruba22) French Guiana40) St Kitts & Nevis

5) Bahamas23) Greenland41) St Lucia

6) Barbados24) Grenada42) St Maarten (Dutch)

7) Belize25) Guadeloupe43) St Martin (French)

8) Bolivia26) Guatemala44) St Pierre & Miquelon

9) Brazil27) Guyana45) St Vincent10) Canada28) Haiti46) Suriname

11) Caribbean NL29) Honduras47) Trinidad & Tobago

12) Cayman Islands30) Jamaica48) Turks & Caicos Is

13) Chile31) Martinique49) United States

14) Colombia32) Mexico50) Uruguay15) Costa Rica

33) Montserrat51) Venezuela16) Cuba34) Nicaragua52) Virgin Islands (UK)

17) Curaçao35) Panama53) Virgin Islands (US)18) Dominica

36) Paraguay#? 9tzselectPlease select one of the following time zone regions.
1) Atlantic islands
2) Pará (east); Amapá
3) Brazil (northeast: MA, PI, CE, RN, PB)
4) Pernambuco
5) Tocantins
6) Alagoas, Sergipe7) Bahia
8) Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS)
9) Mato Grosso do Sul10) Mato Grosso11) Pará (west)12) Rondônia13) Roraima
14) Amazonas (east)15) Amazonas (west)16) Acre#? 8tzselect

The following information has been given:
BrazilBrazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS)
Therefore TZ='America/Sao_Paulo' will be used.
Selected time is now:

sex out 18 18:47:07 -03 2019.

Universal Time is now:

sex out 18 21:47:07 UTC 2019.

Is the above information OK?
1) Yes2) No#? 1
You can make this change permanent for yourself by appending the line
TZ='America/Sao_Paulo'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
America/Sao_Paulo

America/Sao_Paulo/etc/timezone
Asia

Japan

Asia/Tokyo$ cat /etc/timezone
America/Sao_PaulotzselectTZ
TZ='America/Sao_Paulo';

exportTZ~/.profile

TZ

America/Sao_Paulo
TZ$ env TZ='Africa/Cairo' date
Mon Oct 21 15:45:21 EET 2019

env

TZ='Africa/Cairo'

TZ

date

/etc/localtime/usr/share/zoneinfo//etc/localtime/usr/share/zoneinfo/
America/Sao_Paulo/usr/share/zoneinfo/America/Sao_Paulo/usr/share/zoneinfo/

ロケール（locale）
LANG

LANG

ab_CD

LANG

pt_BR.UTF-8$ echo $LANG
pt_BR.UTF-8

LANG

ab

CD

ja_JP.UTF-8

/etc/locale.conf
LANG$ cat /etc/locale.conf
LANG=pt_BR.UTF-8

LANG~/.bash_profile~/.profile

localectl
localectl set-locale LANG=en_US.UTF-8
LANG

LC_COLLATE

LC_CTYPE

LC_MESSAGES

LC_MONETARYLC_NUMERIC

LC_TIME

LC_PAPER

LC_ALLLANG
locale$ locale
LANG=pt_BR.UTF-8
LC_CTYPE="pt_BR.UTF-8"
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_COLLATE="pt_BR.UTF-8"
LC_MONETARY=pt_BR.UTF-8
LC_MESSAGES="pt_BR.UTF-8"
LC_PAPER=pt_BR.UTF-8

LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_ALL=

LC_ALL
pt_BR.UTF-8
LC_ALLdate$ dateseg out 21 10:45:21 -03 2019$ env LC_ALL=en_US.UTF-8 date
Mon Oct 21 10:45:21 -03 2019

LC_ALL

en_US

pt_BR

LC_NUMERICLANG=C

LANG

C

iconv
original.txt
converted.txt$ iconv -f ISO-8859-1 -t UTF-8 original.txt > converted.txt-fISO-8859-1-t UTF-8--from-code=ISO-8859-1--to-code=UTF-8

iconv
-l

iconv
-o

iconv

--listconverted.txt--outputconverted.txt

nkf
iconv

nkf

date

$ dateMon Oct 21 18:45:21 +05 2019

Europe/Brussels/etc/localtime

iconv
old.txt

new.txt

Pacific/Auckland

uptimede_DE.UTF-8
en_US.UTF-8

uptimeiconv//TRANSLIT
readme.txt

ascii.txt

LC_ALL/etc/timezone/etc/localtime/usr/share/zoneinfo/
localetzselect
timedatectl
date
iconv

LANG

TZ

date

$ dateMon Oct 21 18:45:21 +05 2019

Etc/GMT+5
Europe/Brussels/etc/localtime/etc/localtime/usr/share/zoneinfo/Europe/Brussels

iconv
old.txt

iconv -f WINDOWS-1252 -t UTF-8 -o new.txt old.txt

new.txt

Pacific/Auckland

export TZ=Pacific/Auckland
uptimede_DE.UTF-8
en_US.UTF-8

export LC_NUMERIC=en_US.UTF-8

uptimeexport LC_ALL=en_US.UTF-8

iconv//TRANSLIT
readme.txt

iconv -f UTF-8 -t ASCII//TRANSLIT -o ascii.txt readme.txt

ascii.txt

/usr/share/zoneinfo//etc/timezone/etc/localtime/etc/ntp.conf/etc/chrony.conf
date
hwclock
timedatectl
ntpd

ntpdatechronycpool.ntp.org

date$ dateSun Nov 17 12:55:06 EST 2019

date
date -u$ date -u
Sun Nov 17 18:02:51 UTC 2019

-I
-I
date

20200715T143615.23+0900

-R

hours

-Idateminutesseconds

ns

2020-07-15T14:36:15.23+0900

Wed,

15

Jul

2020

--rfc-3339

date$ date +%s
1574014515

date

%s

date

--date$ date --date='@1564013011'
Wed Jul 24 20:03:31 EDT 2019--debug$ date --debug --date="Fri, 03 Jan 2020 14:00:17 -0500"
date: parsed day part: Fri (day ordinal=0 number=5)
date: parsed date part: (Y-M-D) 2020-01-03

14:36:15+0900

date: parsed time part: 14:00:17 UTC-05
date: input timezone: parsed date/time string (-05)
date: using specified time as starting value: '14:00:17'
date: warning: day (Fri) ignored when explicit dates are given
date: starting date/time: '(Y-M-D) 2020-01-03 14:00:17 TZ=-05'
date: '(Y-M-D) 2020-01-03 14:00:17 TZ=-05' = 1578078017 epoch-seconds
date: timezone: system default
date: final: 1578078017.000000000 (epoch-seconds)
date: final: (Y-M-D) 2020-01-03 19:00:17 (UTC)
date: final: (Y-M-D) 2020-01-03 14:00:17 (UTC-05)

hwclocksudo$ sudo hwclock
2019-11-20 11:31:29.217627-05:00--verbose$ sudo hwclock --verbose
hwclock from util-linux 2.34
System Time: 1578079387.976029
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tickTime read from Hardware Clock: 2020/01/03 19:23:08
Hw clock time : 2020/01/03 19:23:08 = 1578079388 seconds since 1969
Time since last adjustment is 1578079388 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2020-01-03 14:23:07.948436-05:00

Calculated

Hardware

Clock

drift

timedatectl

timedatectldate$ timedatectl
Local time: Thu 2019-12-05 11:08:05 EST
Universal time: Thu 2019-12-05 16:08:05 UTC
RTC time: Thu 2019-12-05 16:08:05
Time zone: America/Toronto (EST, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: nodate

hwclock

systemd
timedatectl# timedatectl set-time '2011-11-25 14:00:00'

date

systemd

timedatectl
timedatectl$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Algiers
Africa/Bissau

Africa/Cairo
...

grep

$ timedatectl set-timezone Africa/Cairo$ timedatectl
Local time: Thu 2019-12-05 18:18:10 EET
Universal time: Thu 2019-12-05 16:18:10 UTC
RTC time: Thu 2019-12-05 16:18:10
Time zone: Africa/Cairo (EET, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

Africa/Cairo

cairoafrica/cairosystemctl
timedatectl# timedatectl set-ntp no$ timedatectl
Local time: Thu 2019-12-05 18:19:04 EET Universal time: Thu 2019-12-05
16:19:04 UTC
RTC time: Thu 2019-12-05 16:19:04
Time zone: Africa/Cairo (EET, +0200)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

/usr/share/zoneinfo
zoneinfozoneinfozoneinfo/etc/localtime/etc/localtime/usr/share/zoneinfo$ ln -s /usr/share/zoneinfo/Canada/Eastern /etc/localtime# hwclock --systohc

date/etc/timezone/etc/localtimecat$ cat /etc/timezone
America/Toronto

systemddate
systemd

timedatectl

hwclock

date

--set
--debug# date --set="11 Nov 2011 11:11:11"# date +%Y%m%d -s "20111125"

%Y

2011
%T

# date +%T -s "13:11:00"# hwclock --systohc

systohc# hwclock --set --date "4/12/2019 11:15:19"# hwclockFri 12 Apr 2019 6:15:19 AM EST -0.562862 seconds

hwclock-shctosys# hwclock --hctosys

date -uhwclock --set --date"12:00:00"
timedatectl
timedatectl | grep
RTC
hwclock --hctosys
date +%T -s"08:00:00"
timedatectl set-time
1980-01-10$ date --debug --date "20/20/12 0:10 -3"
date: warning: value 20 has less than 4 digits. Assuming MM/DD/YY[YY]
date: parsed date part: (Y-M-D) 0002-20-20
date: parsed time part: 00:10:00 UTC-03
date: input timezone: parsed date/time string (-03)
date: using specified time as starting value: '00:10:00'
date: error: invalid date/time value:date:user provided time: '(Y-M-D) 0002-20-20 00:10:00 TZ=-03'

date:normalized time: '(Y-M-D) 0003-08-20 00:10:00 TZ=-03'

date:
date:

---- -possible reasons:

date:numeric values overflow;date:

incorrect timezone

date: invalid date ‘20/20/2 0:10 -3’

datehwclock

Eucla

grep

Eucla

date-u+%s--date=--debug-s

hwclock--systohc--hctosys--set --datetimedatectl

set-time

list-timezones

set-timezone

set-ntpdate -uhwclock --set --date"12:00:00"
timedatectl
timedatectl | grep
RTC
hwclock --hctosys
date +%T -s"08:00:00"
timedatectl set-time
1980-01-10$ date --debug --date "20/20/12 0:10 -3"
date: warning: value 20 has less than 4 digits. Assuming MM/DD/YY[YY]
date: parsed date part: (Y-M-D) 0002-20-20
date: parsed time part: 00:10:00 UTC-03
date: input timezone: parsed date/time string (-03)
date: using specified time as starting value: '00:10:00'
date: error: invalid date/time value:date:user provided time: '(Y-M-D) 0002-20-20 00:10:00 TZ=-03'

date:normalized time: '(Y-M-D) 0003-08-20 00:10:00 TZ=-03'

date:
date:

---- -possible reasons:

date:numeric values overflow;date:

incorrect timezone

date: invalid date ‘20/20/2 0:10 -3’

date --debug --set "12/20/20 0:10 -3"
date

date +%m -s "2"
hwclock
hwclock -systohc
Eucla

grep

timedatectl list-timezones | grep -i eucla

grep -ri eucla /usr/share/zoneinfo
Eucla
timedatectl set-timezone 'Australia/Eucla'

ln -s /usr/share/zoneinfo/Australia/Eucla /etc/localtime

timedatectl

timesyncd

$ systemctl status systemd-timesyncd● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor
preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d└─disable-with-time-daemon.conf
Active: active (running) since Thu 2020-01-09 21:01:50 EST; 2 weeks 1 days ago
Docs: man:systemd-timesyncd.service(8)Main PID: 1032 (systemd-timesyn)
Status: "Synchronized to time server for the first time 91.189.89.198:123(ntp.ubuntu.com)."
Tasks: 2 (limit: 4915)
Memory: 3.0M
CGroup: /system.slice/systemd-timesyncd.service└─1032 /lib/systemd/systemd-timesyncd
Jan 11 13:06:18 NeoMex systemd-timesyncd[1032]: Synchronized to time server for the
first time 91.189.91.157:123 (ntp.ubuntu.com).
...

timedatectl

show-timesync$ timedatectl show-timesync --all
LinkNTPServers=
SystemNTPServers=
FallbackNTPServers=ntp.ubuntu.com
ServerName=ntp.ubuntu.com
ServerAddress=91.189.89.198
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=34min 8s
NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=2, Precision=-23,
RootDelay=8.270ms, RootDispersion=18.432ms, Reference=91EECB0E,
OriginateTimestamp=Sat 2020-01-25 18:35:49 EST, ReceiveTimestamp=Sat 2020-01-25
18:35:49 EST, TransmitTimestamp=Sat 2020-01-25 18:35:49 EST,
DestinationTimestamp=Sat 2020-01-25 18:35:49 EST, Ignored=no PacketCount=263,
Jitter=2.751ms }Frequency=-211336

ntpd
ntpd

systemctl
ntp
ntpd$ systemctl status ntpd●

ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset:

disabled)
Active: active (running) since Fri 2019-12-06 03:27:21 EST; 7h ago
Process: 856 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited,
status=0/SUCCESS)
Main PID: 867 (ntpd)
CGroup: /system.slice/ntpd.service`-867 /usr/sbin/ntpd -u ntp:ntp -g

ntpd# systemctl enable ntpd && systemctl start ntpd

ntp
/etc/ntp.conf

vi

nano

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

server IPアドレス
server サーバーのホスト名/etc/ntp.conf

pool.ntp.org

ntpd

ntpdatesystemctl

stop

ntpd

pool.ntp.org

pool.ntp.org

ntpq
ntpq

$ ntpq -p
remoterefid

st t when poll reachdelay

offsetjitter==============================================================================+37.44.185.42

91.189.94.4

3 u

86

128

377

126.509-20.398

6.838+ntp2.0x00.lv

193.204.114.233

2 u

82

128

377

143.885-8.1058.478*inspektor-vlan1 121.131.112.137

2 u

17

128

377

112.878-23.6197.959

b1-66er.matrix. 18.26.4.105

2 u

484

128

10

34.907-0.811

16.123-p-nremote

refid

st

when

poll

reach

delay

offsetjitter

ntpq

?

ntpq

chronychronyd

chronycchronycchronyd
chronyc

tracking$ chronyc tracking
Reference ID: 3265FB3D (bras-vprn-toroon2638w-lp130-11-50-101-251-61.dsl.)

Stratum: 3

Ref time (UTC): Thu Jan 09 19:18:35 2020

System time

: 0.000134029 seconds fast of NTP time

Last offset: +0.000166506 seconds

RMS offset: 0.000470712 seconds

Frequency: 919.818 ppm slow

Residual freq

: +0.078 ppm

Skew: 0.555 ppm

Root delay: 0.006151616 seconds

Root dispersion : 0.010947504 seconds
Update interval : 129.8 seconds
Leap status

Reference ID

Stratum

Ref time

System time

Last offset

RMS offset

Frequency

Residual freq

Skew

Root delay: NormalLeap status# chrony ntpdata
Remote address: 172.105.97.111 (AC69616F)

Remote port

: 123

Local address: 192.168.122.81 (C0A87A51)

Leap status: NormalVersion: 4

Mode: Server

Stratum: 2

Poll interval: 6 (64 seconds)

Precision: -25 (0.000000030 seconds)

Root delay: 0.000381 seconds

Root dispersion : 0.000092 seconds
Reference ID: 61B7CE58 ()Reference time

: Mon Jan 13 21:50:03 2020

Offset: +0.000491960 seconds

Peer delay: 0.004312567 seconds

Peer dispersion : 0.000000068 seconds
Response time

: 0.000037078 seconds

Jitter asymmetry: +0.00
NTP tests: 111 111 1111

Interleaved: No

Authenticated: No

TX timestamping : Daemon
RX timestamping : Kernel
Total TX

: 15

Total RX: 15

Total valid RX: 15

chronyc sources$ chronyc sources
210 Number of sources = 0
MS Name/IP address

Stratum Poll Reach LastRx Last sample===============================================================================
210 Number of sources = 0

pool.ntp.org/etc/chrony.conf===============================================================================# Most computers using chrony will send measurement requests to one or# more 'NTP servers'.

You will probably find that your Internet Service# Provider or company have one or more NTP servers that you can specify.
# Failing that, there are a lot of public NTP servers.

There is a list

# you can access at http://support.ntp.org/bin/view/Servers/WebHome or# you can use servers from the 3.arch.pool.ntp.org project.
! server 0.arch.pool.ntp.org iburst iburst! server 1.arch.pool.ntp.org iburst iburst! server 2.arch.pool.ntp.org iburst iburst! pool 3.arch.pool.ntp.org iburst!

pool.ntp.org! makestep 1.0 3

chronyd# chronyc makestep
200 OK

chronyc

tracking

chronycmakestepchronyc

timedatectl

tracking

show-timesync--allntpq -pnchronychronyc

ntpdatasourcespool.ntp.org

pool.ntp.org

pool.ntp.org

pool.ntp.org
ntpq
chronytimedatectl show-timesync --alltimedatectl
ntpdate <address>

ntpq -p-nchronyc tracking

chronyc ntpdata

chronyc sources

chronyc makestep

chronyc

timedatectl

tracking

show-timesync

ntpq -pn

--all

when

chronychronyc

ntpdatasourcespool.ntp.org/etc/ntp.conf/etc/chrony.conf

pool.ntp.org/etc/ntp.conf/etc/chrony.conf

192.168.0.101

ping
systemctl

statusntpd

systemctl
ntpq

ntpdatepool.ntp.org

statussystemd-timesyncd-pchronytrackingpool.ntp.org

/etc/rsyslog.conf/var/log/
loggerlogrotate

/etc/logrotate.conf/etc/logrotate.d/journalctl
systemd-cat/etc/systemd/journald.conf/var/log/journal/rsyslogsystemd-journald
syslogsyslog-ng

rsyslogrrsyslog/var/log

RELP

rsyslogrsyslogrsyslogrsyslogd

klogd
rsyslogd

klogd

rsyslogd/var/log/var/log/auth.log
sudo

/var/log/syslog
rsyslogd/etc/rsyslog.conf/var/log/debug/var/log/kern.log/var/log/messages/var/log/daemon.log/var/log/mail.log/var/log/Xorg.0.log/var/run/utmp/var/log/wtmp/var/log/btmp/var/log/faillog/var/log/lastlog/var/log/cups/
error_log

page_log

access_log/var/log/apache2//var/log/httpdaccess.log

error_log

other_vhosts_access.log/var/log/mysql
error_log

mysql.log

mysql-

slow.log/var/log/samba/

smbd.log

less

nmbd.log

more

root@debian:~# less /var/log/auth.log
Sep 12 18:47:56 debian sshd[441]: Received SIGHUP; restarting.
Sep 12 18:47:56 debian sshd[441]: Server listening on 0.0.0.0 port 22.
Sep 12 18:47:56 debian sshd[441]: Server listening on :: port 22.
Sep 12 18:47:56 debian sshd[441]: Received SIGHUP; restarting.
Sep 12 18:47:56 debian sshd[441]: Server listening on 0.0.0.0 port 22.
Sep 12 18:47:56 debian sshd[441]: Server listening on :: port 22.
Sep 12 18:49:46 debian sshd[905]: Accepted password for carol from 192.168.1.65
port 44296 ssh2
Sep 12 18:49:46 debian sshd[905]: pam_unix(sshd:session): session opened foruser carol by (uid=0)
Sep 12 18:49:46 debian systemd-logind[331]: New session 2 of user carol.
Sep 12 18:49:46 debian systemd: pam_unix(systemd-user:session): session opened
for user carol by (uid=0)
(...)

zless

zmore

less

more

gzip

logrotate
less

less

root@debian:~# zless /var/log/auth.log.3.gz
Aug 19 20:05:57 debian sudo:

carol : TTY=pts/0 ; PWD=/home/carol ; USER=root; COMMAND=/sbin/shutdown -h now
Aug 19 20:05:57 debian sudo: pam_unix(sudo:session): session opened for userroot by carol(uid=0)
Aug 19 20:05:57 debian lightdm: pam_unix(lightdm-greeter:session): session
closed for user lightdm
Aug 19 23:50:49 debian systemd-logind[333]: Watching system buttons on/dev/input/event2 (Power Button)
Aug 19 23:50:49 debian systemd-logind[333]: Watching system buttons on/dev/input/event3 (Sleep Button)
Aug 19 23:50:49 debian systemd-logind[333]: Watching system buttons on/dev/input/event4 (Video Bus)
Aug 19 23:50:49 debian systemd-logind[333]: New seat seat0.
Aug 19 23:50:49 debian sshd[409]: Server listening on 0.0.0.0 port 22.
(...)

tail
-f

root@suse-server:~# tail -f /var/log/messages
2019-09-14T13:57:28.962780+02:00 suse-server sudo: pam_unix(sudo:session):session closed for user root
2019-09-14T13:57:38.038298+02:00 suse-server sudo:

carol : TTY=pts/0 ;PWD=/home/carol ; USER=root ; COMMAND=/usr/bin/tail -f /var/log/messages
2019-09-14T13:57:38.039927+02:00 suse-server sudo: pam_unix(sudo:session):session opened for user root by carol(uid=0)
2019-09-14T14:07:22+02:00 debian carol: appending new message from client toremote server...

head

root@suse-server:~# head -5 /var/log/mail2019-06-29T11:47:59.219806+02:00 suse-server postfix/postfix-script[1732]: thePostfix mail system is not running2019-06-29T11:48:01.355361+02:00 suse-server postfix/postfix-script[1925]:
starting the Postfix mail system
2019-06-29T11:48:01.391128+02:00 suse-server postfix/master[1930]: daemon
started -- version 3.3.1, configuration /etc/postfix
2019-06-29T11:55:39.247462+02:00 suse-server postfix/postfix-script[3364]:
stopping the Postfix mail system
2019-06-29T11:55:39.249375+02:00 suse-server postfix/master[1930]: terminating
on signal 15

grep

root@debian:~# grep "dhclient" /var/log/syslog
Sep 13 11:58:48 debian dhclient[448]: DHCPREQUEST of 192.168.1.4 on enp0s3 to
192.168.1.1 port 67
Sep 13 11:58:49 debian dhclient[448]: DHCPACK of 192.168.1.4 from 192.168.1.1
Sep 13 11:58:49 debian dhclient[448]: bound to 192.168.1.4 -- renewal in 1368
seconds.
(...)/var/log/wtmp
whow

root@debian:~# who
root

pts/0

2020-09-14 13:05 (192.168.1.75)

root

pts/1

2020-09-14 13:43 (192.168.1.75)

/var/log/btmp
utmpdump

last -froot@debian:~# utmpdump /var/log/btmp
Utmp dump of /var/log/btmp[6] [01287] [] [dave] [ssh:notty] [192.168.1.75[192.168.1.75] [2019-09-07T19:33:32,000000+0000]]/var/log/faillog
faillog

root@debian:~# faillog -a | less
Login

Failures Maximum Latest

On

root

0

0

01/01/70 01:00:00 +0100

daemon0001/01/70 01:00:00 +0100

bin

0

0

01/01/70 01:00:00 +0100

sys

0

0

01/01/70 01:00:00 +0100

sync

0

0

01/01/70 01:00:00 +0100

games

0

0

01/01/70 01:00:00 +0100

man

0

0

01/01/70 01:00:00 +0100

lp

0

0

01/01/70 01:00:00 +0100

mail

0

0

01/01/70 01:00:00 +0100(...)/var/log/lastlog
lastlog

root@debian:~# lastlog | less
Username

Port

From

Latestroot

Never logged indaemonNever logged inbin

Never logged insys

Never logged in

(...)
sync

Never logged inavahi

Never logged incolordNever logged in

saned

Never logged in

hplip

Never logged in

carol

pts/1

192.168.1.75

Sat Sep 14 13:43:06 +0200 2019

dave

pts/3

192.168.1.75

Mon Sep

2 14:22:08 +0200 2019

gnomelogs

KSystemLog/dev/log/dev/kmsg

rsyslogd/etc/rsyslog.conf/etc/ryslog.d/rsyslogd/var/log

systemctl
list-sockets --allrsyslog/etc/rsylog.conf/etc/rsyslog.d/

MODULESGLOBAL

DIRECTIVES

RULES
rsyslog.conf

less /etc/rsyslog.conf
rsyslog

MODULESrsyslog##################### MODULES #####################
module(load="imuxsock") # provides support for local system logging
module(load="imklog")# provides kernel logging support#module(load="immark")# provides --MARK-- message capability# provides UDP syslog reception#module(load="imudp")#input(type="imudp" port="514")

# provides TCP syslog reception#module(load="imtcp")#input(type="imtcp" port="514")

GLOBAL

DIRECTIVES############################### GLOBAL DIRECTIVES ################################# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat## Set the default permissions for all log files.
#$FileOwner root
$FileGroup adm$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022#
# Where to place spool and state files#$WorkDirectory /var/spool/rsyslog## Include all config files in /etc/rsyslog.d/#$IncludeConfig /etc/rsyslog.d/*.conf

RULES

postfix

mail

0

kern

1

user

2

mail

3

daemon4

auth5

syslog

6

lpr

7

news

8

uucp

9

cron

10

auth

11

authpriv

authpriv

15

16 - 23

local0local7

0

emerg

1

alert

2

crit

3

err

error

4

warn

warning

5

notice

panic

6

info

7

debug

rsyslog.conf################### RULES #################### First some standard log files.

Log by facility.

#
auth,authpriv.*/var/log/auth.log*.*;auth,authpriv.none-/var/log/syslog#cron.*/var/log/cron.log

daemon.*-/var/log/daemon.log

kern.*-/var/log/kern.log

lpr.*-/var/log/lpr.log

mail.*-/var/log/mail.log

user.*-/var/log/user.log## Logging for the mail system.

Split it up so that# it is easy to write scripts to parse these files.
#
mail.info-/var/log/mail.info

mail.warn-/var/log/mail.warn

mail.err/var/log/mail.err## Some "catch-all" log files.
#*.=debug;\auth,authpriv.none;\
news.none;mail.none-/var/log/debug*.=info;*.=notice;*.=warn;\auth,authpriv.none;\cron,daemon.none;\mail,news.none-/var/log/messages

<facility>.<priority> <action><facility>.<priority><facility><priority>auth,authpriv.*/var/log/auth.log

authauthpriv*/var/log/auth.log*.*;auth,authpriv.none-/var/log/syslog

*
auth

*

authprivnone/var/log/syslog;,

auth,authpriv

mail.err/var/log/mail.err

mail
alert

emergency

error

critical/var/log/mail.err*.=debug;\auth,authpriv.none;\
news.none;mail.none-/var/log/debug

debug

=
auth

news

mail

none

authpriv/var/log/debug

loggerloggeruser

noticelogger/var/log/syslog/var/log/messages-pcarol@debian:~$ logger this comment goes into "/var/log/syslog"/var/log/syslog-1

root@debian:~# tail -1 /var/log/syslog
Sep 17 17:55:33 debian carol: this comment goes into /var/log/syslog

rsyslogsuse-server
debianrsyslog

root@suse-server:~# systemctl status rsyslog
rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset:
enabled)Active: active (running) since Thu 2019-09-17 18:45:58 CEST; 7min ago
Docs: man:rsyslogd(8)http://www.rsyslog.com/doc/
Main PID: 832 (rsyslogd)
Tasks: 5 (limit: 4915)
CGroup: /system.slice/rsyslog.service└─832 /usr/sbin/rsyslogd -n -iNONE/etc/rsyslog.d/remote.conf

$ModLoad

imtcp.so$InputTCPServerRun# ######### Receiving Messages from Remote Hosts ########### TCP Syslog Server:# provides TCP syslog reception and GSS-API (if compiled to support it)$ModLoad imtcp.so# load module##$UDPServerAddress 10.10.0.1$InputTCPServerRun 514# force to listen on this IP only

# Starts a TCP server on selected port

# UDP Syslog Server:#$ModLoad imudp.so# provides UDP syslog reception##$UDPServerAddress 10.10.0.1#$UDPServerRun 514# force to listen on this IP only

# start a UDP syslog server at standard port 514

ss

-tln

root@suse-server:~# systemctl restart rsyslog
root@suse-server:~# netstat -nltp | grep 514[sudo] password for root:
tcp

0

0 0.0.0.0:514

0.0.0.0:*

LISTEN

0 :::514:::*

LISTEN

2263/rsyslogd
tcp6

0

2263/rsyslogd

root@suse-server:~# firewall-cmd --permanent --add-port 514/tcp
successroot@suse-server:~# firewall-cmd --reload
success

SuSEFirewall2

firewalldrsyslog/etc/rsyslog.conf/etc/rsyslog.d/remote.conf$template RemoteLogs,"/var/log/remotehosts/%HOSTNAME%/%$NOW%.%syslogseveritytext%.log"
if $FROMHOST-IP=='192.168.1.4' then ?RemoteLogs& stop$template
RemoteLogs"/var/log/remotehosts/%HOSTNAME%/%$NOW%.%syslogseveritytext%.log"

RemoteLogs%%HOSTNAME%%syslogseverity-text%

if $FROMHOST-IP=='192.168.1.4'
then ?RemoteLogs& stop/var/log/remotehosts

RemoteLogs

&

stop

/var/log/remotehosts/<リモートホスト名>/var/log/messages

rsyslog.conf

rsyslog/var/log<リモートホスト名>

root@suse-server:~# systemctl restart rsyslog
root@suse-server:~# ls /var/log/
acpid

chronylocalmessages

pbl.log

Xorg.0.log

alternatives.log

cups

mail

pk_backend_zypp

Xorg.0.log.old

apparmor

firebird

mail.err

samba

YaST2

audit

firewallmail.info

snapper.log

zyppboot.log

firewalld

mail.warn

tallylog

zypper.log

boot.msg

krb5

messagestunedboot.omsg

lastlog

mysql

warn

btmp

lightdm

NetworkManager

wtmp

rsyslog

root@debian:~# systemctl status rsyslog
rsyslog.service - System Logging Service
Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor preset:
Active: active (running) since Thu 2019-09-17 18:47:54 CEST; 7min ago
Docs: man:rsyslogd(8)http://www.rsyslog.com/doc/
Main PID: 351 (rsyslogd)
Tasks: 4 (limit: 4915)
CGroup: /system.slice/rsyslog.service└─351 /usr/sbin/rsyslogd -n/etc/hosts
suse-server

192.168.1.6

suse-server

192.168.1.6/etc/rsyslog.d/remote.conf

/etc/rsyslog.conf*.* @@suse-server:514@@

suse-server@
rsyslog

root@debian:~# systemctl restart rsyslog

suse-server/var/log

remotehosts

root@suse-server:~# ls /var/log/remotehosts/debian/
2019-09-17.info.log

2019-09-17.notice.log/var/log/remotehosts
suse-server

tail

-f

2019-09-17.notice.log

root@suse-server:~# tail -f /var/log/remotehosts/debian/2019-09-17.notice.log
2019-09-17T20:57:42+02:00 debian dbus[323]: [system] Successfully activated service'org.freedesktop.nm_dispatcher'2019-09-17T21:01:41+02:00 debian anacron[1766]: Anacron 2.3 started on 2019-09-17
2019-09-17T21:01:41+02:00 debian anacron[1766]: Normal exit (0 jobs run)debianlogger-tcarol@debian:~$ logger -t DEBIAN-CLIENT Hi from 192.168.1.4

suse-server

debianroot@suse-server:~# tail -f /var/log/remotehosts/debian/2019-09-17.notice.log
2019-09-17T20:57:42+02:00 debian dbus[323]: [system] Successfully activated service

'org.freedesktop.nm_dispatcher'2019-09-17T21:01:41+02:00 debian anacron[1766]: Anacron 2.3 started on 2019-09-17
2019-09-17T21:01:41+02:00 debian anacron[1766]: Normal exit (0 jobs run)2019-09-17T21:04:21+02:00 debian DEBIAN-CLIENT: Hi from 192.168.1.4

logrotateroot@debian:~# ls /var/log/messages*/var/log/messages/var/log/messages.1/var/log/messages.3.gz/var/log/messages.2.gz/var/log/messages.4.gz

messages.4.gz
messages.3.gz

messages.4.gz

messages.2.gz

messages.3.gz

messages.1
messagesmessages.2.gz
messages.1

logrotatemessages.1
logrotate/etc/cron.daily/logrotate/etc/logrotate.conf

messagescarol@debian:~$ sudo less /etc/logrotate.conf# see "man logrotate" for details# rotate log files weekly
weekly# keep 4 weeks worth of backlogs
rotate 4# create new (empty) log files after rotating old ones
create# uncomment this if you want your log files compressed#compress# packages drop log rotation information into this directory
include /etc/logrotate.d(...)/etc/lorotate.d/etc/logrotate.conf/etc/logrotate.d/rsyslog/var/log/messages{
rotate 4
weeklymissingok
notifempty
compressdelaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript}=
postrotate

endscript

rotate 4

weeklymissingok

notifempty

compressgzip
delaycompress

sharedscripts/var/log/*

postrotate

invoke-rc.d rsyslog rotate > /dev/null/bin/shinvode-rc.d

endscript

logrotate.confrsyslogd

dmesg
grep

root@debian:~# dmesg | grep "usb"[1.241182] usbcore: registered new interface driver usbfs[

1.241188] usbcore: registered new interface driver hub[

1.250968] usbcore: registered new device driver usb[

1.339754] usb usb1: New USB device found, idVendor=1d6b, idProduct=0001,

bcdDevice= 4.19[(...)

1.339756] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1

/var/log/syslog.7.gz/var/log/syslog/var/log/syslog

renewal/var/log/faillog/var/log/syslog

debian-server
sshd[515]:
Sep 13 21:47:56
Server listening on 0.0.0.0 port 22/etc/rsyslog.conf

mail

crit

/var/log/mail.crit

mail

alert

emergency/var/log/mail.urgent

cron

ntp

/var/log/allmessages

mail192.168.1.88

warning/var/log/warnings/etc/logrotate.d/samba

carol@debian:~$ sudo head -n 11 /etc/logrotate.d/samba/var/log/samba/log.smbd {weeklymissingok
rotate 7
postrotate[ ! -f /var/run/samba/smbd.pid ] || /etc/init.d/smbd reload >/dev/null
endscript
compressdelaycompress
notifempty}

weeklymissingok
rotate 7
postrotate
endscript
compressdelaycompress
notifyempty

rsyslogd

if $FROMHOST-IP=='192.168.1.4' then?RemoteLogs
omusrmsg
root

rsyslogcarolrsyslogd
rsyslog

less
head

tail

rsyslogd

rsyslogd/etc/rsyslog.conf

loggerrsyslog/etc/rsyslog.d/*

more

zless

zmore

grep

/var/log/syslog.7.gz

zmore

zless

/var/log/syslog

more

less

/var/log/syslog

renewalgrep/var/log/faillog

faillog -a/var/log/syslog

tail -fdebian-server
sshd[515]:
Sep 13 21:47:56
Server listening on 0.0.0.0 port 22

Sep 13 21:47:56 debian-server sshd[515]: Server listening on 0.0.0.0 port
22

/etc/rsyslog.conf

mail

crit

/var/log/mail.crit

mail.crit/var/log/mail.crit

mail

alert

/var/log/mail.urgent

mail.alert/var/log/mail.urgent

emergency

cron

ntp

/var/log/allmessages*.*;cron.none;ntp.none/var/log/allmessages

mail192.168.1.88

mail.* @@192.168.1.88:514

warning/var/log/warnings*.=warning-/var/log/warnings/etc/logrotate.d/samba

carol@debian:~$ sudo head -n 11 /etc/logrotate.d/samba/var/log/samba/log.smbd {weeklymissingok
rotate 7
postrotate[ ! -f /var/run/samba/smbd.pid ] || /etc/init.d/smbd reload >/dev/null
endscript
compressdelaycompress
notifempty}

weeklymissingok

rotate 7

postrotate

endscript
compressgzip

delaycompress

compress

notifyempty

rsyslogd

if $FROMHOST-IP=='192.168.1.4' then:fromhost-ip, isequal, "192.168.1.4"?RemoteLogs?RemoteLogs

omusrmsg

rsyslog
root

carol

*.emerg:omusrmsg:root,carolsystemd
systemd-journald

rsyslogd
systemd
systemdsystemd

systemd/lib/systemd/systemservicemountautomount

swap

rget

timer

devicesocket

path

timer

snapshot<リソース名>.<ユニット種別>

graphical.target

scope

ta

reboot.service

ランレベル
systemctl

slice

5

get-default

carol@debian:~$ systemctl get-default
graphical.target

systemd

systemd-journald
systemd-journald

systemd-journald/etc/systemd/journald.conf

systemctl

root@debian:~# systemctl status systemd-journald
systemd-journald.service - Journal Service
Loaded: loaded (/lib/systemd/system/systemd-journald.service; static; vendor
preset: enabled)
Active: active (running) since Sat 2019-10-12 13:43:06 CEST; 5min ago
Docs: man:systemd-journald.service(8)man:journald.conf(5)Main PID: 178 (systemd-journal)
Status: "Processing requests..."Tasks: 1 (limit: 4915)
CGroup: /system.slice/systemd-journald.service└─178 /lib/systemd/systemd-journald(...)

journal.conf.d/*.conf
journald.conf
systemd-journald
less

more
journalctl

journalctl

systemd

sudo

root@debian:~# journalctl-- Logs begin at Sat 2019-10-12 13:43:06 CEST, end at Sat 2019-10-12 14:19:46 CEST.
-Oct 12 13:43:06 debian kernel: Linux version 4.9.0-9-amd64 (debiankernel@lists.debian.org) (...)
Oct 12 13:43:06 debian kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-9-amd64
root=UUID=b6be6117-5226-4a8a-bade-2db35ccf4cf4 ro qu
(...)

-r

root@debian:~# journalctl -r-- Logs begin at Sat 2019-10-12 13:43:06 CEST, end at Sat 2019-10-12 14:30:30
CEST. -Oct 12 14:30:30 debian sudo[1356]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)
Oct 12 14:30:30 debian sudo[1356]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -r
Oct 12 14:19:53 debian sudo[1348]: pam_unix(sudo:session): session closed foruser root(...)-ftail -froot@debian:~# journalctl -f-- Logs begin at Sat 2019-10-12 13:43:06 CEST. -(...)
Oct 12 14:44:42 debian sudo[1356]: pam_unix(sudo:session): session closed foruser root
Oct 12 14:44:44 debian sudo[1375]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -f
Oct 12 14:44:44 debian sudo[1375]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)(...)

root@debian:~# journalctl -e(...)qOct 12 14:44:44 debian sudo[1375]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -f
Oct 12 14:44:44 debian sudo[1375]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)
Oct 12 14:45:57 debian sudo[1375]: pam_unix(sudo:session): session closed foruser rootOct 12 14:48:39 debian sudo[1378]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -e
Oct 12 14:48:39 debian sudo[1378]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)-n <value>--lines=<value><value>root@debian:~# journalctl -n 5(...)
Oct 12 14:44:44 debian sudo[1375]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -f
Oct 12 14:44:44 debian sudo[1375]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)
Oct 12 14:45:57 debian sudo[1375]: pam_unix(sudo:session): session closed foruser root
Oct 12 14:48:39 debian sudo[1378]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/journalctl -e
Oct 12 14:48:39 debian sudo[1378]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)-k--dmesg
dmesg

root@debian:~# journalctl -k-- Logs begin at Sat 2019-10-12 13:43:06 CEST, end at Sat 2019-10-12 14:53:20
CEST. -Oct 12 13:43:06 debian kernel: Linux version 4.9.0-9-amd64 (debiankernel@lists.debian.org) (gcc version 6.3.0 20170516 (Debian 6.3.0-18
Oct 12 13:43:06 debian kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-9amd64 root=UUID=b6be6117-5226-4a8a-bade-2db35ccf4cf4 ro quOct 12 13:43:06 debian kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87
floating point registers'
Oct 12 13:43:06 debian kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE
registers'
(...)

less

>
<

/
?
N

Shift

N

--list-boots
0

-1

-2

root@debian:~# journalctl --list-boots
0 83df3e8653474ea5aed19b41cdb45b78 Sat 2019-10-12 18:55:41 CEST—Sat 2019-1012 19:02:24 CEST-b--bootjournalctl-b-1

root@debian:~# journalctl -b -1
Specifying boot ID has no effect, no persistent journal was found-p-p

root@debian:~# journalctl -b -0 -p err-- No entries --

error
-b -0
syslogjournalctl--since--until

YYYY-MM-DD

HH:MM:SS

root@debian:~# journalctl --since "19:00:00" --until "19:01:00"-- Logs begin at Sat 2019-10-12 18:55:41 CEST, end at Sat 2019-10-12 20:10:50
CEST. -Oct 12 19:00:14 debian systemd[1]: Started Run anacron jobs.
Oct 12 19:00:14 debian anacron[1057]: Anacron 2.3 started on 2019-10-12
Oct 12 19:00:14 debian anacron[1057]: Normal exit (0 jobs run)Oct 12 19:00:14 debian systemd[1]: anacron.timer: Adding 2min 47.988096s random
time.

journalctl--since "-2 minutes"

yesterday

today--since"2

minutes

ago"

+

-

tomorrownow

root@debian:~# journalctl --since "today" --until "21:00:00"-- Logs begin at Sat 2019-10-12 20:45:29 CEST, end at Sat 2019-10-12 21:06:15
CEST. -Oct 12 20:45:29 debian sudo[1416]:

carol : TTY=pts/0 ; PWD=/home/carol ;USER=root ; COMMAND=/bin/systemctl r
Oct 12 20:45:29 debian sudo[1416]: pam_unix(sudo:session): session opened foruser root by carol(uid=0)
Oct 12 20:45:29 debian systemd[1]: Stopped Flush Journal to Persistent
Storage.
(...)

systemd.time

journalctl /path/to/executable

root@debian:~# journalctl /usr/sbin/sshd-- Logs begin at Sat 2019-10-12 20:45:29 CEST, end at Sat 2019-10-12 21:54:49
CEST. -Oct 12 21:16:28 debian sshd[1569]: Accepted password for carol from 192.168.1.65
port 34050 ssh2
Oct 12 21:16:28 debian sshd[1569]: pam_unix(sshd:session): session opened foruser carol by (uid=0)
Oct 12 21:16:54 debian sshd[1590]: Accepted password for carol from 192.168.1.65
port 34052 ssh2
Oct 12 21:16:54 debian sshd[1590]: pam_unix(sshd:session): session opened foruser carol by (uid=0)

systemd

-uroot@debian:~# journalctl -u ssh.service-- Logs begin at Sun 2019-10-13 10:50:59 CEST, end at Sun 2019-10-13 12:22:59
CEST. -Oct 13 10:51:00 debian systemd[1]: Starting OpenBSD Secure Shell server...
Oct 13 10:51:00 debian sshd[409]: Server listening on 0.0.0.0 port 22.
Oct 13 10:51:00 debian sshd[409]: Server listening on :: port 22.
(...)

systemctl listunits
systemctl list-unit-files<フィールド名>=<値>_<フィールド名>=<値>___<フィールド名>=<値>_

PRIORITY=
syslogroot@debian:~# journalctl PRIORITY=3-- Logs begin at Sun 2019-10-13 10:50:59 CEST, end at Sun 2019-10-13 14:30:50
CEST. -Oct 13 10:51:00 debian avahi-daemon[314]: chroot.c: open() failed: No such fileor directory

journalctl -perr
SYSLOG_FACILITY=
syslogroot@debian:~# journalctl SYSLOG_FACILITY=1-- Logs begin at Sun 2019-10-13 10:50:59 CEST, end at Sun 2019-10-13 14:42:52
CEST. -Oct 13 10:50:59 debian mtp-probe[227]: checking bus 1, device 2:"/sys/devices/pci0000:00/0000:00:06.0/usb1/1-1"
Oct 13 10:50:59 debian mtp-probe[227]: bus: 1, device: 2 was not an MTP device
Oct 13 10:50:59 debian mtp-probe[238]: checking bus 1, device 2:"/sys/devices/pci0000:00/0000:00:06.0/usb1/1-1"
Oct 13 10:50:59 debian mtp-probe[238]: bus: 1, device: 2 was not an MTP device_PID=
systemdroot@debian:~# journalctl _PID=1-- Logs begin at Sun 2019-10-13 10:50:59 CEST, end at Sun 2019-10-13 14:50:15
CEST. -Oct 13 10:50:59 debian systemd[1]: Mounted Debug File System.
Oct 13 10:50:59 debian systemd[1]: Mounted POSIX Message Queue File System.
Oct 13 10:50:59 debian systemd[1]: Mounted Huge Pages File System.
Oct 13 10:50:59 debian systemd[1]: Started Remount Root and Kernel File Systems.
Oct 13 10:50:59 debian systemd[1]: Starting Flush Journal to Persistent
Storage...
(...)_BOOT_IDjournalctl_BOOT_ID=83df3e8653474ea5aed19b41cdb45b78_TRANSPORT
audit

driverjournalsyslogstdoutkerneldmesg

journalctl-kjournalctl --dmesg

root@debian:~# journalctl _TRANSPORT=journal-- Logs begin at Sun 2019-10-13 20:19:58 CEST, end at Sun 2019-10-13 20:46:36

CEST. -Oct 13 20:19:58 debian systemd[1]: Started Create list of required static device
nodes for the current kernel.
Oct 13 20:19:58 debian systemd[1]: Starting Create Static Device Nodes in/dev...
Oct 13 20:19:58 debian systemd[1]: Started Create Static Device Nodes in /dev.
Oct 13 20:19:58 debian systemd[1]: Starting udev Kernel Device Manager...
(...)

root@debian:~# journalctl PRIORITY=3 SYSLOG_FACILITY=0-- No entries -root@debian:~# journalctl PRIORITY=4 SYSLOG_FACILITY=0-- Logs begin at Sun 2019-10-13 20:19:58 CEST, end at Sun 2019-10-13 20:21:55 CEST.
-Oct 13 20:19:58 debian kernel: acpi PNP0A03:00: fail to add MMCONFIG information,
can't access extended PCI configuration (...)+

root@debian:~# journalctl PRIORITY=3 + SYSLOG_FACILITY=0-- Logs begin at Sun 2019-10-13 20:19:58 CEST, end at Sun 2019-10-13 20:24:02 CEST.
-Oct 13 20:19:58 debian kernel: Linux version 4.9.0-9-amd64 (debiankernel@lists.debian.org) (...9
Oct 13 20:19:58 debian kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-9-amd64
root=UUID= (...)(...)

root@debian:~# journalctl PRIORITY=1-- Logs begin at Sun 2019-10-13 17:16:24 CEST, end at Sun 2019-10-13 17:30:14 CEST.
--- No entries -root@debian:~# journalctl PRIORITY=1 PRIORITY=3

-- Logs begin at Sun 2019-10-13 17:16:24 CEST, end at Sun 2019-10-13 17:32:12 CEST.
-Oct 13 17:16:27 debian connmand[459]: __connman_inet_get_pnp_nameservers: Cannot
read /pro
Oct 13 17:16:27 debian connmand[459]: The name net.connman.vpn was not provided byany .sesystemd.journal-fields(7)mansystemd-cat
loggerloggersystemd-cat

Ctrl

D

carol@debian:~$ systemd-cat
This line goes into the journal.
^D

carol@debian:~$ echo "And so does this line." | systemd-cat

carol@debian:~$ systemd-cat echo "And so does this line too."-pcarol@debian:~$ systemd-cat -p emerg echo "This is not a real emergency."

systemd-cat

carol@debian:~$ journalctl -n 4(...)-- Logs begin at Sun 2019-10-20 13:43:54 CEST. -Nov 13 23:14:39 debian cat[1997]: This line goes into the journal.
Nov 13 23:19:16 debian cat[2027]: And so does this line.
Nov 13 23:23:21 debian echo[2030]: And so does this line too.
Nov 13 23:26:48 debian echo[2034]: This is not a real emergency.

/run/log/journal/run/var/log/journal/var/log/journal//run/log/journal//etc/machine-id

carol@debian:~$ ls /run/log/journal/8821e1fdf176445697223244d1dfbd73/
system.journal

journalctl

root@debian:~# less/run/log/journal/9a32ba45ce44423a97d6397918de1fa5/system.journal"/run/log/journal/9a32ba45ce44423a97d6397918de1fa5/system.journal" may be a binary
file.

See it anyway?

root@debian:~# journalctl

-- Logs begin at Sat 2019-10-05 21:26:38 CEST, end at Sat 2019-10-05 21:31:27 CEST.
-(...)
Oct 05 21:26:44 debian systemd-journald[1712]: Runtime journal(/run/log/journal/9a32ba45ce44423a97d6397918de1fa5) is 4.9M, max 39.5M, 34.6M free.
Oct 05 21:26:44 debian systemd[1]: Started Journal Service.
(...)/var/log/journal/
systemd-journald/run/log/journal/var/log/journal/

root@debian:~# mkdir /var/log/journal/
root@debian:~# systemctl restart systemd-journald
root@debian:~# journalctl(...)
Oct 05 21:33:49 debian systemd-journald[1712]: Received SIGTERM from PID 1(systemd).
Oct 05 21:33:49 debian systemd[1]: Stopped Journal Service.
Oct 05 21:33:49 debian systemd[1]: Starting Journal Service...
Oct 05 21:33:49 debian systemd-journald[1768]: Journal started
Oct 05 21:33:49 debian systemd-journald[1768]: System journal(/var/log/journal/9a32ba45ce44423a97d6397918de1fa5) is 8.0M, max 1.1G, 1.1G free.
Oct 05 21:33:49 debian systemd[1]: Started Journal Service.
Oct 05 21:33:49 debian systemd[1]: Starting Flush Journal to Persistent Storage...
(...)/var/log/journal/

system.journal

user-1000.journal/etc/systemd/journald.conf

Storage=

Storage=volatile/run/log/journal/

Storage=persistent/var/log/journal//run/log/journal/

Storage=auto
auto

persistent/var/log/journal

Storage=none

systemd-journald/var/log/journal//etc/systemd/journald.conf
sudosystemctl

restartStorage=persistentsystemd-journald

root@debian:~# systemctl status systemd-journald
systemd-journald.service - Journal Service
Loaded: loaded (/lib/systemd/system/systemd-journald.service; static; vendor
preset: enabled)
Active: active (running) since Wed 2019-10-09 10:03:40 CEST; 2s ago
Docs: man:systemd-journald.service(8)man:journald.conf(5)Main PID: 1872 (systemd-journal)
Status: "Processing requests..."Tasks: 1 (limit: 3558)
Memory: 1.1M
CGroup: /system.slice/systemd-journald.service└─1872 /lib/systemd/systemd-journald
Oct 09 10:03:40 debian10 systemd-journald[1872]: Journal started
Oct 09 10:03:40 debian10 systemd-journald[1872]: System journal(/var/log/journal/9a32ba45ce44423a97d6397918de1fa5) is 8.0M, max 1.2G, 1.2G free.

/var/log/journal/<machine-id>//run/log/journal/<machine-id>/.journal

system.journal~
system.journal~/run/log/journal/var/log/journal.journal.journal~--disk-usage

root@debian:~# journalctl --disk-usage
Archived and active journals take up 24.0M in the filesystem.

systemd/etc/systemd/journald.conf/var/log/journal

System/run/log/journal

SystemMaxUse=

Runtime

RuntimeMaxUse=
SystemMaxUse=500M

SystemKeepFree=

RuntimeKeepFree=
SystemKeepFree=500M*MaxUse*KeepFree

SystemMaxFileSize=

RuntimeMaxFileSize=*MaxUseK

M

P

E

SystemMaxFiles=

RuntimeMaxFiles=

G

T

MaxRetentionSec=
MaxFileSec=
journald.confsystemd-journald/etc/systemd/journald.conf--vacuum-time=
s
days

d

months

weeks

w

years

m

y

root@debian:~# journalctl --vacuum-time=1months
Deleted archived journal/var/log/journal/7203088f20394d9c8b252b64a0171e08/system@27dd08376f71405a91794e6
32ede97ed-0000000000000001-00059475764d46d6.journal (16.0M).
Deleted archived journal /var/log/journal/7203088f20394d9c8b252b64a0171e08/user1000@e7020d80d3af42f0bc31592b39647e9c-000000000000008e-00059479df9677c8.journal(8.0M).

--vacuum-size=

K

M

G

T

root@debian:~# journalctl --vacuum-size=100M
Vacuuming done, freed 0B of archived journals from/run/log/journal/9a32ba45ce44423a97d6397918de1fa5.

--vacuum-files=

root@debian:~# journalctl --vacuum-files=10
Vacuuming done, freed 0B of archived journals from/run/log/journal/9a32ba45ce44423a97d6397918de1fa5.

h--rotate
SIGUSR2--flushSIGUSR1）
/run/

/var/
/var/

--syncSIGRTMIN+1

journalctl

journalctl-D </path/to/dir>--verify/var/log/journal/<machine-id>/--directory=</path/to/dir>journalctl

ルートFS/dev/sda1/media/carol/faulty.system/root@debian:~# journalctl -D /media/carol/faulty.system/var/log/journal/-- Logs begin at Sun 2019-10-20 12:30:45 CEST, end at Sun 2019-10-20 12:32:57 CEST.
-oct 20 12:30:45 suse-server kernel: Linux version 4.12.14-lp151.28.16-default(geeko@buildhost) (...)
oct 20 12:30:45 suse-server kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-4.12.14lp151.28.16-default root=UUID=7570f67f-4a08-448e-aa09-168769cb9289 splash=>oct 20 12:30:45 suse-server kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87

floating point registers'
oct 20 12:30:45 suse-server kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE
registers'
(...)

-m

--merge/var/log/journal--filejournalctl/var/log/journal/64319965bda04dfa81d3bc4e7919814a/user-1000.journal--rootjournalctl --root /faulty.system/journalctl
syslogsyslogForwardToSyslog=yes/run/systemd/journal/syslog

syslogdrsyslog
Storagenone

ForwardToKMsg

kmsg
ForwardToWall

journald.confwall

ForwardToConsole--filejournalctl

warning/etc/systemd/journald.conf

Storage

Storage
Storage=auto

Storage=none

Storage=persiste Storage=volatilent/var/log/journal/var/log/journal

Storage=auto

Storage=none

Storage=persiste Storage=volatilent/var/run/journal

journalctl

/dev/tty5/etc/systemd/journald.conf

journalctl

debian

root
sudo

sudo

journalctl-perr
journalctl

journalctl

systemd
systemd
systemd-journald
systemd-journald

systemctl

stop/etc/systemd/journald.conf

syslogsystemctl
systemdjournalctl
systemd
ls

less

mkdir

start

statusrestartjournalctl

journalctl -kjournalctl --dmesg

journalctl -b 2

journalctl -b -2 -rjournalctl -f

journalctl --since "now" -fwarning

journalctl -b -1 -p warning -r/etc/systemd/journald.conf

Storage

Storage
Storage=auto

Storage=none

Storage=persiste Storage=volatilent/var/log/journal/var/log/journal

Storage=auto

Storage=none

Storage=persiste Storage=volatilent/var/run/journal

journalctl

journalctl --disk-usage

journalctl --vacuum-size=200M

journalctl --disk-usage--disk-usage--vacuum-size

/dev/tty5/etc/systemd/journald.conf

ForwardToConsole=yes
TTYPath=/dev/tty5

journalctl_ID=<user-id>_HOSTNAME=debiandebian_GID=<group-id>_UID=0

root
sudo

sudo

_EXE=/usr/bin/sudo_COMM=sudojournalctl-perr
journalctl

journalctl

journalctl -p warning..critjournalctl -p 4..2

~/.forward

newaliases
mail
mailq
postfix
sendmaileximinfo@lpi.org

lpi.org

@

Exim

nc
nc

Postfix

Sendmaillab1.campus

emma

lab2.campus

nc

dave
lab2.campus
lab1.compus

lab2.campus$ nc lab2.campus 25
220 lab2.campus ESMTP Sendmail 8.15.2/8.15.2; Sat, 16 Nov 2019 00:16:07 GMT
HELO lab1.campus
250 lab2.campus Hello lab1.campus [10.0.3.134], pleased to meet you
MAIL FROM: emma@lab1.campus
250 2.1.0 emma@lab1.campus... Sender ok
RCPT TO: dave@lab2.campus
250 2.1.5 dave@lab2.campus... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject: Recipient MTA Test
Hi Dave, this is a test for your MTA.
.
250 2.0.0 xAG0G7Y0000595 Message accepted for delivery
QUIT
221 2.0.0 lab2.campus closing connection

HELO

lab1.campus
MAIL

lab1.campus
FROM:

emma@lab1.campus

RCPT

dave@lab2.campus

TO:
DATA

subject

DATA

QUIT
lab2.campus
lab2.campus
new

mail

in

dave
/var/spool/mail/daveemma$ cat /var/spool/mail/dave
From emma@lab1.campus

Sat Nov 16 00:19:13 2019

You

have

Return-Path: <emma@lab1.campus>
Received: from lab1.campus (lab1.campus [10.0.3.134])by lab2.campus (8.15.2/8.15.2) with SMTP id xAG0G7Y0000595
for dave@lab2.campus; Sat, 16 Nov 2019 00:17:06 GMT
Date: Sat, 16 Nov 2019 00:16:07 GMT
From: emma@lab1.campus
Message-Id: <201911160017.xAG0G7Y0000595@lab2.campus>
Subject: Recipient MTA Test
Hi Dave, this is a test for your MTA.

Received:

lab1.campus
emma

lab2.campus

lab3.campus

lab3.campus

henry
lab2.campus$ nc lab2.campus 25
220 lab2.campus ESMTP Sendmail 8.15.2/8.15.2; Sat, 16 Nov 2019 00:31:44 GMT
HELO lab1.campus
250 lab2.campus Hello lab1.campus [10.0.3.134], pleased to meet you
MAIL FROM: emma@lab1.campus
250 2.1.0 emma@lab1.campus... Sender ok
RCPT TO: henry@lab3.campus
550 5.7.1 henry@lab3.campus... Relaying denied

lab2.campus
Relayinglab1.campus
lab2.campus

lab3.campus

deniedsendmailsendmailemma@lab1.campus

dave@lab2.campus$ sendmail -f emma@lab1.campus dave@lab2.campus
From: emma@lab1.campus
To: dave@lab2.campus
Subject: Sender MTA Test
Hi Dave, this is a test for my MTA.
.

-fsendmailmailq
lab2.campus# mailq/var/spool/mqueue (1 request)-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------xAIK3D9S000453

36 Mon Nov 18 20:03 <emma@lab1.campus>(Deferred: Connection refused by lab2.campus.)<dave@lab2.campus>

Total requests: 1/var/spool/mqueue//var/spool/postfix/
mailq

sendmailsendmail-bp

sendmail-q

dave/var/spool/mail/doveemma@lab1.campus/var/mail/dave

dave@lab2.campus$ cat /var/spool/mail/dave
From emma@lab1.campus

Mon Nov 18 20:07:39 2019

Return-Path: <emma@lab1.campus>
Received: from lab1.campus (lab1.campus [10.0.3.134])by lab2.campus (8.15.2/8.15.2) with ESMTPS id xAIK7clC000432(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT)
for <dave@lab2.campus>; Mon, 18 Nov 2019 20:07:38 GMT
Received: from lab1.campus (localhost [127.0.0.1])
by lab1.campus (8.15.2/8.15.2) with ESMTPS id xAIK3D9S000453(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT)
for <dave@lab2.campus>; Mon, 18 Nov 2019 20:03:13 GMT
Received: (from emma@localhost)by lab1.campus (8.15.2/8.15.2/Submit) id xAIK0doL000449
for dave@lab2.campus; Mon, 18 Nov 2019 20:00:39 GMT
Date: Mon, 18 Nov 2019 20:00:39 GMT
Message-Id: <201911182000.xAIK0doL000449@lab1.campus>
From: emma@lab1.campus
To: dave@lab2.campus
Subject: Sender MTA Test
Hi Dave, this is a test for my MTA.

Received:
Received:

lab1.campus

emma

sendmaildave@lab2.campus
Received:

lab1.campus
Received:

lab1.campus
lab2.campus

lab1@campus
Received:

mail

mail
mail
mail

mail
mail
s-nail

mailx

mail

print
print
d

reply

r
quit

q

1
p

delete$ mail -s "Maintenance fail" henry@lab3.campus <<<"The maintenance script failed at`date`"

-s

Ctrl

mail

D

sendmaillab2.campus

carol

carol@lab2.campus/etc/aliases

postmaster@lab2.campus
lab2.campus
lab2.campus/etc/aliases

postmaster:/etc/alias

carol

newaliases
sendmail-bisendmail -I<alias（別名）>:,<destination（宛先）><destination>/<destination>
lab2.campus
subscribe@lab2.campus|
subscribe:|subscribe.sh
subscribe.sh

:include:/var/local/destinations:include:.forward
dave

emma@laba1.campus~/.forward.forward$ cat ~/.forward
emma@lab1.campus\.forward\dave/etc/aliases.forward.forwardmailhenry@lab3.campus
henry@lab3.campus

dave@lab2.campus

mail

emma@lab1.campus

uname

log.tar.gz

test/dev/null/etc/alias
newaliases

-a

mail

sendmail
mailq

mail

/etc/aliases

newaliases~/.forwardmailhenry@lab3.campus
henry@lab3.campus

Ctrl

mailq

D

sendmail -bp

dave@lab2.campus~/.forward

dave@lab2.campus

mail

emma@lab1.campus

uname

-a

log.tar.gz

uname -a | mail -a logs.tar.gz emma@lab1.campus

test/dev/null/etc/aliases

test:/dev/null/dev/null/etc/alias
newaliases
sendmail -bi

sendmail -I

test

/etc/cups/
lpr lprm lpq

cupsd$ sudo apt install cups

systemctl

enable$ sudo dnf install cups...
$ sudo systemctl start cups.service

systemctl$ systemctl status cups.service● cups.service - CUPS Scheduler
Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset:
enabled)Active: active (running) since Thu 2020-06-25 14:35:47 EDT; 41min ago
Docs: man:cupsd(8)Main PID: 3136 (cupsd)
Tasks: 2 (limit: 1119)
Memory: 3.2M
CGroup: /system.slice/cups.service├─3136 /usr/sbin/cupsd -l└─3175 /usr/lib/cups/notifier/dbus dbus:///etc/cups/cupsd.conf
cupsd.conf

/etc/printcap/run/cups/printcap/etc/cups/printers.conf<Printer></Printer>/etc/printcap/etc/cups/printers.conf/etc/cups/ppd/.ppd/var/log/cups/
access_log

page_log

error_log

access_log

page_log
error_log/etc/cups/cupsd.conf# Web interface setting...
WebInterface Yes

http://localhost:631/etc/cups/cupsd.conf# All administration operations require an administrator to authenticate...

<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPSDelete-Class CUPS-Set-Default>
AuthType Default
Require user @SYSTEM
Order deny,allow</Limit>

AuthType Default

Require user @SYSTEM@groupname
groupname
Requireuser

carol,

tim

Order deny,allow

WebInterface

Yes

No

/etc/cups/cupsd.conf/etc/cups/printers.conf

lpadmin$ sudo lpadmin -p ENVY-4510 -L "office" -v socket://192.168.150.25 -m everywhere

lpadmin

sudo
-p

-L

-v

-m
-v

lpinfo--make-and-model-m$ lpinfo --make-and-model "HP Envy 4510" -m
hplip:0/ppd/hplip/HP/hp-envy_4510_series-hpijs.ppd HP Envy 4510 Series hpijs,
3.17.10
hplip:1/ppd/hplip/HP/hp-envy_4510_series-hpijs.ppd HP Envy 4510 Series hpijs,
3.17.10
hplip:2/ppd/hplip/HP/hp-envy_4510_series-hpijs.ppd HP Envy 4510 Series hpijs,
3.17.10
drv:///hpcups.crv/hp-envy_4510_series.ppd HP Envy 4510 Series, hpcups 3.17.10
everywhere IPP Everywhere

lpinfolpoptions-d$ lpoptions -d ENVY-4510

lpadmin-p
printer-is-shared$ sudo lpadmin -p FRONT-DESK -o printer-is-shared=true$ sudo lpadmin -p FRONT-DESK -u allow:carol,frank,grace$ sudo lpadmin -p FRONT-DESK -u deny:dave@$ sudo lpadmin -p FRONT-DESK -u deny:@sales,@marketing

abort-job
retry-job
stop-printerretry-current-job
FRONT-DESK

$ sudo lpadmin -p FRONT-DESK -o printer-error-policy=abort-job

lpadmin(8)

Ctrl

p

lpr
lpr

$ lpr report.txt

report.txt/etc/cups/printers.conf
lpstatpd$ lpstat -p -dprinter FRONT-DESK is idle.

enabled since Mon 03 Aug 2020 10:33:07 AM EDT

printer PostScript_oc0303387803 disabled since Sat 07 Mar 2020 08:33:11 PM EST reason unknown
printer ENVY-4510 is idle.

enabled since Fri 31 Jul 2020 10:08:31 AM EDT

system default destination: ENVY-4510

report.txt

ENVY-4510-P$ lpr -P FRONT-DESK report.txt

lpr
-o

landscapeorientation-requested=4

two-sided-long-edge

two-sided-short-edge

media

A4
Letter
Legal
DL
COM10
collatetrue
false
page-ranges-ofit-to-page

page-ranges=5-7,9,15

outputorder-ooutputorder=normal-ooutputorder=reverse

normalreverse$ lpr -P ACCOUNTING-LASERJET -o landscape -o media=A4 -o two-sided-short-edge
finance-report.pdf-#NN$ lpr -#7 -o collate=true status-report.pdf

lpr

lp

lpr
lpr

lp
lp

lp(1)
-d

lp

lpr

$ lp -d ACCOUNTING-LASERJET -n 7 -o collate=true status-report.pdf

lpq-a$ lpq -a
Rank

Owner

Job

File(s)Total Size

1st

carol

20

finance-report.pdf

5072 bytes

lpstat-o$ lpstat -o
ACCOUNTING-LASERJET-4

carol

19456

Wed 05 Aug 2020

04:29:44 PM EDT

lpq

lprm

$ lprm 20

lprm$ lprm -cancel$ cancellpstat$ cancel ACCOUNTING-LASERJET-20

FRONT-DESK$ sudo lpmove ACCOUNTING-LASERJET-20 FRONT-DESK

lpstat$ lpstat -v
device for FRONT-DESK: socket://192.168.150.24-

device for ENVY-4510: socket://192.168.150.25
device for PostScript_oc0303387803: ///dev/null-v$ sudo cupsreject -r "Printer to be removed" FRONT-DESK

sudo
lpadmin$ sudo lpadmin -x FRONT-DESK-xoffice-mgr

office-mgr
cancelFRONT-DESKACCOUNTING-LASERJET

printer-driver-cups-pdf
cups-pdf
cups-client/etc/services/etc/fstab

PDF

/etc/cups/cupsd.conf/etc/printcap/etc/cups/printers.conf

http://localhost:631

lpadminlpoptionslpstat

lpr

lp

lpq

lprm
lpq

cancellprm

lpadmin(8)cupsenable(8)lpoptions(1)cupsaccept(8)lpr(1)

lpq(1)

http://localhost:631/help

lprm(1)cancel(1)lpstat(1)office-mgr$ lpoptions -d office-mgr$ lpstat -p-poffice-mgr
cancel$ cancel office-mgr-15

FRONT-DESKACCOUNTING-LASERJET$ sudo lpmove FRONT-DESK-2 ACCOUNTING-LASERJET

printer-driver-cups-pdf
cups-pdf
cups-client$ lpstat -p -dprinter PDF is idle.

enabled since Thu 25 Jun 2020 02:36:07 PM EDTi

system default destination: PDF/etc/services

PDF$ lp -d PDF /etc/services$ sudo cupsdisable PDF

lpstat-t$ lpstat -tscheduler is runningsystem default destination: PDF
device for PDF: cups-pdf:/
PDF accepting requests since Wed 05 Aug 2020 04:19:15 PM EDT
printer PDF disabled since Wed 05 Aug 2020 04:19:15 PM EDT -Paused/etc/fstab
lp

-d

PDF

/etc/fstab
lpstat-olpcancel$ cancel PDF-4

lpstat -o
sudo

lpadmin-x

PDF

lpstat-a/etc/services

11000000.10101000.00001010.00010100

192.168.10.20

1.0.0.0

10.25.13.10

126.255.255.255
128.0.0.0

141.150.200.1

191.255.255.255
192.0.0.0
223.255.255.255

200.178.12.242

105/2
商 = 52余り = 1

52/2
商 = 26余り = 026/2
商 = 13余り = 013/2
商 = 6
余り = 1

1.0.0.0

10.0.0.0

126.255.255.255

10.255.255.255

128.0.0.0

172.16.0.0

191.255.255.255

172.31.255.255

192.0.0.0

192.168.0.0

223.255.255.255

192.168.255.255

6/2
商 = 3
余り = 03/2
商 = 1
余り = 11101001

01101001

10110000255.0.0.0

11111111.00000000.00000000.0 80000000

255.255.0.0

11111111.11111111.00000000.0 160000000

255.255.255.0

11111111.11111111.11111111.0 240000000
255.255.0.0

255.255.255.0/

24

1.0.0.0

255.0.0.0 / 8

126.255.255.255
128.0.0.0

255.255.0.0 / 16

191.255.255.255
192.0.0.0
223.255.255.255

255.255.255.0 / 24

192.168.8.12 / 255.255.255.128 / 24

192.168.8.0

192.168.8.255

192.168.8.0

192.168.8.255

192.168.8.1

192.168.8.254

192.168.8.0

192.168.8.255

192.168.8.0
192.168.8.255

192.168.8.1
192.168.8.254

192.168.8.12 / 255.255.252.0 / 22

192.168.8.0

192.168.11.255

192.168.8.0

192.168.11.255

192.168.8.1

192.168.11.254

11111111.11111111.11111100.00000000 = 255.255.252.0 = 2211111111.11111111.11111110.00000000 = 255.255.254.0 = 23

192.168.8.0- 192.168.9.255

192.168.10.0 - 192.168.11.255

11111111.11111111.11111111.00000000 = 255.255.255.0 = 24

192.168.8.0- 192.168.8.255

192.168.9.0- 192.168.9.255

192.168.10.0 - 192.168.10.255
192.168.11.0 - 192.168.11.255

192.168.8.12
255.255.255.192

11000000.10101000.00001000.00001100 (192.168.8.12)
11111111.11111111.11111111.11000000 (255.255.255.192)

11000000.10101000.00001000.00001100 (192.168.8.12)
11111111.11111111.11111111.11000000 (255.255.255.192)
11000000.10101000.00001000.00000000

192.168.8.0

11000000.10101000.00001000.00000000 (192.168.8.0)
11111111.11111111.11111111.11000000 (255.255.255.192)
11000000.10101000.00001000.00111111

192.168.8.63

192.168.8.12 / 255.255.255.192（ネットマスク） / 26（プレフィックス長）

192.168.8.0

192.168.8.0

192.168.8.63

192.168.8.63

192.168.8.1

192.168.8.62

192.168.10.0/24

192.168.200.0/24
192.168.10.20

192.168.200.100

192.168.10.1

192.168.200.1

192.168.10.0/24
192.168.10.1
192.168.200.1

192.168.200.0/24

172.16.30.230

255.255.255.224

127

224

172.16.30.230

255.255.255.224

27
172.16.30.224
172.16.30.255
30

127

127
127.0.0.1
224

224

/etc/services:
200.216.10.15
200.216.10.15:443

ping

:

2001:0db8:85a3:08d3:1319:8a2e:0370:7344

2001:0db8:85a3:0000:0000:0000:0000:7344

0

0000

0

2001:db8:85a3:0:0:0:0:7344

0::

2001:db8:85a3::7344::

2001:db8:85a3:0000:0000:1319:0000:7344::

0:0:0:0

2001:db8:85a3:0:0:1319:0:7344
2001:db8:85a3::1319:0:7344[][]

200.216.10.15:443[2001:db8:85a3:8d3:1319:8a2e:370:7344]:443

ff02::1
224.0.0.1

fe80::/10/etc/hostname/etc/hosts/etc/nsswitch.conf/etc/resolv.conf
nmcli
hostnamectl
ifup
ifdown/etc

ip
iprouteiproute2

ip

link

show

$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode
DEFAULT group default qlen 1000
link/ether 00:16:3e:8d:2b:5b brd ff:ff:ff:ff:ff:ff

nmcli

device$ nmcli device
DEVICE

TYPE

STATE

CONNECTION

enp3s5ethernetconnected

Gigabit Powerline Adapterloloopback

unmanaged--lo

enp3s5

eth0
wlan0

eth1
wlan1
eth0

en

ib

sl

wl

ww

eno1
ens1
enp3s5

enx78e7d1ea46da
eth0
enp3s5lspci
03:05.0$ lspci | fgrep Ethernet
03:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC
Gigabit Ethernet (rev 10)

ifconfig

ip
ifconfig
ifup

ifdown/etc/network/interfaces

ifup

ifdown/etc/network/interfaces
auto

ifup

-a
ifup

ifup

-a

auto

ifdown

iface
iface
lo

enp3s5

auto lo
iface lo inet loopback
auto enp3s5
iface enp3s5 inet dhcp

inetloopback

inet6

lo

dhcp
ifup

enp3s5

enp3s5# ifup enp3s5
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/enp3s5/00:16:3e:8d:2b:5bSending on

LPF/enp3s5/00:16:3e:8d:2b:5bSending on

Socket/fallback

DHCPDISCOVER on enp3s5 to 255.255.255.255 port 67 interval 4
DHCPOFFER of 10.90.170.158 from 10.90.170.1
DHCPREQUEST for 10.90.170.158 on enp3s5 to 255.255.255.255 port 67
DHCPACK of 10.90.170.158 from 10.90.170.1
bound to 10.90.170.158 -- renewal in 1616 seconds.

enp3s5
ifdowndhcp
enp3s5ifup
enp3s5static/etc/network/interfaces

iface enp3s5 inet static
address 192.168.1.2/24
gateway 192.168.1.1

staticenp3s5

auto
iface

.
/etc/hostname/etc/hostname
hostnamectl

hostnamectl
set-hostname/etc/hostname# hostnamectl set-hostname storage# cat /etc/hostname
storage/etc/hostname

hostnamectl# hostnamectl --pretty set-hostname "LAN Shared Storage"

localhost
hostnamectl--pretty--transient--static/etc/hostname
hostnamectl$ hostnamectl status
Static hostname: storage
Pretty hostname: LAN Shared Storage
Transient hostname: generic-hostIcon name: computer-server
Chassis: server
Machine ID: d91962a957f749bbaf16da3c9c86e093
Boot ID: 8c11dcab9c3d4f5aa53f4f4e8fdc6318
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 4.19.0-8-amd64
Architecture: x86-64

hostnamectl

status/etc/nsswitch.conf/etc/nsswitch.conf

hosts

hosts: files dns

files
dns

/etc/hosts

127.0.0.1 localhost

192.168.1.10 foo.mydomain.org foo/etc/hosts#/etc/hosts::1 localhost ip6-localhost ip6-loopback

files

dns
/etc/resov.conf/etc/resolv.conf

nameserver 8.8.4.4
nameserver 8.8.8.8

resolv.conf

nameserver
nameserver

nameserver 8.8.4.4
nameserver 8.8.8.8
domain mydomain.org
search mydomain.net mydomain.com

domainmydomain.org
searchwlo1/etc/network/interfaces

eno1/etc/network/interfaceshostnamectl
firewallhostnamectl

firewallrouter

10.8.0.1/etc/hosts

1.1.1.1/etc/resolv.conf

ip
ifup

nmcli
ifdownhostnamectl/etc/hostname/etc/nsswitch.conf/etc/hosts/etc/resolv.conf

ip link show

nmcli device

ifconfig

wlo1
wl/etc/network/interfaces/etc/network/interface

eno1/etc/network/interfaces
iface eno1 inet dhcp

hostnamectl
firewall--static

hostnamectl --static set-hostname firewall

hostnamectl
hostnamectl

firewallrouter

10.8.0.1/etc/hosts
10.8.0.1 firewall router
1.1.1.1

nameserver

nameserver 1.1.1.1/etc/resolv.conf

/etc/network/interfaces

nmcli
nmtui

nmcli
nmcli

generalnetworking

radioconnection

devicenmtui

agentmonitor

nmcli
general$ nmcli general
STATE

CONNECTIVITY

WIFI-HW

WIFI

WWAN-HW

WWAN

connected

full

enabledenabledenabledenabledSTATE
CONNECTIVITYCONNECTIVITY

full

Portal
WIFI

WWAN
HW

nmcli
statusnmcli

generalnmcli general status

nmcli

nmcli device wifi list

$ nmcli device wifi list
IN-USE

BSSID

SSID

MODE

CHAN

RATE

SIGNAL

BARS

90:F6:52:C5:FA:12

Hypnotoad

Infra

11

130 Mbit/s

67

▂▄▆_

WPA2

10:72:23:C7:27:AC

JumbaoInfra

1

130 Mbit/s

55

▂▄__

WPA2

00:1F:33:33:E9:BE

NETGEARInfra

1

54 Mbit/s

35

▂▄__

WPA1

A4:33:D7:85:6D:B0

AP53

Infra

11

130 Mbit/s

32

▂▄__

WPA1

SECURITY

WPA2

WPA2
98:1E:19:1D:CC:3A

Bruma

Infra

1

195 Mbit/s

22

▂___

WPA1

WPA2

SSID

Hypnotoad$ nmcli device wifi connect Hypnotoad$ nmcli device wifi connect Hypnotoad password MyPassword

hiddenyes$ nmcli device wifi connect Hypnotoad password MyPassword hidden yes

ifnamewlo1$ nmcli device wifi connect Hypnotoad password MyPassword ifname wlo1

nmcli

connection

show$ nmcli connection show
NAME

UUID

TYPE

DEVICE

Ethernet

53440255-567e-300d-9922-b28f0786f56e

ethernet

enp3s5tun0

cae685e1-b0c4-405a-8ece-6d424e1fb5f8

tun

tun0

Hypnotoad

6fdec048-bcc5-490a-832b-da83d8cb7915

wifi

wlo1

4G

a2cf4460-0cb7-42e3-8df3-ccb927f2fd88

gsm

--

ethernet

wifi

tun

gsm

bridgeHypnotoad$ nmcli connection down Hypnotoad
Connection 'Hypnotoad' successfully deactivatednmcli

connectionup

Hypnotoadconnection

Hypnoaddevice$ nmcli device disconnect wlo2
Device 'wlo1' successfully disconnected.

$ nmcli device connect wlo2
Device 'wlo1' successfully activated with '833692de-377e-4f91-a3dc-d9a2b1fcf6cb'.

nmcli$ nmcli radio wifi off

nmcli radio wifi on

systemd-networkd
systemd-resolved

/lib/systemd/network/run/systemd/network/etc/systemd/network

/etc
/run

/lib

/etc/systemd/network/lib/systemd/network.netdev.link.network[Match]/etc/systemd/network/30-lan.network
enp3s5[Match]Name=enp3s5[Match]Name=enp3s5

en*[Match]MACAddress=00:16:3e:8d:2b:5b[Network]
Address

Gateway[Match]MACAddress=00:16:3e:8d:2b:5b[Network]
Address=192.168.0.100/24
Gateway=192.168.0.1

DHCP[Match]MACAddress=00:16:3e:8d:2b:5b[Network]
DHCP=yes

DHCP=ipv4

DHCP=ipv6

wpa_passphrase# wpa_passphrase MyWifi > /etc/wpa_supplicant/wpa_supplicant-wlo1.conf

MyWifi/etc/wpa_supplicant/wpa_supplicant-wlo1.conf
wlo1
WPA_supplicant/etc/wpa_supplicant/wpa_supplicant@wlo1.service

systemctl

wpa_supplicant@wlo1.service
systemctl

wlo1

enable.network
wlo1
wlo1

wpa_supplicant@wlo1.service/etc/systemd/network/

startnmcli

generalstatusCONNECTIVITY

Portalnmcli
MyWifi
MyPassword

nmcli

HotelInternet

nmcli
wifi

list
nmcli

[Match]wpa_passphrase

namedevicenmcli
nmcli

nmtui

nmcli

generalstatusCONNECTIVITY

Portalnmcli
MyWifi
MyPassword$ nmcli device wifi connect MyWifi password MyPassword$ nmcli radio wifi on/etc/systemd/networknmcli

HotelInternet$ nmcli connection delete "Hotel Internet"

nmcli
wifi

list
nmcli

nmcli

devicewifi

name=en*wpa_passphrase MyWifi MyPassword

rescanendeviceiphostname
ss
ping
ping6
traceroute
traceroute6
tracepathtracepath6

netcatifconfig
netstatroutetcpdump

ip
ip
ip
ip
ip
ip

ip

SEE

$ man ip...
SEE ALSO
ip-address(8), ip-addrlabel(8), ip-l2tp(8), ip-link(8), ip-maddress(8),ip-monitor(8), ip-mroute(8), ip-neighbour(8), ip-netns(8), ipntable(8), ip-route(8), ip-rule(8), ip-tcp_metrics(8), ip-token(8), iptunnel(8), ip-xfrm(8)IP Command reference ip-cref.ps
...

ip

ip

man ip-route
help$ ip address help
Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ][ CONFFLAG-LIST ]ip address del IFADDR dev IFNAME [mngtmpaddr]
ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ][ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ][ type TYPE ] [ to PREFIX ] [ FLAG-LIST ][ label LABEL ] [up] [ vrf NAME ] ]ip address {showdump|restore}
IFADDR := PREFIX | ADDR peer PREFIX
...

ALSO

/20

192.168.130.5/20
192

168

130

5

11000000 10101000 10000010 00000101
20ビット= 11111111 11111111 11110000 00000000

ネットワーク = 192.168.128.0
ホスト

=

2.5

ifconfig
ifconfig

net-tools
inetutils-tools

ifconfig-aifconfig$ ifconfig -a

ip

ip

addr

ip

a

ip

address
ip

addressman

ip-addrman ip-address
ip

link

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000
link/ether 08:00:27:54:18:57 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000
link/ether 08:00:27:ab:11:3e brd ff:ff:ff:ff:ff:ff

sys/sys/class/net$ ls /sys/class/net
enp0s3

ifconfig

enp0s8

ip

lo

ip

sudo

# ifconfig enp1s0 192.168.50.50/24

ifconfig# ifconfig eth2 192.168.50.50 netmask 255.255.255.0# ifconfig eth2 192.168.50.50 netmask 0xffffff00# ifconfig enp0s8 add 2001:db8::10/64

add

add

ip

# ip addr add 192.168.5.5/24 dev enp0s8# ip addr add 2001:db8::10/64 dev enp0s8

ip

ip

ip

link

link
ifconfig# ip link set dev enp0s8 down
# ip link show dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT
group default qlen 1000
link/ether 08:00:27:ab:11:3e brd ff:ff:ff:ff:ff:ff# ifconfig enp0s8 up# ip link show dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000

link/ether 08:00:27:ab:11:3e brd ff:ff:ff:ff:ff:ff

ip

link

ifconfig# ip link set enp0s8 mtu 2000
# ip link show dev enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2000 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000
link/ether 08:00:27:54:53:59 brd ff:ff:ff:ff:ff:ff# ifconfig enp0s3 mtu 1500
# ip link show dev enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
mode DEFAULT group default qlen 1000
link/ether 08:00:27:54:53:59 brd ff:ff:ff:ff:ff:ff

route

netstat

-r

ip

route

route

ip

route

$ netstat -r
Kernel IP routing table
Destination

Gateway

Genmask

Flags

default

10.0.2.2

0.0.0.0

UG

MSS Window
0 0irtt Iface
0 enp0s3

10.0.2.0

0.0.0.0

255.255.255.0U

0 0

0 enp0s3

192.168.150.0

0.0.0.0

255.255.255.0U

0 0

0 enp0s8$ ip routedefault via 10.0.2.2 dev enp0s3 proto dhcp metric 100
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
192.168.150.0/24 dev enp0s8 proto kernel scope link src 192.168.150.200$ routeKernel IP routing table
Destination

Gateway

GenmaskFlags Metric Ref

Use Ifacedefault

10.0.2.2

0.0.0.0

UG

100

0

0 enp0s3

10.0.2.0

0.0.0.0

255.255.255.0

U

100

0

0 enp0s3

192.168.150.0

0.0.0.0

255.255.255.0

U

0

0

0 enp0s8

route -6

netstat -6r

ip -6 route$ route -6
Kernel IPv6 routing table
Destination

Next Hop

Flag Met Ref Use If

2001:db8::/64

[::]

U

256 0

0 enp0s8

fe80::/64

[::]

U

100 0

0 enp0s3

2002:a00::/24

[::]

!n

1024 00 lo[::]/02001:db8::1

UG

1

0

0 enp0s8

localhost/128

[::]

Un

0

2

84 lo

2001:db8::10/128

[::]

Un

0

1

0 lo

fe80::a00:27ff:fe54:5359/128

[::]

Un

0

1

0 lo

ff00::/8

[::]

U

256 1

3 enp0s3

ff00::/8

[::]

U

256 1

6 enp0s8

netstat

-r6

route

route

route

-6
-6

Destination

Gateway

Next

Hop

Genmask

Flag
U

!

n

G
MetricMet

Ref

MetricUse

Iface
netstat

If-r

MSS
Window

ip route

ip -6 route

proto
scope

Metricirtt

default via 10.0.2.2 dev enp0s3 proto dhcp metric 100

enp0s310.0.2.2

100

fc0::/64 dev enp0s8 proto kernel metric 256 pref medium

fc0::/64
enp0s8256
medium

route

ip

route

route
-6

# ping6 -c 2 2001:db8:1::20
connect: Network is unreachable# route -6 add 2001:db8:1::/64 gw 2001:db8::3# ping6 -c 2 2001:db8:1::20
PING 2001:db8:1::20(2001:db8:1::20) 56 data bytes
64 bytes from 2001:db8:1::20: icmp_seq=1 ttl=64 time=0.451 ms

64 bytes from 2001:db8:1::20: icmp_seq=2 ttl=64 time=0.438 ms# route -6 del 2001:db8:1::/64 gw 2001:db8::3# ping6 -c 2 2001:db8:1::20
connect: Network is unreachable

ip route# ping6 -c 2 2001:db8:1:20
connect: Network is unreachable# ip route add 2001:db8:1::/64 via 2001:db8::3# ping6 -c 2 2001:db8:1:20
PING 2001:db8:1::20(2001:db8:1::20) 56 data bytes
64 bytes from 2001:db8:1::20: icmp_seq=2 ttl=64 time=0.529 ms
64 bytes from 2001:db8:1::20: icmp_seq=2 ttl=64 time=0.438 ms# ip route del 2001:db8:1::/64 via 2001:db8::3# ping6 -c 2 2001:db8:1::20
connect: Network is unreachable

wlan1

0.0.0.255
255.0.255.0
255.252.0.0/24

enp0s9172.16.15.16/16

ip

enp0s920

192.168.1.1

ip

ip

neighbour

enp0s950

ss

ifconfig

ip

netstatroute

ipip link

ifconfig -als /sys/class/net
wlan1

ifconfig

ip link

ifconfig$ ifconfig wlan1 down
$ ifconfig wlan1 up

ip link$ ip link set wlan1 down
$ ip link set wlan1 up

255.252.0.0
/24

route

netstat -r

ip route$ routeKernel IP routing table
Destination

Gateway

GenmaskFlags Metric Ref

default

server

0.0.0.0

UG

600

0

0 wlan1

192.168.1.0

0.0.0.0

255.255.255.0

U

600

0

0 wlan1$ netstat -r
Kernel IP routing table

Use IfaceDestination

Gateway

Genmask

Flags

MSS Window

irtt Iface

default

server

0.0.0.0UG

0 0

0 wlan1

192.168.1.0

0.0.0.0

255.255.255.0U

0 0

0 wlan1$ ip routedefault via 192.168.1.20 dev wlan1 proto static metric 600
192.168.1.0/24 dev wlan1 proto kernel scope link src 192.168.1.24 metric 600

enp0s9ip address

ifconfig

172.16.15.16/16

ifconfig$ ip addr add 172.16.15.16/16 dev enp0s9 label enp0s9:sub1

label

enp0s9:sub1

ifconfig
ifconfig
ifconfig$ ifconfig enp0s9:sub1 172.16.15.16/16

enp0s9
ifconfig

ip

ip

enp0s9

link

20

vlan

# ip link add link enp0s9 name enp0s9.20 type vlan id 20

192.168.1.1
route

ip route# route add default gw 192.168.1.1# ip route add default via 192.168.1.1

ip

neighbour$ man ip-neigbour

ip

neighbour$ ip neighbour
10.0.2.2 dev enp0s3 lladdr 52:54:00:12:35:02 REACHABLE# ip route save > /root/routes/route_backup# ip route restore < /root/routes/route_backup

ip

enp0s9

50

ip

link

# ip link add link enp0s9 name enp0s9.50 type bridge priority 50

bridge

ping
ping

ping6

$ ping -c 3 192.168.50.2
PING 192.168.50.2 (192.168.50.2) 56(84) bytes of data.
64 bytes from 192.168.50.2: icmp_seq=1 ttl=64 time=0.525 ms

64 bytes from 192.168.50.2: icmp_seq=2 ttl=64 time=0.419 ms
64 bytes from 192.168.50.2: icmp_seq=3 ttl=64 time=0.449 ms--- 192.168.50.2 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 2006ms
rtt min/avg/max/mdev = 0.419/0.464/0.525/0.047 ms$ ping6 -c 3 2001:db8::10
PING 2001:db8::10(2001:db8::10) 56 data bytes
64 bytes from 2001:db8::10: icmp_seq=1 ttl=64 time=0.425 ms
64 bytes from 2001:db8::10: icmp_seq=2 ttl=64 time=0.480 ms
64 bytes from 2001:db8::10: icmp_seq=3 ttl=64 time=0.725 ms--- 2001:db8::10 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.425/0.543/0.725/0.131 ms

-c
ping

ping6

Ctrl

C

traceroute
traceroute

traceroute6$ traceroute 192.168.1.20
traceroute to 192.168.1.20 (192.168.1.20), 30 hops max, 60 byte packets
1

10.0.2.2 (10.0.2.2)

2

192.168.1.20 (192.168.1.20)

0.396 ms

0.171 ms
2.665 ms

0.132 ms
2.573 ms

2.573 ms$ traceroute 192.168.50.2
traceroute to 192.168.50.2 (192.168.50.2), 30 hops max, 60 byte packets
1

192.168.50.2 (192.168.50.2)

0.433 ms

0.273 ms

0.171 ms

$ traceroute6 2001:db8::11
traceroute to 2001:db8::11 (2001:db8::11), 30 hops max, 80 byte packets
1

2001:db8::11 (2001:db8::11)

0.716 ms

0.550 ms

0.641 ms

$ traceroute 2001:db8::11
traceroute to 2001:db8::11 (2001:db8::11), 30 hops max, 80 byte packets
1

2001:db8::10 (2001:db8::11)

0.617 ms

0.461 ms

0.387 ms

$ traceroute net2.example.net
traceroute to net2.example.net (192.168.50.2), 30 hops max, 60 byte packets
1

net2.example.net (192.168.50.2)

0.533 ms

0.529 ms

0.504 ms

$ traceroute6 net2.example.net
traceroute to net2.example.net (2001:db8::11), 30 hops max, 80 byte packets
1

net2.example.net (2001:db8::11)

0.738 ms

0.607 ms

0.304 ms

traceroute*

traceroute
*

root

-I

traceroute# traceroute -I learning.lpi.org
traceroute to learning.lpi.org (208.94.166.201), 30 hops max, 60 byte packets
1

047-132-144-001.res.spectrum.com (47.132.144.1)

9.764 ms

9.702 ms

9.693 ms

2

096-034-094-106.biz.spectrum.com (96.34.94.106)

8.389 ms

8.481 ms

8.480 ms

3

dtr01hlrgnc-gbe-4-15.hlrg.nc.charter.com (96.34.64.172)

8.763 ms

8.775 ms

27.080 ms

27.154 ms

8.770 ms
4

acr01mgtnnc-vln-492.mgtn.nc.charter.com (96.34.67.202)

27.151 ms
5

bbr01gnvlsc-bue-3.gnvl.sc.charter.com (96.34.2.112)

31.339 ms

31.398 ms

31.395 ms
6bbr01aldlmi-tge-0-0-0-13.aldl.mi.charter.com (96.34.0.161)

ms

38.821 ms

7

prr01ashbva-bue-3.ashb.va.charter.com (96.34.3.51)

36.544 ms

39.092 ms

34.208 ms

38.79436.474 ms8bx2-ashburn.bell.ca (206.126.236.203)

53.973 ms

35.975 ms

9tcore4-ashburnbk_0-12-0-0.net.bell.ca (64.230.125.190)

38.250 ms

66.315 ms

65.319 ms

65.345 ms
10tcore4-toronto47_2-8-0-3.net.bell.ca (64.230.51.22)

67.427 ms

67.502 ms

67.498 ms
11

agg1-toronto47_xe-7-0-0_core.net.bell.ca (64.230.161.114)

61.270 ms

61.299 ms

61.177 ms

61.16861.291 ms
12

dis4-clarkson16_5-0.net.bell.ca (64.230.131.98)

61.101 ms

ms
13

207.35.12.142 (207.35.12.142)

70.009 ms

70.069 ms

14

unassigned-117.001.centrilogic.com (66.135.117.1)

59.893 ms
61.778 ms

61.950 ms

63.041

ms
15

unassigned-116.122.akn.ca (66.135.116.122)

62.702 ms

62.759 ms

16

208.94.166.201 (208.94.166.201)

62.932 ms

62.921 ms

62.936 ms-T

62.755 ms-proot# traceroute -m 60 -T -p 80

learning.lpi.org

traceroute to learning.lpi.org (208.94.166.201), 60 hops max, 60 byte packets
1

* * *

2

096-034-094-106.biz.spectrum.com (96.34.94.106)

12.178 ms

12.229 ms

12.175ms
3dtr01hlrgnc-gbe-4-15.hlrg.nc.charter.com (96.34.64.172)

12.134 ms

12.093 ms

31.146 ms

31.192 ms

12.062 ms
4

acr01mgtnnc-vln-492.mgtn.nc.charter.com (96.34.67.202)

31.828 ms
5bbr01gnvlsc-bue-3.gnvl.sc.charter.com (96.34.2.112)

39.057 ms

46.706 ms

39.745 ms
6bbr01aldlmi-tge-0-0-0-13.aldl.mi.charter.com (96.34.0.161)

ms

58.841 ms

7

prr01ashbva-bue-3.ashb.va.charter.com (96.34.3.51)

50.590 ms

34.556 ms

58.85237.892 ms

38.274 ms
8bx2-ashburn.bell.ca (206.126.236.203)

9tcore4-ashburnbk_0-12-0-0.net.bell.ca (64.230.125.190)

66.779 ms

tcore3-ashburnbk_100ge0-12-0-0.net.bell.ca (64.230.125.188)

60.441 ms

10

38.249 ms

36.991 ms

tcore4-toronto47_2-8-0-3.net.bell.ca (64.230.51.22)

36.270 ms

63.932 ms

63.218 ms

63.733 ms

68.847 ms
11

agg2-toronto47_xe-7-0-0_core.net.bell.ca (64.230.161.118)

agg1-toronto47_xe-7-0-0_core.net.bell.ca (64.230.161.114)
12

dis4-clarkson16_5-0.net.bell.ca (64.230.131.98)

60.144 ms

60.443 ms

60.851 ms

67.246 ms dis4-clarkson16_7-

0.net.bell.ca (64.230.131.102)(64.230.131.98)

68.404 ms dis4-clarkson16_5-0.net.bell.ca

67.403 ms

13

207.35.12.142 (207.35.12.142)

66.138 ms

60.608 ms

14

unassigned-117.001.centrilogic.com (66.135.117.1)

64.656 ms
70.690 ms

62.190 ms

61.787

ms
15

unassigned-116.122.akn.ca (66.135.116.122)

62.692 ms

69.470 ms

16

208.94.166.201 (208.94.166.201)

61.433 ms

65.421 ms

65.247 ms

17

208.94.166.201 (208.94.166.201)

64.023 ms

62.181 ms

61.899 msping

68.815 ms

traceroute
traceroute

root

-n

tracepathtracepathtraceroute

tracepathtraceroute

tracepath$ tracepath 192.168.1.20
1?: [LOCALHOST]

pmtu 1500

1:10.0.2.2

0.321ms

1:

10.0.2.20.110ms2:

192.168.1.20

2.714ms reached

Resume: pmtu 1500 hops 2 back 64

traceroute

tracepath6$ tracepath 2001:db8::11
tracepath: 2001:db8::11: Address family for hostname not supported$ tracepath6 2001:db8::11
1?: [LOCALHOST]
1:

net2.example.net

0.027ms pmtu 1500
0.917ms reached1:

net2.example.net

0.527ms reached

Resume: pmtu 1500 hops 1 back 1

traceroute

ping

tracepathtraceroute

tracepathnc1234
net2.example.net$ nc -l 1234
LPI Example

nc

-l

1234
nc

net2.example.net

1234

LPI

Example$ nc net2.example.net 1234
LPI Example

Ctrl

C

nc

-e
nc

-e
nc

-e
-e

$ hostnamenet2

$ nc -u -e /bin/bash -l 1234

-u

-e
-e
/bin/bash$ hostname
net1$ nc -u net2.example.net 1234
hostname
net2
pwd/home/emmanc-unet2.example.net

netstatifconfig

-a

-l

-p

-n

-t

-u

1234

hostname

pwd

ss

netstatnetstatss

# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address

Foreign Address

State

PID/Program nametcp

0

0 0.0.0.0:22

0.0.0.0:*

LISTEN00 127.0.0.1:25

0.0.0.0:*

LISTEN00 :::22:::*

LISTEN0

0 ::1:25:::*

LISTEN0 0.0.0.0:68

0.0.0.0:*892/sshd
tcp
1141/mastertcp6
892/sshd
tcp6
1141/masterudp

0692/dhclient# ss -tulnp
Netid

State

Recv-Q Send-Q

Address:Port

Process

udp

UNCONN0

LISTEN0

LISTEN0

LISTEN

0

*:
tcp

128

:22

100

127.0.0.1:25

users:(("master",pid=1099,fd=13))[::]:*
tcp:68

users:(("sshd",pid=892,fd=3))

:
tcp

0

Peer

users:(("dhclient",pid=693,fd=6))*:
tcp

Local Address:Port

128[::]:22

users:(("sshd",pid=892,fd=4))
LISTEN0[::]:*

100[::1]:25

users:(("master",pid=1099,fd=14))

Recv-Q
Send-Q
Proto
Local

Address

Foreign
State

Local

Address

Netid
Address:Port
Peer

PID/Program name

Address:Port
Processlearning.lpi.org

8.8.8.8

somehost.example.com

learning.lpi.org

traceroute

traceroute/index.html

ss

ping

ip

ping6

traceroute

traceroute6

tracepathtracepath6

nc

netstatss

learning.lpi.org
ping

ping6

$ ping learning.lpi.org$ ping6 learning.lpi.org

8.8.8.8
tracepathtraceroute$ tracepath 8.8.8.8$ traceroute 8.8.8.8

ss$ ss -ln | grep ":80"

netstat$ netstat -ln | grep ":80"lsof# lsof -Pi:80

lsof

-p
netstat# netstat -lnp | grep ":22"

netstatss# ss -lnp | grep ":22"

somehost.example.com
tracepath$ tracepath somehost.example.com

netstatss

learning.lpi.org

nc/index.html

learning.lpi.org$ nc learning.lpi.org 80
GET /index.html HTTP/1.1
HOST: learning.lpi.org
HTTP/1.1 302 Found
Location: https://learning.lpi.org:443/index.html
Date: Wed, 27 May 2020 22:54:46 GMT
Content-Length: 5Content-Type: text/plain; charset=utf-8
Foundtcpdump

wireshark

traceroute-i$ traceroute -i eth2 learning.lpi.org
traceroute -i eth2 learning.lpi.org
traceroute to learning.lpi.org (208.94.166.201), 30 hops max, 60 byte packets...

traceroute--mtu# traceroute -I --mtu

learning.lpi.org

traceroute to learning.lpi.org (208.94.166.201), 30 hops max, 65000 byte
packets
1

047-132-144-001.res.spectrum.com (47.132.144.1)

9.974 ms F=1500

10.476 ms

4.743 ms2
ms...

096-034-094-106.biz.spectrum.com (96.34.94.106)

8.697 ms

9.963 ms

10.321

/etc/hosts/etc/resolv.conf/etc/nsswitch.conf
hostdiggetent/etc/nsswitch.conf/etc/nsswitch.conf/etc/nsswitch.conf

/etc/nsswitch.confmannsswitch.conf/etc/nsswitch.conf

passwd:compatgroup:

compatshadow:

compathosts:

dns [!UNAVAIL=return] files

networks:

nis [NOTFOUND=return] files

ethers:nis [NOTFOUND=return] files

protocols:

nis [NOTFOUND=return] files

rpc:

nis [NOTFOUND=return] files

services:nis [NOTFOUND=return] files# This is a comment. It is ignored by the resolution functions.

[][]learning.lpi.org
gethostbyname/etc/nsswitch.conf
hosts

dns
[!UNAVAIL=return]files[result=action]
result[]actionresult!

result
resultactionactionservices[NOTFOUND=return]
[]
files
#
/etc/resolv.conf/etc/resolv.conf/etc/resolv.conf/etc/nsswitch.confman/etc/resolv.conf

resolv.conf

nameserver
nameserver
nameserversearch lpi.org
nameserver 10.0.0.53
nameserver fd00:ffff::2:53

searchlpi.org/etc/resolv.conf

.lpi.org
learning.lpi.org

searchlearning
searchdomainsearchoptions:

options timeout:3

resolv.conf/etc/hosts/etc/hosts

localhost/etc/hosts

127.0.0.1

localhost

127.0.1.1

proxy

::1

localhost ip6-localhost ip6-loopback

ff02::1

ip6-allnodes

ff02::2

ip6-allrouters10.0.0.1

gateway.lpi.org gateway gw

fd00:ffff::1

gateway.lpi.org gateway gw

10.0.1.53

dns1.lpi.org

fd00:ffff::1:53 dns1.lpi.org
10.0.2.53

dns2.lpi.org

fd00:ffff::2:53 dns2.lpi.org

systemd-resolved
systemdresolved

127.0.0.53/etc/systemd/resolv.conf/etc/nsswitch.conf/etc/resolv.conf
hosts

resolvesystemd-resolved
systemd-resolved

getenthostdiggetentgetent/etc/nsswitch.conf
getent$ getent hosts
127.0.0.1

localhost

127.0.1.1

proxy

10.0.1.53

dns1.lpi.org

10.0.2.53

dns2.lpi.org

127.0.0.1

localhost ip6-localhost ip6-loopback$ getent hosts dns1.lpi.org
fd00:ffff::1:53 dns1.lpi.org-s$ getent -s files hosts learning.lpi.org::1

learning.lpi.org$ getent -s dns hosts learning.lpi.org
208.94.166.198

learning.lpi.org

host
host

$ host wikipedia.org
wikipedia.org has address 208.80.154.224
wikipedia.org has IPv6 address 2620:0:861:ed1a::1
wikipedia.org mail is handled by 10 mx1001.wikimedia.org.
wikipedia.org mail is handled by 50 mx2001.wikimedia.org.
$ host 208.80.154.224
224.154.80.208.in-addr.arpa domain name pointer text-lb.eqiad.wikimedia.org.

-t$ host -t NS lpi.org
lpi.org name server dns1.easydns.com.
lpi.org name server dns3.easydns.ca.
lpi.org name server dns2.easydns.net.
$ host -t SOA lpi.org
lpi.org has SOA record dns1.easydns.com. zone.easydns.com. 1593109612 3600 600
1209600 300/etc/resolv.confhost$ host -t MX lpi.org dns1.easydns.com
Using domain server:
Name: dns1.easydns.com
Address: 64.68.192.10#53
Aliases:
lpi.org mail is handled by 10 aspmx4.googlemail.com.
lpi.org mail is handled by 10 aspmx2.googlemail.com.
lpi.org mail is handled by 5 alt1.aspmx.l.google.com.
lpi.org mail is handled by 0 aspmx.l.google.com.
lpi.org mail is handled by 10 aspmx5.googlemail.com.
lpi.org mail is handled by 10 aspmx3.googlemail.com.
lpi.org mail is handled by 5 alt2.aspmx.l.google.com.

dig
dig

host
dig
dig

$ dig learning.lpi.org; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> learning.lpi.org;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63004;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 5;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096
; COOKIE: ca7a415be1cec45592b082665ef87f3483b81ddd61063c30 (good);; QUESTION SECTION:;learning.lpi.org.

IN

A

600 INA

208.94.166.198;; ANSWER SECTION:
learning.lpi.org.

;; AUTHORITY SECTION:
lpi.org.

86400

IN

NS

dns2.easydns.net.

lpi.org.

86400

IN

NS

dns1.easydns.com.

lpi.org.

86400

IN

NS

dns3.easydns.ca.

dns1.easydns.com.

172682IN

A

64.68.192.10

dns2.easydns.net.

170226IN

A

198.41.222.254

dns1.easydns.com.

172682IN

AAAA

2400:cb00:2049:1::a29f:1835

dns2.easydns.net.

170226IN

AAAA

2400:cb00:2049:1::c629:defe;; ADDITIONAL SECTION:;; Query time: 135 msec;; SERVER: 192.168.1.20#53(192.168.1.20);; WHEN: Sun Jun 28 07:29:56 EDT 2020;; MSG SIZE

rcvd: 266

dig
dig

learning.lpi.org

host

-t

$ dig -t SOA lpi.org; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> -t SOA lpi.org;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16695;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 6;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 185c67140a63baf46c4493215ef8906f7bfbe15bdca3b01a (good);; QUESTION SECTION:;lpi.org.

IN

SOA;; ANSWER SECTION:
lpi.org.

600 IN

SOA dns1.easydns.com. zone.easydns.com. 1593109612 3600 600

1209600 300;; AUTHORITY SECTION:
lpi.org.

81989

IN

NS

dns1.easydns.com.

lpi.org.

81989

IN

NS

dns2.easydns.net.

lpi.org.

81989

IN

NS

dns3.easydns.ca.

dns1.easydns.com.

168271IN

A

64.68.192.10

dns2.easydns.net.

165815INA

198.41.222.254

dns3.easydns.ca.

107 INA

64.68.196.10

dns1.easydns.com.

168271IN

AAAA

2400:cb00:2049:1::a29f:1835

dns2.easydns.net.

165815IN

AAAA

2400:cb00:2049:1::c629:defe;; ADDITIONAL SECTION:;; Query time: 94 msec;; SERVER: 192.168.1.20#53(192.168.1.20);; WHEN: Sun Jun 28 08:43:27 EDT 2020

;; MSG SIZE

rcvd: 298+
short

$ dig +short lpi.org
65.39.134.165$ dig +short -t SOA lpi.org
dns1.easydns.com. zone.easydns.com. 1593109612 3600 600 1209600 300

nocookie$ dig +nocookie -t MX lpi.org; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> +nocookie -t MX lpi.org;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47774;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 3, ADDITIONAL: 5;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 4096;; QUESTION SECTION:;lpi.org.

INMX

lpi.org.

468 INMX

0 aspmx.l.google.com.

lpi.org.

468 INMX

10 aspmx4.googlemail.com.

lpi.org.

468 INMX

10 aspmx5.googlemail.com.

lpi.org.

468 INMX

10 aspmx2.googlemail.com.

lpi.org.

468 INMX

10 aspmx3.googlemail.com.

lpi.org.

468 INMX

5 alt2.aspmx.l.google.com.

lpi.org.

468 INMX

5 alt1.aspmx.l.google.com.

;; ANSWER SECTION:;; AUTHORITY SECTION:
lpi.org.

77130

IN

NS

dns2.easydns.net.

lpi.org.

77130

IN

NS

dns3.easydns.ca.

lpi.org.

77130

IN

NS

dns1.easydns.com.

dns1.easydns.com.

76140

IN

A

64.68.192.10

dns2.easydns.net.

73684

IN

A

198.41.222.254

dns1.easydns.com.

76140

IN

AAAA

;; ADDITIONAL SECTION:

2400:cb00:2049:1::a29f:1835

dns2.easydns.net.

73684

IN

AAAA

;; Query time: 2 msec

2400:cb00:2049:1::c629:defe;; SERVER: 192.168.1.20#53(192.168.1.20);; WHEN: Mon Jun 29 10:18:58 EDT 2020;; MSG SIZE

rcvd: 389

$ getent group openldap

getent

host

dig

dig

host

/etc/hosts::1 localhost
localhost 127.0.0.1
getent/etc/resolv.conf# Generated by NetworkManager
nameserver 192.168.1.20/etc/nsswitch.conf

hosts: files [SUCCESS=continue] dns/etc/resolv.conf

search lpi.org#nameserver fd00:ffff::1:53#nameserver 10.0.1.53

dig +noall +answer +question lpi.org

diggetenthostdiggetenthostdig/etc/nsswitch.conf/etc/resolv.conf/etc/hosts

localhost#$ getent group openldap/etc/nsswitch.conf

group

openldap
getenthostdiggetenthostdiggetent/etc/nsswitch.conf
host

dig

host
dig

host

-t
/etc/hosts::1 localhost
localhost 127.0.0.1::1 localhost
getent-s$ getent -s files hosts learning.lpi.org
192.168.10.25

learning.lpi.org$ getent -s dns hosts learning.lpi.org
208.94.166.198

learning.lpi.org

dig/etc/resolv.conf# Generated by NetworkManager
nameserver 192.168.1.20/etc/nsswitch.conf

hosts: files [SUCCESS=continue] dns/etc/hosts/etc/hosts/etc/resolv.conf

search lpi.org#nameserver fd00:ffff::1:53#nameserver 10.0.1.53

dig +noall +answer +question lpi.org
lpi.orgdig

.digrc

findpasswd
fuser
lsof
nmap
chage
netstatsudo

/etc/sudoerssuusermodulimitwho w last

su

sudo

4000
s
passwdcarol@debian:~$ ls -l /usr/bin/passwd-rwsr-xr-x 1 root root 63736 jul 27

2018 /usr/bin/passwd

S

rws

s
S

passwd

s

S

2000
chmod
2

755

carol@debian:~$ ls -ld shared_directory
drwxr-xr-x 2 carol carol 4096 may 30 23:55 shared_directorycarol@debian:~$ sudo chmod 2755 shared_directory/
carol@debian:~$ ls -ld shared_directory
drwxr-sr-x 2 carol carol 4096 may 30 23:55 shared_directory

find
-perm
-

/

-perm 数値表記

-perm 記号表記

-perm -数値表記-perm -記号表記-perm /数値表記-perm /記号表記

find . -perm 4000

carol@debian:~$ find . -perm 4000
carol@debian:~$ touch filecarol@debian:~$ chmod 4000 filecarol@debian:~$ find . -perm 4000./filecarol@debian:~$ find . -perm u+s./file/usr/bin/carol@debian:~$ sudo find /usr/bin -perm -4000/usr/bin/umount/usr/bin/newgrp/usr/bin/gpasswd/usr/bin/chfn/usr/bin/mount/usr/bin/passwd/usr/bin/chsh/usr/bin/sudo/usr/bin/su
carol@debian:~$ sudo find /usr/bin -perm -u+s
/usr/bin/umount/usr/bin/newgrp/usr/bin/gpasswd/usr/bin/chfn/usr/bin/mount/usr/bin/passwd/usr/bin/chsh/usr/bin/sudo/usr/bin/su

find /usr/bin/ -perm -2000

find /usr/bin/ -perm -g+s

/
/6000

6

4

2

6

carol@debian:~$ sudo find /usr/bin -perm /6000/usr/bin/dotlock.mailutils/usr/bin/umount/usr/bin/newgrp/usr/bin/wall/usr/bin/ssh-agent/usr/bin/chage/usr/bin/dotlockfile/usr/bin/gpasswd/usr/bin/chfn/usr/bin/mount/usr/bin/passwd/usr/bin/chsh/usr/bin/expiry/usr/bin/sudo/usr/bin/bsd-write/usr/bin/crontab/usr/bin/su

passwd-S--status

carol@debian:~$ passwd -S
carol P 12/07/2019 0 99999 7 -1

carol

P
P

L
NP

12/07/2019

0
0

99999
99999

7

-1
-1

passwd
-l

-u
-e
-d

su
su
passwd

carol

carol

L
carol

root@debian:~# passwd -l carol
passwd: password expiry information changed.
root@debian:~# su - carol
carol@debian:~$ passwd -S
carol L 05/31/2020 0 99999 7 -1
carol@debian:~$ passwd
Changing password for carol.
Current password:
passwd: Authentication token manipulation error
passwd: password unchanged
carol@debian:~$ exit
logoutroot@debian:~# passwd -u carol
passwd: password expiry information changed.

usermodcarol
usermod -L carol

usermod --lock carol

carol
usermod -U carol

usermod --unlock carol

usermod-f--inactive
usermod -f 3 carol

passwdusermod-lchage--listchage

carol@debian:~$ chage -l carol
Last password change: Aug 06, 2019

Password expires: never

Password inactive: never

Account expires: never

Minimum number of days between password change: 0

Maximum number of days between password change: 99999

Number of days of warning before password expires

: 7

chage

root@debian:~# chage carol
Changing the aging information for carolEnter the new value, or press ENTER for the default
Minimum Password Age [0]:Maximum Password Age [99999]:
Last Password Change (YYYY-MM-DD) [2020-06-01]:
Password Expiration Warning [7]:Password Inactive [-1]:
Account Expiration Date (YYYY-MM-DD) [-1]:chage-m 日数 ユーザー名--mindays 日数 ユーザー名

chage -m 5 carol-M 日数 ユーザー名

0--maxdays 日数 ユーザー名
chage

carol

-M

30

chage -d 10 carol

0

99999

-d 日数 ユーザー名--lastday 日数 ユーザー名-W 日数 ユーザー名--warndays 日数 ユーザー名-I 日数 ユーザー名--inactive 日数 ユーザー名
chage

-I

10

carol

usermod-fusermod--inactive

0-E 日付 ユーザー名--expiredate 日付 ユーザー名
YYYY-MM-DD
passwdchage-E 2050-12-13 carol
usermod

chage

lsof

fuser

netstat

nmap

lsof
lsof
lsof
-i

root@debian:~# lsof -i
COMMAND

PID

USER

FD

TYPE DEVICE SIZE/OFF NODE NAME

dhclient 357

root

7u

IPv4

13493

0t0

UDP *:bootpc

sshd

389

root

3u

IPv4

13689

0t0

TCP *:ssh (LISTEN)

sshd

389

root

4u

IPv6

13700

0t0

TCP *:ssh (LISTEN)

apache2

399

root

3u

IPv6

13826

0t0

TCP *:http (LISTEN)

apache2

401 www-data

3u

IPv6

13826

0t0

TCP *:http (LISTEN)

apache2402 www-data

3u

IPv6

13826

0t0

TCP *:http (LISTEN)

sshd

557

3u

IPv4

14701

0t0

TCP 192.168.1.7:ssh-

14701

0t0

TCP 192.168.1.7:ssh-root>192.168.1.4:60510 (ESTABLISHED)
sshd

569

carol

3u

IPv4

>192.168.1.4:60510 (ESTABLISHED)

bootpcssh
httpdroot@debian:~# lsof -i@192.168.1.7
COMMAND PID

USER

FD

TYPE DEVICE SIZE/OFF NODE NAME

sshd

root

3u

IPv4

557

14701

0t0

TCP 192.168.1.7:ssh-

0t0

TCP 192.168.1.7:ssh->192.168.1.4:60510 (ESTABLISHED)
sshd

569 carol

3u

IPv4

14701

>192.168.1.4:60510 (ESTABLISHED)

-i4

-i6

-i

-i@ip-address:port

root@debian:~# lsof -i :22
COMMAND PID

USER

FD

TYPE DEVICE SIZE/OFF NODE NAME

sshd

389

root

3u

IPv4

13689

0t0

TCP *:ssh (LISTEN)

sshd

389

root

4u

IPv6

13700

0t0

TCP *:ssh (LISTEN)

sshd

557

root

3u

IPv4

14701

0t0

TCP 192.168.1.7:ssh-

0t0

TCP 192.168.1.7:ssh->192.168.1.4:60510 (ESTABLISHED)
sshd

569 carol

3u

IPv4

14701

>192.168.1.4:60510 (ESTABLISHED)

root@debian:~# lsof -i@192.168.1.7:22,80
COMMAND PID

USER

FD

TYPE DEVICE SIZE/OFF NODE NAME

sshd

root

3u

IPv4

705

13960

0t0

TCP 192.168.1.7:ssh-

0t0

TCP 192.168.1.7:ssh->192.168.1.4:44766 (ESTABLISHED)
sshd

718 carol

3u

IPv4

13960

>192.168.1.4:44766 (ESTABLISHED)

lsof

fuser
fuser
--verboseroot@debian:~# fuser .
/root:

580c

root@debian:~# fuser -v .
/root:USER

PID ACCESS COMMAND

root

580 ..c.. bash

/root
USER
root
PID
580
ACCESS
..c..
c

e

.

-v

f

F

r

m

.

COMMANDbash-n--namespaceroot@debian:~# fuser -vn tcp 80
80/tcp:-k

USER

PID ACCESS COMMAND

root

402 F.... apache2

www-data

404 F.... apache2

www-data

405 F.... apache2--killfuser

fuser -k 80/tcp

netstatnetstatnetstatlesscarol@debian:~$ netstat |less
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address

Foreign Address

State

tcp

0

0 192.168.1.7:ssh

192.168.1.4:55444

ESTABLISHED

Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags

Type

unix

DGRAM

2

[ ]

State

I-Node

Path

10509

/run/systemd/journal/syslog
unix

3

[ ]

DGRAM

10123

/run/systemd/notify

(...)

-l

--listening
-t

--tcp

-u
-e

--udp

--extendcarol@debian:~$ netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address

Foreign Address

udp

0.0.0.0:*00 0.0.0.0:bootpc

Statecarol@debian:~$ netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address

Foreign Address

State

tcp

0

0 0.0.0.0:ssh

0.0.0.0:*

LISTENtcp

00 localhost:smtp

0.0.0.0:*

LISTEN

tcp6

00 [::]:http[::]:*

LISTEN

tcp6

00 [::]:ssh[::]:*

LISTENtcp6

00 localhost:smtp[::]:*

LISTEN

Foreign Address

State0 0.0.0.0:ssh

0.0.0.0:*

LISTEN0 localhost:smtp

0.0.0.0:*

LISTEN

0 [::]:http[::]:*

LISTEN

0 [::]:ssh[::]:*

LISTEN0 localhost:smtp[::]:*

LISTEN0 0.0.0.0:bootpc

0.0.0.0:*

carol@debian:~$ netstat -lute
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address
User

Inode

tcp

0

root

13729

tcp

0

root

14372

tcp6

0

root

14159

tcp6

0

root

13740

tcp6

0

root

14374

udp

0

root

13604

-l

carol@debian:~$ netstat -ute
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address
User

Inode

tcp

0

root

15103

-n

0 192.168.1.7:ssh

Foreign AddressState

192.168.1.4:39144

ESTABLISHED--numeric
-n

ssh
22

carol@debian:~$ netstat -uten
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address
User

Inode

tcp

0

0 192.168.1.7:22

Foreign AddressState

192.168.1.4:39144

ESTABLISHED 0

15103

netstatnetstatss

nmap

root@debian:~# nmap localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2020-06-04 19:29 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000040s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 998 closed ports
PORT

STATE SERVICE

22/tcp open

ssh

80/tcp open

httpNmap done: 1 IP address (1 host up) scanned in 1.58 seconds

nmap

nmap localhost 192.168.1.7

nmap 192.168.1.3-20

nmap
192.168.1.0/24

192.168.1.*-p
nmap -p 22

nmap -p ssh

root@debian:~# nmap -p 22 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2020-06-04 19:54 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000024s latency).
Other addresses for localhost (not scanned): ::1
PORT

STATE SERVICE

22/tcp open

ssh

Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds

root@debian:~# nmap -p ssh,80 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2020-06-04 19:58 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000051s latency).
Other addresses for localhost (not scanned): ::1
PORT

STATE SERVICE

22/tcp open

ssh

80/tcp open

http

nmap

nmap 192.168.1.0/24 --exclude 192.168.1.7

Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds

root@debian:~# nmap -p 22-80 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2020-06-04 19:58 CEST

Nmap scan report for localhost (127.0.0.1)
Host is up (0.000011s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 57 closed ports
PORT

STATE SERVICE

22/tcp open

ssh

80/tcp open

httpNmap done: 1 IP address (1 host up) scanned in 1.47 seconds

nmap
-F

-v
-vv
nmap

ulimitulimit-S-H

ulimitcarol@debian:~$ ulimit
unlimited-aulimit-Sa-Ha

carol@debian:~$ ulimit -acore file size

(blocks, -c) 0

data seg size

(kbytes, -d) unlimitedscheduling priority(-e) 0(...)
carol@debian:~$ ulimit -Ha
core file size

(blocks, -c) unlimited

data seg size

(kbytes, -d) unlimitedscheduling priority(-e) 0

(...)

-b

-f

-l

-m

-v

-u

ulimit-S-H-S

carol@debian:~$ ulimit -u
10000
carol@debian:~$ ulimit -Su
10000
carol@debian:~$ ulimit -Hu
15672

-H

ulimit

-S

-H
soft

hard
-S

unlimited-H-froot@debian:~# ulimit -Sf
unlimited
root@debian:~# ulimit -Hf
unlimited

unlimited

500

-S

-H

root@debian:~# ulimit -f 500
root@debian:~# ulimit -Sf
500
root@debian:~# ulimit -Hf
500

200

root@debian:~# ulimit -Sf 200
root@debian:~# ulimit -Sf
200
root@debian:~# ulimit -Hf
500/etc/security/limits.conf
limists.con

ulimithelp

ulimit

last
who

w

last

root@debian:~# last
carol

pts/0

192.168.1.4

Sat Jun

6 14:25

still logged inrebootsystem boot4.19.0-9-amd64

Sat Jun

6 14:24

still running

mimi

pts/0

192.168.1.4

Sat Jun

6 12:07 - 14:24(02:16)

rebootsystem boot4.19.0-9-amd64

Sat Jun

6 12:07 - 14:24(02:17)(...)
wtmp begins Sun May 31 14:14:58 2020

carol

pts/0

192.168.1.4

14:25（6月6日土曜日14時25分）
Sat

Jun

still
6

logged

Sat

Jun

6

in（現在もログイン中）

14:24（6月6日土曜日14時24分）

4.19.0-9-amd64

still running（現在も稼働中）
mimi

pts/0

192.168.1.4

12:07（6月6日土曜日12時07分）

Sat

Jun

6

14:24（14時24分）

02:16（2時間16分）
月6日土曜日12時07分）

Sat Jun 6 12:07（64.19.0-9-amd64

14:24（14時24分）

02:17（2時間17分）

mini

last

/var/log/wtmp
Sun

May

31

14:14:58

2020

last

root@debian:~# last carol
carol

pts/0

192.168.1.4

Sat Jun

6 14:25

still logged in

carol

pts/0

192.168.1.4

Sat Jun

6 12:07 - 14:24(02:16)

carol

pts/0

192.168.1.4

Fri Jun

5 00:48 - 01:28(00:39)

(...)

pts
tty

0

tty
pts

last
who

lastb

w

who
w
who

root@debian:~# who
carol

pts/0

2020-06-06 17:16 (192.168.1.4)

mimi

pts/1

2020-06-06 17:28 (192.168.1.4)-b--boot-r--runlevel-H--headingw

who

root@debian:~# w
17:56:12 up 40 min,2 users,

USER

TTY

FROM

carol

pts/0

192.168.1.4

mimi

pts/1

192.168.1.4

load average: 0.04, 0.12, 0.09
LOGIN@IDLE

JCPU

PCPU WHAT

17:16

1.00s

0.15s

0.05s sshd: carol [priv]

17:28

15:08

0.05s

0.05s -bash

17:56:12
up

40

min

average: 0.04, 0.12, 0.09

2

users

load

USER

TTY

FROM

LOGIN@

IDLE

JCPU

PCPU
WHAT
WHAT

who

w

root@debian:~# w mimi
18:23:15 up

1:07,

2 users,load average: 0.00, 0.02, 0.05

USER

TTY

FROM

LOGIN@IDLE

JCPU

PCPU WHAT

mimi

pts/1

192.168.1.4

17:28

9:23

0.06s

0.06s -bash

sudo
su

su
su
su

su

-

変更後のユーザー名

sudo

sudo

sudo

passwdroot

carol@debian:~$ su - root
Password:root@debian:~# exit
logoutcarol@debian:~$ su Password:root@debian:~#-~/.profile-

carol@debian:~$ su
Password:root@debian:/home/carol#

su

sudo
sudo

su

sudoers/etc/sudoers/etc/sudoers.d/

su

sudo

sudo

-u

実行ユーザー名コマンド-u 実行ユーザー名

carol@debian:~$ sudo -u mimi whoami
mimi
carol@debian:~$ sudo whoami
root

sudo

sudoerssudo/etc/sudoers

Defaults

timestamp_timeout

Defaults

timestamp_timeout=1/etc/sudoers
sudo/etc/sudoers/etc/sudoers.dsudo

carol@debian:~$ sudo less /etc/sudoers(...)# User privilege specification
root

ALL=(ALL:ALL) ALL# Allow members of group sudo to execute any command%sudo

ALL=(ALL:ALL) ALL(...)

ALL=(ALL:ALL)

ALL

ALL

root
(ALL:ALL)

ALL

%

sudo
carol

apache2sudoers

carol

carol

carol

ALL=(ALL:ALL) /usr/bin/systemctl restart apache2

systemctl

restartapache2

ALL=(ALL:ALL) NOPASSWD: /usr/bin/systemctl restart apache2

192.168.1.7/usr/local/bin/weekly_reportmimicarol192.168.1.7=(mimi) /usr/local/bin/weekly_reportcarol

usermod
-G

carol

sudo
-a

usermod-aroot@debian:~# sudo usermod -aG sudo carol

wheel
sudo
/etc/sudoers

visudovisudo/etc/sudoers
editorDefaults

Defaults
nano

editor=/usr/bin/nanovisudovipw
EDITOR

VISUALEDITOR=/usr/bin/nano/etc/sudoers# Host alias specification
Host_Alias SERVERS = 192.168.1.7, server1, server2# User alias specification
User_Alias REGULAR_USERS = john, mary, alex
User_Alias PRIVILEGED_USERS = mimi

User_Alias ADMINS = carol, %sudo, PRIVILEGED_USERS, !REGULAR_USERS# Cmnd alias specification
Cmnd_Alias SERVICES = /usr/bin/systemctl *# User privilege specification
root

ALL=(ALL:ALL) ALL

ADMINSSERVERS=SERVICES# Allow members of group sudo to execute any command%sudo

ALL=(ALL:ALL) ALL

sudoers+
SERVERS

Host_Alias SERVERS = 192.168.1.7, server1, server2

#

%

%#

+

!
carol

sudo

PRIVILEGE_USERS

mimi

ADMINSREGULAR_USERS
john、mary、alex

User_Alias ADMINS = carol, %sudo, PRIVILEGED_USERS, !REGULAR_USERS/usr/bin/systemctl*

SERVICES

Cmnd_Alias SERVICES = /usr/bin/systemctl *Userprivilege

SERVERS=SERVICES

specification

ADMINSADMINSSERVERSSERVICES

sudo(ALL:ALL)
Runas

Runas_Alias(Runas_Alias:Runas_Alias)

Runas

:
:

SUID
SGID
SUID

SGID

/usr/bin

SUID/usr/bin

SGID/usr/bin

SUID

SGID

chage
mary

chage

chage192.168.1.55

22
lsof

fuser

netstat192.168.1.55
443

80

nmap
ulimit

last

carol

pts/0

192.168.1.4

Sun May 31 14:16 - 14:22(00:06)

carol

carol

/etc/sudoers# Host alias specification
Host_Alias SERVERS = 192.168.1.7, server1, server2# User alias specification
User_Alias REGULAR_USERS = john, mary, alex
User_Alias PRIVILEGED_USERS = mimi
User_Alias ADMINS = carol, %sudo, PRIVILEGED_USERS, !REGULAR_USERS# Cmnd alias specification
Cmnd_Alias WEB_SERVER_RESTART = /usr/bin/systemctl restart apache2# User privilege specification
root

ALL=(ALL:ALL) ALL

ADMINSSERVERS=WEB_SERVER_RESTART# Allow members of group sudo to execute any command
%sudo

alex

ALL=(ALL:ALL) ALL

SUID

SGID
/tmp

~/temporal~/temporal

passwd-l

ユーザー名

usermod-L

ユーザー名/etc/shadow

chage

-E

日付

ユーザー名

chage

--expiredate

日付

ユーザー名

usermod

nmap

SUID

sudo

find

passwd

chmod

chage

lsof

fuser

netstatnmap

ulimitSGID/etc/sudoers

last

lastb

/var/log/wtmp

who

w

su

sudo

/etc/sudoers
sudo

SUID

4000

s

find -perm 4000

S

find -perm u+s
SGID

2000

s

find -perm 2000

S

find -perm g+s
SUID

SGID

/usr/bin

SUIDfind /usr/bin -perm -4000

find /usr/bin -perm -u+s

/usr/bin

SGIDfind /usr/bin -perm -2000/usr/bin

SUIDfind /usr/bin -perm -g+s
SGIDfind /usr/bin -perm /6000
chage
mary

chage
chage -M 365 marychage --maxdays 365

marychage -d 0 marychage --lastday 0 marychagechage -m 1 marychage --mindays 1 marychage -M 99999 marychage --maxdays

99999 marychage -m 0 marychage --mindays 0 marychage -W 7 -E 2050-08-20 marychage--warndays 7 --expiredate 2050-08-20 marychage -l mary

192.168.1.55

22

chage --list marylsof -i@192.168.1.55:22

lsof

fuser -vn tcp 80
fuser

fuser --verbose--namespace tcp 80

netstat -lu

netstat --listening --udp

netstat192.168.1.55443

80

nmap -p 80-443 192.168.1.55

nmap
ulimitulimit -m

ulimit -Sm

ulimit -Hmulimit -Sm 5000

ulimit -Hm 10000

last

carol

pts/0

192.168.1.4

Sun May 31 14:16 - 14:22(00:06)

carol

carol

/etc/sudoers# Host alias specification
Host_Alias SERVERS = 192.168.1.7, server1, server2# User alias specification
User_Alias REGULAR_USERS = john, mary, alex
User_Alias PRIVILEGED_USERS = mimi
User_Alias ADMINS = carol, %sudo, PRIVILEGED_USERS, !REGULAR_USERS# Cmnd alias specification
Cmnd_Alias WEB_SERVER_RESTART = /usr/bin/systemctl restart apache2# User privilege specification
root

ALL=(ALL:ALL) ALL

ADMINSSERVERS=WEB_SERVER_RESTART

# Allow members of group sudo to execute any command%sudo

ALL=(ALL:ALL) ALL

alex
alex
ADMINS
restart apache2

REGULAR_USERSSERVERSADMINS

systemctl

SUID

SGID
/tmp

~/temporalchmod +t temporalchmod 1755 temporalfind ~ -perm -1000

find ~ -perm /1000~/temporalchmod -t temporal
passwd-l

ユーザー名

chmod 0755 temporal
usermod-L

ユーザー名/etc/shadow

mary:!$6$gOg9xJgv…
chage

-E

日付

ユーザー名

usermod -e 日付 ユーザー名

chage--expiredate

日付

ユーザー名

usermod

usermod --expiredate 日付 ユーザー名
nmap

nmap -p 1-65535 localhost

nmap -p- localhost

/etc/nologin/etc/passwd/etc/shadow/etc/xinetd.d//etc/xinetd.conf
systemd.socket/etc/inittab/etc/init.d//etc/hosts.allow/etc/hosts.deny

/etc/passwd/etc/passwdx/etc/passwd

/etc/passwdx/etc/shadow/etc/shadow
passwdchage/etc/shadowemma$ sudo passwd emma
New password:
Retype new password:
passwd: password updated successfullyemma$ sudo chage -l emma
Last password change: Apr 27, 2020

Password expires: never

Password inactive: never

Account expires: never

Minimum number of days between password change: 0

Maximum number of days between password change: 99999

Number of days of warning before password expires

: 7

emma

$ sudo chage -E 2020-03-26 emmaemma

$ sudo passwd -l emma-lpasswd

sudo

chage

-E

2020-03-26

emma

emma

$ sudo login emma
Password:Your account has expired; please contact your system administrator
Authentication failure/etc/nologin
man 5 nologin
nologinemma$ sudo usermod -s /sbin/nologin emma

man 8 nologin

servicesystemctl

inetd
systemd.socket

xinetdsshd

xinetdxinetdopenssh-server

xinetdxinetdxinetd$ systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset:
enabled)Active: active (running) since Mon 2020-04-27 09:33:48 EDT; 3h 11min ago
Docs: man:sshd(8)man:sshd_config(5)Process: 430 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 460 (sshd)
Tasks: 1 (limit: 1119)
Memory: 5.3M
CGroup: /system.slice/ssh.service└─460 /usr/sbin/sshd -D$ sudo lsof -i :22
COMMAND

PID USER

FD

TYPE

sshd

1194 root

3u

IPv4 16053268

0t0

TCP *:ssh (LISTEN)

sshd

1194 root

4u

IPv6 16053270

0t0

TCP *:ssh (LISTEN)

sshd

DEVICE SIZE/OFF NODE NAME

xinetd$ sudo systemctl stop sshd.service

systemctl

disablesshd.service/etc/xinetd.d/ssh

service ssh{disable= nosocket_type = stream
protocol

= tcp

wait

= no

user

= rootserver= /usr/sbin/sshd

server_args = -i
flags

= IPv4interface= 192.168.178.1}$ sudo systemctl restart xinetd.service$ sudo lsof -i :22
COMMAND

PID USER

FD

TYPE

DEVICE SIZE/OFF NODE NAME

xinetd24098 root

5u

IPv4 7345141

xinetd0t0

TCP 192.168.178.1:ssh (LISTEN)/etc/xinetd.conf# Simple configuration file for xinetd## Some defaults, and include /etc/xinetd.d/
defaults{# Please note that you need a log_type line to be able to use log_on_success# and log_on_failure. The default is the following :# log_type = SYSLOG daemon info}
includedir /etc/xinetd.ddefaults
includedir/etc/xinetd.d{}/etc/xinetd.dxinetd/etc/xinetd.d/ssh.

~/etc/xinetd.d$ ls -l /etc/xinetd.d
total 52
-rw-r--r-- 1 root root 640 Feb

52018 chargen-rw-r--r-- 1 root root 313 Feb

52018 chargen-udp-rw-r--r-- 1 root root 502 Apr 11 10:18 daytime-rw-r--r-- 1 root root 313 Feb

52018 daytime-udp-rw-r--r-- 1 root root 391 Feb

52018 discard-rw-r--r-- 1 root root 312 Feb

52018 discard-udp-rw-r--r-- 1 root root 422 Feb

52018 echo-rw-r--r-- 1 root root 304 Feb

52018 echo-udp-rw-r--r-- 1 root root 312 Feb

52018 servers-rw-r--r-- 1 root root 314 Feb

52018 services-rw-r--r-- 1 root root 569 Feb

52018 time-rw-r--r-- 1 root root 313 Feb

52018 time-udp

daytimedisableyesno/etc/xinetd.d/ssh

service ssh{disable= nosocket_type = stream
protocol

= tcp

wait

= no

user

= rootserver= /usr/sbin/sshd

server_args

}

= -i

flags

= IPv4interface= 192.168.178.1=

yesservicessh/etc/services{

disablenoyessocket_type
streamdgram

protocol

wait
no
user

serverxinetdserver_args
-i
flags

interfacexinetdbind}

xinetdxinetd
lsof

-i

sudo

:22

sshd

xinetd$ sudo systemctl start ssh.socket

lsof
-P

$ sudo lsof -i :22 -P
COMMAND PID USER

FD

TYPE

systemd

57u

IPv6 14730112

1 rootsystemctl

start

DEVICE SIZE/OFF NODE NAME

ssh.socket$ sudo service --status-all$ sudo update-rc.d サービス名 remove

0t0

TCP *:22 (LISTEN)

systemctl

startsshd.socket$ sudo chkconfig サービス名 off$ systemctl list-units --state active --type service$ sudo systemctl disable ユニット --now

netstatnet-tools$ netstat -ltu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address

Foreign Address

State

tcp

0

0 0.0.0.0:ssh

0.0.0.0:*

LISTENtcp

00 localhost:mysql

0.0.0.0:*

LISTEN

tcp6

00 [::]:http[::]:*

LISTEN

tcp6

00 [::]:ssh[::]:*

LISTEN

udp

0

0 0.0.0.0:bootpc

0.0.0.0:*ss$ ss -ltu
Netid

State

Recv-Q

Send-Q

Local Address:PortUNCONN00

0.0.0.0:bootpc

LISTEN0128

0.0.0.0:ssh

LISTEN080127.0.0.1:mysql

Peer Address:Port
udp
0.0.0.0:*
tcp
0.0.0.0:*
tcp
0.0.0.0:*

tcp

LISTEN0128*:http

LISTEN0128[::]:ssh*:*tcp[::]:*

tcpd

libwrap$ ldd /usr/sbin/sshd | grep "libwrap"
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f91dbec0000)/etc/hosts.denysshd: ALL

/etc/hosts.allow

sshd: LOCAL

ssh

emma

emma

/etc/nologinroot/etc/nologin

login

currentlyisnotpossibleemma/etc/passwd

grep

root

/etc/passwd

root

emma
/etc/shadow/etc/nologin

grep

-i

emma

/etc/shadow

xinetd

xinetd

sshd

chage

chkconfig

netstatnet-tools
nologinpasswdservicess
netstatsystemctl

update-rc.dxinetd
xinetdemma
passwd -u emma
emma

chage

-E

-1

emma

chage -l emma

systemctl disable cups.service --now

netstat -l | grep ":ipp "ss -l | grep ":ipp "ldd /usr/sbin/nginx | grep "libwrap"-E-1

/etc/nologin

root

root
/etc/nologin

login

currentlyisnotpossiblelogin

currentlyisnotpossibleemma/etc/passwd/etc/nologin

grep

root

/etc/passwd

root/etc/passwd

root

emma

grep

-i

emma

/etc/shadow/etc/shadow/etc/shadow/etc/xinetd.d/daytime
systemctl
servicexinetdlocalhost daytime

disablerestartdisable=noxinetd.service

restartnetcat localhost daytime

nc

ssh
ssh-keygenssh-agentssh-add~/.ssh/id_rsa

id_rsa.pub~/.ssh/id_dsa

id_dsa.pub~/.ssh/id_ecdsa~/.ssh/id_ed25519

id_ecdsa.pub
id_ed25519.pub/etc/ssh/ssh_host_rsa_key

ssh_host_rsa_key.pub/etc/ssh/ssh_host_dsa_key

ssh_host_dsa_key.pub

/etc/ssh/ssh_host_ecdsa_key/etc/ssh/ssh_host_ed25519_key~/.ssh/authorized_keys
ssh_known_hosts
gpg
gpg-agent~/.gnupg/

ssh_host_ecdsa_key.pub
ssh_host_ed25519_key.pub

192.168.1.55

debiancarol

192.168.1.77

halof

ina

ssh
openssh-server
openssh-clients

openssh-clientsshcarol@debian:~$ ssh ina@192.168.1.77
The authenticity of host '192.168.1.77 (192.168.1.77)' can't be established.
ECDSA key fingerprint is SHA256:5JF7anupYipByCQm2BPvDHRVFJJixeslmppi2NwATYI.
Are you sure you want to continue connecting (yes/no)?

yes

Warning: Permanently added '192.168.1.77' (ECDSA) to the list of known hosts.
Password:
Last login: Sat Jun 20 10:52:45 2020 from 192.168.1.4
Have a lot of fun...
ina@halof:~>

192.168.1.77
SHA256
ECDSA

key~/.sshfingerprint（ECDSA鍵指紋）

known_hosts

ina@halof:~> exit
logoutConnection to 192.168.1.77 closed.
carol@debian:~$ ls .ssh/
known_hosts.sshknown_hosts~/.sshyessshssh ina@halof ls

debian
halof

carol

carol

ssh

192.168.1.77

ssh halof

carol@debian:~$ ssh halof
Password:
Last login: Wed Jul

1 23:45:02 2020 from 192.168.1.55

Have a lot of fun...
carol@halof:~>halof

carol@debian:~$ ssh john@192.168.1.77@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:KH4q3vP6C7e0SEjyG8Wlz9fVlf+jmWJ5139RBxBh3TY.
Please contact your system administrator.
Add correct host key in /home/carol/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/carol/.ssh/known_hosts:1
remove with:ssh-keygen -f "/home/carol/.ssh/known_hosts" -R "192.168.1.77"
ECDSA host key for 192.168.1.77 has changed and you have requested strict checking.
Host key verification failed.

.ssh/known_hosts"/home/carol/.ssh/known_hosts"-f-fssh-keygen-R"192.168.1.77"

ファイル名~/.ssh/known_hosts
ssh-keygen-R

192.168.1.77-fsshkeygen-t~/.ssh/carol@debian:~/.ssh$ ssh-keygen -t ecdsa
Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/carol/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/carol/.ssh/id_ecdsa.
Your public key has been saved in /home/carol/.ssh/id_ecdsa.pub.
The key fingerprint is:
SHA256:tlamD0SaTquPZYdNepwj8XN4xvqmHCbe8g5FKKUfMo8 carol@debianThe key's randomart image is:+---[ECDSA 256]---+
|

.

|

|

o .

|

|

= o o

|

|

B *

|

|

E B S o

|

|

o & O

|

|

@ ^ =

|

|

*.@ @.

||

o.o+B+o|+----[SHA256]-----+

ssh-keygen-bssh-keygen521~/.sshcarol@debian:~/.ssh$ ls
id_ecdsa

id_ecdsa.pub

known_hosts

-t

ecdsa

-b

id_ecdsa

id_ecdsa.pub~/.ssh/authorized_keys~/.ssh
scp
cat

ssh

cat

~/.ssh/authorized_keys

carol@debian:~/.ssh$ cat id_ecdsa.pub |ssh ina@192.168.1.77 'cat >>.ssh/authorized_keys'
Password:

authorized_keyssshcarol@debian:~$ ssh ina@192.168.1.77
Last login: Thu Jun 25 20:31:03 2020 from 192.168.1.55
Have a lot of fun...
ina@halof:~>ssh

carol@debian:~/.ssh$ ssh ina@192.168.1.77
Enter passphrase for key '/home/carol/.ssh/id_ecdsa':
Last login: Thu Jun 25 20:39:30 2020 from 192.168.1.55

Have a lot of fun...
ina@halof:~>ssh-agentssh-agentcarol@debian:~/.ssh$ ssh-agent /bin/bash
carol@debian:~/.ssh$

ssh-addcarol@debian:~/.ssh$ ssh-add
Enter passphrase for /home/carol/.ssh/id_ecdsa:
Identity added: /home/carol/.ssh/id_ecdsa (carol@debian)ssh-agentssh-keygen

RSA

DSA

ecdsa

ed25519
EdDSA-t

ssh-keygen/etc/ssh

halof:~ # tree /etc/ssh/etc/ssh├── moduli├── ssh_config├── ssh_host_dsa_key├── ssh_host_dsa_key.pub├── ssh_host_ecdsa_key├── ssh_host_ecdsa_key.pub├── ssh_host_ed25519_key├── ssh_host_ed25519_key.pub├── ssh_host_rsa_key├── ssh_host_rsa_key.pub└── sshd_config
0 directories, 11 files

modulissh_config

sshd_config

ssh_host__key

ssh_host__key.pub

ssh_host_rsa_key

ssh_host_rsa_key.pub

RSA

0600

rw-------

root
0644

rw-r--r--

halof:~ # ls -l /etc/ssh/ssh_host_*-rw------- 1 root root 1381 Dec 21 20:35 /etc/ssh/ssh_host_dsa_key-rw-r--r-- 1 root root

605 Dec 21 20:35 /etc/ssh/ssh_host_dsa_key.pub-rw------- 1 root root

505 Dec 21 20:35 /etc/ssh/ssh_host_ecdsa_key-rw-r--r-- 1 root root

177 Dec 21 20:35 /etc/ssh/ssh_host_ecdsa_key.pub-rw------- 1 root root

411 Dec 21 20:35 /etc/ssh/ssh_host_ed25519_key-rw-r--r-- 1 root root

97 Dec 21 20:35 /etc/ssh/ssh_host_ed25519_key.pub-rw------- 1 root root 1823 Dec 21 20:35 /etc/ssh/ssh_host_rsa_key-rw-r--r-- 1 root root-l397 Dec 21 20:35 /etc/ssh/ssh_host_rsa_key.pub-fssh-keygen

halof:~ # ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key
256 SHA256:8cnPrinC49ZHc+/9Ai5pV+1JfZ4WBRZhd3rDOsc2zlA root@halof (ED25519)
halof:~ # ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub
256 SHA256:8cnPrinC49ZHc+/9Ai5pV+1JfZ4WBRZhd3rDOsc2zlA root@halof (ED25519)-v

halof:~ # ssh-keygen -lv -f /etc/ssh/ssh_host_ed25519_key.pub
256 SHA256:8cnPrinC49ZHc+/9Ai5pV+1JfZ4WBRZhd3rDOsc2zlA root@halof (ED25519)+--[ED25519 256]--+
|

+oo|

|

.+o.|

|

.

..E.|

|

+ .

+.o|

|

S +

+ *o|

|

ooo Oo=||. . . =o+.==||= o =oo o=o||o.o +o+..o.+|+----[SHA256]-----+

8585
halof

www.gnu.org

80

carol@debian:~$ ssh -L 8585:www.gnu.org:80 ina@halof
Enter passphrase for key '/home/carol/.ssh/id_ecdsa':
Last login: Thu Jun 25 20:39:30 2020 from 192.168.1.55
Have a lot of fun...
ina@halof:~>

-L

8585

www.gnu.org:80
8585
www.gnu.org:80
http://localhost:8585
www.gnu.org

carol@debian:~$ lynx http://localhost:8585(...)* Back to Savannah Homepage* Not Logged in* Login* New User
* This Pagelynx

* Language* Clean Reload* Printer Version* Search* _(...)

carol@debian:~$ ssh -L 8585:www.gnu.org:80 -Nf ina@192.168.1.77
Enter passphrase for key '/home/carol/.ssh/id_ecdsa':
carol@debian:~$carol@debian:~$ lynx http://localhost:8585(...)* Back to Savannah Homepage* Not Logged in* Login* New User
* This Page
* Language* Clean Reload* Printer Version* Search
* _
(...)

-N

halof

-f
ina@192.168.1.77

halof

ina

ina@halof

halof

192.168.1.77

8585
80

carol@debian:~$ ssh -R 8585:localhost:80 -Nf ina@192.168.1.77
Enter passphrase for key '/home/carol/.ssh/id_ecdsa':
carol@debian:~$

halof

8585

Debiancarol@debian:~$ lynx 192.168.1.77:8585(...)
Apache2 DebianDefault Page: It works (p1 of 3)
Debian Logo Apache2 Debian Default Page
It works!
This is the default welcome page used to test the correct operation of the
Apache2 server after
installation on Debian systems. If you can read this page, it means that the
Apache HTTP server
installed at this site is working properly. You should replace this file(located at/var/www/html/index.html) before continuing to operate your HTTP server.
(...)

ssh

-X

carol@debian:~$ ssh -X ina@halof...

firefoxDISPLAY-x
firefoxcarol@debian:~$ ssh -x ina@halof
carol@192.168.0.106's password:(...)
ina@halof:~$ firefox(firefox-esr:1779): Gtk-WARNING **: 18:45:45.603: Locale not supported by C
library.
Using the fallback 'C' locale.
Error: no DISPLAY environment variable specified

AllowTcpForwarding
X11Forwardingman

GatewayPorts

ssh_config

mansshd_config

sonyahalof

serena~/.sshserenasonya~/.ssh/known_hosts

halof

ecdsa

ed25519ssh-agent/bin/bash

ssh-keygenssh-add~/.ssh/authorized_keys~/.ssh~/.sshssh-L

8888:localhost:80-Nf

ina@halof
http://localhost:8888

root/etc/ssh/sshd_config/etc/ssh/sshd_config

halofwww.gnu.org
ina

-Nf

www.melpa.org

RSA
ed25519ssh

ssh-keygenssh-agentssh-add

DSA

ecdsa

sonyahalof

serena~/.sshssh serena@halof ls .ssh

serenassh serena@halof

sonya

ssh halof~/.ssh/known_hosts

ssh-keygen -R halof

ecdsa

ssh-keygen -t ecdsa -b 256

ed25519

ssh-keygen -t ed25519

ssh-agentssh-keygen/bin/bash

halofssh-add~/.ssh/authorized_keys~/.ssh~/.sshssh-keygen~/.ssh~/.ssh~/.ssh/authorized_keys

ssh-agent /bin/bash

ssh-addssh-L

8888:localhost:80-L

AllowTcpForwarding-R

GatewayPorts-X

X11Forwarding-Nf

ina@halof
http://localhost:8888

halof

localhost
localhostroot/etc/ssh/sshd_config

PermitRootLogin/etc/ssh/sshd_config

AllowUsers

ssh-copy-id
halof
www.gnu.org
ina

www.melpa.org-Nfssh -L 8080:www.gnu.org:80 -L 8585:www.melpa.org:80 -Nf ina@halof

gpg
carol

gpg

--gen-keycarol@debian:~$ gpg --gen-key
gpg (GnuPG) 2.2.12; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
gpg: directory '/home/carol/.gnupg' created
gpg: keybox '/home/carol/.gnupg/pubring.kbx' createdNote: Use "gpg --full-generate-key" for a full featured key generation dialog.
GnuPG needs to construct a user ID to identify your key.
Real name:(...)~/.gnupg~/.gnugpg/pubring.kbx(...)
Real name: carol
Email address: carol@debianYou selected this USER-ID:"carol <carol@debian>"
Change (N)ame, (E)mail, or (O)kay/(Q)uit?

USER-ID
O┌──────────────────────────────────────────────────────┐│ Please enter the passphrase to││ protect your new key

│

│

│

│ Passphrase:│(...)(...)
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize thedisks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: /home/carol/.gnupg/trustdb.gpg: trustdb created
gpg: key 19BBEFD16813034E marked as ultimately trusted
gpg: directory '/home/carol/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/carol/.gnupg/openpgprevocs.d/D18FA0021F644CDAF57FD0F919BBEFD16813034E.rev'
public and secret key created and signed.
pub

rsa3072 2020-07-03 [SC] [expires: 2022-07-03]
D18FA0021F644CDAF57FD0F919BBEFD16813034E

uid
sub

carol <carol@debian>rsa3072 2020-07-03 [E] [expires: 2022-07-03]~/.gnupg

carol@debian:~/.gnupg$ ls -ltotal 16
drwx------ 2 carol carol 4096 Jul

3 23:34 openpgp-revocs.ddrwx------ 2 carol carol 4096 Jul

3 23:34 private-keys-v1.d-rw-r--r-- 1 carol carol 1962 Jul

3 23:34 pubring.kbx-rw------- 1 carol carol 1240 Jul

3 23:34 trustdb.gpg

opengp-revocs.d

private-keys-v1.d

pubring.kbx

trustdb.gpg

secring.gpg
private-keys-v1.d

pubring.gpg

pubring.kbx
gpg--list-keys

carol@debian:~/.gnupg$ gpg --list-keys/home/carol/.gnupg/pubring.kbx-----------------------------pubrsa3072 2020-07-03 [SC] [expires: 2022-07-03]
D18FA0021F644CDAF57FD0F919BBEFD16813034E

uid
sub

[ultimate] carol <carol@debian>rsa3072 2020-07-03 [E] [expires: 2022-07-03]

D18FA0021F644CDAF57FD0F919BBEFD16813034E
USER-ID

carol

KEY-ID

KEY-ID
6813

gpg--fingerprint

034E

USER-ID

gpg--export

USER-ID

carol@debian:~/.gnupg$ gpg --export carol > carol.pub.key
carol@debian:~/.gnupg$ lscarol.pub.key

gpg

openpgp-revocs.d--export

private-keys-v1.d-apubring.kbx

trustdb.gpg--armor

gpg--export --armor carol > carol.pub.key

carol.pub.key
scp
halof

ina

carol@debian:~/.gnupg$ scp carol.pub.key ina@halof:/home/ina/Enter passphrase for key '/home/carol/.ssh/id_ecdsa':
carol.pub.key
100% 1740

775.8KB/s

00:00

carol@debian:~/.gnupg$

inacarol.pub.key

gpg

carol

--keyserver

keyserver-name--send-keys

KEY-ID
gpg

keyserver-name--recv-keys--keyserver

KEY-ID

keys.openpgp.org

gpg--gen-revoke

USER-ID--gen-revoke--outputsonya@debian:~/.gnupg$ gpg --output revocation_file.asc --gen-revoke sonyasec

rsa3072/0989EB7E7F9F2066 2020-07-03 sonya <sonya@debian>Create a revocation certificate for this key? (y/N) y
Please select the reason for the revocation:

0 = No reason specified （理由を指定しない）
1 = Key has been compromised （鍵の漏洩）
2 = Key is superseded （鍵の切り替え）
3 = Key is no longer used （鍵の破棄）
Q = Cancel(Probably you want to select 1 here)Your decision? 1
Enter an optional description; end it with an empty line:> My laptop was stolen.
>
Reason for revocation: Key has been compromised
My laptop was stolen.
Is this okay? (y/N) y
ASCII armored output forced.
Revocation certificate created.
Please move it to a medium which you can hide away; if Mallory gets
access to this certificate he can use it to make your key unusable.
It is smart to print this certificate and store it away, just in caseyour media become unreadable.

But have some caution:

The print system ofyour machine might store the data and make it available to others!
（要約：安全なメディアにファイルを保管します。誰かに漏洩すると悪者はあなたの鍵を無効化できます。メディアが読めなくなることに備えて印刷しておくとよいでしょう。）

revocation_file.asc.asc

sonya@debian:~/.gnupg$ ls
openpgp-revocs.d

private-keys-v1.d

pubring.kbx

revocation_file.asc

sonya@debian:~/.gnupg$ cat revocation_file.asc-----BEGIN PGP PUBLIC KEY BLOCK----Comment: This is a revocation certificate
iQHDBCABCgAtFiEEiIVjfDnnpieFi0wvnlcN6yLCeHEFAl8ASx4PHQJzdG9sZW4g
bGFwdG9wAAoJEJ5XDesiwnhxT9YMAKkjQiMpo9Uyiy9hyvukPPSrLcmtAGLk4pKS
pLZfzA5kxa+HPQwBglAEvfNRR6VMxqXUgUGYC/IAyQQM62oNAcY2PCPrxyJNgVF7
8l4mMZKvW++5ikjZwyg6WWV0+w6oroeo9qruJFjcu752p4T+9gsHVa2r+KRqcPQe
aZ65sAvsBJlcsUDZqfWUXg2kQp9mNPCdQuqvDaKRgNCHA1zbzNFzXWVd2X5RgFo5
nY+tUP8ZQA9DTQPBLPcggICmfLopMPZYB2bft5geb2mMi2oNpf9CNPdQkdccimNV
aRjqdUP9C89PwTafBQkQiONlsR/dWTFcqprG5KOWQPA7xjeMV8wretdEgsyTxqHp
v1iRzwjshiJCKBXXvz7wSmQrJ4OfiMDHeS4ipR0AYdO8QCzmOzmcFQKikGSHGMy1z/YRlttd6NZIKjf1TD0nTrFnRvPdsZOlKYSArbfqNrHRBQkgirOD4JPI1tYKTffq
iOeZFx25K+fj2+0AJjvrbe4HDo5m+Q===umI8

trustdb.gpg

-----END PGP PUBLIC KEY BLOCK-----

sonya@debian:~/.gnupg$ gpg --import revocation_file.asc
gpg: key 9E570DEB22C27871: "sonya <sonya@debian>" revocation certificate imported
gpg: Total number processed: 1
gpg:

new key revocations: 1

gpg: marginals needed: 3completes needed: 1

gpg: depth: 0

signed:valid:

1

0

trust model: pgp

trust: 0-, 0q, 0n, 0m, 0f, 1u

gpg: next trustdb check due at 2022-07-04

sonya@debian:~/.gnupg$ gpg --list-keys/home/sonya/.gnupg/pubring.kbx
pub

rsa3072 2020-07-04 [SC] [revoked: 2020-07-04]
8885637C39E7A627858B4C2F9E570DEB22C27871

uid[ revoked] sonya <sonya@debian>

carol

ina

carol

ina

carol.pub.key

ina@halof:~> gpg --import carol.pub.key
gpg: /home/ina/.gnupg/trustdb.gpg: trustdb created
gpg: key 19BBEFD16813034E: public key "carol <carol@debian>" imported
gpg: Total number processed: 1
gpg:

imported: 1

ina@halof:~> gpg --list-keys

/home/ina/.gnupg/pubring.kbx---------------------------pubrsa3072 2020-07-03 [SC] [expires: 2022-07-03]
D18FA0021F644CDAF57FD0F919BBEFD16813034E

uid[ unknown] carol <carol@debian>sub

rsa3072 2020-07-03 [E] [expires: 2022-07-03]

gpg
carol

carol

--lsign-key
Web

of

Trust

ina@halof:~> echo "This is the message ..." > unencrypted-message
ina@halof:~> gpg --output encrypted-message --recipient carol --armor --encrypt
unencrypted-message
gpg: 0227347CC92A5CB1: There is no assurance this key belongs to the named usersubrsa3072/0227347CC92A5CB1 2020-07-03 carol <carol@debian>Primary key fingerprint: D18F A002 1F64 4CDA F57F

D0F9 19BB EFD1 6813 034E

Subkey fingerprint: 9D89 1BF9 39A4 C130 E44B

1135 0227 347C C92A 5CB1

It is NOT certain that the key belongs to the person namedin the user ID.

If you really know what you are doing,

you may answer the next question with yes.
Use this key anyway? (y/N) y

gpg--output encrypted-message
encrypted-message--recipient carol
USER-ID--default-recipient--armorcarol
USER-ID

--encrypt unencrypted-message

scp

debiancarol

encrypted-message

ina@halof:~> scp encrypted-message carol@debian:/home/carol/
carol@debian's password:
encrypted-message
736

1.8MB/s

carol

100%
00:00

encrypted-message

carol@debian:~$ cat encrypted-message-----BEGIN PGP MESSAGE----hQGMAwInNHzJKlyxAQv/brJ8Ubs/xya35sbv6kdRKm1C7ONLxL3OueWA4mCs0Y/P
GBna6ZEUCrMEgl/rCyByj3Yq74kuiTmzxAIRUDdvHfj0TtrOWjVAqIn/fPSfMkjk
dTxKo1i55tLJ+sj17dGMZDcNBinBTP4U1atuN71A5w7vH+XpcesRcFQLKiSOmYTt
F7SN3/5x5J6io4ISn+b0KbJgiJNNx+Ne/ub4Uzk4NlK7tmBklyC1VRualtxcG7R9
1klBPYSld6fTdDwT1Y4MofpyILAiGMZvUR1RXauEKf7OIzwC5gWU+UQPSgeCdKQu
X7QL0ZIBS0Ug2XKrO1k93lmDjf8PWsRIml6n/hNelaOBA3HMP0b6Ozv1gFeEsFvC
IxhUYPb+rfuNFTMEB7xIO94AAmWB9N4qknMxdDqNE8WhA728Plw6y8L2ngsplY15
MR4lIFDpljA/CcVh4BXVe9j0TdFWDUkrFMfaIfcPQwKLXEYJp19XYIaaEazkOs5D
W4pENN0YOcX0KWyAYX6r0l8BF0rq/HMenQwqAVXMG3s8ATuUOeqjBbR1x1qCvRQP
CR/3V73aQwc2j5ioQmhWYpqxiro0yKX2Ar/E6rZyJtJYrq+CUk8O3JoBaudknNFj
pwuRwF1amwnSZ/MZ/9kMKQ===g1jw-----END PGP MESSAGE-----

carol

gpg

--decrypt

carol@debian:~$ gpg --decrypt encrypted-message
gpg: encrypted with 3072-bit RSA key, ID 0227347CC92A5CB1, created 2020-07-03"carol <carol@debian>"This is the message ...

--outputcarol@debian:~$ gpg --output unencrypted-message --decrypt encrypted-message
gpg: encrypted with 3072-bit RSA key, ID 0227347CC92A5CB1, created 2020-07-03"carol <carol@debian>"carol@debian:~$ cat unencrypted-message
This is the message ...

--signmessage--signcarol@debian:~$ echo "This is the message to sign ..." > message
carol@debian:~$ gpg --output message.sig --sign message
(...)

gpg
--output message.sig
message.sig--sign message--signscp

message.sig
ina

ina@halof:/home/ina
gpg

halof
--verify

ina@halof:~> gpg --verify message.sig
gpg: Signature made Sat 04 jul 2020 14:34:41 CEST
gpg:

using RSA key D18FA0021F644CDAF57FD0F919BBEFD16813034E

gpg: Good signature from "carol <carol@debian>" [unknown]
(...)

ina

--output
message

ina@halof:~> gpg --output message --decrypt message.sig
gpg: Signature made Sat 04 jul 2020 14:34:41 CEST
gpg:

using RSA key D18FA0021F644CDAF57FD0F919BBEFD16813034E

gpg: Good signature from "carol <carol@debian>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:

There is no indication that the signature belongs to the owner.

Primary key fingerprint: D18F A002 1F64 4CDA F57F

D0F9 19BB EFD1 6813 034E

ina@halof:~> cat message
This is the message to sign ...

gpg-agent

gpg-agent
gpg-agent

gpg--helpagent -hcarol@debian:~$ gpg-agent --help
gpg-agent (GnuPG) 2.2.4
libgcrypt 1.8.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Syntax: gpg-agent [options] [command [args]]
Secret key management for GnuPG
Options:--daemonrun in daemon mode (background)--serverrun in server mode (foreground)--supervised

run in supervised mode-v, --verbose

verbose-q, --quiet

be somewhat more quiet-s, --shsh-style command output-c, --csh

csh-style command output(...)

gpg-agentssh-agentgpg-

ssh-agent

07A6 5898 2D3A F3DD 43E3 DA95 1F3F 3147 FA7F 54C7

KEY-IDgpg --output encrypted-message --recipient carol--armor--encrypt

unencrypted-message--armorgpg--armor--output--recipient--decrypt--encrypt--signall.key

all_private.key

gpg

gpg

~/.gnupg
USER-ID

gpg

KEY-IDtrustdb.gpg
opengp-revocs.d
private-keys-v1.d
pubring.kbx

07A6 5898 2D3A F3DD 43E3 DA95 1F3F 3147 FA7F 54C7

FA7F 54C7

KEY-IDgpg --output encrypted-message --recipient carol--armor--encrypt

unencrypted-message--armorgpg--armor-a--output-o--recipient-r--decrypt-d--encrypt-e--sign-s

all.key

gpg --export --output all.key

gpg --export -o all.key

all_private.key

gpg--export-secret-keys

-keys

-o

--output

all_private.key

all_private.key-secret-subkeys--export-secret--exportman

gpg--edit-key
gpg--clearsign

gpg--export-secret-keys

gpg