This is the repository for the training Learning Linux
Pierre-Yves Barriat d3237b3bc8 Removing html ressources | 1 year ago | |
---|---|---|
assets | 1 year ago | |
.gitignore | 1 year ago | |
Linux_ACELI.md | 1 year ago | |
Linux_ACELI.pdf | 1 year ago | |
README.md | 1 year ago | |
compile.sh | 1 year ago |
This is the repository for the training Learning Linux
Pierre-Yves Barriat
Many versions of Linux
Red Hat, Debian, Suse, etc
But one common linux kernel: kernel is like an engine. A distribution is an actual car that hosts the engine
Distributions differ from
Security
: there are very few viruses for Linux
Privacy
: most Linux distributions don't collect your data at all
Reliability
: if you want to stop something, you really can
Updates
: package manager
Customisation
: you can make Linux look, feel and behave as you want it to
Command Line Interface:
faster & efficient
get the latest Ubuntu LTS : ubuntu-22.04.2-desktop-amd64.iso
Using a virtual machine: test Linux without changing anything to your computer
You need to install a VM and then install the Linux inside
Get a Virtual Machine: https://www.virtualbox.org/wiki/Downloads
VirtualBox + Extension Pack
Install Linux in a VM: Install Linux Inside Windows Using VirtualBox
Step by Step Guide
A Linux distribution contains a display server, a window manager (manage windows, panel, menus, dash interfaces and core applications), and a desktop environment (eg status bars, drag-and-drop capabilities, etc)
These 3 items are bundled together to make what is known as a GUI environment
Using Linux through a GUI environment is similar to Windows or MacOSX
Linux users do not install software the same way that Windows users do: Linux has a tool known as a package manager
A package manager provides a way to search for software, install software, keep the software up to date and remove the software
Similar to Google or Apple store
Using Linux with GUI, it's already great ! Using CLUI = unlock the power of Linux !
Each Linux system contains a terminal
A terminal is where you enter Linux commands
It's called the Command Line User Interface
CLUI is one of the many strengths of Linux and can be more efficient than using the GUI
People tend to think command line is difficult. It's not.
A shell is a program that takes commands from the keyboard and gives them to the operating system to perform
The main function is to interpret your commands = language
The bash shell is one of several shells available for Linux
Learning the shell:
"When you are a child you use a computer by looking at the pictures. When you grow up, you learn to read and write"
It's more or less like SMSing to your PC, telling it what to do
Shells have some built-in commands
A shell also supports programming constructs, allowing complex commands to be built from smaller parts = scripts
Scripts can be saved as files to become new commands
many commands on a typical Linux system are scripts
An open terminal show you a PROMPT waiting for your commands
Commands can have options and parameters
All your commands are saved in a history
Rename many files at once ?
mmv '*.JPG' '#1.jpg'
Download a youtube video ?
youtube-dl https://www.youtube.com/watch?v=G7KNmW9a75Y&ab_channel=MileyCyrusVEVO
Convert color pictures in BW at once ?
#!/bin/bash
for file in *.jpg
do
convert ${file} -colorspace Gray "${file%.*}_bw.jpg"
echo "${file}... converted"
done
Navigating the File System
Get up and running with the CLUI by navigating directories and files
Viewing and Changing Files and Directories
Learn to manipulate directories and files from the CLUI
Configuring the Environment
Learn to configure the environment using the CLUI
Accessing Linux remotely
Learn to use SSH (basics)
A file system is a section of hard disk that has been allocated to contain files
it's arranged like hierarchical tree structure
Files are grouped in the directory structure
The top of the tree is called root
and /
is used to present the root
In the tree /users/usern/file1
is an absolute pathname
If you are already in the users
directory, the relative pathname for file1
is usern/file1
~
(tilda) points to the user's home directory. Useful if you are logging into a workstation with many users. It's the default working directory when you log in. If you are user usern
, then /users/usern/file1
is the same as ~/file1
.
refers to the current directory
..
refers to the parent directory
ls
: lists folders/files in a directorycd
: change directory
> use cd name
to navigate to directory namepwd
: print working directory. Prints the path of the current directorydu
: disk usage. Shows the disk usage of the current directoryman
: manualman name
to bring up a manual entry for command or program called name
mkdir
: use mkdir name
to create a new directory named name
in the current directorycp
: use cp file1 file2
to create file2
which is a copy of file1
> can also use cp -r
to copy whole directoriesmv
: move = same as copy, but deletes the original filerm
: delete files ( cannot recover your files after removed them ! )
> can also use rm -rf
to remove whole directoriesBe careful : there is no trash in CLUI
tab
is used for auto-complete
> If a file/directory name was partly typed in, tab will auto-complete itIf there are multiple options, tab will auto-complete up to the point where the options branch and show you a list of possible options
*
is used as a wild card
> rm blah*
removes all files which start with blah
: eg blah1
, blah2
, and blahblah
would all be removed
using
cp public/* private/
copies all files in apublic
directory into aprivate
directory, and keeps all file names intact
Each file and directory has three user based permission groups
owner
permissions apply only the owner of the file or directory, they will not impact the actions of other usersgroup
permissions apply only to the group that has been assigned to the file or directory, they will not effect the actions of other usersall users
permissions apply to all other users on the system, this is the permission group that you want to watch the mostEach file or directory has three basic permission types
read
permission refers to a user's capability to read the contents of the filewrite
permission refer to a user's capability to write or modify a file or directoryexecute
permission affects a user's capability to execute a file or view the contents of a directoryThe following command :
ls -l
gives :
1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|
-rwxr-xr-x |
1 |
dupont |
grpelic |
3528 |
2022-08-04 |
file_1 |
drwxr-xr-x |
3 |
dupont |
grpelic |
512 |
2022-01-02 |
dir_1 |
lrwxr-xr-x |
2 |
dupont |
grpelic |
210 |
2020-12-16 |
short -> /data |
-rw------- |
1 |
dupont |
grpelic |
4587 |
2022-12-04 |
file_2 |
Linux has a robust permissions system: this is a very good thing, as it enables a clear separation of roles among users
Especially between the root
user and your standard
user
Sometimes, though, you might want your standard user to have some or all of root's privileges : this is accomplished with sudo
Shells use three "standard I/O streams"
stdin
is the standard input stream, which provides input to commands.stdout
is the standard output stream, which displays output from commands.stderr
is the standard error stream, which displays error output from commands.Shell has several meta-characters and control operators
|
,&
,>
,;
, etc.
In a bash shell many things constitute your environment
Environment includes many variables that may have been set by bash or by you
Access the value of a variable by prefixing its name with
$
USER
: the name of the logged-in userUID
: the numeric user id of the logged-in userHOME
: the user's home directory (similar to ~
)PWD
: the current working directorySHELL
: the name of the shellSet a shell variable : typing a name followed immediately by an equal sign ( =
)
if the variable exists, you will modify it to assign the new value
You can use special files to control bash variables : $HOME/.bashrc
SSH
(or Secure SHell) is a protocol used to securely log onto remote systems
the most common way to access remote Linux and Unix-like servers
VNC
(or Virtual Network Computing) is a software that allows a personal computer's desktop environment to be run
Aside from bandwidth, latency and security issues (which can vary a bit), the big differences are the functionality
You need:
ssh -X pbarriat@coriolis.elic.ucl.ac.be
ssh -X -i ~/.ssh/id_rsa.ceci pbarriat@gwcism.cism.ucl.ac.be
Using a SSH client to reach a distant Linux Workstation
mobaXTerm is free and easy to use
allow you to test a Linux environmment but in CLUI only
Get a SSH client https://mobaxterm.mobatek.net/download-home-edition.html
How to use a SSH client https://support.ceci-hpc.be/doc/_contents/QuickStart/ConnectingToTheClusters/MobaXTerm.html
How to do a backup ?
Backup on external drive ?
Why don't do that with a simple linux script ?
Advantages of Linux | Disadvantages of Linux |
---|---|
Cost | Not easy to master ( CLUI only ) |
Security and robustness | Hardware compatibility issues ( sometimes ) |
Freedom | Not compatible with some Windows software |
Software | |
Development |
Check out the list of the best Linux software
The massive community is one of Ubuntu's biggest strengths
Visit https://askubuntu.com/ or https://answers.launchpad.net/