Skip to content

Tipsandtricks

Tim Welch edited this page Jan 30, 2023 · 2 revisions

Tips and Tricks

Editing a file in Ubuntu using nano text editor

Assume you want to add some lines of text to a file called foo.txt in your home directory using nano.

  1. Open a Ubuntu shell
  2. nano ~/foo.txt
  3. Copy and paste the following lines into the file
This is file foo
It doesn't do much
  1. Save and exit with Ctrl-O and Enter
  2. Look at your results
echo ~/foo.txt
  1. Now delete the file with rm ~/.foo.txt

Editing your startup bash script in Ubuntu

On occasion, you'll need to modify your Ubuntu bash shell environment to load something on startup. Building on the last tip, you can edit your .bashrc file

  1. Open a Ubuntu shell
  2. nano ~/.bashrc
  3. Add or paste in your configuration. This can be done at the top or bottom of the file usually.
  4. Save and exit with Ctrl-O and Enter
  5. Reload your bashrc with source ~/.bashrc or you can just close and restart your Ubuntu shell.

/Users/MAC-OS-USER/Library/CloudStorage/Box-Box

Access Cloud Drive folder

This is useful if you manage your spatial data in Box and collaborators sync it to their local computers. This lets you bring your Box Drive folder into your Ubuntu docker container so that you can symlink it to your data/src folder and import data in a consistent way across all users.

Note, this could be used with other drive share systems such as Google Drive.

First, ensure you have Box Drive installed, and you have enabled sync of your data to your local computer.

MacOS

Open a terminal and assuming your username is alex check that the following path exists

ls /Users/alex/Library/CloudStorage/Box-Box

If you see the top-level of your synced files, then you are good to go.

Ubuntu on Windows WSL2

Source - https://github.com/microsoft/WSL/issues/4310

C:\Users\alex\box

Now add the following to your bashrc:

if ! findmnt -M /mnt/box &>/dev/null; then
    sudo mount -t drvfs 'C:\Users\alex\box' /mnt/box
fi

On every Ubuntu shell startup you will nowbe prompted for your root password. Once entered the drive mount will be performed.

Now verify your box files are accessible from Linux

ls /mnt/box