diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1db64e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,82 @@ +# Created by https://www.gitignore.io + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Vagrant +.vagrant + diff --git a/Igor_Smirnov/.gitkeep b/Igor_Smirnov/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Igor_Smirnov/part1.sh b/Igor_Smirnov/part1.sh new file mode 100644 index 0000000..1574e69 --- /dev/null +++ b/Igor_Smirnov/part1.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +#1 Download using shell +wget http://www.sec.gov/dera/data/Public-EDGAR-log-file-data/2017/Qtr2/log20170630.zip + +#2 Unpack the log file +unzip log20170630.zip + +if [[ ! -d ./log20170630 ]] +then + mkdir log20170630 +fi + +mv log20170630.csv ./log20170630/log20170630.csv + + +#3 Change owner of log file to your current user using chown +chown $USER:$USER log20170630.csv + +#4 Change executive bit to a random.sh script using chmod +chmod +x random-picker.sh + +#5 Execute the random-picker.sh script +./random-picker.sh + +#6 Find the file using find +find / -name log20170630.csv 2> /dev/null + +#7 Try to look for errors using your favorite editor +vim /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv + +#8 Try to find errors using grep ------> error.csv +cat /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv | grep error > error.csv + +#9 Tail last 500 lines of file ------> tail500.csv +tail -n 500 /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv > tail500.csv + +#10 Find how many index.htm hits were at 30.06.2017 14:00 ------> 10416 +cat /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv | grep "2017-06-30,14:00:[0-5][0-9]" | grep "index.htm" | wc -l + +#11 Find how many index.htm hits were at 30.06.2017 17:00-18:00 ------> 409996 +cat /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv | grep "2017-06-30,1[7]:[0-5][0-9]:[0-5][0-9]" | grep "index.htm" | wc -l + +#13 Show the number of times each IP shows up in the log – using sort and uniq utilities ------> ip_count.csv +cut -d, -f1 /usr/src/linux-raspi2-headers-5.3.0-1014/drivers/staging/greybus/tools/log20170630.csv | sort | uniq -ic > ip_count.csv + +#14 Count all 13.94.212.jdf IP hits us ------> 87313 +cat ip_count.csv | grep 13.94.212.jdf | grep -Eo '^[^ ]+' diff --git a/Igor_Smirnov/part2.sh b/Igor_Smirnov/part2.sh new file mode 100644 index 0000000..2f96168 --- /dev/null +++ b/Igor_Smirnov/part2.sh @@ -0,0 +1,11 @@ +#!bin/bash + +#1 add ubuntu user to adm and root groups using sed +sed -i 's/^root.*/&ubuntu/g' /etc/group +sed -i 's/^adm.*/&,ubuntu/g' /etc/group + +#2 Change timezone to Europe/Berlin in /etc/timezone using sed +sed -i 's/Minsk/Berlin' /etc/timezone + +#3 Change timezone to Europe/Minsk using bash shell utilites and apply it using system commands +timedatectl set-timezone Europe/Minsk diff --git a/Igor_Smirnov/part3.sh b/Igor_Smirnov/part3.sh new file mode 100644 index 0000000..2f836b0 --- /dev/null +++ b/Igor_Smirnov/part3.sh @@ -0,0 +1,14 @@ +#!/bin/bash + + +#1 Examine ls using strace command +apt-get install strace +strace ls ./ + +#2 Assess how Linux executes the ./random_picker.sh script +touch ./log20170630/log20170630.csv +strace ./random_picker.sh + +#3 Count number of 'mv' commands paths using pipes and grep for strace ./random_picker.sh +strace ./random_picker.sh 2>&1 | grep mv | wc -l + diff --git a/Igor_Smirnov/random_picker.sh b/Igor_Smirnov/random_picker.sh new file mode 100755 index 0000000..2fd0cec --- /dev/null +++ b/Igor_Smirnov/random_picker.sh @@ -0,0 +1,5 @@ +#!/bin/bash +mv ./log20170630/log20170630.csv `find /usr -type d | shuf -n 1` + + +