introduction
What is GNU Linux?
GNU Linux is an open source operating system.
What is BASH?
BASH (Bourne Again SHell) is the most popular shell for Linux terminal.
What is Debian?
Debian is an important GNU Linux distribution. Many other distros are derived from Debian, such as Ubuntu or Linux Mint.
How can we use GNU Linux?
On most distributions (e.g. Ubuntu (Desktop), Linux Mint), we can use it with CLI (Command-Line Interface) and GUI (Graphical User Interface).
There are distributions that do not have a GUI installed by default. Typically, these are versions used as server operating systems, such as Ubuntu Server.
If we are just using a Graphical User Interface, we can run a terminal emulator (pseudoterminal) or go to the Command Line Interface.
How to run the terminal in GUI (Graphical User Interface)?
On most distributions, click the menu button or press and type terminal.
How to go to the CLI (Command-Line Interface) from GUI?
Press Ctrl + Alt + F2. Instead of F2 can be F3, F4, F5, F6 or F1.
How to back to the GUI (Graphical User Interface)?
Press Alt + F1. Instead of F1 can be F6, F7 or other function key. You can also quickly switch between instances of the command line with Alt + or Alt + .
disks & partitions
Disks numbering
sda
│ └─ disk number
└─── type of disk controller
types of disks controllers
- h - IDE controller
- s - SATA / SCSI controller
disk number (as a letter)
- a - 1st disk
- b - 2nd disk
- c - 3rd disk
examples
- sda - disk #1 in SATA / SCSI controller
- sdb - disk #2 in SATA / SCSI controller
- hda - disk #1 in IDE controller
Partitions numbering
sda1
│ │└─ partition number
│ └── disk number
└──── type of disk controller
partition number
- 1 - 1st partition
- 2 - 2nd partition
- 3 - 3rd partition
examples
- sda1 - disk #1, partition #1
- sda2 - disk #1, partition #2
- sdb1 - disk #2, partition #1
GNU Linux (BASH) - Linux Mint [Debian-based distro]
karol@core2duo:~$ sudo fdisk -l
[sudo] password for karol:
Disk /dev/sda: 223,58 GiB, 240056327680 bytes, 468860015 sectors
Disk model: SanDisk SSD PLUS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9438d1e9
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 296962047 296960000 141,6G 7 HPFS/NTFS/exFAT
/dev/sda2 296962048 358401501 61439454 29,3G 83 Linux
/dev/sda3 358402048 464662527 106260480 50,7G 83 Linux
/dev/sda4 464662528 468858879 4196352 2G 82 Linux swap / Solaris
Disk /dev/sdb: 55,92 GiB, 60022480896 bytes, 117231408 sectors
Disk model: KINGSTON SVP200S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x781a275d
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 96751615 96749568 46,1G 7 HPFS/NTFS/exFAT
/dev/sdb2 96751616 117229567 20477952 9,8G b W95 FAT32
directory structure
├── bin
├── boot
├── cdrom
├── dev
├── etc
├── home
├── lib
├── lib64
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
GNU Linux (BASH) - Linux Mint [Debian-based distro]
karol@core2duo:/$ tree -L 1
.
├── bin
├── boot
├── cdrom
├── dev
├── etc
├── home
├── lib
├── lib32
├── lib64
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
environment variables
$PWD
$OLDPWD
GNU Linux (BASH) - Linux Mint [Debian-based distro]
karol@core2duo:~$ set | head -96
BASH=/usr/bin/bash
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:globasciiranges:histappend:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=([0]="0")
BASH_ARGV=()
BASH_CMDS=()
BASH_COMPLETION_VERSINFO=([0]="2" [1]="10")
BASH_LINENO=()
BASH_REMATCH=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="5" [1]="0" [2]="17" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='5.0.17(1)-release'
COLORTERM=truecolor
COLUMNS=80
COMP_WORDBREAKS=$' \t\n"\'><=;|&(:'
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=cinnamon
DIRSTACK=()
DISPLAY=:0
EUID=1000
GDMSESSION=cinnamon
GDM_LANG=en_US
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/b124d479_898d_49c3_945a_f597a820f69a
GNOME_TERMINAL_SERVICE=:1.1716
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
GROUPS=()
GTK3_MODULES=xapp-gtk3-module
GTK_MODULES=gail:atk-bridge
GTK_OVERLAY_SCROLLING=1
HISTCONTROL=ignoreboth
HISTFILE=/home/karol/.bash_history
HISTFILESIZE=2000
HISTSIZE=1000
HOME=/home/karol
HOSTNAME=core2duo
HOSTTYPE=x86_64
IFS=$' \t\n'
INSIDE_NEMO_PYTHON=
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_ADDRESS=pl_PL.UTF-8
LC_IDENTIFICATION=pl_PL.UTF-8
LC_MEASUREMENT=pl_PL.UTF-8
LC_MONETARY=pl_PL.UTF-8
LC_NAME=pl_PL.UTF-8
LC_NUMERIC=pl_PL.UTF-8
LC_PAPER=pl_PL.UTF-8
LC_TELEPHONE=pl_PL.UTF-8
LC_TIME=pl_PL.UTF-8
LESSCLOSE='/usr/bin/lesspipe %s %s'
LESSOPEN='| /usr/bin/lesspipe %s'
LINES=24
LOGNAME=karol
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
MACHTYPE=x86_64-pc-linux-gnu
MAILCHECK=60
OLDPWD=/home/karol
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PAPERSIZE=a4
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PIPESTATUS=([0]="0")
PPID=10883
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS2='> '
PS4='+ '
PWD=/home/karol
QT_ACCESSIBILITY=1
QT_QPA_PLATFORMTHEME=qt5ct
SESSION_MANAGER=local/core2duo:@/tmp/.ICE-unix/1161,unix/core2duo:/tmp/.ICE-unix/1161
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_AGENT_PID=1310
SSH_AUTH_SOCK=/tmp/ssh-5epUrs6SzHHy/agent.1161
TERM=xterm-256color
UID=1000
USER=karol
VTE_VERSION=6003
XAUTHORITY=/home/karol/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
XDG_CURRENT_DESKTOP=X-Cinnamon
XDG_DATA_DIRS=/usr/share/cinnamon:/usr/share/gnome:/home/karol/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/karol
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=cinnamon
XDG_SESSION_ID=c1
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
_=--color=auto
GNU Linux (BASH) - Linux Mint [Debian-based distro]
karol@core2duo:~$ env
SHELL=/bin/bash
SESSION_MANAGER=local/core2duo:@/tmp/.ICE-unix/1161,unix/core2duo:/tmp/.ICE-unix/1161
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
LANGUAGE=en_US
LC_ADDRESS=pl_PL.UTF-8
LC_NAME=pl_PL.UTF-8
SSH_AUTH_SOCK=/tmp/ssh-5epUrs6SzHHy/agent.1161
DESKTOP_SESSION=cinnamon
LC_MONETARY=pl_PL.UTF-8
SSH_AGENT_PID=1310
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
PWD=/home/karol
LOGNAME=karol
XDG_SESSION_DESKTOP=cinnamon
QT_QPA_PLATFORMTHEME=qt5ct
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
XAUTHORITY=/home/karol/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/karol
GDM_LANG=en_US
INSIDE_NEMO_PYTHON=
HOME=/home/karol
LC_PAPER=pl_PL.UTF-8
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=X-Cinnamon
VTE_VERSION=6003
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/e5a4ca93_cb6c_4a7b_97b7_e8c8534460a0
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
TERM=xterm-256color
LC_IDENTIFICATION=pl_PL.UTF-8
GTK_OVERLAY_SCROLLING=1
LESSOPEN=| /usr/bin/lesspipe %s
USER=karol
GNOME_TERMINAL_SERVICE=:1.2033
DISPLAY=:0
SHLVL=1
LC_TELEPHONE=pl_PL.UTF-8
LC_MEASUREMENT=pl_PL.UTF-8
XDG_VTNR=7
XDG_SESSION_ID=c1
PAPERSIZE=a4
XDG_RUNTIME_DIR=/run/user/1000
LC_TIME=pl_PL.UTF-8
GTK3_MODULES=xapp-gtk3-module
XDG_DATA_DIRS=/usr/share/cinnamon:/usr/share/gnome:/home/karol/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
GDMSESSION=cinnamon
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
LC_NUMERIC=pl_PL.UTF-8
_=/usr/bin/env
OLDPWD=/home/karol/Documents/cmd
access rights
GNU Linux (BASH) - Linux Mint [Debian-based distro]
karol@core2duo:~$ ls -l
razem 44
drwxr-xr-x 15 karol karol 4096 sie 3 20:57 Aplikacje
drwxr-xr-x 4 karol karol 4096 sie 4 10:47 Dokumenty
drwxr-xr-x 22 karol karol 4096 sie 2 13:20 ePSXe
drwxr-xr-x 7 karol karol 4096 sie 3 20:54 Muzyka
drwxr-xr-x 2 karol karol 4096 sie 2 16:14 Obrazy
drwxr-xr-x 2 karol karol 4096 sie 4 10:38 Pobrane
drwxrwxr-x 2 karol karol 4096 sie 4 18:32 Projects
drwxr-xr-x 2 karol karol 4096 sie 2 16:14 Publiczny
drwxr-xr-x 4 karol karol 4096 sie 4 13:06 Pulpit
drwxr-xr-x 2 karol karol 4096 sie 2 16:14 Szablony
drwxr-xr-x 2 karol karol 4096 sie 2 16:14 Wideo
┌───────┬─ all
drwxr-xr-x
│└┬┘└┬┘└┬┘
│ │ │ └─ other
│ │ └─ group
│ └─ user
└─ type of file / directory
types of files
- d - directory
- - - usual file
- l - link
who is who?
- user - the file (directory) owner
- group - users who are in the same group as the owner of the file
- other - other users
- all - all users
what means ...?
- r - reading right
- w - writing right
- x - executing right
numerical value of access rights
- rwx = 7
- rw- = 6
- r-x = 5
- r-- = 4
- --- = 0
how to change access rights?
by numerical values
chmod 777 fileName
- rwxrwxrwx - set all rights to all users
chmod 700 fileName
- rwx------ - only the owner has rights (all)
chmod 644 fileName
- rw-r--r-- - the owner can read and write; users from group and other users can only read
chmod 755 fileName
- rwxr-xr-x - the owner has all rights; users from group and other users can read and execute
by assigning
chmod u+x fileName
- add executing right for the file owner user
chmod o-r fileName
- remove reading right for other users
chmod g=rx fileName
- set reading and executing right for group users
chmod a=rw fileName
- set reading and writing right for all users