Skip to content

Commit ddaf101

Browse files
authored
Update getting-started.mdx
1 parent dc34ac6 commit ddaf101

File tree

1 file changed

+349
-11
lines changed

1 file changed

+349
-11
lines changed

docs/technologies/ubuntu/getting-started.mdx

Lines changed: 349 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,352 @@ description: Getting Started with Ubuntu
1515
- In a virtual machine via `VirtualBox`
1616
- How to manage the system using the CLI
1717
- `sudo`
18-
- Install the recommended packages for programming
19-
- How to add/remove users via CLI
20-
- How to install packages
21-
- How to install MySql
22-
- How to install Python3
23-
- How to install Mysql
24-
- How to install PostgreSQL
25-
- How to install Redis
26-
- How to install Mongo
27-
- Services: how to create/suspend a service
28-
- CRON: create, list, and remove jobs
18+
- `apt`
19+
- `apt-get`
20+
- Managing the users via CLI
21+
- Installing the recommended packages for programming
22+
- How to install Python3
23+
- How to install MySQL
24+
- How to install PostgreSQL
25+
- How to install MongoDB
26+
- How to install Redis
27+
28+
- Managing the services
29+
- CRON
30+
31+
## `Ubuntu` a short story
32+
33+
Ubuntu is a popular Linux-based operating system that was first released in 2004. It was developed by Canonical Ltd. and is based on the Debian Linux distribution, with the aim of providing an easy-to-use and user-friendly alternative to proprietary operating systems such as Microsoft Windows
34+
35+
Ubuntu uses a package management system called `apt` (Advanced Package Tool) that allows users to easily install, remove, and update software packages on their system.. Today, Ubuntu is one of the most popular Linux distributions in the world, used by millions of people across a wide range of devices, from desktop computers to servers and even smartphones.
36+
37+
## Managing the system using the CLI
38+
39+
The command-line interface (CLI) is a powerful tool for managing Ubuntu. It allows you to perform various tasks quickly and efficiently Here are some basic commands you need to know:
40+
41+
### `sudo`
42+
43+
The `sudo` command allows you to execute a command with administrative privileges. `sudo` stands for "superuser do". To use `sudo`, simply type `sudo` followed by the command you want to execute. For example, let's say you want to edit a file system, you need to use `sudo` to run it.
44+
45+
```bash
46+
sudo nano /etc/config
47+
```
48+
49+
When you run this command, Ubuntu will prompt you to enter your password. This is a security measure to prevent unauthorized access to administrative functions.
50+
51+
### `apt`
52+
53+
`apt` is the package manager for Ubuntu. It allows you to install, update, and remove packages from your system. Here are some basic `apt` commands:
54+
55+
- `update`: updates the package list on your system.
56+
- `upgrade`: upgrades all the installed packages on your system.
57+
- `install <packages>`: installs a package.
58+
- `remove <package>`: removes a package.
59+
- `purge <package>`: removes a package and its configuration files.
60+
- `autoremove`: removes any unused packages from your system
61+
- `autoclean`: removes any downloaded package files that are no longer needed.
62+
63+
### `apt-get`
64+
65+
You might notice some people use `apt-get` instead of `apt`. Both command are used for managing software packages on Ubuntu systems. `apt` is actually a newer and more user-friendly version of `apt-get`. However, both commands are still available and you can use whichever one you prefer.
66+
67+
## Managing the users via CLI
68+
69+
With the command-line tools available in Ubuntu, you can easily add and remove users, modify user settings, and perform other tasks related to user management.
70+
71+
Here are some basic commands for managing users via the CLI in Ubuntu:
72+
73+
### Adding a new user
74+
75+
To add a new user to your Ubuntu system, use the following command:
76+
77+
```bash
78+
sudo adduser <username>
79+
```
80+
81+
Replace `<username>` with the desired username. You will then be prompted to set a password and enter some basic information about the user.
82+
83+
### Removing a user
84+
85+
To remove a user from your Ubuntu system, use the following command:
86+
87+
```bash
88+
sudo deluser <username>
89+
```
90+
91+
Replace `<username>` with the username of the user you want to remove. After running this command, the user's home directory and any files or directories associated with their account will be removed from your system.
92+
93+
### Changing user passwords
94+
95+
To change the password for an existing user account, use the following command:
96+
97+
```bash
98+
sudo passwd <username>
99+
```
100+
101+
Replace `<username>` with the username of the user. After running this command, you will be prompted to enter a new password for the user.
102+
103+
## Installing the recommended packages for programming
104+
105+
In Ubuntu, you can install packages easily using the package manager through CLI. To install a package on your Ubuntu system, use the following command:
106+
107+
```bash
108+
sudo apt install <package-name>
109+
```
110+
111+
Replace `<package-name>` with the name of the package you want to install.
112+
113+
Here are some recommended package to be installed:
114+
115+
### How to Install Python3
116+
117+
Python is a simple and versatile open-source programming language used for web development, data analysis, artificial intelligence, and more. It has an easy-to-learn syntax and a large library of pre-built modules, making it an excellent choice for beginners and professionals. You can install Python by running this command.
118+
119+
```bash
120+
sudo apt update
121+
sudo apt install python3 python3-pip
122+
```
123+
124+
Then, verify the installation with the following command.
125+
126+
```bash
127+
python3 --version
128+
pip --version
129+
```
130+
131+
### How to install MySQL
132+
133+
MySQL is a popular relational database management system (RDBMS) used to store, manage and retrieve data. It is an open-source software that is widely used in web applications, and can be accessed through a variety of programming languages. To install and configure MySQL, follow these steps:
134+
135+
1. Install the MySQL server package.
136+
137+
```bash
138+
sudo apt install mysql-server
139+
```
140+
141+
2. Start the service
142+
143+
Once the installation is complete, MySQL will be automatically running. Otherwise, use the following command to start the service.
144+
145+
```basH
146+
sudo systemctl start mysql
147+
```
148+
149+
MySQL will be running on port 3306. This is MySQL's default port number.
150+
151+
3. Configure the database and user
152+
153+
- Login to MySQL
154+
155+
```bash
156+
sudo mysql
157+
```
158+
159+
- Create database
160+
161+
```mysql
162+
CREATE DATABASE appseed_db;
163+
```
164+
165+
Replace `appseed_db` with the name that you want.
166+
167+
- Create user and grant permission to the user.
168+
169+
MySQL creates `root` user by default, but it's better to use another user for non-administrative functions. For this demo, we'll grant all permissions to all tables for the created user.
170+
171+
```mysql
172+
CREATE USER 'appseed_db_usr'@'localhost' IDENTIFIED BY 'pass';
173+
GRANT ALL PRIVILEGES ON appseed_db.* TO 'appseed_db_usr'@'localhost';
174+
FLUSH PRIVILEGES;
175+
```
176+
177+
Replace `appseed_db` with your database name, `appseed_db_usr` and `pass` with your desired username and password.
178+
179+
- Exit MySQL
180+
181+
```mysql
182+
exit
183+
```
184+
185+
### How to install PostgreSQL
186+
187+
PostgreSQL is a powerful open-source object-relational database management system (ORDBMS) that offers robustness, scalability, and a wide range of advanced features. Its reliability and ability to handle large amounts of data make it a popular choice for enterprise-level applications. To install and configure PostgreSQL, follow these steps:
188+
189+
1. Install the PostgreSQL server package.
190+
191+
```bash
192+
sudo apt install postgresql
193+
```
194+
195+
2. Start the service
196+
197+
Once the installation is complete, PostgreSQL will be automatically running. Otherwise, use the following command to start the service.
198+
199+
```basH
200+
sudo systemctl start postgresql
201+
```
202+
203+
PortgreSQL will be running on port 5432. This is PortgreSQL's default port number.
204+
205+
3. Configure the database and user
206+
207+
- Login to PostgreSQL
208+
209+
```bash
210+
sudo -u postgres psql
211+
```
212+
213+
- Create database
214+
215+
```postgresql
216+
CREATE DATABASE appseed_db;
217+
```
218+
219+
Replace `appseed_db` with the name that you want.
220+
221+
- Create a user and grant permission to the user.
222+
223+
For this demo, we'll grant all permissions to all tables for the created user.
224+
225+
```postgresql
226+
CREATE USER appseed_db_usr WITH PASSWORD 'pass';
227+
GRANT ALL PRIVILEGES ON DATABASE appseed_db TO appseed_db_usr;
228+
```
229+
230+
Replace `appseed_db` with your database name, `appseed_db_usr` and `pass` with your desired username and password.
231+
232+
- Exit PostgreSQL
233+
234+
```postgresql
235+
\q
236+
```
237+
238+
### How to Install MongoDB
239+
240+
MongoDB is a popular open-source NoSQL document-oriented database that stores data in flexible, JSON-like documents. It is designed for scalability and performance, making it ideal for handling big data and high-traffic applications. To install Mongo, follow these steps:
241+
242+
1. Install mongo
243+
244+
```bash
245+
sudo apt install mongodb
246+
```
247+
248+
2. Start the service
249+
250+
```bash
251+
sudo systemctl start mongod
252+
```
253+
254+
MongoDB will be running on port 27017. This is MongoDB's default port number.
255+
256+
3. Connect to MongoDB
257+
258+
```bas
259+
mongo
260+
```
261+
262+
This command will start the `mongo` client and connect to the local MongoDB instance.
263+
264+
### How to Install Redis
265+
266+
Redis is an open-source in-memory data structure store that can be used as a database, cache, and message broker. It offers fast read and write speeds, high availability, and support for multiple data structures. Redis is ideal for real-time data processing and caching, with a reliable and active developer community. To install Redis, follow these steps:
267+
268+
1. Install Redis server
269+
270+
```bash
271+
sudo apt install redis-server
272+
```
273+
274+
2. Start the service
275+
276+
After installing Redis, you need to start the Redis service to begin using it. To start the Redis service, run the following command:
277+
278+
```bash
279+
sudo systemctl start redis
280+
```
281+
282+
3. Connect to Redis
283+
284+
```bash
285+
redis-cli
286+
```
287+
288+
This will connect to the local Redis instance.
289+
290+
## Managing the services
291+
292+
Services are background processes that perform various tasks, They are used to manage various system functions and can be controlled using the `systemctl` command.
293+
294+
- `start <service-name>`: to start a service
295+
- `stop <service-name>`: to stop a service
296+
- `restart <service-name>`: to restart a service
297+
- `enable <service-name>`: to enable a service to start automatically at boot
298+
- `disable <service-name>`: to disable a service from start automatically at boot
299+
- `status <service-name>`: to check status of a service
300+
301+
For example, if you want to stop MySQL, you can run this command:
302+
303+
```bash
304+
sudo systemctl stop mysql
305+
```
306+
307+
## CRON
308+
309+
CRON is a time-based job scheduling system used in Unix-like operating systems. It allows users to schedule repetitive tasks, such as running scripts or performing backups, at specific times or intervals.
310+
311+
### Creating CRON job
312+
313+
To create a new CRON job, follow these steps:
314+
315+
1. Open your terminal and type the following command.
316+
317+
```bash
318+
crontab -e
319+
```
320+
321+
This command will open the CRON configuration file. If this is your first time using CRON, you'll be prompted to choose your default text editor. Choose your preferred editor and press Enter.
322+
323+
2. Once the editor opens, add a new line at the bottom of the file with the following syntax:
324+
325+
```
326+
* * * * * command-to-be-executed
327+
```
328+
329+
This line represents your CRON job. The first five asterisks is a crontab that represents the time and date parameters for the job.
330+
331+
- Minute (0-59)
332+
- Hour (0-23)
333+
- Day of the month (1-31)
334+
- Month (1-12)
335+
- Day of the week (0-6, where Sunday is 0)
336+
337+
You can use tools like [crontab.guru](https://crontab.guru/) to help you creating a crontab. For example, to schedule a job to run at 0:00 AM every day, use the following crontab.
338+
339+
```bash
340+
0 0 * * * command-to-be-executed
341+
```
342+
343+
3. Once you've added your CRON job, save and exit the editor.
344+
345+
### Viewing CRON jobs
346+
347+
To view your current CRON jobs, Open your terminal and type the following command:
348+
349+
```bash
350+
crontab -l
351+
```
352+
353+
This will display a list of all your current CRON jobs in the terminal window.
354+
355+
### Removing CRON jobs
356+
357+
To remove a CRON job, follow these steps:
358+
359+
1. Open your terminal and type the following command to open the CRON configuration file:
360+
361+
```bash
362+
crontab -e
363+
```
364+
365+
2. Once the editor opens, locate the line that corresponds to the job you want to remove and delete it.
366+
3. Save and exit the editor.

0 commit comments

Comments
 (0)