Linux Fundamentals 1: The File System

In preparation for installing AEM on Linux I am going to recap some basic Linux knowledge.

I will be be working with Ubuntu installed on Windows Sub System for Linux (WSL2) which I have setup by following the instructions at  https://docs.microsoft.com/en-us/windows/wsl/.

Navigating the File System

ls - Shows the contents of the folder.

cd - The cd command is used to change directories. e.g cd /opt - use tab key to auto complete.

  • To navigate into the root directory, use "cd /"
  • To navigate to your home directory, use "cd" or "cd ~"
  • To navigate up one directory level, use "cd .."
  • To navigate to the previous directory use "cd -"

Linux Folder Structure

Run the the 'ls' command on the root folder and you will see the following structure.

/bin - This folder is used for the most commonly used terminal commands, looking inside we can see common commands such as grep, whoami etc.
/boot- contains files for startup including the Linux Kernel and boot loader configuration
/dev - contains device files that refer to various hardware devices
/etc - contains global config files that effect all users.
/home - for users directories.
/lib - contains dynamic libraries
/media -  this is for mounting drives e.g hard drive, cd, floppy disc
/mnt - for temporary mount points such as network drives - (when using WSL the windows file system is mounted here)
/opt - used to store additional software.
/proc - a virtual file system for the kernel to send processes
/root - the super users home directory
/run - temporary file system used in the boot process
/sbin - contains important admin commands that should be used by the super user
/srv - data for for services like HTTP of FTP
/tmp - used for temporary files
/usr - contains the majority of user applications.
/var - contains variable data - such as logs, databases, websites that persist between boots.

Help and Linux Manual

You can use the 'man' command to read the manual for any command. For example to see the manual for the Linux folder structure use the command.

man hier

And to view the manual for 'ls' use

man ls

Package Manager

On Ubuntu the 'apt' command can be used for installing and uninstalling packages.

Install A Package

sudo apt install openjdk-11-jdk  

Note: 'apt' is supposed to be interactive and ran from the command line by a human user, if you want to create a script use apt-get.

View Installed Packages

apt list --installed

Remove Package

sudo apt remove openjdk-11-jdk

Creating/managing folders

A quick recap on managing files and folders.

mkdir : To create a folder.
rm : Remove file or directory.
rm  -rf : Remove directory recursively.
cp : Copy file or directory.
cp -R : copy directory and all sub directories.
mv : Move and rename files.
touch - Create file.

Next up we will recap how to view files and logs .

Part 2 Linux Basics - Viewing Log Files