This is the repo for updating my current pc configuration, works for ubuntu 14.10 and macOS 10.12.6 (where specified)
Setting up ubuntu (14.10)
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python-software-properties
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
https://packagecontrol.io/installation
Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X
type install, select Package Control: Install Package
type prettify, select HTML-CSS-JS Prettify
type prettify, select GitGutter
type prettify, select SideBarEnhancements
type prettify, select AutoFileName
type prettify, select BracketHighlighter
type prettify, select DocBlockr
type prettify, select Babel
sudo apt-get install gufw
gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"
sudo apt-get autoremove unity-lens-shopping
sudo apt-get install rar
sudo apt-get update
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install guake
sudo apt-get install gksu
sudo apt-get install indicator-multiload
sudo apt-get install gpick
sudo apt-get install filezilla
sudo mkdir /etc/gconf/schemas
cd /etc/gconf/schemas/
sudo ln -s /usr/share/gconf/schemas/guake.schemas
sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update
sudo apt-get install atom
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install flashplugin-installer
Generate public ssh key Credit-SSH Key-Based Authentication on a Linux Server
ssh-keygen -t rsa -b 2048 -C "[email protected]"
ls ~/.ssh/*.pub
cat ~/.ssh/id_rsa.pub
Google Chrome Credit
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
sudo dpkg -i google-chrome*.deb
google-chrome
This installs a needed library for Google Chrome, then downloads the latest version of Chrome to a temporary directory and installs it
During the installation a PPA is added to your system so that Google Chrome receives the latest updates whenever you check for system updates
Fix Skype Credit
sudo apt-get install sni-qt:i386
Installation Credit
sudo apt-get install openjdk-7-jdk
Set variables Credit
echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ".profile"
echo "export PATH=\$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin" >> ".profile"
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin
Safely remove Credit
sudo apt-get remove openjdk-7-jdk
sudo apt-get purge openjdk*
Installation Credit
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer
javac -version
sudo apt install oracle-java8-set-default
Apache2 Credit
sudo apt-get install apache2
sudo update-rc.d -f apache2 remove
sudo update-rc.d apache2 defaults
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
MariaDB Credit
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo subl /etc/apt/sources.list.d/mariadb.list
http://mariadb.org/mariadb/repositories/
deb http://mariadb.bytenet.in//repo/10.0/ubuntu utopic main
deb-src http://mariadb.bytenet.in//repo/10.0/ubuntu utopic main
sudo apt-get update
sudo apt-get install mariadb-server
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
We need to tell MySQL to generate the directory structure it needs to store its databases and information. We can do this by typing :
sudo mysql_install_db
mysql > show process list;
PHP5 and phpmyadmin Credit
sudo apt-get install php5 libapache2-mod-php5 php5-mysql
sudo apt-get install phpmyadmin
sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo subl /etc/apache2/ports.conf
Listen 80
sudo subl /etc/apache2/sites-enabled/000-default.conf
Listen 80
Changing the default webroot for apache 2
Include /etc/phpmyadmin/apache.conf
/var/www/html
/home/starscream/public_html
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /home/starscream/public_html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/starscream/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
Nginx Credit
sudo apt-get update
sudo apt-get install nginx
We can make sure that our web server will restart automatically when the server is rebooted by typing
sudo update-rc.d nginx defaults
System start/stop links for /etc/init.d/nginx already exist.
This just means that it was already configured correctly and that no action was necessary. Either way, your Nginx service is now configured to start up at boot time.
Changing the default webroot for nginx / adding virtual host/s Credit
sudo subl /etc/hosts
127.0.0.1 localhost
127.0.1.1 starscream
127.0.0.1 angular.example.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
sudo subl /etc/nginx/sites-enabled/example
server {
listen 80;
server_name angular.example.com;
root /home/starscream/public_html/example_web;
index app/index.html;
location /{
try_files $uri /app/index.html;
}
}
sudo ln -s example /etc/nginx/sites-available/example
sudo service nginx reload
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
command -v nvm
# Gives
nvm
nvm ls-remote
nvm ls
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Reload .bash_profile from the command line Credit
source ~/.bash_profile
nvm install node
nvm install <SPECIFIC_NODE_VERSION>
nvm use node
nvm use <SPECIFIC_NODE_VERSION>
React Native on macOS 10.15.3 Credit
Know your JDK flavor Credit
java -version
# Gives following for oracle
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
brew install watchman
# If it gives following error
Updating Homebrew...
Error: The following formula
[#<Dependency: "[email protected]" []>, #<Options: []>]
cannot be installed as binary package and must be built from source.
Install the Command Line Tools:
xcode-select --install
# Then execute below commands
xcode-select --install
brew install watchman
Install Android Developer Studio Credit
ls -l /Library/Java
# Gives
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
9) Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that 28.0.3 is selected.
export ANDROID_HOME=$HOME/Library/Android/sdk >> ~/.bash_profile
export PATH=$PATH:$ANDROID_HOME/emulator >> ~/.bash_profile
export PATH=$PATH:$ANDROID_HOME/tools >> ~/.bash_profile
export PATH=$PATH:$ANDROID_HOME/tools/bin >> ~/.bash_profile
export PATH=$PATH:$ANDROID_HOME/platform-tools >> ~/.bash_profile
Realm on macOS 10.15.3
npm install -g realm-object-server
# If it gives
“ERROR:root:code for hash md5 was not found”
# Then [Credit](https://stackoverflow.com/a/60894282/3152654)
brew unlink openssl
brew reinstall python@2
brew link --overwrite python@2
python -v
python --version
brew link --overwrite python@2
ls /usr/local/Cellar/openssl
brew switch openssl 1.0.2o_2
If you have trouble running a ros command it may be due to your version of NVM. Try running nvm use 8 in your terminal. [Credit] (realm/realm-object-server#435 (comment))
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install -y build-essential
sudo apt-get install python-software-properties python g++ make
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm -g --verbose install sails
sudo add-apt-repository --remove ppa:chris-lea/node.js
sails new testProject
Lift the server (serves at http://localhost:1337/ by default)
cd testProject
sails lift
Generate a REST API (serves at http://localhost:1337/user by default)
sails generate api user
sails lift
sudo rm -r node_modules && npm install
brew install jmeter
jmeter
Reference1 Reference2 Reference3 Reference4
sudo dpkg --add-architecture i386
sudo apt-get install -qq -y libc6:i386 libgcc1:i386 libstdc++6:i386 libz1:i386
sudo apt-get update && sudo apt-get upgrade
http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
cd ~/Desktop
sudo tar zxf "android-sdk.tgz" -C "/opt"
cd "/opt" && sudo mv "android-sdk-linux" "android-sdk"
cd "/opt" && sudo chown root:root "android-sdk" -R
cd "$INSTALL_PATH" && sudo chmod 777 "android-sdk" -R
cd ~/
echo "export PATH=\$PATH:/opt/android-sdk/tools" >> ".profile"
echo "export PATH=\$PATH:/opt/android-sdk/platform-tools" >> ".profile"
echo "export PATH=\$PATH:/usr/bin/node/bin" >> ".profile"
export PATH=$PATH:/opt/android-sdk/tools
export PATH=$PATH:/opt/android-sdk/platform-tools
export PATH=$PATH:/usr/bin/node/bin
sudo apt-get -qq -y install default-jdk ant --verbose
If java is properly installed you can find it's location, by using the following command (Don't forget to remove bin/java from the end of the path while putting it into JAVA_HOME)
readlink -f $(which java)
echo "export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64" >> ".profile"
echo "export PATH=\$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin" >> ".profile"
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin
sudo nano /etc/environment
sudo npm install -g cordova --verbose
sudo npm install -g ionic --verbose
android
ionic start ExampleProject blank
cd ExampleProject
ionic platform add android
ionic build android
sudo npm install -g bower --verbose
bower init
bower install <package> --save
bower install <package> --save-dev
sudo npm install --global gulp --verbose
sudo npm install --save-dev gulp --verbose
sudo npm install --save-dev gulp-notify --verbose
sudo npm install --save-dev gulp-rename --verbose
sudo npm install --save-dev gulp-stylus --verbose
sudo npm install --save-dev gulp-uglify --verbose
sudo npm install --save-dev gulp del --verbose
// Sample gulpfile.js
// Load required gulp modules
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
stylus = require('gulp-stylus'),
del = require('del');
// Defining gulp task for performing cleaning of built files
gulp.task('clean', function(cb) {
del(['app/*.min.js', 'app/assets/css/build/**/*.css'], cb)
});
// Defining gulp task for uglification/minification of .js files
gulp.task('scripts', function() {
return gulp.src('app/*.js')
.pipe(rename({
suffix: '.min'
}))
.pipe(uglify())
.pipe(gulp.dest('app/'));
// .pipe(notify({
// message: 'Uglification complete !'
// }));
});
// Defining gulp task to get .styl files and render
gulp.task('styles', function() {
return gulp.src('./app/assets/css/*.styl')
.pipe(rename({
suffix: '.min'
}))
.pipe(stylus({
compress: true
}))
.pipe(gulp.dest('./app/assets/css/build'));
// .pipe(notify({
// message: 'Minification complete !'
// }));
});
// Defining watch task watches specified sources for changes and reloads on change
gulp.task('watch', function() {
// Watch .js files
gulp.watch('app/main.js', ['scripts']);
// Create LiveReload server
livereload.listen();
// Watch any files in dist/, reload on change
gulp.watch(['app/dist/**']).on('change', livereload.changed);
});
// A default task is a gulp that runs when you just run just 'gulp'
gulp.task('default', ['clean'], function() {
gulp.start('scripts', 'styles');
});
gulp
sudo npm install -g grunt-cli --verbose
sudo npm install -g yo --verbose
sudo npm install stylus -g --verbose
stylus -c file.styl
stylus file.styl
bower install angular
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo PATH=$PATH:/home/starscream/.composer/vendor/bin/
sudo composer install --verbose
sudo composer update --verbose
php artisan down
php artisan up
php artisan serve
php artisan serve --port=8001
php artisan vendor:publish
MongoDB community edition on macOS 10.15.3 Credit
- XCode
- Homebrew
brew tap mongodb/brew
brew install [email protected]
In addition to the binaries, the install creates:
- the configuration file (/usr/local/etc/mongod.conf)
- the log directory path (/usr/local/var/log/mongodb)
- the data directory path (/usr/local/var/mongodb)
brew services start [email protected]
brew services stop [email protected]
mongod --config /usr/local/etc/mongod.conf --fork
To stop a mongod running as a background process, connect to the mongod from the mongo shell, and issue the shutdown command as needed.
ps aux | grep -v grep | grep mongod
/usr/local/var/log/mongodb/mongo.log.
mongo
sudo apt-get install couchdb
sudo npm install -g add-cors-to-couchdb
add-cors-to-couchdb
As a root user, edit /etc/couchdb/local.ini and uncomment the bind_address line. Also change 127.0.0.1 to 0.0.0.0. Now everyone can access the database.
sudo subl /etc/couchdb/local.ini
http://localhost:5984/_utils/
sudo npm install -g fauxton
fauxton
fauxton --port=8001
sudo service couchdb start
sudo service couchdb stop
sudo service couchdb restart
mysqldump --set-gtid-purged=OFF --user=root --host=localhost --protocol=tcp --port=3307 --default-character-set=utf8 --skip-triggers "dbtoexport" > /pathtoexportlocation/dbtoexport.sql
tar -zcvf dbtoexport.tar.gz dbtoexport.sql
scp [email protected]:/pathtoexportlocation/dbtoexport.tar.gz /pathtoimportlocation
tar -zxvf dbtoexport.tar.gz
idbmysql dbtoexport < dbtoexport.sql
Change data directory in Infinidb (CentOS) Credit
cc stopSystem
cp /usr/local/Calpont/mysql/db /pathtofolder/
cp /usr/local/Calpont/data /pathtofolder/
cp /usr/local/Calpont/data1 /pathtofolder/
chown -R mysql:mysql /pathtofolder/data
chown -R mysql:mysql /pathtofolder/db
chown -R mysql:mysql /pathtofolder/data1
ln -s /pathtofolder/db /usr/local/Calpont/mysql/db
ln -s /pathtofolder/data /usr/local/Calpont/data
ln -s /pathtofolder/data1 /usr/local/Calpont/data1
getEnforce
sudo setEnfoce 0
cc startSystem
Infinidb common tweaks Credit
sudo vim /usr/local/Calpont/mysql/my.cnf
# Change following values
max_allowed_packet= 64MB
max_length_for_sort_data= 8388608
mysqldump --set-gtid-purged=OFF --user=root --host=localhost --protocol=tcp --port=3306 --password --default-character-set=utf8 --skip-triggers "dbtoexport" > /pathtoexportlocation/dbtoexport.sql
tar -zcvf dbtoexport.tar.gz dbtoexport.sql
scp [email protected]:/pathtoexportlocation/dbtoexport.tar.gz /pathtoimportlocation
tar -zxvf dbtoexport.tar.gz
mysql -u root -p dbtoexport < dbtoexport.sql
sudo /etc/init.d/mysql stop
sudo cp -R -p /var/lib/mysql /pathtofolder
Edit the MySQL configuration file, change the datadir path (default /var/lib/mysql) to the new data directory
sudo vim /etc/mysql/my.cnf
Edit apparmor profile, find and replace /var/lib/mysql (default path) with the new path to directory
sudo vim /etc/apparmor.d/usr.sbin.mysqld
sudo /etc/init.d/apparmor reload
sudo /etc/init.d/mysql restart
now=$(date +"%Y%m%d_%H%M%S")
mysqlFileName="mysqldbname"$now".sql"
mysqldump -u root -p root mysqldbname > $mysqlFileName
infinidbFileName="infinidbdbname"$now".sql"
mysqldump --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root infinidbdbname > $infinidbFileName
MySQL skip-hostname resolution Credit
sudo vim /etc/mysql/my.cnf
# Skip reverse DNS lookup of clients
skip-name-resolve
sudo /etc/init.d/mysql restart
MySQL regex replace Credit
Ubuntu tricks / commands Master Reference
Environment Variables Credit
export EDITOR=nano
printenv printenv TERM echo $TERM
export LC_ALL= unset LC_ALL
It is also possible to use the "-n" switch to the export command in order to un-export an environment variable and therefore demote it to become a shell variable while preserving its value. export -n LC_ALL
Session-wide environment variables Suitable files for environment variable settings that should affect just a particular user (rather than the system as a whole) are ~/.pam_environment and ~/.profile. After having edited one of those files, you should re-login in order to initialize the variables.
~/.profile In this file you can also place environment variable assignments, since it gets executed automatically by the DisplayManager during the start-up process desktop session as well as by the login shell when one logs in from the textual console. This is a ~/.profile equivalent of the above example: export FOO=bar export PATH="$PATH:$HOME/MyPrograms"
Shell config files such as ~/.bashrc, ~/.bash_profile, and ~/.bash_login are often suggested for setting environment variables. While this may work on Bash shells for programs started from the shell, variables set in those files are not available by default to programs started from the graphical environment in a desktop session.
System-wide environment variables A suitable file for environment variable settings that affect the system as a whole (rather than just a particular user) is /etc/environment. An alternative is to create a file for the purpose in the /etc/profile.d directory.
/etc/environment
This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line.
FOO=bar Note: Variable expansion does not work in /etc/environment.
/etc/profile.d/*.sh
Files with the .sh extension in the /etc/profile.d directory get executed whenever a bash login shell is entered (e.g. when logging in from the console or over ssh), as well as by the DisplayManager when the desktop session loads.
You can for instance create the file /etc/profile.d/myenvvars.sh and set variables like this:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0 export PATH=$PATH:$JAVA_HOME/bin
sudo apt-get install libnotify-bin
notify-send 'Title of the message' 'Text of the message'
notify-send -i /home/sathiya/deal.ico 'Deal success'
notify-send -u critical -i "notification-message-IM" 'Boss !!' 'Am done with the execution'
command && notify-send
gnome-screensaver-command --lock
sudo chown -R starscream: /opt/lampp/htdocs/Dropbox/xampp-root
sudo chmod -R 777 /opt/lampp/htdocs/Dropbox/xampp-root
chmod 400 mykeyfile.pem
sudo /etc/init.d/apache2 start
or
sudo service apache2 start
sudo /etc/init.d/apache2 stop
or
sudo service apache2 stop
sudo /etc/init.d/apache2 restart
or
sudo service apache2 restart
sudo service nginx start
sudo service nginx restart
sudo service nginx stop
sudo service nginx reload
^ + Alt + F2
dconf reset -f /org/compiz/
unity --reset-icons
sudo apt-get update
sudo apt-get install --reinstall ubuntu-desktop
sudo apt-get install unity
sudo shutdown -r now
sudo apt-get update
sudo apt-get install --reinstall ubuntu-desktop
sudo apt-get install unity
sudo apt-get remove --purge nvidia*
sudo shutdown -r now
node --max_old_space_size=8192 app.js 2>/path/error.log > /path/console.log
System stats with sar Credit
sar -r
crontab -l
crontab -e
SSH Tunneling Credit
Multiport tunneling (-4 required to force IPv4 - useful for RDP, -L 23305:localhost:3305 is in the form of -L local-port:host:remote-port, -i for private key)
ssh -4 -L 23305:localhost:3305 -L 23306:localhost:3306 [email protected]
ssh -4 -L 23305:localhost:3305 -L 23306:localhost:3306 -i private_key.pem [email protected]
df -h
Usage (The weight (size) of subdirectories under the root directory (-d 1, trailing /) with a sum total at the end (-c), all displayed in human-readable format (-h) without traversing into other filesystems (-x). Useful when /var /tmp or other directories are on separate storage from the root directory:)
du --max-depth=1 -c -h
sudo scp [email protected]:/data/filetobecopied.txt /home/Desktop/
sudo apt-get install screen
screen -ls
screen -S foo
screen -r foo
Keypress = Ctrl A D
Finding and deleting files Credit
Delete all files with a specific extension (e.g. .bak) from current directory and all subfolders (Also, make sure that -delete is the last argument in your command. If you put it before the -name *.bak argument, it will delete everything.)
find . -name "*.bak" -type f -delete
find . -name "*.bak" -type f
List contents Credit
tar -tvf foo.tar.gz '*filenamesearchterm*'
Extract specific file Credit
tar -xf foo.tar.gz /pathtofile/filename.ext
File links Credit
ln -s /pathtofolder/foldername filename
Delete user & remove home directory Credit
sudo userdel username
sudo rm -r /home/username
Safely uninstall ubuntu from windows dual boot PC Credit
Boot from Windows CD/DVD and choose “Repair” when it shows up. Choose command prompt on the resulting screen and run the following two commands:
bootrec /fixmbr
bootrec /fixboot
New file permissions to inherit from parent directory Credit
Raising the maximum number of file descriptors Credit
Allow SFTP (CentOS) Credit
sudo vim /etc/ssh/sshd_config
# Add “Subsystem sftp internal-sftp”
service sshd restart
Increase ulimit Credit
sudo launchctl limit maxfiles unlimited
Install pip Credit
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --user
vim ~/.bash_profile
Add export PATH=${PATH}:/Users/ishansheth/Library/Python/2.7/bin to bash_profile and then export for current session and then check version to verify installation
export PATH=${PATH}:/Users/ishansheth/Library/Python/2.7/bin
pip --version
Install maven Credit
Download zip from here and add it to path and then check version to verify installation
vim ~/.bash_profile
export MAVEN_HOME="/Users/ishan/public_html/apache-maven-3.6.0"
export PATH=${PATH}:${MAVEN_HOME}/bin
mvn -version