Linux Setup
- In the 1980s, GNU was developed at MIT. GNU stands for “GNU’s not Unix” and was made as a free, open source set of the existing Unix system tools. And in 1991, Linus Torvalds developed a free, open source version of the Unix kernel called Linux.
- Linux is widely used today in mobile devices, desktops, supercomputers, data centers, and cloud servers.
- Linux distributions (also known as distros) differ by their UIs, shell applications, and how the OS is supported and built.
- The design of a distro is catered toward its specific audience and/or use case. Popular Linux distributions include Red Hat Enterprise Linux (RHEL), Debian, Ubuntu, Suse (SLES, SLED, OpenSuse), Fedora, Mint, and Arch.
- The Linux system consists of five key layers: the UI, application, OS, kernel, and hardware.
- The user interface enables users to interact with applications.
- Applications enable users to perform tasks within the system
- The operating system runs on top of the kernel and is vital for system health and stability and
- The kernel is the lowest-level software that enables applications to interact with hardware
- Hardware includes all the physical or electronic components of your PC.
- You can use a variety of command-line or GUI-based text editors such as GNU nano, vim, vi, and gedit.
- .deb and .rpm are distinct file types used by package mangers in Linux operating systems.
- You can use GUI-based and command-line package managers to update and install software on Linux systems.
Updating
sudo
: “super-user do” - you’ll needsudo
to activate theapt
commandapt
: Advanced Packaging Tool, is used to perform system admin operations such as installing software packages, upgrading existing packages, updating your system…update
: before installing or upgrading any packages it is best to firstupdate
your package list indexapt
will access those resources in file/etc/apt/sources.list
sudo apt update
Nano
nano is a simple command line editor that enables you to use the terminal window as a text editor.
The system I happen to be on already had nano installed, so we’ll upgrade it with
sudo apt upgrade nano
# Create and edit a file
nano hello_world.txt
# type some text in the file and exit/save
# view content with
cat hello_world.txt
Vim
Another popular text-editing program is Vim. Vim is a highly configurable text editor built for efficiency. It takes some practice to get good at using Vim, but the time investment is very worthwhile.
Because Vim isn’t preinstalled on your Linux system, you’ll need to install it yourself. If you haven’t already done so in this session, ensure you run the command sudo apt update
. Then to install Vim, enter the following command:
sudo apt install vim
Vim has two basic modes:
Insert
mode, where you enter text, andCommand
mode, where you do everything else.- You can start Vim simply by entering
vim
- You get this screen above
- type
:help
- When done enter :q
# create a file
vim hello_world_2.txt
# type i to INSERT & type in the text you want, when done press Esc to exit the INSERT mode and back to the command mode
iin the text(when done)
Type <Esc>
# save the work by typing
:w
# vim will return the file name, nunmber of lines and number of characters written in the file
Packages
Packages are archived files containing the required components for either installing new software or updating existing software. Different Linux distros provide different packages managers. Deb and RPM packages are used by package managers in Linux OS
- .deb files are used for distributions such as: Debian, Ubuntu and Mint
- .rpm files are used for Red Hat-based distributions such as: CentOS/RHEL, Fedora, OpenSUSE
You can convert one package to another as they both can be used in one another distro. Use the following
# RPM to deb:
<package-name>.rpm
alien
# deb to RPM
-r <package-name>.deb alien
Some package managers are:
- PackageKit
- Yum
- pip
- conda
GitBash
GitBash accommodates Linux commands, and I happen to have it on my system so I’ll briefly go through how to load packages to it
Load packages in GitBash
I’ll use GitBash as the Linux equivalent, as it’s the simplest to setup since it’s already on my computer.
All I had to do was install:
wget
- Downloaded the .exe file
- From Windows Search: GitBash
- File location
- Properties
- Copied the path to the ~\Git
- Go to that location ~\Git\mingw64\bin
- Paste the wget .exe application file in that folder
cronetab
- Was not installed so using
- winget install cron
Install WSL -Ubuntu
I am using a winows laptop so I thought I’d activate WSL which is built-in windows to accommodate Linux. In W Powershell to install WSL, which automatically insall Linux: Ubuntu
- - install
wsl # It installed Ubuntu v2 To check the installation from Powershell
-l -v wsl
Install Linux - Ubuntu
Ubuntu: command prompt
@YASHAYA:~$ yashaya
If you forgot the password for your Linux distribution:
Open PowerShell and enter the root of your default WSL distribution using the command:
wsl -u root
If you need to update the forgotten password on a distribution that is not your default, use the command: wsl -d Debian -u root, replacing Debian with the name of your targeted distribution.
Once your WSL distribution has been opened at the root level inside PowerShell, you can use this command to update your password: passwd <username> where
<username>
is the username of the account in the distribution whose password you’ve forgotten.You will be prompted to enter a new UNIX password and then confirm that password. Once you’re told that the password has updated successfully, close WSL inside of PowerShell using the command:
exit
.
Update & Upgrade Ubuntu
&& sudo apt upgrade sudo apt update
Install MySQL
- To interact with MySQL databases on your local machine, you need to install and start the MySQL server. To install the MySQL server run the following command.
- This command will prompt you to enter your password, and once you confirm, it will download and install the MySQL server package along with any necessary dependencies.
-get install mysql-server sudo apt
Start MySQL
sudo systemctl start mysql
This command is used to start the MySQL service on a system running systemd, which is a system and service manager for Linux.
Here’s what each part of the command does:
- sudo: This prefix grants temporary administrative privileges to the command that follows it. It allows the user to execute the subsequent command with superuser (root) privileges.
- systemctl: This is a command-line utility used to manage systemd, which is a system and service manager for Linux operating systems. It allows users to start, stop, enable, disable, and manage services and other units.
- start: This subcommand of systemctl instructs systemd to start the specified service. In this case, mysql refers to the MySQL service.
Next, to access the MySQL CLI(Command Line Interface), you can use the command below in the terminal:
-u root -p sudo mysql
Here’s what each part of the command does:
- mysql: This is the command used to launch the MySQL command-line interface.
- -u root: This option specifies the username to use when connecting to the MySQL server. In this case, it specifies that the root user should be used.
- -p: This option prompts the user to enter the password for the specified MySQL user (in this case, the root user). After entering the password, if it’s correct, the user gains access to the MySQL CLI with administrative privileges.
Create db
Create a new database world using the command below in the terminal
create database world;
Connect to db
; use world
Complete DB w Scripts
- Use the script files we downloaded above
; source world_mysql_script.sql
Show Table
SHOW TABLES:
Show Records
* FROM city WHERE countrycode='CAN'; SELECT
Update Table with Update Script
; source world_mysql_update_A.sql
Show Records to verify
* FROM city WHERE countrycode='CAN'; SELECT
Quit db
\q