Skip to content

Instantly share code, notes, and snippets.

@mickgeek
Created January 31, 2018 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickgeek/0e72c2c251a9181fe258bb8ec7940612 to your computer and use it in GitHub Desktop.
Save mickgeek/0e72c2c251a9181fe258bb8ec7940612 to your computer and use it in GitHub Desktop.
notes
=====
LINUX
=====
apt-get update
apt-get upgrade
apt-cache search apache2
apt-cache policy apache2 - show available versions
apt-cache depends apache2 - show Depends and Suggests of a package
apt-get --remove autoremove apache2
apt-get --purge autoremove apache2 - remove with configuration files
shutdown -h now
shutdown -r now
mkdir /home/mydir - create folder (-p - with parents; -m 755 - mode)
rm -rf /home/mydir - delete folder recursive
chown www-data:www-data /var/run/apache2
chmod 644 /etc/mysql/conf.d/mariadb.cnf - good for files (readable)
chmod 755 /usr/local/bin/docker-entrypoint - good for directories (executable)
ifconfig - see the IP for the hosts file
ss -tunlp - display used ports
telnet 107.170.11.79 5432 - check IP with port
mkdir /home/lemobyte
useradd --base-dir /home lemobyte
passwd lemobyte
cat /etc/passwd - all users
cat /etc/group - all groups
useradd <user> - create a user
userdel -r <user> - delete a user
id -u <user> - ID of a user
id -nG <user> - groups of a user
lid -g <group> | cut -f1 -d'(' - ID of a group
usermod -aG <group> <user> - add a user to a group
usermod -G <group> <user> - delete a user from all groups except a group
type git - check if git was set up
ls -la ~/.ssh - show hide dirs and files
ssh-keygen -t rsa -b 4096 -C "olegbelostotsky@gmail.com" - create SSH key (https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/)
crontab -e - set user crontab commands
nano /etc/cron.(hourly|daily|weekly|monthly) - set system crontab commands
nano /etc/crontab - set system crontab commands (this file can be overwritten after some upgrade)
nano /etc/rc.local - set system autostart commands (deprecated)
systemctl enable <unit> - add a unit to the system autostart (e.g. from /etc/systemd/system)
loginctl enable <unit> - add a unit to the user login autostart (e.g. from /etc/systemd/user)
systemctl -l status <unit> - show status information about a unit
systemctl daemon-reload - reload systemd daemon after a unit updating
journalctl -xe - show last log messages (systemd)
rpm -qa | grep -i <package name> - show information about an RPM package
rpm -e <package name> - delete an RPM package
- SELinux:
getenforce
setenforce 0 - to set to permissive mode
setenforce 1 - to set to enforcing mode
- nano:
поиск - Ctrl+W
выделение - Alt+A
вырезание - Alt+K или [F9]
копирование - Alt+6 или [Alt+Shift+6]
вставка - Ctrl+U
- nginx:
nginx -s reload
add_header X-debug-message "A php file was used" always;
===
GIT
===
- to create a new repository:
git init
git remote add origin https://github.com/mickgeek/symfony-react-restful-boilerplate.git
git add -A
git commit -m "initial commit"
git push -u origin master
- to add changes:
git commit -a -m "add a new file" (or: git add -A && git commit -m "add a new file")
git push
git clone https://github.com/mickgeek/djangoblog.git - to download a repository
git pull - to update a reposiory to last changes
git checkout -f - to return changes
git checkout -b modify-README - to create and switch to a new branch "modify-README"
git branch - to show branches (* - active branche)
git checkout master - to switch to branch "master"
git merge modify-README - to merge the branch "modify-README" with the branch "master"
git branch -d modify-README - to delete the branch "modify-README"
================
VAGRANT & DOCKER
================
vagrant init ubuntu/xenial64 - initializes the current directory to be a Vagrant environment
vagrant up - creates and configures guest (virtual) machines
vagrant suspend - suspends the guest machine
vagrant halt - shuts down the running guest machine
vagrant destroy -f - stops the running guest machine
vagrant reload - shuts down followed by starts the guest machine
vagrant global-status - the state of active Vagrant environments
vagrant box list - lists the installed boxes
sudo docker-compose up --build - starts containers for services (in the background and builds images)
sudo docker-compose down - stops and removes containers
sudo docker-compose start - starts containers for services
sudo docker-compose stop - stops containers
sudo docker-compose restart [php-fpm] - restarts stopped and running containers
sudo docker-compose down && sudo docker-compose up --build
sudo docker-compose run --service-ports --rm -w /srv/www/client node yarn run start:dev - runs a command in a new container (with ports enabled)
sudo docker-compose run --rm -w /srv/www postgres psql -h postgres -U root postgres
sudo docker run -i -t -rm php:fpm pwd - runs a command in a new image
sudo docker-compose ps - lists containers
sudo docker inspect php:fpm [vagrant_nginx_1] - displays detailed information on one or more services
sudo docker volume ls - lists volumes
sudo docker ps -a - shows containers (with exited containers)
sudo docker images -a - shows images (with intermediate images)
sudo docker rm -v $(sudo docker ps -a -q -f "status=exited") - removes stopped containers (with volumes)
sudo docker rmi -f $(sudo docker images -q -f "dangling=true") - removes dangling images
sudo docker volume rm -f $(sudo docker volume ls -q) - removes volumes
sudo docker network rm $(sudo docker network ls -q) - remove networks
sudo docker system prune -f -a --volumes - remove all unused data (containers, images, volumes, networks)
sudo docker container prune -f - removes stopped containers
sudo docker image prune -f - removes dangling images
sudo docker volume prune -f - removes unused volumes (of stopped containers)
sudo docker network prune -f - removes unused networks (of stopped containers)
Ansible or Kubernetes (or Chef, or Capistrano)
Vagrant + Ansible (or Docker-Machine), Docker/Docker Compose + Ansible
========
COMPOSER
========
composer init
composer create-project symfony/framework-standard-edition /srv/www/framework-standard-edition
composer create-project yiisoft/yii2-app-basic /srv/www/yii2-app-basic
composer install
composer update [package]
composer remove [package]
composer dump-autoload
=======
SYMFONY
=======
php bin/console debug:container --types - lists container public and private services (for using autowiring)
php bin/console debug:router - shows all possible routes
php bin/console assets:install --symlink - creates symlinks assets in default folder "web"
php bin/console doctrine:database:create - creates an empty "database_name" database
php bin/console doctrine:generate:entity - creates a simple entity class
php bin/console doctrine:generate:entity --no-interaction --entity="AppBundle:Category" --fields="name:string(255)" - creates the entity class
php bin/console doctrine:schema:validate - validates the entity mappings
php bin/console doctrine:schema:update --force - creates all the database tables
=====
YII 2
=====
php yii migrate/up
==========
NPM & YARN
==========
sh -c "yarn init && yarn add -D webpack babel-core babel-loader babel-preset-env babel-preset-react && yarn add react react-dom"
yarn install
yarn install bootstrap@^4.0.0-beta.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment