/l3/users/slm/2018-12-minsk-aws/student06.BigClassRoom/user :1 :2 :3 :4 :5 :6 :7 |
|
$git scripts/install.sh
git: 'scripts/install.sh' is not a git command. See 'git --help'. |
$git add scripts/install.sh
|
$git status
On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: scripts/install.sh |
$git commit
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Your branch is up-to-date with 'origin/master'. # # Changes to be committed: # modified: scripts/install.sh # Aborting commit due to empty commit message. |
$git commit -m 'Install script error correction'
[master add5b13] Install script error correction 1 file changed, 2 insertions(+), 2 deletions(-) |
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 376 bytes | 0 bytes/s, done. Total 4 (delta 3), reused 0 (delta 0) remote: Resolving deltas: 100% (3/3), completed with 3 local objects. To https://github.com/DmitrySnitko/aws 9362275..add5b13 master -> master |
$ll
total 16 drwxr-xr-x 2 user user 4096 Dec 20 14:41 config -rw-r--r-- 1 user user 112 Dec 17 16:45 Hello_world.md -rw-r--r-- 1 user user 33 Dec 17 16:01 README.md drwxr-xr-x 2 user user 4096 Dec 20 16:25 scripts |
$cd
|
$ll
total 64 drwxr-xr-x 5 user user 4096 Dec 20 14:41 aws -rw-r--r-- 1 root root 127 Dec 18 10:52 credentials.csv drwxr-xr-x 2 user user 4096 Dec 17 12:15 Desktop drwxr-xr-x 2 user user 4096 Dec 17 12:15 Documents drwxr-xr-x 2 user user 4096 Dec 18 12:50 Downloads -rw-r--r-- 1 root root 203 Dec 20 16:26 ec2.yaml -rw-r--r-- 1 user user 13 Dec 17 15:13 github.txt -rw------- 1 user user 389 Dec 19 10:57 m7_id_rsa.pub drwxr-xr-x 2 user user 4096 Dec 17 12:15 Music drwxr-xr-x 2 user user 4096 Dec 17 12:15 Pictures drwxr-xr-x 2 user user 4096 Dec 17 12:15 Public -rw------- 1 user user 1766 Dec 19 10:44 ssh-key -rw-r--r-- 1 user user 389 Dec 19 10:44 ssh-key.pub -rw-r--r-- 1 user user 0 Dec 20 16:19 start_log drwxr-xr-x 2 user user 4096 Dec 17 12:15 Templates -rw-r--r-- 1 user user 77 Dec 17 14:45 test.json drwxr-xr-x 2 user user 4096 Dec 17 12:15 Videos |
$ll
total 64 drwxr-xr-x 5 user user 4096 Dec 20 14:41 aws -rw-r--r-- 1 root root 127 Dec 18 10:52 credentials.csv drwxr-xr-x 2 user user 4096 Dec 17 12:15 Desktop drwxr-xr-x 2 user user 4096 Dec 17 12:15 Documents drwxr-xr-x 2 user user 4096 Dec 18 12:50 Downloads -rw-r--r-- 1 root root 203 Dec 20 16:26 ec2.yaml -rw-r--r-- 1 user user 13 Dec 17 15:13 github.txt -rw------- 1 user user 389 Dec 19 10:57 m7_id_rsa.pub drwxr-xr-x 2 user user 4096 Dec 17 12:15 Music drwxr-xr-x 2 user user 4096 Dec 17 12:15 Pictures drwxr-xr-x 2 user user 4096 Dec 17 12:15 Public -rw------- 1 user user 1766 Dec 19 10:44 ssh-key -rw-r--r-- 1 user user 389 Dec 19 10:44 ssh-key.pub -rw-r--r-- 1 user user 0 Dec 20 16:19 start_log drwxr-xr-x 2 user user 4096 Dec 17 12:15 Templates -rw-r--r-- 1 user user 77 Dec 17 14:45 test.json drwxr-xr-x 2 user user 4096 Dec 17 12:15 Videos |
$cat ec2.yaml
--- Resources: EC2Instance: Type: AWS::EC2::Instance Properties: InstanceType: t2.micro KeyName: 'default' # keypair must already exist ImageId: ami-6869aa05 # AMI us-east-1 |
$vi test_script.sh
|
$chmod +x test_script.sh
|
$./test_script.sh
su: must be run from a terminal % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 15 100 15 0 0 34 0 --:--:-- --:--:-- --:--:-- 34 (23) Failed writing body |
$sudo apt-get update
[sudo] password for user: Ign:1 http://ftp.by.debian.org/debian stretch InRelease Hit:2 http://ftp.by.debian.org/debian stretch Release Reading package lists... Done |
$vi aws/scripts/install.sh
|
$~
#!/bin/bash IMAGE_ID=ami-02fc24d56bc5f3d67 #ami-09693313102a30b2c INSTANCE_TYPE=t2.micro VPC_ID=vpc-0e4dfd64aef6a44fc KEY_NAME=user6 AME}}]" USER_NAME=user6-vpc3 SHUTDOWN_TYPE=stop initial_command() SECURITY_GROUP_ID=sg-0f0cc75216aa3485b ... } icDnsName''.Reservations[0].Instances[0].NetworkInterfaces[0].Association.Publl a start () : # local vm_number="$1" :~ ~ :~ [Command Line] 4,0-1 All |
$user_data" \
|
$sudo -s
root@m6:/home/user# exit exit |
$man su
|
$sudo -s
~ ~ ~ ~ ~ ~ ~ root@m6:/home/user# curl cht.sh/sudo/no+password /* * Use sudo without password INSIDE a script ... "/etc/sudoers" 28L, 724C written root@m6:/home/user# bash ./test_script.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 20 100 20 0 0 16 0 0:00:01 0:00:01 --:--:-- 16 Ign:1 http://ftp.by.debian.org/debian stretch InRelease Hit:2 http://ftp.by.debian.org/debian stretch Release Reading package lists... Done root@m6:/home/user# exit exit |
$git status
fatal: Not a git repository (or any of the parent directories): .git |
$cd aws/
|
$git status
On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working tree clean |
$cd
|
$aws
aws aws.cmd aws_zsh_completer.sh aws_bash_completer aws_completer |
$aws/scripts/create_infrustructure.sh start
i-05845cf8a44dc0b29 null |
$http://ec2-34-246-174-176.eu-west-1.compute.amazonaws.com/Hello
bash: http://ec2-34-246-174-176.eu-west-1.compute.amazonaws.com/Hello: No such file or directory |
$cd aws/
|
$git status
On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: scripts/install.sh no changes added to commit (use "git add" and/or "git commit -a") |
$git add scripts/install.sh
|
$git commit -m 'Script corrected'
[master 0d0f2e7] Script corrected 1 file changed, 1 insertion(+), 1 deletion(-) |
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': To https://github.com/DmitrySnitko/aws ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/DmitrySnitko/aws' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
$./scripts/create_infrustructure.sh stop
{ "TerminatingInstances": [ { "InstanceId": "i-05845cf8a44dc0b29", "CurrentState": { "Code": 32, "Name": "shutting-down" }, "PreviousState": { "Code": 16, "Name": "running" } } ] } |
$ssh ec2-34-254-183-46.eu-west-1.compute.amazonaws.com
The authenticity of host 'ec2-34-254-183-46.eu-west-1.compute.amazonaws.com (34.254.183.46)' can't be established. ECDSA key fingerprint is SHA256:LtIG2dNXW5Yd/u1ZLaoTDSVYHFYS7ewS8Oalr/pwx7M. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ec2-34-254-183-46.eu-west-1.compute.amazonaws.com,34.254.183.46' (ECDSA) to the list of known hosts. Permission denied (publickey). |
$git status
On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean |
$./scripts/create_infrustructure.sh start
i-03b9806917d49d495 null |
$cat ./scripts/create_infrustructure.sh
#!/bin/bash IMAGE_ID=ami-02fc24d56bc5f3d67 #ami-09693313102a30b2c INSTANCE_TYPE=t2.micro VPC_ID=vpc-0e4dfd64aef6a44fc KEY_NAME=user6 USER_NAME=user6-vpc3 SHUTDOWN_TYPE=stop SECURITY_GROUP_ID=sg-0f0cc75216aa3485b SUBNET_ID=subnet-0a8edbfe14d168679 TAGS="ResourceType=instance,Tags=[{Key=Name,Value=NAME},{Key=tag,Value=${KEY_NAME}}]" ... if [ "$1" = start ]; then start elif [ "$1" = stop ]; then stop else cat <<EOF Usage: $0 start|stop EOF fi |
$git status
On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean |
$cat scripts/install.sh
DIR="$HOME/qrencode" mkdir -p "$DIR" cd "$DIR" sudo apt-get update sudo apt-get install -y nginx git-core qrencode python-virtualenv git clone https://github.com/chubin/qrenco.de cd qrenco.de virtualenv ve/ ve/bin/pip install -r requirements.txt #sudo cp config/qrencode.conf /etc/nginx/sites-available/default curl https://raw.githubusercontent.com/DmitrySnitko/AWS/master/config/qrencode.conf | sudo tee /etc/nginx/sites-available/default mkdir -p "$DIR"/log/ nohup ve/bin/python bin/srv.py >> "$DIR"/log/qrencode.log 2>&1 & sudo /etc/init.d/nginx restart |
$git status
On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean |
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': To https://github.com/DmitrySnitko/aws ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/DmitrySnitko/aws' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': To https://github.com/DmitrySnitko/aws ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/DmitrySnitko/aws' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
$git pull https://github.com/DmitrySnitko/AWS
# the commit. To add files to local PC Merge made by the 'recursive' strategy. scripts/install2.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/install2.sh |
$cat ./scripts/create_infrustructure.sh
#!/bin/bash IMAGE_ID=ami-02fc24d56bc5f3d67 #ami-09693313102a30b2c INSTANCE_TYPE=t2.micro VPC_ID=vpc-0e4dfd64aef6a44fc KEY_NAME=user6 AME}}]" USER_NAME=user6-vpc3 SHUTDOWN_TYPE=stop initial_command() SECURITY_GROUP_ID=sg-0f0cc75216aa3485b ... --tag-specifications "$tags" \ --user-data "$user_data" \ { } 5s stop() } { ids=($( aws ec2 describe-instances \ <ts/create_infrustructure.sh" 108L, 2374C written |
$git add scripts/create_infrustructure.sh
|
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 423 bytes | 0 bytes/s, done. Total 4 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To https://github.com/DmitrySnitko/aws ae24e2b..9fdcba0 master -> master |
$git add scripts/create_infrustructure.sh
|
$git commit -m 'Correction'
[master 78d99b0] Correction 1 file changed, 1 insertion(+), 1 deletion(-) |
$git push
Username for 'https://github.com': DmitrySnitko Password for 'https://DmitrySnitko@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 415 bytes | 0 bytes/s, done. Total 4 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To https://github.com/DmitrySnitko/aws 9fdcba0..78d99b0 master -> master |
$./aws/scripts/create_infrustructure.sh start
An error occurred (Blocked) when calling the RunInstances operation: This account is currently blocked and not recognized as a valid account. Please contact aws-verification@amazon.com if you have questions. null |
$./aws/scripts/create_infrustructure.sh start
An error occurred (Blocked) when calling the RunInstances operation: This account is currently blocked and not recognized as a valid account. Please contact aws-verification@amazon.com if you have questions. null |
$sudo apt-get install docker
[sudo] password for user: Sorry, try again. [sudo] password for user: Sorry, user user is not allowed to execute '/usr/bin/apt-get install docker' as root on m6.class.sl. |
$sudo apt-get install docker
[sudo] password for user: Sorry, user user is not allowed to execute '/usr/bin/apt-get install docker' as root on m6.class.sl. |
$vi /etc/su
|
$vi /etc/su
|
$vi /etc/sudoers
|
$~
[sudo] password for user: Sorry, user user is not allowed to execute '/bin/bash' as root on m6.class.sl. |
$su -
# Host alias specification Defaults env_reset Defaults mail_badpass # User alias specification Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binn # Cmnd alias specification user ALL=(ALL:ALL) NOPASSWD:/usr/bin/apt-get update userer pALL=(ALL:ALL)iALLation root ALL=(ALL:ALL) ALL user ALL=(ALL:ALL) NOPASSWD:/usr/bin/apt-get update ... ~ ~ ~ ~ "/etc/sudoers" 29L, 750C written root@m6:~# root@m6:~# root@m6:~# root@m6:~# exit logout |
$curl -fsSL https://get.docker.com -o get-docker.sh
|
$ll
total 84 drwxr-xr-x 5 user user 4096 Dec 20 14:41 aws -rw-r--r-- 1 root root 127 Dec 18 10:52 credentials.csv drwxr-xr-x 2 user user 4096 Dec 17 12:15 Desktop drwxr-xr-x 2 user user 4096 Dec 17 12:15 Documents drwxr-xr-x 2 user user 4096 Dec 18 12:50 Downloads -rw-r--r-- 1 root root 203 Dec 20 16:26 ec2.yaml -rw-r--r-- 1 user user 13380 Dec 21 10:42 get-docker.sh -rw-r--r-- 1 user user 13 Dec 17 15:13 github.txt -rw------- 1 user user 389 Dec 19 10:57 m7_id_rsa.pub drwxr-xr-x 2 user user 4096 Dec 17 12:15 Music drwxr-xr-x 2 user user 4096 Dec 17 12:15 Pictures drwxr-xr-x 2 user user 4096 Dec 17 12:15 Public -rw------- 1 user user 1766 Dec 19 10:44 ssh-key -rw-r--r-- 1 user user 389 Dec 19 10:44 ssh-key.pub -rw-r--r-- 1 user user 0 Dec 21 10:32 start_log drwxr-xr-x 2 user user 4096 Dec 17 12:15 Templates -rw-r--r-- 1 user user 77 Dec 17 14:45 test.json -rwxr-xr-x 1 user user 116 Dec 20 16:39 test_script.sh drwxr-xr-x 2 user user 4096 Dec 17 12:15 Videos |
$sudo sh get-docker.sh
[sudo] password for user: # Executing docker install script, commit: 4957679 + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null + sh -c curl -fsSL "https://download.docker.com/linux/debian/gpg" | apt-key add -qq - >/dev/null Warning: apt-key output should not be parsed (stdout is not a terminal) + sh -c echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch edge" > /etc/apt/sources.list.d/docker.list + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null + sh -c docker version ... Experimental: false If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like: sudo usermod -aG docker your-user Remember that you will have to log out and back in for this to take effect! WARNING: Adding a user to the "docker" group will grant the ability to run containers which can be used to obtain root privileges on the docker host. Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface for more information. |
$sudo usermod -aG docker user6
usermod: user 'user6' does not exist |
$sudo usermod -aG docker user
|
$sudo docker pull busybox
[sudo] password for user: Using default tag: latest latest: Pulling from library/busybox 90e01955edcd: Pull complete Digest: sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812 Status: Downloaded newer image for busybox:latest |
$ll
total 84 drwxr-xr-x 5 user user 4096 Dec 20 14:41 aws -rw-r--r-- 1 root root 127 Dec 18 10:52 credentials.csv drwxr-xr-x 2 user user 4096 Dec 17 12:15 Desktop drwxr-xr-x 2 user user 4096 Dec 17 12:15 Documents drwxr-xr-x 2 user user 4096 Dec 18 12:50 Downloads -rw-r--r-- 1 root root 203 Dec 20 16:26 ec2.yaml -rw-r--r-- 1 user user 13380 Dec 21 10:42 get-docker.sh -rw-r--r-- 1 user user 13 Dec 17 15:13 github.txt -rw------- 1 user user 389 Dec 19 10:57 m7_id_rsa.pub drwxr-xr-x 2 user user 4096 Dec 17 12:15 Music drwxr-xr-x 2 user user 4096 Dec 17 12:15 Pictures drwxr-xr-x 2 user user 4096 Dec 17 12:15 Public -rw------- 1 user user 1766 Dec 19 10:44 ssh-key -rw-r--r-- 1 user user 389 Dec 19 10:44 ssh-key.pub -rw-r--r-- 1 user user 0 Dec 21 10:32 start_log drwxr-xr-x 2 user user 4096 Dec 17 12:15 Templates -rw-r--r-- 1 user user 77 Dec 17 14:45 test.json -rwxr-xr-x 1 user user 116 Dec 20 16:39 test_script.sh drwxr-xr-x 2 user user 4096 Dec 17 12:15 Videos |
$docker images
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/json: dial unix /var/run/docker.sock: connect: permission denied |
$docker images
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/json: dial unix /var/run/docker.sock: connect: permission denied |
$docker pull busybox
Using default tag: latest Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/create?fromImage=busybox&tag=latest: dial unix /var/run/docker.sock: connect: permission denied |
$cd /var/lib/docker
|
$ll
ls: cannot open directory '.': Permission denied |
$sudo ll
[sudo] password for user: sudo: ll: command not found |
$sudo ls
builder containers network plugins swarm trust buildkit image overlay2 runtimes tmp volumes |
$sudo ls -la
total 56 drwx--x--x 14 root root 4096 Dec 21 10:50 . drwxr-xr-x 51 root root 4096 Dec 21 10:50 .. drwx------ 2 root root 4096 Dec 21 10:50 builder drwx------ 4 root root 4096 Dec 21 10:50 buildkit drwx------ 2 root root 4096 Dec 21 10:50 containers drwx------ 3 root root 4096 Dec 21 10:50 image drwxr-x--- 3 root root 4096 Dec 21 10:50 network drwx------ 4 root root 4096 Dec 21 11:13 overlay2 drwx------ 4 root root 4096 Dec 21 10:50 plugins drwx------ 2 root root 4096 Dec 21 10:50 runtimes drwx------ 2 root root 4096 Dec 21 10:50 swarm drwx------ 2 root root 4096 Dec 21 11:13 tmp drwx------ 2 root root 4096 Dec 21 10:50 trust drwx------ 2 root root 4096 Dec 21 10:50 volumes |
$cd ..
|
$ls -la
total 204 drwxr-xr-x 51 root root 4096 Dec 21 10:50 . drwxr-xr-x 11 root root 4096 Dec 15 19:56 .. drwxr-xr-x 4 root root 4096 Dec 15 20:25 AccountsService drwxr-xr-x 2 root root 4096 Dec 20 17:16 alsa drwxr-xr-x 2 root root 4096 Nov 3 21:46 apache2 drwxr-xr-x 4 root root 4096 Dec 16 13:31 app-info drwxr-xr-x 5 root root 4096 Dec 21 10:50 apt drwxr-xr-x 2 root root 4096 Dec 15 20:39 aspell drwxr-xr-x 4 colord colord 4096 Dec 15 20:44 colord ... drwxr-xr-x 6 root root 4096 Dec 15 20:44 systemd drwxr-xr-x 3 root root 4096 Dec 15 20:39 ucf drwx------ 2 root root 4096 Dec 15 20:45 udisks2 drwxr-xr-x 2 root root 4096 Sep 19 2016 upower drwxr-xr-x 2 root root 4096 Jan 23 2017 usb_modeswitch drwxr-xr-x 2 root root 4096 Dec 15 19:59 usbutils drwxr-xr-x 3 root root 4096 Dec 15 19:58 vim drwxr-xr-x 2 root root 4096 Dec 15 20:37 xfonts drwxr-xr-x 2 root root 4096 Dec 15 20:28 xkb drwxr-xr-x 2 root root 4096 Dec 15 20:38 xml-core |
$docker run -it busybox sh
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'. |
$history
11 man git 12 man git 13 git --help 14 git clone 15 git clone https://github.com/DmitrySnitko/aws 16 ls -la 17 ls -la aws/ 18 cd aws/ 19 vi Hello_world 20 mv Hello_world Hello_world.md ... 501 docker pull busybox 502 cd /var/lib/docker 503 ll 504 sudo ll 505 sudo ls 506 sudo ls -la 507 cd .. 508 ls -la 509 docker run -it busybox sh 510 history |
$ll /var/run/
total 32 drwx------ 3 root root 60 Dec 21 10:15 alsa drwxr-xr-x 2 avahi avahi 80 Dec 21 10:50 avahi-daemon drwxr-xr-x 2 root root 80 Dec 21 10:15 console-setup drwx--x--x 4 root root 100 Dec 21 10:50 containerd -rw-r--r-- 1 root root 4 Dec 21 10:15 crond.pid ---------- 1 root root 0 Dec 21 10:15 crond.reboot drwxr-xr-x 3 root lp 120 Dec 21 10:20 cups drwxr-xr-x 2 root root 60 Dec 21 10:15 dbus -rw-r--r-- 1 root root 4 Dec 21 10:15 dhclient-enp1s0.pid ... lrwxrwxrwx 1 root root 8 Dec 21 10:15 shm -> /dev/shm drwxr-xr-x 2 root root 40 Dec 21 10:15 sshd -rw-r--r-- 1 root root 4 Dec 21 10:50 sshd.pid drwxr-xr-x 18 root root 440 Dec 21 10:50 systemd drwxr-xr-x 2 root root 60 Dec 21 10:15 tmpfiles.d drwxr-xr-x 7 root root 220 Dec 21 10:50 udev drwx------ 2 root root 40 Dec 21 10:16 udisks2 drwxr-xr-x 4 root root 80 Dec 21 10:16 user -rw-rw-r-- 1 root utmp 1152 Dec 21 10:16 utmp -rw------- 1 root root 0 Dec 21 10:50 xtables.lock |
$sudo usermod -aG docker user
|
$cat /etc/passwd
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin ... speech-dispatcher:x:110:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false sshd:x:111:65534::/run/sshd:/usr/sbin/nologin pulse:x:112:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false avahi:x:113:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false colord:x:114:120:colord colour management daemon,,,:/var/lib/colord:/bin/false saned:x:115:121::/var/lib/saned:/bin/false hplip:x:116:7:HPLIP system user,,,:/var/run/hplip:/bin/false Debian-gdm:x:117:122:Gnome Display Manager:/var/lib/gdm3:/bin/false debian:x:1000:1000:debian,,,:/home/debian:/bin/bash user:x:1001:1001::/home/user:/bin/bash |
$sudo docker run -it busybox sh
/ # ls bin dev etc home proc root sys tmp usr var / # ls -l total 36 drwxr-xr-x 2 root root 12288 Oct 1 22:37 bin drwxr-xr-x 5 root root 360 Dec 21 08:25 dev drwxr-xr-x 1 root root 4096 Dec 21 08:25 etc drwxr-xr-x 2 nobody nogroup 4096 Oct 1 22:37 home dr-xr-xr-x 189 root root 0 Dec 21 08:25 proc drwx------ 1 root root 4096 Dec 21 08:25 root ... link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 4: eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0 valid_lft forever preferred_lft forever / # / # / # exit |
$sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2ee8f05ced0b busybox "sh" 7 minutes ago Exited (0) 10 seconds ago boring_mayer |
$docker ps -a
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied |
$docker ps -a
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied |
$cat /etc/passwrd
cat: /etc/passwrd: No such file or directory |
$cat /etc/passwd
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin ... speech-dispatcher:x:110:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false sshd:x:111:65534::/run/sshd:/usr/sbin/nologin pulse:x:112:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false avahi:x:113:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false colord:x:114:120:colord colour management daemon,,,:/var/lib/colord:/bin/false saned:x:115:121::/var/lib/saned:/bin/false hplip:x:116:7:HPLIP system user,,,:/var/run/hplip:/bin/false Debian-gdm:x:117:122:Gnome Display Manager:/var/lib/gdm3:/bin/false debian:x:1000:1000:debian,,,:/home/debian:/bin/bash user:x:1001:1001::/home/user:/bin/bash |
$cat /etc/g
gai.conf gimp/ group gshadow- gdm3/ gnome/ group- gss/ geoclue/ gnome-chess/ grub.d/ gtk-2.0/ ghostscript/ groff/ gshadow gtk-3.0/ |
$cat /etc/g
gai.conf gimp/ group gshadow- gdm3/ gnome/ group- gss/ geoclue/ gnome-chess/ grub.d/ gtk-2.0/ ghostscript/ groff/ gshadow gtk-3.0/ |
$docker run
"docker run" requires at least 1 argument. See 'docker run --help'. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container |
$docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Options: --add-host list Add a custom host-to-IP mapping (host:ip) -a, --attach list Attach to STDIN, STDOUT or STDERR --blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) --blkio-weight-device list Block IO weight (relative device ... <name|uid>[:<group|gid>]) --userns string User namespace to use --uts string UTS namespace to use -v, --volume list Bind mount a volume --volume-driver string Optional volume driver for the container --volumes-from list Mount volumes from the specified container(s) -w, --workdir string Working directory inside the container |
$docker run -it busybox sh
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'. |
$docker pull busybox
Using default tag: latest Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/create?fromImage=busybox&tag=latest: dial unix /var/run/docker.sock: connect: permission denied |
$docker --help
Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/home/user/.docker") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") ... start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command. |
$sudo ls -l /var/
backups/ lib/ lock/ mail/ run/ tmp/ cache/ local/ log/ opt/ spool/ |
$sudo ls -l /var/lo
local/ lock/ log/ |
$sudo ls -l /var/lo
local/ lock/ log/ |
#!/bin/bash IMAGE_ID=ami-02fc24d56bc5f3d67 #ami-09693313102a30b2c INSTANCE_TYPE=t2.micro VPC_ID=vpc-0e4dfd64aef6a44fc KEY_NAME=user6 AME}}]" USER_NAME=user6-vpc3 SHUTDOWN_TYPE=stop initial_command() SECURITY_GROUP_ID=sg-0f0cc75216aa3485b { SUBNET_ID=subnet-0a8edbfe14d168679 cat <<EOF TAGS="ResourceType=instance,Tags=[{Key=Name,Value=NAME},{Key=tag,Value=${KEY_NN #!/bin/sh "./scripts/create_infrustructure.sh" 108L, 2374C # # if [ "$1" < "0" ]; then # echo "Number of VMs should be more then 1" # elif [ "$1" = "1" ]; then # start_log=$( start_vm 10.3.1.61 associate-public-ip ${USER_NAME}-vm1 file://<(initial_comm mand) > ~/start_log # ) sleep 2s instance_id=$( cat ~/start_log | jq -r .Instances[0].InstanceId) # else # for i in {2..2}; do # start_vm 10.3.1.$((60+i)) no-associate-public-ip-address ${USER_NAME}-vv m$i > /dev/null # done sleep 3s dns_name=$(get_dns_name "$instance_id") #fi echo $dns_namee_id}1" 80,0-1 66% #local tags=$(TAGS/NAME/$name) aws ec2 run-instances \ --image-id "$IMAGE_ID" \ --instance-type "$INSTANCE_TYPE" \ --key-name "$KEY_NAME" \ --subnet-id "$SUBNET_ID" \ --instance-initiated-shutdown-behavior "$SHUTDOWN_TYPE" \ --private-ip-address "$private_ip_addr" \ --tag-specifications "$tags" \ --user-data "$user_data" \ { } 5s stop() } { ids=($( aws ec2 describe-instances \ <ts/create_infrustructure.sh" 108L, 2374C written
gai.conf gimp/ group gshadow- gdm3/ gnome/ group- gss/ geoclue/ gnome-chess/ grub.d/ gtk-2.0/ ghostscript/ groff/ gshadow gtk-3.0/
root:x:0: daemon:x:1: bin:x:2: sys:x:3: adm:x:4: tty:x:5: disk:x:6: lp:x:7: mail:x:8: news:x:9: uucp:x:10: man:x:12: proxy:x:13: kmem:x:15: dialout:x:20: fax:x:21: voice:x:22: cdrom:x:24:debian floppy:x:25:debian tape:x:26: sudo:x:27: audio:x:29:pulse,debian dip:x:30:debian www-data:x:33: backup:x:34: operator:x:37: list:x:38: irc:x:39: src:x:40: gnats:x:41: shadow:x:42: utmp:x:43: video:x:44:debian sasl:x:45: plugdev:x:46:debian staff:x:50: games:x:60: users:x:100: nogroup:x:65534: systemd-journal:x:101: systemd-timesync:x:102: systemd-network:x:103: systemd-resolve:x:104: systemd-bus-proxy:x:105: input:x:106: crontab:x:107: netdev:x:108:debian ssl-cert:x:109: rtkit:x:110: messagebus:x:111: ssh:x:112: bluetooth:x:113:debian lpadmin:x:114:debian geoclue:x:115: pulse:x:116: pulse-access:x:117: scanner:x:118:saned,debian avahi:x:119: colord:x:120: saned:x:121: Debian-gdm:x:122: debian:x:1000: user:x:1001: docker:x:999:user
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false _apt:x:104:65534::/nonexistent:/bin/false rtkit:x:105:110:RealtimeKit,,,:/proc:/bin/false dnsmasq:x:106:65534:dnsmasq,,,:/var/lib/misc:/bin/false messagebus:x:107:111::/var/run/dbus:/bin/false usbmux:x:108:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false geoclue:x:109:115::/var/lib/geoclue:/bin/false speech-dispatcher:x:110:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false sshd:x:111:65534::/run/sshd:/usr/sbin/nologin pulse:x:112:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false avahi:x:113:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false colord:x:114:120:colord colour management daemon,,,:/var/lib/colord:/bin/false saned:x:115:121::/var/lib/saned:/bin/false hplip:x:116:7:HPLIP system user,,,:/var/run/hplip:/bin/false Debian-gdm:x:117:122:Gnome Display Manager:/var/lib/gdm3:/bin/false debian:x:1000:1000:debian,,,:/home/debian:/bin/bash user:x:1001:1001::/home/user:/bin/bash
--- Resources: EC2Instance: Type: AWS::EC2::Instance Properties: InstanceType: t2.micro KeyName: 'default' # keypair must already exist ImageId: ami-6869aa05 # AMI us-east-1
DIR="$HOME/qrencode" mkdir -p "$DIR" cd "$DIR" sudo apt-get update sudo apt-get install -y nginx git-core qrencode python-virtualenv git clone https://github.com/chubin/qrenco.de cd qrenco.de virtualenv ve/ ve/bin/pip install -r requirements.txt #sudo cp config/qrencode.conf /etc/nginx/sites-available/default curl https://raw.githubusercontent.com/DmitrySnitko/AWS/master/config/qrencode.conf | sudo tee /etc/nginx/sites-available/default mkdir -p "$DIR"/log/ nohup ve/bin/python bin/srv.py >> "$DIR"/log/qrencode.log 2>&1 & sudo /etc/init.d/nginx restart
Время первой команды журнала | 14:26:14 2018-12-20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Время последней команды журнала | 09:35:08 2018-12-21 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в журнале | 101 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент команд с ненулевым кодом завершения, % | 26.73 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент синтаксически неверно набранных команд, % | 0.99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Суммарное время работы с терминалом *, час | 1.86 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в единицу времени, команда/мин | 0.90 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Частота использования команд |
|
В журнал автоматически попадают все команды, данные в любом терминале системы.
Для того чтобы убедиться, что журнал на текущем терминале ведётся, и команды записываются, дайте команду w. В поле WHAT, соответствующем текущему терминалу, должна быть указана программа script.
Команды, при наборе которых были допущены синтаксические ошибки, выводятся перечёркнутым текстом:
$ l s-l bash: l: command not found |
Если код завершения команды равен нулю, команда была выполнена без ошибок. Команды, код завершения которых отличен от нуля, выделяются цветом.
$ test 5 -lt 4 |
Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
$ find / -name abc find: /home/devi-orig/.gnome2: Keine Berechtigung find: /home/devi-orig/.gnome2_private: Keine Berechtigung find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung find: /home/devi-orig/.metacity: Keine Berechtigung find: /home/devi-orig/.inkscape: Keine Berechtigung ^C |
Команды, выполненные с привилегиями суперпользователя, выделяются слева красной чертой.
# id uid=0(root) gid=0(root) Gruppen=0(root) |
Изменения, внесённые в текстовый файл с помощью редактора, запоминаются и показываются в журнале в формате ed. Строки, начинающиеся символом "<", удалены, а строки, начинающиеся символом ">" -- добавлены.
$ vi ~/.bashrc
|
Для того чтобы изменить файл в соответствии с показанными в диффшоте изменениями, можно воспользоваться командой patch. Нужно скопировать изменения, запустить программу patch, указав в качестве её аргумента файл, к которому применяются изменения, и всавить скопированный текст:
$ patch ~/.bashrc |
Для того чтобы получить краткую справочную информацию о команде, нужно подвести к ней мышь. Во всплывающей подсказке появится краткое описание команды.
Если справочная информация о команде есть, команда выделяется голубым фоном, например: vi. Если справочная информация отсутствует, команда выделяется розовым фоном, например: notepad.exe. Справочная информация может отсутствовать в том случае, если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно; (3) если информация о команде неизвестна LiLaLo. Последнее возможно для редких команд.
Большие, в особенности многострочные, всплывающие подсказки лучше всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer. В браузерах Mozilla и Firefox они отображаются не полностью, а вместо перевода строки выводится специальный символ.
Время ввода команды, показанное в журнале, соответствует времени начала ввода командной строки, которое равно тому моменту, когда на терминале появилось приглашение интерпретатора
Имя терминала, на котором была введена команда, показано в специальном блоке. Этот блок показывается только в том случае, если терминал текущей команды отличается от терминала предыдущей.
Вывод не интересующих вас в настоящий момент элементов журнала, таких как время, имя терминала и других, можно отключить. Для этого нужно воспользоваться формой управления журналом вверху страницы.
Небольшие комментарии к командам можно вставлять прямо из командной строки. Комментарий вводится прямо в командную строку, после символов #^ или #v. Символы ^ и v показывают направление выбора команды, к которой относится комментарий: ^ - к предыдущей, v - к следующей. Например, если в командной строке было введено:
$ whoami
user
$ #^ Интересно, кто я?в журнале это будет выглядеть так:
$ whoami
user
Интересно, кто я? |
Если комментарий содержит несколько строк, его можно вставить в журнал следующим образом:
$ whoami
user
$ cat > /dev/null #^ Интересно, кто я?
Программа whoami выводит имя пользователя, под которым мы зарегистрировались в системе. - Она не может ответить на вопрос о нашем назначении в этом мире.В журнале это будет выглядеть так:
$ whoami user
|
Комментарии, не относящиеся непосредственно ни к какой из команд, добавляются точно таким же способом, только вместо симолов #^ или #v нужно использовать символы #=
1 2 3 4Группы команд, выполненных на разных терминалах, разделяются специальной линией. Под этой линией в правом углу показано имя терминала, на котором выполнялись команды. Для того чтобы посмотреть команды только одного сенса, нужно щёкнуть по этому названию.
LiLaLo (L3) расшифровывается как Live Lab Log.
Программа разработана для повышения эффективности обучения Unix/Linux-системам.
(c) Игорь Чубин, 2004-2008