Linux basics session 2

Course overview

Linux user environment

Ubuntu provides a decent graphical user interface (GUI) with most common applications available from Free Open Source Software (FOSS) sources. Window Manager (called Gnome in Ubuntu) is running on top X Server which is an ordinary daemon (service). Underlying system can always be controlled using a console - Terminal - Command Line Interface (CLI). Linux servers powering the majority of Internet sites don't have GUI installed unlike Windows servers.

Desktop

SUPER key (WIN key or COMMAND on Mac) to access "spotlight", start typing to open applications.

web browser - FireFox

PRINT SCREEN key - creates a screenshot into Pictures folder - combine with SHIFT for a snip

Calculator, LibreOffice Calc (Excel alternative)

Nautilus (files) - browsing files - home folder structure

installing programs (graphical mainly)

graphical editors - Gimp (raster graphics), Inkscape (Vector graphics)

communicators available: Slack, Teams, Skype, WhatsApp, Messenger, Telegram, ...

Remina - remote desktop

FileZilla - FTP - file transfers

openscad - 3D modeling

terminal - command line window - shell - Bash for Ubuntu - shortcut CTRL+ALT+T

Command Line Interface (CLI)

All the time use TAB key to autocomplete your command or file path - it saves time and prevents typos!

whoami, id, who - users, groups

uptime, date - time info

cal -jy 1750 - calendar - anatomy of a command: ' '

man cal - manual pages - documentation - how to read Usage section

for any command you don't know start with man <command> or <command> --help or <command> -h

What is my HW configuration?

free - memory info

cat /proc/cpuinfo - cpu info - command cat prints out the content of a file

df -h - disk usage info

cat /etc/issue - Linux distribution and version

uname -a - Linux kernel version and build architecture

Network configuration:

ip a l - shows IP addresses on network devices - ip address list in full - modern style of providing arguments to commands

route - routing table

hostname -f - full hostname of the machine (doesn't work well for our test machines)

Filesystem Hierarchy Standard (see Linux Brief presentation):

Everything in Linux is a file mounted under "/" (root of filesystem), unlike C: drive, E: drive, ... in Windows

Administrator user is always called "root", it's home folder is in "/root/", other users have their home directories in "/home//".

Daemons (services) have configuration in "/etc/" and logs under "/var/log/".

Working in the home directory:

pwd - print current directory

ls, ls -la - file listing, hidden files starts with ".", owner, group, permissions

ls ./Downloads - relative path

ls /home/vasek/Downloads - absolute path

cd Download - change directory

cd .. - one directory up

mkdir test - create new directory

rmdir test - remove directory

touch test.txt - create empty file

rm test.txt - remove file

mv test.txt test2.txt - move or rename file - "-i" to not accidentally overwrite existing file

alias mv=mv -i adding "-i" to mv command by default

Linux command line cheat sheet: linux_cheat_sheet.pdf - from fosswire.com

Self-study

Mastering linux is mainly about mastering keyboard input, practice makes perfect.

Use the command line exclusively. In your home folder create a directory structure with files as follows.

HINT: use mkdir for directories and touch for files.

Stretch goal: instead of creating empty files, create proper content or find suitable examples on-line and put them in place (command wget for download, mv for moving/renaming file).

Solution

$ mkdir -p work/project_A/images
$ mkdir -p work/project_A/images
$ mkdir -p work/project_A/data
$ mkdir -p work/project_b
$ mkdir -p work/project_X
$ touch work/project_X/idea.txt
$ touch work/project_b/draft.doc
$ touch work/project_A/README.txt
$ touch work/project_A/data/sample.csv
$ touch work/project_A/images/01.jpg
$ tree work/
work/
├── project_A
│   ├── data
│   │   └── sample.csv
│   ├── images
│   │   └── 01.jpg
│   └── README.txt
├── project_b
│   └── draft.doc
└── project_X
    └── idea.txt

5 directories, 5 files