Run with Powershell powershell.exe -command “& ‘D:\powershell.ps1′” -ExecutionPolicy Bypass How long script takes? [datetime]$startDate = Get-Date[datetime]$endDate = Get-DateWrite-Host $(NEW-TIMESPAN –Start $startDate –End $endDate ) Find duplicate user values Get-ADUser -Filter { employeeID -like “*” } -SearchBase “OU=yourOU,DC=domain,DC=com” -property employeeID | Group-Object employeeID | Where-Object {$_.Count -ge 2} | select -ExpandProperty group | Select-Object Name, UserPrincipalName,… Continue reading Powershell
Python
Installation Data structures Tuple Cannot edit after it is created – Immutable. thistuple = (“1”, “2”, “3”)for x in thistuple: print(x) List thislist = [“1”, “2”, “3”]for x in thislist: print(x)
Databases
Postgres sudo apt install postgresqlsudo service postgresql statussudo passwd postgressudo -u postgres psql create database dbname; create user username with encrypted password ‘password’; grant all privileges on database dbname to username; Useful commands ALTER TABLE table ADD column dataType NOT NULL; \l list databases\c select database\dt list tables
Move a wordpress site to the new server
Backup mysqldump -u root -p database1 > database.sql tar -zcvf data.tar.gz data Restore CREATE DATABASE database1;CREATE USER ‘user’@’localhost’ IDENTIFIED BY ‘pwd’;GRANT ALL PRIVILEGES ON database1 . * TO ‘user’@’localhost’;FLUSH PRIVILEGES; mysql -u root -p database1 < database.sql tar -zxvf data.tar.gz new website: update wp-config.php with the new password sudo chown -R www-data:www-data /var/www/datafind /var/www/data -type… Continue reading Move a wordpress site to the new server
Ubuntu basic commands
Update packages/apps sudo apt update && sudo apt upgrade Compress/Decompress a file tar -zcvf compressedFileName.tar.gz directoryName tar -zxvf compressedFileName.tar.gz WSL use ssh key on remote server:eval ‘ssh-agent -s‘ssh-add -t 60m ~/.ssh/id_rsassh -A user:address MySQL sudo apt install mysql-server sudo mysql_secure_installation sudo /etc/init.d/mysql start sudo service mysql restart For WSL automatic start after restart: sudo update-rc.d… Continue reading Ubuntu basic commands
Win10 tools and settings for work with Ubuntu
I spent a last few years working in Ubuntu and Linux Mint. Now I have a new computer and will do the setup with Win10 and WSL2. WSL settings and setup Turn Windows features on or off: Telnet client Virtual Machine Platform Windows subsystem for linux Powershell: wsl –set-default-version 2 Tools and apps Ubuntu –… Continue reading Win10 tools and settings for work with Ubuntu
Git: Basic commands and scenarios
If you use a repository on one of the version control platforms like github, gitlab or bitbucket then you need some basic commands. When I was first introduced to git many years ago, I had to start with git pull, add, commit and push. I use this bulk of commands till nowdays. These commands basically… Continue reading Git: Basic commands and scenarios