If you are switching from Windows to Linux based operating system, then it might be difficult in early days to get hang of it. Here are some commands that will be useful.
- If you want to find out size of current directory, just type
2. Check your disk usage
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 388M 12M 377M 3% /run
/dev/sda6 407G 59G 328G 16% /
tmpfs 1.9G 83M 1.9G 5% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda2 96M 32M 65M 34% /boot/efi
tmpfs 388M 60K 388M 1% /run/user/1000
3. See all files and directory size in current path
$ ls -lh
-rw-r--r-- 1 deven deven 75K Jul 4 2017 1470493410_1499166814.jpg
drwxrwxr-x 15 deven deven 4.0K Mar 17 11:54 ach-hq
-rw-rw-r-- 1 deven deven 35K Jun 28 2017 address.php
drwxrwxr-x 4 deven deven 4.0K Jul 15 2017 bil 2
-rw-rw-r-- 1 deven deven 355K Jul 15 2017 bill 2.zip
drwxrwxr-x 3 deven deven 4.0K Jul 29 2017 book_ge_api
-rw-rw-r-- 1 deven deven 96K Aug 8 2017 cities.sql
drwxrwxr-x 13 deven deven 4.0K Jun 27 2017 clon
4. Truncate log files
truncate -s 0 /path-to-log-file/log.log
5. List content of a directory using ls command
6. If you want to know about a command, you can take of man command, for example if you want to go into details of ls command, just type
It will give you an output something similar to this
ls - list directory contents
ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
do not ignore entries starting with .
do not list implied . and ..
with -l, print the author of each file
I will be updating this with more useful commands as and when I found.
I run a web development agency and most of the time it happens that we create servers for client in our own Digital Ocean account during the development phase. When project gets over we usually transfer the ownership of the droplet to client. I have seen Digital Ocean customers
struggling with the transfer of ownership of droplet.
So here is I am giving a simple step by step guide to transfer a droplet from one Digital Ocean account to another.
Step 1: Take a snapshot of droplet
We need to first take a snapshot of the droplet that you want to transfer. You can either take a live snapshot which doesn’t require shutting down the droplet or to avoid any data loss just power off the droplet before taking snapshot. You can power off the droplet from the control panel or by logging into server through ssh.
Enter the name of snapshot and click on “Take Snapshot” button.
Step 2: Enter recipient owner digital account email address
Once the snapshot is ready, click on “Change Owner” option. It will prompt to enter recipient email address. Enter the address of the account to which you want to transfer the droplet.
Step 3: Accept snapshot transfer
Now log into the control panel of the recipient account. Go to Images and then Snapshots. You will see the snapshot that you had transferred to this account. Click on Accept to complete the transfer process.
Step 4: Create a new droplet from snapshot
Since we have the snapshot with us now, we need to create a droplet from this snapshot. To Click on “Create Droplet” option from menu and select the appropriate plan for your droplet, and your droplet is ready!
Comodo offers a wide range of SSL certificates to suit a diverse range of business requirements and budgets.
Follow below steps to install comodo positive ssl certificate on your ubuntu server.
Step 1 – Before applying for a certificate we need to submit Certificate Signing Request (CSR) to Certificate Authority (CA). Run below command on your server
openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr
* replace example_com with your domain name if you want to
It will ask following details
- Organization Name
- Organizational Unit
- Country Code
- State / Province
- Common Name – This is the domain name for which you want to purchase SSL certificate
After providing above mentioned details this command will create two files
- example_com.key – Your private key which you need to configure Apache or Nginx
- example_com.csr – CSR
Step 2 – Apply for the certificate and provide content of CSR file
Step 3 – After submitting CSR, CA will send you an email on email selected by you. You should get your SSL certificate after verifying your domain.
Your certificate zip file will contain
example_com.crt – Your ssl certificate
AddTrustExternalCARoot.crt – Root CA certificate
COMODORSAAddTrustCA.crt – Intermediate CA certificate
COMODORSADomainValidationSecureServerCA.crt – Intermediate CA certificate
Step 4 – Create a bundle of all crt files
cat www_example_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > ssl-bundle.crt
Step 5 – Configuring Apache web server to serve website over HTTPS
Step 6 (Optional) – Configure Nginx to serve website over HTTPS
Using nvmNVM, which stands for “Node.js version manager” we can install multiple versions of nodejs on Ubuntu.
or using Wget:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Run the script by running
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
To get the list of available Node.js versions
nvm install 6.0.0
nvm use 6.0.0
Recently I started learning React Native to build native mobile applications using React JS. I faced lots of issues while making my first application run on my Ubuntu desktop. Here I am recording issues I faced and the solutions that worked for me, so that beginners like me don’t have to reinvent the wheel.
A problem occurred configuring project ‘:app’.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
- Go to your React native Project -> Android
- Create a file
- Open the file
- paste your Android SDK path like below
- in Windows
sdk.dir = C:/Users/USERNAME/AppData/Local/Android/sdk
- in macOS
sdk.dir = /Users/USERNAME/Library/Android/sdk
- in linux
sdk.dir = /home/USERNAME/Android/Sdk
USERNAME with your user name
react-native run-android in your terminal
ENOENT: no such file or directory, open ‘android/app/src/main/assets/index.android.bundle’
Manually create this directory
Unable to load script from assets index.android.bundle
- (in project directory)
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
ou can automate the above steps by placing them in
scripts part of
package.json like this:
<span class="str">"android-linux"</span><span class="pun">:</span> <span class="str">"react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android"</span>
Then you can just execute
npm run android-linux from your command line every time.
I will keep updating this as and when I encounter new issues with solutions that worked for me.
Following code snippet converts a date time in GMT to Local timezone.
$myDateTime = new DateTime('2014-08-27 18:21', new DateTimeZone('GMT'));
echo $myDateTime->format('Y-m-d H:i');
If you are running a migration to change the data type of a column in a table. You might come across this error message in terminal.
Changing columns for table "***" requires Doctrine DBAL; install "doctrine/
This error message is telling you to install doctrine/dbal to make this work. You can learn more about this package here https://github.com/doctrine/dbal
To install this package through composer, run following command in terminal.
composer require doctrine/dbal
Now you can run your migration by running
This should work now.
If you are getting this error while running npm install, then you are not having write permission on .npm directory.
To get the ownership of this directory run following command
sudo chown -R $(whoami) ~/.npm
Also we need to give write permission to node_modules directory
sudo chown -R $USER /usr/local/lib/node_modules
ref – http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
I was getting this error in my error log, after searching for solutions online I stumbled upon this solution that worked for me. I am writing this post for my personal reference, it would be great if someone gets benefited by this.