## Check RAM memory size on Ubuntu

From a terminal , issue the following command accordingly.

$free to see RAM information in KB.$ free -m                 to see RAM information in MB.

$free -g o see RAM information in GB. For more commonly used Linux commands, check my other posts at here and here . ## Ubuntu command line check disk usage To check hard disk usage on Ubuntu from a terminal (command line), issue the following command in your terminal. liping:~$ df -h

-h stands for human which makes it readable by us humans, otherwise the file size will be in bytes:)

After you issue the command, you would  see your disk usage similar to the info given below.

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda7              68G   23G   43G  35% /
udev                   10M     0   10M   0% /dev
tmpfs                 800M  1.6M  798M   1% /run
tmpfs                 5.0M     0  5.0M   0% /run/lock
/dev/sda6             264G  173G   78G  69% /home
tmpfs                 3.2G  992K  3.2G   1% /tmp
.
.
.

For more commonly used Linux commands, check my other posts at here  and here .

## [LaTeX] subfigures with captions

This post provides Latex code examples for how to generate sub-figures with and without captions.

• Sub-figures with captions
\documentclass{article}
\usepackage{graphicx, caption, subcaption}
\begin{document}

\begin{figure}
\begin{subfigure}{0.96\textwidth}
\includegraphics[width=\textwidth]{subfig1}
\caption{subfig 1 caption text here}
\end{subfigure}
\centering  %note: this centering command applies to subfig1
\hfill
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=\textwidth]{subfig2}
\caption{subfig 2 caption text here}
\end{subfigure}
\hfill
\begin{subfigure}{0.47\textwidth}
\includegraphics[width=\textwidth]{subfig3}
\caption{subfig 3 caption text here}
\end{subfigure}
\caption{the overall fig caption text here}
\label{fig:subfig_example} % Give a unique label
\end{figure}

\end{document}

• Sub-figures without caption 
\documentclass{article}
\usepackage{graphicx}
\begin{document}

%*For figures without sub-captions
\begin{figure}
\includegraphics[width=0.96\textwidth]{subfig1}
\centering
\hfill
\includegraphics[width=.48\textwidth]{subfig2}
\hfill
\includegraphics[width=.48\textwidth]{subfig3}
% figure caption is below the figure
\caption{figure caption text here}
\label{fig:subfig_example2} % Give a unique label
\end{figure}

\end{document}

## Install DB Browser for SQLite on Ubuntu 16.04

This post introduces how to install DB Browser for SQLite on Ubuntu 16.04.

For Ubuntu and derivaties, @deepsidhu1313 provides a PPA with the latest release at here:

Step 1: Add the PPA shown above by issuing the following command in your terminal:

$sudo add-apt-repository -y ppa:linuxgndu/sqlitebrowser Step 2: Update the cache using: $ sudo apt-get update

Step 3: Install the DB Browser for SQLite package by issuing the following command:

$sudo apt-get install sqlitebrowser Reference: http://sqlitebrowser.org/ ## [LaTeX] Add appendices in an article This post introduces how to add appendices to an article. The command \appendix is included in all basic class files, so you do not need to include any extra package to add appendix, unless the journal that you aim at has specific appendix style requirements. \begin{document} \section{Your section name here} \section{Your section name here} % Activate the appendix in the doc % from here on sections are numerated with capital letters \appendix \section{Appendix A title here} \subsection{Appendix subsection title here} \subsection{Appendix subsection title here} \section{Appendix B title here} \end{document} ## VPN setup on Ubuntu 16.04 (using Cisco AnyConnect client) This post introduces how to setup VPN on Ubuntu 16.04 LTS using Cisco AnyConnect Client. Step 1: Download Cisco AnyConnect client. Penn Stater can download at here. Step 2: Extract the file(s) and install as root. (1) extract the downloaded file; (2) then cd to the extracted directory where it has an installation .sh file; (3) then issue the following command to install Cisco AnyConnect Client: $sudo ./AnyConnectInstall.sh

# note your .sh file may have slight different name

Step 3:  Run the following command.

$sudo apt-get install openconnect network-manager-openconnect-gnome We need to issue this command to show Cisco Compatible VPN in the list when we open network manager and add a new VPN. Step 4: Open Network Manager. Step 5: Add a VPN in the Network Manager Step6: Choose Cisco AnyConnect Compatible VPN (openconnect) and click Create. Step 7: Enter the following info • Connection name: Tech Services VPN [Note you can name this as you wish] • Gateway: vpn.its.psu.edu [type in your vpn accordinly] Click Save. Step 8: Open Cisco Anyconnect client Type your VPN address in the connect to textbox, and then enter your username and psw. Then you are ready to go:) References: VPN, CISCO AnyConnect, Linux Cisco VPN client on Ubuntu 16.04 LTS ## Two ways to merge PDF files on Mac (GUI and command line) This post introduces how to merge PDF files on Mac from GUI and from Terminal on Mac OS. (For Ubuntu and Windows users, check out my post here for solutions.) Method 1: GUI — using Preview that comes with your Mac OS. Check here for how to combine PDFs and reorder, rotate, and delete pages. If the page is not accessible, check the pdf I linked to in the references. Method 2: From Terminal We will introduce using gs command. many people may already have gs package installed and are already using gs. TO check whether your Mac has gs installed, in your terminal, issue the following command: $ which gs


If you see something like this “/usr/local/bin/gs”, you OS has gs installed

If you see something like “… command not found”, you will need to install gs first.

You can use brew to install it.

$brew install gs If you do not have brew installed, check: Install Homebrew. After you have gs installed, in your terminal, cd to the directory where the pdf files you want to merge are located, and then issue the following command: $ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf source1.pdf source2.pdf source3.pdf

Then you will see a merged.pdf appear in the same folder where you source pdfs are.

Note: You may encounter these two errors in your terminal after your issue the pdf merge command I mentioned above, but be assured, the merge.pdf is correct. you can double check if you are worried about that:)

References:

How can I combine multiple PDFs using the command line?

## Read the first line of a file from terminal (on Ubuntu and Mac)

This post introduces how to read the first line of a file from terminal. It works on both Linux (Ubuntu) and Mac OS.

For getting top or bottom 10 files under a director from terminal (on Ubuntu and Mac), check here.

Note: you do not need to install anything, it is built-in on your Ubuntu/Mac OS.

Step 1: open a terminal

Step 2: cd to the directory where your file (e.g., .txt file) is located

Step 3: issue the following command

$head -n 1 example.txt # this will read and print the first line of the file in the terminal$ head -n 2 example.txt
# this will read and print the first two lines of the file ... you got the idea...

***********************************************

Analogously, see the following command for displaying the last line of a file from terminal:

$tail -n 1 example.txt # this will read and print the last line of the file in the terminal$ tail -n 2 example.txt # this will read and print the last two lines of the file ... you got the idea...

## Get top or bottom 10 files under a director from terminal (on Ubuntu and Mac)

This post get top/bottom 10 from the sorted file names in current directory.

For reading the first line of a file from terminal (on Ubuntu and Mac), check here.

Note: you do not need to install anything, it is built-in on your Ubuntu/Mac OS.

Step 1: open a terminal

Step 2: cd to the directory where your file (e.g., .txt file) is located

Step 3: issue the following command accordingly 

$ls | head -10 # the pipe symbol (i.e., |) puts the output of the ls command as the input of the head command. if you would like to get more information of the files, use the following instead: $ ls -l | head -10

similarly,

if you would like to get the bottom 10 files in the current directory, issue the following command:

$ls | tail -10 or for detailed information of the files, use $ ls -l | tail -10

You guessed it, if you would like to get the top/bottom 20, just change the -10 to -20:)

simply, enough, right?

For more commonly used Linux commands, check my other posts at here  and here .

## Word count in pdf using wc command (on Ubuntu and Mac)

This post introduces how to count the number of words in a pdf file using wc command. It works on both Linux (Ubuntu) and Mac OS.

Note: you do not need to install anything, it is built-in on your Ubuntu/Mac OS.

Step 1: open a terminal

Step 2: cd to the directory where your pdf file is located

Step 3: issue the following command

\$ ps2ascii example.pdf | wc -w

Step 4: Then you should see the number of words in that example.pdf

P.S.   the wc command has several arguments, see below.

wc -l: print the number of lines in a file.

wc -w: print the number of words in a file.

wc -c: print the number of bytes in a file.

wc -m: print the number of characters from a file.

wc -L: print only the length of the longest line in a file.